summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kremmel <xing@synapse.plus.com>2007-07-13 17:28:35 +0000
committerMax Kremmel <xing@synapse.plus.com>2007-07-13 17:28:35 +0000
commit43bddc341499d073cc622bb46f37e0b688ad18f4 (patch)
tree0b09e828c7fb063a49033e9fb093e7cfcf0d0251
parent83f878fbe2398effea047955cc00b637e9c9a803 (diff)
downloadliberty-43bddc341499d073cc622bb46f37e0b688ad18f4.tar.gz
liberty-43bddc341499d073cc622bb46f37e0b688ad18f4.tar.bz2
liberty-43bddc341499d073cc622bb46f37e0b688ad18f4.zip
large update to how data plugins are parsed. data plugin parsing is not done by the format handlers anymore but by LibertyContent::parseData. this simplifies code in the format handlers somewhat and give better global control over plugin parsing. data parsed by plugins is now also excluded from parser and filter - this reduces load and allows plugins to do more stuff without having to deal with stuff that might happen in the parsers. hence, <\!--~np~--> type escaping is not required anymore in the plugins.
-rw-r--r--LibertyContent.php24
-rw-r--r--liberty_lib.php167
-rw-r--r--plugins/format.bbcode.php32
-rw-r--r--plugins/format.bithtml.php4
-rw-r--r--plugins/format.markdown.php4
-rw-r--r--plugins/format.tikiwiki.php128
6 files changed, 164 insertions, 195 deletions
diff --git a/LibertyContent.php b/LibertyContent.php
index fb82914..97ef762 100644
--- a/LibertyContent.php
+++ b/LibertyContent.php
@@ -3,7 +3,7 @@
* Management of Liberty content
*
* @package liberty
-* @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertyContent.php,v 1.262 2007/07/11 18:23:45 spiderr Exp $
+* @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertyContent.php,v 1.263 2007/07/13 17:28:34 squareing Exp $
* @author spider <spider@steelsun.com>
*/
@@ -1973,13 +1973,19 @@ class LibertyContent extends LibertyBase {
// if $ret is empty, we haven't read anything from cache yet - we need to parse the raw data
if( empty( $ret ) || !empty( $parseAndCache )) {
+ if( !empty( $parseHash['data'] ) && $parseHash['format_guid'] ) {
+ // we only filter if this is not a split parse - if it's a split parse, it will fetch its own filters
+ if( empty( $parseHash['split_parse'] )) {
+ $parseHash['data'] = LibertyContent::filterData( $parseHash['data'], $parseHash, 'pre' );
+ }
- // we only filter if this is not a split parse
- if( empty( $parseHash['split_parse'] )) {
- $parseHash['data'] = LibertyContent::filterData( $parseHash['data'], $parseHash, 'pre' );
- }
+ $replace = array();
+ // extract and protect ~pp~...~/pp~ and ~np~...~/np~ sections
+ parse_protect( $parseHash['data'], $replace );
+
+ // this will handle all liberty data plugins like {code} and {attachment} usage in all formats
+ parse_data_plugins( $parseHash['data'], $replace, $this );
- if( !empty( $parseHash['data'] ) && $parseHash['format_guid'] ) {
if( $func = $gLibertySystem->getPluginFunction( $parseHash['format_guid'], 'load_function' ) ) {
// get the beast parsed
if( $ret = $func( $parseHash, $this )) {
@@ -1988,6 +1994,12 @@ class LibertyContent extends LibertyBase {
$ret = LibertyContent::filterData( $ret, $parseHash, 'post' );
}
+ // before we cache we insert the protected sections back - currently this is even after the filters.
+ // this might not be ideal but it allows stuff like ~pp~{maketoc}~/pp~
+ foreach( $replace as $rep ) {
+ $ret = str_replace( $rep["key"], $rep["data"], $ret );
+ }
+
if( !empty( $parseAndCache )) {
LibertyContent::writeCacheFile( $cacheFile, $ret );
}
diff --git a/liberty_lib.php b/liberty_lib.php
index 281f4dc..b6f4b44 100644
--- a/liberty_lib.php
+++ b/liberty_lib.php
@@ -1,6 +1,6 @@
<?php
/**
- * @version $Header: /cvsroot/bitweaver/_bit_liberty/liberty_lib.php,v 1.4 2007/07/12 14:40:13 squareing Exp $
+ * @version $Header: /cvsroot/bitweaver/_bit_liberty/liberty_lib.php,v 1.5 2007/07/13 17:28:34 squareing Exp $
* @package liberty
* @subpackage functions
*/
@@ -10,36 +10,32 @@
* This crazy function will parse all the data plugin stuff found within any
* parsed text section
*
- * @param array $data Data to be parsed
- * @param array $preparsed
- * @param array $noparsed
- * @param array $pParser
+ * @param array $pData Data to be parsed
* @access public
- * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ * @return void
*/
-function parse_data_plugins( &$data, &$preparsed, &$noparsed, &$pParser, &$pCommonObject ) {
+function parse_data_plugins( &$pData, &$pReplace, &$pCommonObject ) {
global $gLibertySystem, $gBitSystem;
- // Find the plugins
- if( $gBitSystem->isPackageActive( 'stencil' ) ) {
+
+ // this should go to a filter
+ if( $gBitSystem->isPackageActive( 'stencil' )) {
require_once( STENCIL_PKG_PATH.'BitStencil.php' );
- $data = preg_replace_callback("/\{\{\/?([^|]+)([^\}]*)\}\}/", 'parse_stencil_data', $data );
+ $pData = preg_replace_callback( "/\{\{\/?([^|]+)([^\}]*)\}\}/", 'parse_stencil_data', $pData );
}
// note: $curlyTags[0] is the complete match, $curlyTags[1] is plugin name, $curlyTags[2] is plugin arguments
- preg_match_all("/\{\/?([A-Za-z0-9]+)([^\}]*)\}/", $data, $curlyTags);
+ preg_match_all( "/\{\/?([A-Za-z0-9]+)([^\}]*)\}/", $pData, $curlyTags );
if( count( $curlyTags[0] ) ) {
- // if true, replace only CODE plugin, if false, replace all other plugins
- $code_first = true;
+ // if TRUE, replace only CODE plugin, if false, replace all other plugins
+ $code_first = TRUE;
- // Process plugins in reverse order, so that nested plugins are handled
- // from the inside out.
+ // Process plugins in reverse order, so that nested plugins are handled from the inside out.
$i = count( $curlyTags[0] ) - 1;
- $paired_tag_seen = array();
while( $i >= 0 ) {
$plugin_start = $curlyTags[0][$i];
$plugin = $curlyTags[1][$i];
- $pos = strpos( $data, $plugin_start ); // where plugin starts
+ $pos = strpos( $pData, $plugin_start ); // where plugin starts
$dataTag = strtolower( $plugin );
// hush up the return of this in case someone uses curly braces to enclose text
$pluginInfo = $gLibertySystem->getPluginInfo( @$gLibertySystem->mDataTags[$dataTag] ) ;
@@ -51,12 +47,12 @@ function parse_data_plugins( &$data, &$preparsed, &$noparsed, &$pParser, &$pComm
$paired_close_tag_seen[$dataTag] = 0;
}
- $is_opening_tag = 0;
+ $is_opening_tag = FALSE;
if( ( empty( $pluginInfo['requires_pair'] ) && (strtolower($plugin_start) != '{/'. $dataTag . '}' ) )
|| (strpos( $plugin_start, ' ' ) > 0)
|| (strtolower($plugin_start) == '{'.$dataTag.'}' && !$paired_close_tag_seen[$dataTag] )
) {
- $is_opening_tag = 1;
+ $is_opening_tag = TRUE;
}
if(
@@ -65,20 +61,19 @@ function parse_data_plugins( &$data, &$preparsed, &$noparsed, &$pParser, &$pComm
// when NOT in CODE parsing mode, replace all other plugins
|| ( !$code_first && ( $dataTag <> 'code' ) )
)
- && isset( $gLibertySystem->mDataTags[$dataTag] )
- && ( $pluginInfo )
- && ( $gLibertySystem->getPluginFunction( $gLibertySystem->mDataTags[$dataTag], 'load_function' ) )
+ && !empty( $gLibertySystem->mDataTags[$dataTag] )
+ && !empty( $pluginInfo )
&& ( $loadFunc = $gLibertySystem->getPluginFunction( $gLibertySystem->mDataTags[$dataTag], 'load_function' ) )
&& ( $is_opening_tag )
) {
if( $pluginInfo['requires_pair'] ) {
$plugin_end = '{/'.$plugin.'}';
- $pos_end = strpos( strtolower( $data ), strtolower( $plugin_end ), $pos ); // where plugin data ends
+ $pos_end = strpos( strtolower( $pData ), strtolower( $plugin_end ), $pos ); // where plugin data ends
$plugin_end2 = '{'.$plugin.'}';
- $pos_end2 = strpos( strtolower( $data ), strtolower( $plugin_end2 ), $pos+1 ); // where plugin data ends
+ $pos_end2 = strpos( strtolower( $pData ), strtolower( $plugin_end2 ), $pos+1 ); // where plugin data ends
- if( ( $pos_end2 > 0 && $pos_end2 > 0 && $pos_end2 < $pos_end ) || $pos_end === false ) {
+ if( ( $pos_end2 > 0 && $pos_end2 > 0 && $pos_end2 < $pos_end ) || $pos_end === FALSE ) {
$pos_end = $pos_end2;
$plugin_end = $plugin_end2;
}
@@ -87,13 +82,13 @@ function parse_data_plugins( &$data, &$preparsed, &$noparsed, &$pParser, &$pComm
$plugin_end = '';
}
-//print " if ( ((($code_first) && ($plugin == 'CODE')) || ((!$code_first) && ($plugin <> 'CODE'))) && ($pos_end > $pos)) { <br/>";
+ //print "if ( ((($code_first) && ($plugin == 'CODE')) || ((!$code_first) && ($plugin <> 'CODE'))) && ($pos_end > $pos)) { <br/>";
// Extract the plugin data
$plugin_data_len = $pos_end - $pos - strlen( $curlyTags[0][$i] );
- $plugin_data = substr( $data, $pos + strlen( $plugin_start ), $plugin_data_len );
-//print " $plugin_data_len = $pos_end - $pos - strlen(".$curlyTags[0][$i].") substr( $pos + strlen($plugin_start), $plugin_data_len);";
+ $plugin_data = substr( $pData, $pos + strlen( $plugin_start ), $plugin_data_len );
+ //print "$plugin_data_len = $pos_end - $pos - strlen(".$curlyTags[0][$i].") substr( $pos + strlen($plugin_start), $plugin_data_len);";
$arguments = array();
// Construct argument list array
@@ -120,32 +115,118 @@ function parse_data_plugins( &$data, &$preparsed, &$noparsed, &$pParser, &$pComm
}
if( $ret = $loadFunc( $plugin_data, $arguments, $pCommonObject ) ) {
- // temporarily replace end of lines so tables and other things render properly
-// $ret = preg_replace( "/\n/", '#EOL', $ret );
-
- // Handle pre- & no-parse sections and plugins inserted by this plugin
- if( is_object( $pParser ) ) {
- // we were passed in a parser object, assume tikiwiki that has parse_first method
- $pParser->parse_pp_np( $ret, $preparsed, $noparsed );
- } else {
- // just nuke all np/pp for now in non tikiwiki formats
- $ret = preg_replace( "/\~(\/?)[np]p\~/", '', $ret );
-
- }
- // Replace plugin section with its output in data
- $data = substr_replace($data, $ret, $pos, $pos_end - $pos + strlen($plugin_end));
+ $key = md5( mt_rand() );
+ $pReplace[] = array(
+ 'key' => $key,
+ 'data' => $ret,
+ );
+ $pData = substr_replace( $pData, $key, $pos, $pos_end - $pos + strlen( $plugin_end ));
}
}
$i--;
// if we are in CODE parsing mode and list is done, switch to 'parse other plugins' mode and start all over
if( ( $code_first ) && ( $i < 0 ) ) {
$i = count( $curlyTags[0] ) - 1;
- $code_first = false;
+ $code_first = FALSE;
}
} // while
}
}
+/**
+ * This function replaces pre- and no-parsed sections with unique keys and
+ * saves the section contents for later reinsertion. It is needed by
+ * parse_data_plugins() to extract sections that don't require parsing
+ *
+ * @param array $pData data that might contain ~np~ or ~pp~ strings
+ * @param array $preparsed array that is updated by refrerence with key and data that needs to be substituted later
+ * @param array $noparsed array that is updated by refrerence with key and data that needs to be substituted later
+ * @access public
+ * @return void
+ */
+function parse_protect( &$pData, &$pReplace ) {
+ // Find all sections delimited by ~pp~ ... ~/pp~
+ preg_match_all( "/\~pp\~(.*?)\~\/pp\~/s", $pData, $preparse );
+ if( count( $preparse[0] )) {
+ foreach( array_unique( $preparse[1] ) as $pp ) {
+ $aux["key"] = md5( mt_rand() );
+ $aux["data"] = "<pre><code>".htmlspecialchars( $pp )."</code></pre>";
+ $pReplace[] = $aux;
+ $pData = str_replace( "~pp~$pp~/pp~", $aux['key'], $pData );
+ }
+ }
+
+ // now remove <pre>...<pre> sections
+ preg_match_all( "!(<pre[^>]*>)(.*?)(</pre[^>]*>)!si", $pData, $preparse );
+ if( count( $preparse[0] )) {
+ foreach( $preparse[2] as $key => $pre ) {
+ $aux["key"] = md5( mt_rand() );
+ $aux["data"] = $preparse[1][$key].htmlspecialchars( $pre ).$preparse[3][$key];
+ $pReplace[] = $aux;
+ $pData = str_replace( $preparse[1][$key].$pre.$preparse[3][$key], $aux['key'], $pData );
+ }
+ }
+
+ // and now ~np~...~/np~ sections
+ preg_match_all( "/\~np\~(.*?)\~\/np\~/s", $pData, $noparse );
+ if( count( $noparse[0] )) {
+ foreach( array_unique( $noparse[1] ) as $np ) {
+ $aux["key"] = md5( mt_rand() );
+ $aux["data"] = htmlspecialchars( $np );
+ $pReplace[] = $aux;
+ $pData = str_replace( "~np~$np~/np~", $aux['key'], $pData );
+ }
+ }
+
+ /* don't quite understand why this has to be so complicated - i've replaced the code below with the short section above
+ // Find all sections delimited by ~np~ ... ~/np~
+ if( preg_match( "!\~np\~(.*?)\~/np\~!s", $pData, $nparse )) {
+ $new_data = '';
+ $nopa = '';
+ $state = TRUE;
+ $skip = FALSE;
+ $dlength = strlen( $pData );
+
+ for( $i = 0; $i < $dlength; $i++ ) {
+ $tag5 = substr( $pData, $i, 5 );
+ $tag4 = substr( $tag5, 0, 4 );
+ $tag1 = substr( $tag4, 0, 1 );
+
+ // Beginning of a noparse section found
+ if( $state && $tag4 == '~np~' ) {
+ $i += 3;
+ $state = FALSE;
+ $skip = TRUE;
+ }
+
+ // Termination of a noparse section found
+ if( !$state && $tag5 == '~/np~' ) {
+ $state = TRUE;
+ $i += 4;
+ $skip = TRUE;
+ $key = md5( mt_rand() );
+ $new_data .= $key;
+ $aux["key"] = $key;
+ $aux["data"] = htmlspecialchars( $nopa );
+ $pReplace[] = $aux;
+ $nopa = '';
+ }
+
+ if( !$skip ) { // This character is not part of a noparse tag
+ if( $state ) { // This character is not within a noparse section
+ $new_data .= $tag1;
+ } else { // This character is within a noparse section
+ $nopa .= $tag1;
+ }
+ } else { // Tag is now skipped over
+ $skip = FALSE;
+ }
+ }
+ $pData = $new_data;
+ }
+ */
+}
+
// ================== Liberty Plugin Helper ==================
/**
diff --git a/plugins/format.bbcode.php b/plugins/format.bbcode.php
index c013f09..c26093b 100644
--- a/plugins/format.bbcode.php
+++ b/plugins/format.bbcode.php
@@ -1,6 +1,6 @@
<?php
/**
- * @version $Revision: 1.11 $
+ * @version $Revision: 1.12 $
* @package liberty
* @subpackage plugins_format
*/
@@ -55,28 +55,26 @@ function bbcode_parse_data( &$pParseHash, &$pCommonObject ) {
$data = preg_replace( '/\[(quote|code):[0-9a-f]+=/', '[\1=', $data );
$data = preg_replace( '/:[0-9a-f]+\]/', ']', $data );
-/* get options from the ini file
-// $config = parse_ini_file('BBCodeParser.ini', true);
-$config = parse_ini_file('doc/Text_Wiki_BBCode/doc/BBCodeParser_V2.ini', true);
-$options = &PEAR::getStaticProperty('HTML_BBCodeParser', '_options');
-$options = $config['HTML_BBCodeParser'];
-unset($options);
-*/
+ /* get options from the ini file
+ // $config = parse_ini_file('BBCodeParser.ini', true);
+ $config = parse_ini_file('doc/Text_Wiki_BBCode/doc/BBCodeParser_V2.ini', true);
+ $options = &PEAR::getStaticProperty('HTML_BBCodeParser', '_options');
+ $options = $config['HTML_BBCodeParser'];
+ unset($options);
+ */
-$parser = new HTML_BBCodeParser('BBCodeParser_V2.ini');
-$parser->setText( $data );
-$parser->parse();
-$ret = $parser->getParsed();
+ $parser = new HTML_BBCodeParser('BBCodeParser_V2.ini');
+ $parser->setText( $data );
+ $parser->parse();
+ $ret = $parser->getParsed();
-/*
+ /*
$parser = new HTML_BBCodeParser();
$parser->setText( $data );
$parser->parse();
$ret = $parser->getParsed();
-*/
+ */
- // eventually we should strip tags, maybe tikilink, or other things.
- parse_data_plugins( $ret, $foo, $bar, $empty, $pCommonObject );
if( preg_match( "/\(\(([^\)][^\)]+)\)\)/", $ret ) ) {
preg_match_all( "/\(\(([^\)][^\)]+)\)\)/", $ret, $pages );
foreach (array_unique($pages[1])as $page_parse) {
@@ -91,6 +89,6 @@ $ret = $parser->getParsed();
}
}
-}
+} // PEAR check
?>
diff --git a/plugins/format.bithtml.php b/plugins/format.bithtml.php
index 138e9a0..20216de 100644
--- a/plugins/format.bithtml.php
+++ b/plugins/format.bithtml.php
@@ -1,6 +1,6 @@
<?php
/**
- * @version $Revision: 1.16 $
+ * @version $Revision: 1.17 $
* @package liberty
* @subpackage plugins_format
*/
@@ -46,8 +46,6 @@ function bithtml_save_data( &$pParamHash ) {
function bithtml_parse_data( &$pParseHash, &$pCommonObject ) {
global $gLibertySystem;
$ret = $pParseHash['data'];
- // eventually we should strip tags, maybe tikilink, or other things.
- parse_data_plugins( $ret, $foo, $bar, $empty, $pCommonObject );
if( preg_match( "/\(\(([^\)][^\)]+)\)\)/", $ret ) ) {
preg_match_all( "/\(\(([^\)][^\)]+)\)\)/", $ret, $pages );
foreach (array_unique($pages[1])as $page_parse) {
diff --git a/plugins/format.markdown.php b/plugins/format.markdown.php
index f1039b8..9107f13 100644
--- a/plugins/format.markdown.php
+++ b/plugins/format.markdown.php
@@ -1,6 +1,6 @@
<?php
/**
- * @version $Revision: 1.11 $
+ * @version $Revision: 1.12 $
* @package liberty
* @subpackage plugins_format
*/
@@ -43,8 +43,6 @@ function markdown_save_data( &$pParamHash ) {
function markdown_parse_data( &$pParseHash, &$pCommonObject ) {
global $gLibertySystem;
$ret = Markdown( $pParseHash['data'] );
- // eventually we should strip tags, maybe tikilink, or other things.
- parse_data_plugins( $ret, $foo, $bar, $empty, $pCommonObject );
return $ret;
}
diff --git a/plugins/format.tikiwiki.php b/plugins/format.tikiwiki.php
index 456ff7a..db06b3c 100644
--- a/plugins/format.tikiwiki.php
+++ b/plugins/format.tikiwiki.php
@@ -1,6 +1,6 @@
<?php
/**
- * @version $Revision: 1.105 $
+ * @version $Revision: 1.106 $
* @package liberty
*/
global $gLibertySystem;
@@ -119,7 +119,7 @@ function tikiwiki_parse_data( &$pParseHash, &$pCommonObject ) {
if( empty( $parser ) ) {
$parser = new TikiWikiParser();
}
- $ret = $parser->parse_data( $pParseHash, $pCommonObject );
+ $ret = $parser->parseData( $pParseHash, $pCommonObject );
return $ret;
}
@@ -351,105 +351,6 @@ class TikiWikiParser extends BitBase {
return $ret;
}
- function parse_data_raw($data) {
- $data = $this->parseData($data);
-
- $data = str_replace( WIKI_PKG_URL."index", WIKI_PKG_URL."index_raw", $data );
- return $data;
- }
-
-
- // This recursive function handles pre- and no-parse sections and plugins
- function parse_first(&$data, &$preparsed, &$noparsed, &$pCommonObject) {
- global $gLibertySystem;
- $this->parse_pp_np($data, $preparsed, $noparsed);
- // Handle pre- and no-parse sections
- parse_data_plugins( $data, $preparsed, $noparsed, $this, $pCommonObject );
- }
-
-
- // AWC ADDITION
- // This function replaces pre- and no-parsed sections with unique keys
- // and saves the section contents for later reinsertion.
- function parse_pp_np(&$data, &$preparsed, &$noparsed) {
- // Find all sections delimited by ~pp~ ... ~/pp~
- // and replace them in the data stream with a unique key
- preg_match_all("/\~pp\~(.*?)\~\/pp\~/s", $data, $preparse);
- if( count( $preparse[0] ) ) {
- foreach (array_unique($preparse[1])as $pp) {
- $key = md5(BitSystem::genPass());
-
- $aux["key"] = $key;
- $aux["data"] = $pp;
- $preparsed[] = $aux;
- $data = str_replace("~pp~$pp~/pp~", $key, $data);
- }
-
- // Temporary remove <pre> tags too
- // TODO: Is this a problem if user insert <PRE> but after parsing
- // will get <pre> (lowercase)?? :)
- preg_match_all("/(<[Pp][Rr][Ee]>)((.|\n)*?)(<\/[Pp][Rr][Ee]>)/", $data, $preparse);
- $idx = 0;
-
- foreach (array_unique($preparse[2])as $pp) {
- $key = md5(BitSystem::genPass());
-
- $aux["key"] = $key;
- $aux["data"] = $pp;
- $preparsed[] = $aux;
- $data = str_replace($preparse[1][$idx] . $pp . $preparse[4][$idx], $key, $data);
- $idx = $idx + 1;
- }
- }
-
- if( preg_match("!\~np\~(.*?)\~/np\~!s", $data, $preparse) ) {
- // Find all sections delimited by ~np~ ... ~/np~
- $new_data = '';
- $nopa = '';
- $state = true;
- $skip = false;
-
- $dlength=strlen($data);
- for ($i = 0; $i < $dlength; $i++) {
- $tag5 = substr($data, $i, 5);
- $tag4 = substr($tag5, 0, 4);
- $tag1 = substr($tag4, 0, 1);
-
- // Beginning of a noparse section found
- if ($state && $tag4 == '~np~') {
- $i += 3;
- $state = false;
- $skip = true;
- }
-
- // Termination of a noparse section found
- if (!$state && ($tag5 == '~/np~')) {
- $state = true;
- $i += 4;
- $skip = true;
- $key = md5(BitSystem::genPass());
- $new_data .= $key;
- $aux["key"] = $key;
- $aux["data"] = $nopa;
- $noparsed[] = $aux;
- $nopa = '';
- }
-
- if (!$skip) { // This character is not part of a noparse tag
- if ($state) { // This character is not within a noparse section
- $new_data .= $tag1;
- } else { // This character is within a noparse section
- $nopa .= $tag1;
- }
- } else { // Tag is now skipped over
- $skip = false;
- }
- }
- $data = $new_data;
- }
- }
-
-
// This function handles wiki codes for those special HTML characters
// that textarea won't leave alone.
function parse_htmlchar( &$data ) {
@@ -682,7 +583,7 @@ class TikiWikiParser extends BitBase {
return $data;
}
- function parse_data( $pParseHash, &$pCommonObject ) {
+ function parseData( $pParseHash, &$pCommonObject ) {
global $gBitSystem, $gLibertySystem, $gBitUser, $page;
$data = $pParseHash['data'];
@@ -728,11 +629,6 @@ class TikiWikiParser extends BitBase {
$data = preg_replace( '/(\)\))('.WIKI_WORDS_REGEX.')(\(\()/', "~np~" . "$2" . "~/np~", $data);
- // Handle pre- and no-parse sections and plugins
- $preparsed = array();
- $noparsed = array();
- $this->parse_first($data, $preparsed, $noparsed, $pCommonObject);
-
// Extract [link] sections (to be re-inserted later)
$noparsedlinks = array();
@@ -889,13 +785,6 @@ class TikiWikiParser extends BitBase {
if( strlen( trim( $text[0] ) ) > 0 ) {
$repl = preg_replace( "#{$pages[1][$i]}</a>$#", "{$text[0]}</a>", $repl );
}
-
- // this still relevant? -- xing
-// // Check is timeout expired?
-// if (isset($text[1]) && (time() - $modTime ) < intval($text[1])) {
-// // Append small 'new' image. TODO: possible 'updated' image more suitable...
-// $repl .= '&nbsp;<img src="img/icons/new.gif" border="0" alt="'.tra("new").'" />';
-// }
} else {
$repl = BitPage::getDisplayLink( $pages[1][$i], $exists );
if( strlen( trim( $text[0] ) ) > 0 ) {
@@ -947,6 +836,7 @@ class TikiWikiParser extends BitBase {
}
}
+ // the hotwords stuff should go in a filter
if ($gBitSystem->isPackageActive( 'hotwords' ) ) {
if( empty( $hotwordlib ) ) {
include_once(HOTWORDS_PKG_PATH."hotword_lib.php");
@@ -1444,15 +1334,7 @@ class TikiWikiParser extends BitBase {
// Close BiDi DIVs if any
for ($i = 0; $i < $bidiCount; $i++) {
- $data .= "</div>";
- }
-
- foreach ($noparsed as $np) {
- $data = str_replace($np["key"], $np["data"], $data);
- }
-
- foreach ($preparsed as $pp) {
- $data = str_replace($pp["key"], "<pre>" . $pp["data"] . "</pre>", $data);
+ $data .= "</div>";
}
$data = str_replace( "<!-- bitremovebr --><br />", "", $data );