equal
deleted
inserted
replaced
213 } |
213 } |
214 |
214 |
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; |
|
219 |
218 $random_id = md5( time() . mt_rand() ); |
220 $random_id = md5( time() . mt_rand() ); |
219 |
221 |
220 // Strip out <nowiki> sections and PHP code |
222 // Strip out <nowiki> sections and PHP code |
221 |
223 |
222 $php = preg_match_all('#<\?php(.*?)\?>#is', $text, $phpsec); |
224 $php = preg_match_all('#<\?php(.*?)\?>#is', $text, $phpsec); |
235 |
237 |
236 $text = preg_replace('/<noinclude>(.*?)<\/noinclude>/is', '\\1', $text); |
238 $text = preg_replace('/<noinclude>(.*?)<\/noinclude>/is', '\\1', $text); |
237 if ( $paths->namespace == 'Template' ) |
239 if ( $paths->namespace == 'Template' ) |
238 { |
240 { |
239 $text = preg_replace('/<nodisplay>(.*?)<\/nodisplay>/is', '', $text); |
241 $text = preg_replace('/<nodisplay>(.*?)<\/nodisplay>/is', '', $text); |
|
242 } |
|
243 |
|
244 preg_match_all('/<lang code="([a-z0-9_]+)">([\w\W]+?)<\/lang>/', $text, $langmatch); |
|
245 foreach ( $langmatch[0] as $i => $match ) |
|
246 { |
|
247 if ( $langmatch[1][$i] == $lang->lang_code ) |
|
248 { |
|
249 $text = str_replace_once($match, $langmatch[2][$i], $text); |
|
250 } |
|
251 else |
|
252 { |
|
253 $text = str_replace_once($match, '', $text); |
|
254 } |
240 } |
255 } |
241 |
256 |
242 $code = $plugins->setHook('render_wikiformat_pre'); |
257 $code = $plugins->setHook('render_wikiformat_pre'); |
243 foreach ( $code as $cmd ) |
258 foreach ( $code as $cmd ) |
244 { |
259 { |
616 { |
631 { |
617 global $db, $session, $paths, $template, $plugins; // Common objects |
632 global $db, $session, $paths, $template, $plugins; // Common objects |
618 $random_id = md5( time() . mt_rand() ); |
633 $random_id = md5( time() . mt_rand() ); |
619 |
634 |
620 $can_do_php = ( $session->get_permissions('php_in_pages') && !$strip_all_php ); |
635 $can_do_php = ( $session->get_permissions('php_in_pages') && !$strip_all_php ); |
621 |
636 $can_do_html = $session->get_permissions('html_in_pages'); |
622 if ( !$can_do_php ) |
637 |
|
638 if ( $can_do_html && !$can_do_php ) |
|
639 { |
|
640 $text = preg_replace('#<(\?|\?php|%)(.*?)(\?|%)>#is', '<\\1\\2\\3>', $text); |
|
641 } |
|
642 else if ( !$can_do_html && !$can_do_php ) |
623 { |
643 { |
624 $text = sanitize_html($text, true); |
644 $text = sanitize_html($text, true); |
625 // If we can't do PHP, we can't do Javascript either. |
645 // If we can't do PHP, we can't do Javascript either. |
626 $text = RenderMan::destroy_javascript($text); |
646 $text = RenderMan::destroy_javascript($text); |
627 } |
647 } |
823 $s_delim = "\xFF"; |
843 $s_delim = "\xFF"; |
824 $f_delim = "\xFF"; |
844 $f_delim = "\xFF"; |
825 $taglist = array(); |
845 $taglist = array(); |
826 |
846 |
827 // Wicked huh? |
847 // Wicked huh? |
828 $regex = '/\[\[:' . $paths->nslist['File'] . '([\w\s0-9_\(\)!@%\^\+\|\.-]+?)((\|thumb)|(\|([0-9]+)x([0-9]+)))?(\|left|\|right)?(\|raw|\|(.+))?\]\]/i'; |
848 $regex = '/\[\[:' . str_replace('/', '\\/', preg_quote($paths->nslist['File'])) . '([\w\s0-9_\(\)!@%\^\+\|\.-]+?)((\|thumb)|(\|([0-9]+)x([0-9]+)))?(\|left|\|right)?(\|raw|\|(.+))?\]\]/i'; |
829 |
849 |
830 preg_match_all($regex, $text, $matches); |
850 preg_match_all($regex, $text, $matches); |
831 |
851 |
832 foreach ( $matches[0] as $i => $match ) |
852 foreach ( $matches[0] as $i => $match ) |
833 { |
853 { |