includes/render.php
changeset 715 29663506e85c
parent 685 17ebe24cdf85
child 717 236360cf79a0
equal deleted inserted replaced
714:2f1706c4231f 715:29663506e85c
   269     foreach ( $code as $cmd )
   269     foreach ( $code as $cmd )
   270     {
   270     {
   271       eval($cmd);
   271       eval($cmd);
   272     }
   272     }
   273     
   273     
   274     if ( !$plaintext )
       
   275     {
       
   276       // Process images
       
   277       $text = RenderMan::process_image_tags($text, $taglist);
       
   278       $text = RenderMan::process_imgtags_stage2($text, $taglist);
       
   279     }
       
   280     
       
   281     if($do_params)
       
   282     {
       
   283       preg_match_all('#\(_([0-9]+)_\)#', $text, $matchlist);
       
   284       foreach($matchlist[1] as $m)
       
   285       {
       
   286         $text = str_replace('(_'.$m.'_)', $paths->getParam((int)$m), $text);
       
   287       }
       
   288     }
       
   289     
       
   290     //$template_regex = "/\{\{([^\]]+?)((\n([ ]*?)[A-z0-9]+([ ]*?)=([ ]*?)(.+?))*)\}\}/is";
   274     //$template_regex = "/\{\{([^\]]+?)((\n([ ]*?)[A-z0-9]+([ ]*?)=([ ]*?)(.+?))*)\}\}/is";
   291     $template_regex = "/\{\{(.+)((\n|\|[ ]*([A-z0-9]+)[ ]*=[ ]*(.+))*)\}\}/isU";
   275     $template_regex = "/\{\{(.+)((\n|\|[ ]*([A-z0-9]+)[ ]*=[ ]*(.+))*)\}\}/isU";
   292     $i = 0;
   276     $i = 0;
   293     while ( preg_match($template_regex, $text) )
   277     while ( preg_match($template_regex, $text) )
   294     {
   278     {
   295       $i++;
   279       $i++;
   296       if ( $i == 5 )
   280       if ( $i == 5 )
   297         break;
   281         break;
   298       $text = RenderMan::include_templates($text);
   282       $text = RenderMan::include_templates($text);
       
   283     }
       
   284     
       
   285     if ( !$plaintext )
       
   286     {
       
   287       // Process images
       
   288       $text = RenderMan::process_image_tags($text, $taglist);
       
   289       $text = RenderMan::process_imgtags_stage2($text, $taglist);
       
   290     }
       
   291     
       
   292     if($do_params)
       
   293     {
       
   294       preg_match_all('#\(_([0-9]+)_\)#', $text, $matchlist);
       
   295       foreach($matchlist[1] as $m)
       
   296       {
       
   297         $text = str_replace('(_'.$m.'_)', $paths->getParam((int)$m), $text);
       
   298       }
   299     }
   299     }
   300     
   300     
   301     // Before shipping it out to the renderer, replace spaces in between headings and paragraphs:
   301     // Before shipping it out to the renderer, replace spaces in between headings and paragraphs:
   302     $text = preg_replace('/<\/(h[0-9]|div|p)>([\s]+)<(h[0-9]|div|p)( .+?)?>/i', '</\\1><\\3\\4>', $text);
   302     $text = preg_replace('/<\/(h[0-9]|div|p)>([\s]+)<(h[0-9]|div|p)( .+?)?>/i', '</\\1><\\3\\4>', $text);
   303     
   303     
   493     // stage 1 - links with alternate text
   493     // stage 1 - links with alternate text
   494     preg_match_all('/\[\[([^\[\]<>\{\}\|]+)\|(.+?)\]\]/', $text, $matches);
   494     preg_match_all('/\[\[([^\[\]<>\{\}\|]+)\|(.+?)\]\]/', $text, $matches);
   495     foreach ( $matches[0] as $i => $match )
   495     foreach ( $matches[0] as $i => $match )
   496     {
   496     {
   497       list($page_id, $namespace) = RenderMan::strToPageID($matches[1][$i]);
   497       list($page_id, $namespace) = RenderMan::strToPageID($matches[1][$i]);
       
   498       if ( ($pos = strrpos($page_id, '#')) !== false )
       
   499       {
       
   500         $hash = substr($page_id, $pos);
       
   501         $page_id = substr($page_id, 0, $pos);
       
   502       }
       
   503       else
       
   504       {
       
   505         $hash = '';
       
   506       }
   498       $pid_clean = $paths->nslist[$namespace] . sanitize_page_id($page_id);
   507       $pid_clean = $paths->nslist[$namespace] . sanitize_page_id($page_id);
   499       
   508       
   500       $url = makeUrl($pid_clean, false, true);
   509       $url = makeUrl($pid_clean, false, true) . $hash;
   501       $inner_text = $matches[2][$i];
   510       $inner_text = $matches[2][$i];
   502       $quot = '"';
   511       $quot = '"';
   503       $exists = ( isPage($pid_clean) ) ? '' : ' class="wikilink-nonexistent"';
   512       $exists = ( isPage($pid_clean) ) ? '' : ' class="wikilink-nonexistent"';
   504       
   513       
   505       if ( $tplcode )
   514       if ( $tplcode )