diff -r d8156d18ac58 -r 97ae8e9d5e29 includes/render.php --- a/includes/render.php Thu Sep 27 15:55:37 2007 -0400 +++ b/includes/render.php Sat Nov 03 07:43:35 2007 -0400 @@ -248,6 +248,12 @@ $text = preg_replace('/(.*?)<\/nodisplay>/is', '', $text); } + $code = $plugins->setHook('render_wikiformat_pre'); + foreach ( $code as $cmd ) + { + eval($cmd); + } + if ( !$plaintext ) { // Process images @@ -264,7 +270,8 @@ } } - $template_regex = "/\{\{([^\]]+?)((\n([ ]*?)[A-z0-9]+([ ]*?)=([ ]*?)(.+?))*)\}\}/is"; + //$template_regex = "/\{\{([^\]]+?)((\n([ ]*?)[A-z0-9]+([ ]*?)=([ ]*?)(.+?))*)\}\}/is"; + $template_regex = "/\{\{(.+)((\n|\|[ ]*([A-z0-9]+)[ ]*=[ ]*(.+))*)\}\}/isU"; $i = 0; while ( preg_match($template_regex, $text) ) { @@ -290,10 +297,26 @@ $result = $wiki->transform($text, 'Xhtml'); } - // if ( !$plaintext ) - // { - // $result = RenderMan::process_imgtags_stage2($result, $taglist); - // } + // HTML fixes + $result = preg_replace('#([\s]*?)<\/tr>#is', '', $result); + $result = preg_replace('#

([\s]*?)<\/p>#is', '', $result); + $result = preg_replace('#
([\s]*?)\n", "

", $result);
+    $result = preg_replace("/

]*?)><\/p>/", "", $result); + $result = str_replace("
\n", "\n", $result); + $result = str_replace("

", "", $result); + $result = str_replace("
", "", $result); + $result = str_replace("
", "", $result); + $result = str_replace("
", "", $result); + $result = preg_replace('/<\/table>$/', "

", $result); + $result = str_replace("

", "", $result); + $result = str_replace("

", "", $result); + + $code = $plugins->setHook('render_wikiformat_post'); + foreach ( $code as $cmd ) + { + eval($cmd); + } // Reinsert sections for($i=0;$i<$nw;$i++) @@ -311,7 +334,8 @@ } - function wikiFormat($message, $filter_links = true, $do_params = false, $plaintext = false) { + function wikiFormat($message, $filter_links = true, $do_params = false, $plaintext = false) + { global $db, $session, $paths, $template, $plugins; // Common objects return RenderMan::next_gen_wiki_format($message, $plaintext, $filter_links, $do_params); @@ -384,6 +408,8 @@ $result = str_replace("

", "", $result); $result = str_replace("
", "", $result); $result = preg_replace('/<\/table>$/', "

", $result); + $result = str_replace("

", "", $result); + $result = str_replace("

", "", $result); $result = str_replace('', '<nowiki>', $result); $result = str_replace('', '</nowiki>', $result); @@ -460,8 +486,8 @@ list($page_id, $namespace) = RenderMan::strToPageID($matches[1][$i]); $pid_clean = $paths->nslist[$namespace] . sanitize_page_id($page_id); - $url = makeUrl($matches[1][$i], false, true); - $inner_text = htmlspecialchars(get_page_title($pid_clean)); + $url = makeUrl($pid_clean, false, true); + $inner_text = ( isPage($pid_clean) ) ? htmlspecialchars(get_page_title($pid_clean)) : htmlspecialchars($matches[1][$i]); $quot = '"'; $exists = ( isPage($pid_clean) ) ? '' : ' class="wikilink-nonexistent"'; @@ -473,46 +499,6 @@ return $text; } - /* * - * Replaces template inclusions with the templates - * @param string $message The text to format - * @return string - * / - - function old_include_templates($message) - { - $random_id = md5( time() . mt_rand() ); - preg_match_all('#\{\{(.+?)\}\}#s', $message, $matchlist); - foreach($matchlist[1] as $m) - { - $mn = $m; - // Strip out wikilinks and re-add them after the explosion (because of the "|") - preg_match_all('#\[\[(.+?)\]\]#i', $m, $linklist); - //echo '
'.print_r($linklist, true).'
'; - for($i=0;$i $line ) { - if ( preg_match('/^([ ]*?)([A-z0-9_]+?)([ ]*?)=([ ]*?)(.+?)$/i', $line, $matches) ) + if ( preg_match('/^[ ]*([A-z0-9_]+)([ ]*)=([ ]*)(.+?)$/is', $line, $matches) ) { - $parm =& $matches[2]; - $text =& $matches[5]; + $parm =& $matches[1]; + $text =& $matches[4]; if ( $parm == $current_parm ) { $current_line .= $text; @@ -570,6 +566,7 @@ /** * Processes all template tags within a block of wikitext. + * Updated in 1.0.2 to also parse template tags in the format of {{Foo |a = b |b = c |c = therefore, a}} * @param string The text to process * @return string Formatted text * @example @@ -578,16 +575,18 @@ parm1 = Foo parm2 = Bar }}'; - $text = include_templates($text); + $text = RenderMan::include_templates($text); *
*/ function include_templates($text) { global $db, $session, $paths, $template, $plugins; // Common objects - $template_regex = "/\{\{([^\]]+?)((\n([ ]*?)[A-z0-9]+([ ]*?)=([ ]*?)(.+?))*)\}\}/is"; + // $template_regex = "/\{\{([^\]]+?)((\n([ ]*?)[A-z0-9]+([ ]*?)=([ ]*?)(.+?))*)\}\}/is"; + $template_regex = "/\{\{(.+)(((\n|[ ]*\|)[ ]*([A-z0-9]+)[ ]*=[ ]*(.+))*)\}\}/isU"; if ( $count = preg_match_all($template_regex, $text, $matches) ) { + //die('
' . print_r($matches, true) . '
'); for ( $i = 0; $i < $count; $i++ ) { $matches[1][$i] = sanitize_page_id($matches[1][$i]); @@ -595,10 +594,9 @@ if ( !empty($parmsection) ) { $parms = RenderMan::parse_template_vars($parmsection); - foreach ( $parms as $j => $parm ) - { - $parms[$j] = $parm; - } + if ( !is_array($parms) ) + // Syntax error + $parms = array(); } else { @@ -710,6 +708,7 @@ ':-/' => 'face-plain.png', ':joke:' => 'face-plain.png', ']:->' => 'face-devil-grin.png', + ']:->' => 'face-devil-grin.png', ':kiss:' => 'face-kiss.png', ':-P' => 'face-tongue-out.png', ':P' => 'face-tongue-out.png',