equal
deleted
inserted
replaced
215 public static function next_gen_wiki_format($text, $plaintext = false, $filter_links = true, $do_params = false) |
215 public static function next_gen_wiki_format($text, $plaintext = false, $filter_links = true, $do_params = false) |
216 { |
216 { |
217 global $db, $session, $paths, $template, $plugins; // Common objects |
217 global $db, $session, $paths, $template, $plugins; // Common objects |
218 global $lang; |
218 global $lang; |
219 |
219 |
|
220 require_once(ENANO_ROOT.'/includes/wikiformat.php'); |
|
221 require_once(ENANO_ROOT.'/includes/wikiengine/Tables.php'); |
|
222 |
220 profiler_log("RenderMan: starting wikitext render"); |
223 profiler_log("RenderMan: starting wikitext render"); |
221 |
224 |
222 $random_id = md5( time() . mt_rand() ); |
225 $random_id = md5( time() . mt_rand() ); |
223 |
226 |
224 // Strip out <nowiki> sections and PHP code |
227 // Strip out <nowiki> sections and PHP code |
472 } |
475 } |
473 |
476 |
474 /** |
477 /** |
475 * Parses internal links (wikilinks) in a block of text. |
478 * Parses internal links (wikilinks) in a block of text. |
476 * @param string Text to process |
479 * @param string Text to process |
|
480 * @param string Optional. If included will be used as a template instead of using the default syntax. |
477 * @return string |
481 * @return string |
478 */ |
482 */ |
479 |
483 |
480 public static function parse_internal_links($text) |
484 public static function parse_internal_links($text, $tplcode = false) |
481 { |
485 { |
482 global $db, $session, $paths, $template, $plugins; // Common objects |
486 global $db, $session, $paths, $template, $plugins; // Common objects |
|
487 |
|
488 if ( is_string($tplcode) ) |
|
489 { |
|
490 $parser = $template->makeParserText($tplcode); |
|
491 } |
483 |
492 |
484 // stage 1 - links with alternate text |
493 // stage 1 - links with alternate text |
485 preg_match_all('/\[\[([^\[\]<>\{\}\|]+)\|(.+?)\]\]/', $text, $matches); |
494 preg_match_all('/\[\[([^\[\]<>\{\}\|]+)\|(.+?)\]\]/', $text, $matches); |
486 foreach ( $matches[0] as $i => $match ) |
495 foreach ( $matches[0] as $i => $match ) |
487 { |
496 { |
491 $url = makeUrl($pid_clean, false, true); |
500 $url = makeUrl($pid_clean, false, true); |
492 $inner_text = $matches[2][$i]; |
501 $inner_text = $matches[2][$i]; |
493 $quot = '"'; |
502 $quot = '"'; |
494 $exists = ( isPage($pid_clean) ) ? '' : ' class="wikilink-nonexistent"'; |
503 $exists = ( isPage($pid_clean) ) ? '' : ' class="wikilink-nonexistent"'; |
495 |
504 |
496 $link = "<a href={$quot}{$url}{$quot}{$exists}>{$inner_text}</a>"; |
505 if ( $tplcode ) |
|
506 { |
|
507 $parser->assign_vars(array( |
|
508 'HREF' => $url, |
|
509 'FLAGS' => $exists, |
|
510 'TEXT' => $inner_text |
|
511 )); |
|
512 $link = $parser->run(); |
|
513 } |
|
514 else |
|
515 { |
|
516 $link = "<a href={$quot}{$url}{$quot}{$exists}>{$inner_text}</a>"; |
|
517 } |
497 |
518 |
498 $text = str_replace($match, $link, $text); |
519 $text = str_replace($match, $link, $text); |
499 } |
520 } |
500 |
521 |
501 // stage 2 - links with no alternate text |
522 // stage 2 - links with no alternate text |
508 $url = makeUrl($pid_clean, false, true); |
529 $url = makeUrl($pid_clean, false, true); |
509 $inner_text = ( isPage($pid_clean) ) ? htmlspecialchars(get_page_title($pid_clean)) : htmlspecialchars($matches[1][$i]); |
530 $inner_text = ( isPage($pid_clean) ) ? htmlspecialchars(get_page_title($pid_clean)) : htmlspecialchars($matches[1][$i]); |
510 $quot = '"'; |
531 $quot = '"'; |
511 $exists = ( isPage($pid_clean) ) ? '' : ' class="wikilink-nonexistent"'; |
532 $exists = ( isPage($pid_clean) ) ? '' : ' class="wikilink-nonexistent"'; |
512 |
533 |
513 $link = "<a href={$quot}{$url}{$quot}{$exists}>{$inner_text}</a>"; |
534 if ( $tplcode ) |
|
535 { |
|
536 $parser->assign_vars(array( |
|
537 'HREF' => $url, |
|
538 'FLAGS' => $exists, |
|
539 'TEXT' => $inner_text |
|
540 )); |
|
541 $link = $parser->run(); |
|
542 } |
|
543 else |
|
544 { |
|
545 $link = "<a href={$quot}{$url}{$quot}{$exists}>{$inner_text}</a>"; |
|
546 } |
514 |
547 |
515 $text = str_replace($match, $link, $text); |
548 $text = str_replace($match, $link, $text); |
516 } |
549 } |
517 |
550 |
518 return $text; |
551 return $text; |
843 * @return string |
876 * @return string |
844 */ |
877 */ |
845 public static function diff($str1, $str2) |
878 public static function diff($str1, $str2) |
846 { |
879 { |
847 global $db, $session, $paths, $template, $plugins; // Common objects |
880 global $db, $session, $paths, $template, $plugins; // Common objects |
|
881 require_once(ENANO_ROOT.'/includes/diff.php'); |
848 $str1 = explode("\n", $str1); |
882 $str1 = explode("\n", $str1); |
849 $str2 = explode("\n", $str2); |
883 $str2 = explode("\n", $str2); |
850 $diff = new Diff($str1, $str2); |
884 $diff = new Diff($str1, $str2); |
851 $renderer = new TableDiffFormatter(); |
885 $renderer = new TableDiffFormatter(); |
852 return '<table class="diff">'.$renderer->format($diff).'</table>'; |
886 return '<table class="diff">'.$renderer->format($diff).'</table>'; |