diff -r 250aeb408ed7 -r 4c5c2b66a34d includes/render.php --- a/includes/render.php Sat Oct 06 20:47:09 2007 -0400 +++ b/includes/render.php Sun Oct 07 08:39:40 2007 -0400 @@ -270,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) ) { @@ -498,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; @@ -595,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 @@ -603,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]); @@ -620,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 {