includes/render.php
changeset 162 ad00dc1f8706
parent 158 f7e83b6db3be
child 165 d53cc29308f4
child 170 4c5c2b66a34d
equal deleted inserted replaced
161:e1a22031b5bd 162:ad00dc1f8706
   246     if ( $paths->namespace == 'Template' )
   246     if ( $paths->namespace == 'Template' )
   247     {
   247     {
   248       $text = preg_replace('/<nodisplay>(.*?)<\/nodisplay>/is', '', $text);
   248       $text = preg_replace('/<nodisplay>(.*?)<\/nodisplay>/is', '', $text);
   249     }
   249     }
   250     
   250     
       
   251     $code = $plugins->setHook('render_wikiformat_pre');
       
   252     foreach ( $code as $cmd )
       
   253     {
       
   254       eval($cmd);
       
   255     }
       
   256     
   251     if ( !$plaintext )
   257     if ( !$plaintext )
   252     {
   258     {
   253       // Process images
   259       // Process images
   254       $text = RenderMan::process_image_tags($text, $taglist);
   260       $text = RenderMan::process_image_tags($text, $taglist);
   255       $text = RenderMan::process_imgtags_stage2($text, $taglist);
   261       $text = RenderMan::process_imgtags_stage2($text, $taglist);
   288       $wiki->setRenderConf('Xhtml', 'wikilink', 'view_url', contentPath);
   294       $wiki->setRenderConf('Xhtml', 'wikilink', 'view_url', contentPath);
   289       $wiki->setRenderConf('Xhtml', 'Url', 'css_descr', 'external');
   295       $wiki->setRenderConf('Xhtml', 'Url', 'css_descr', 'external');
   290       $result = $wiki->transform($text, 'Xhtml');
   296       $result = $wiki->transform($text, 'Xhtml');
   291     }
   297     }
   292     
   298     
   293     // if ( !$plaintext )
   299     // HTML fixes
   294     // {
   300     $result = preg_replace('#<tr>([\s]*?)<\/tr>#is', '', $result);
   295     //   $result = RenderMan::process_imgtags_stage2($result, $taglist);
   301     $result = preg_replace('#<p>([\s]*?)<\/p>#is', '', $result);
   296     // }
   302     $result = preg_replace('#<br />([\s]*?)<table#is', '<table', $result);
       
   303     $result = str_replace("<pre><code>\n", "<pre><code>", $result);
       
   304     $result = preg_replace("/<p><table([^>]*?)><\/p>/", "<table\\1>", $result);
       
   305     $result = str_replace("<br />\n</td>", "\n</td>", $result);
       
   306     $result = str_replace("<p><tr>", "<tr>", $result);
       
   307     $result = str_replace("<tr><br />", "<tr>", $result);
       
   308     $result = str_replace("</tr><br />", "</tr>", $result);
       
   309     $result = str_replace("</table><br />", "</table>", $result);
       
   310     $result = preg_replace('/<\/table>$/', "</table><br /><br />", $result);
       
   311     $result = str_replace("<p></div></p>", "</div>", $result);
       
   312     $result = str_replace("<p></table></p>", "</table>", $result);
       
   313     
       
   314     $code = $plugins->setHook('render_wikiformat_post');
       
   315     foreach ( $code as $cmd )
       
   316     {
       
   317       eval($cmd);
       
   318     }
   297     
   319     
   298     // Reinsert <nowiki> sections
   320     // Reinsert <nowiki> sections
   299     for($i=0;$i<$nw;$i++)
   321     for($i=0;$i<$nw;$i++)
   300     {
   322     {
   301       $result = str_replace('{NOWIKI:'.$random_id.':'.$i.'}', $nowiki[1][$i], $result);
   323       $result = str_replace('{NOWIKI:'.$random_id.':'.$i.'}', $nowiki[1][$i], $result);
   309     
   331     
   310     return $result;
   332     return $result;
   311     
   333     
   312   }
   334   }
   313   
   335   
   314   function wikiFormat($message, $filter_links = true, $do_params = false, $plaintext = false) {
   336   function wikiFormat($message, $filter_links = true, $do_params = false, $plaintext = false)
       
   337   {
   315     global $db, $session, $paths, $template, $plugins; // Common objects
   338     global $db, $session, $paths, $template, $plugins; // Common objects
   316     
   339     
   317     return RenderMan::next_gen_wiki_format($message, $plaintext, $filter_links, $do_params);
   340     return RenderMan::next_gen_wiki_format($message, $plaintext, $filter_links, $do_params);
   318     
   341     
   319     $random_id = md5( time() . mt_rand() );
   342     $random_id = md5( time() . mt_rand() );
   382     $result = str_replace("<tr><br />", "<tr>", $result);
   405     $result = str_replace("<tr><br />", "<tr>", $result);
   383     $result = str_replace("</tr><br />", "</tr>", $result);
   406     $result = str_replace("</tr><br />", "</tr>", $result);
   384     $result = str_replace("</table></p>", "</table>", $result);
   407     $result = str_replace("</table></p>", "</table>", $result);
   385     $result = str_replace("</table><br />", "</table>", $result);
   408     $result = str_replace("</table><br />", "</table>", $result);
   386     $result = preg_replace('/<\/table>$/', "</table><br /><br />", $result);
   409     $result = preg_replace('/<\/table>$/', "</table><br /><br />", $result);
       
   410     $result = str_replace("<p></div></p>", "</div>", $result);
       
   411     $result = str_replace("<p></table></p>", "</table>", $result);
   387     
   412     
   388     $result = str_replace('<nowiki>',  '&lt;nowiki&gt;',  $result);
   413     $result = str_replace('<nowiki>',  '&lt;nowiki&gt;',  $result);
   389     $result = str_replace('</nowiki>', '&lt;/nowiki&gt;', $result);
   414     $result = str_replace('</nowiki>', '&lt;/nowiki&gt;', $result);
   390     
   415     
   391     return $result;
   416     return $result;