379 $local_page = $page->namespace . substr($paths->nslist['Special'], -1) . $page->page_id . $page_append; |
379 $local_page = $page->namespace . substr($paths->nslist['Special'], -1) . $page->page_id . $page_append; |
380 } |
380 } |
381 $local_fullpage = $local_page . $page_append; |
381 $local_fullpage = $local_page . $page_append; |
382 $local_page_id =& $page->page_id; |
382 $local_page_id =& $page->page_id; |
383 $local_namespace =& $page->namespace; |
383 $local_namespace =& $page->namespace; |
|
384 $local_page_exists =& $page->page_exists; |
384 $perms =& $page->perms; |
385 $perms =& $page->perms; |
385 } |
386 } |
386 else |
387 else |
387 { |
388 { |
388 $local_page =& $paths->page; |
389 $local_page =& $paths->page; |
389 $local_page_id =& $paths->page_id; |
390 $local_page_id =& $paths->page_id; |
390 $local_fullpage =& $paths->fullpage; |
391 $local_fullpage =& $paths->fullpage; |
391 $local_namespace =& $paths->namespace; |
392 $local_namespace =& $paths->namespace; |
|
393 $local_page_exists =& $paths->page_exists; |
|
394 $local_page_protected =& $paths->page_protected; |
392 $perms =& $session; |
395 $perms =& $session; |
|
396 } |
|
397 |
|
398 if ( $local_page_exists && isset($paths->pages[$local_page]) ) |
|
399 { |
|
400 $local_cdata =& $paths->pages[$local_page]; |
|
401 } |
|
402 else |
|
403 { |
|
404 // if the page doesn't exist but we're trying to load it, it was requested manually and $paths->cpage should match it. |
|
405 if ( $paths->page_id == $local_page_id ) |
|
406 { |
|
407 // load metadata from cpage |
|
408 $local_cdata =& $paths->cpage; |
|
409 } |
|
410 else |
|
411 { |
|
412 // generate our own failsafe metadata |
|
413 $local_cdata = array( |
|
414 'urlname' => $local_page, |
|
415 'urlname_nons' => $local_page_id, |
|
416 'namespace' => $local_namespace, |
|
417 'name' => get_page_title_ns($local_page_id, $local_namespace), |
|
418 'comments_on' => 0, |
|
419 'protected' => 0, |
|
420 'wiki_mode' => 2, |
|
421 'delvotes' => 0, |
|
422 'delvote_ips' => serialize(array()) |
|
423 ); |
|
424 } |
|
425 } |
|
426 |
|
427 // calculate protection |
|
428 if ( !isset($local_page_protected) ) |
|
429 { |
|
430 if ( $local_cdata['protected'] == 0 ) |
|
431 { |
|
432 $local_page_protected = false; |
|
433 } |
|
434 else if ( $local_cdata['protected'] == 1 ) |
|
435 { |
|
436 $local_page_protected = true; |
|
437 } |
|
438 else if ( $local_cdata['protected'] == 2 ) |
|
439 { |
|
440 if ( |
|
441 ( !$session->user_logged_in || // Is the user logged in? |
|
442 ( $session->user_logged_in && $session->reg_time + ( 4 * 86400 ) >= time() ) ) // If so, have they been registered for 4 days? |
|
443 && !$perms->get_permissions('even_when_protected') ) // And of course, is there an ACL that overrides semi-protection? |
|
444 { |
|
445 $local_page_protected = true; |
|
446 } |
|
447 else |
|
448 { |
|
449 $local_page_protected = false; |
|
450 } |
|
451 } |
393 } |
452 } |
394 |
453 |
395 $tplvars = $this->extract_vars('elements.tpl'); |
454 $tplvars = $this->extract_vars('elements.tpl'); |
396 |
455 |
397 if(isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) |
456 if(isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) |
571 'TEXT' => $lang->get('onpage_btn_viewsource') |
630 'TEXT' => $lang->get('onpage_btn_viewsource') |
572 )); |
631 )); |
573 $tb .= $button->run(); |
632 $tb .= $button->run(); |
574 } |
633 } |
575 // History button |
634 // History button |
576 if ( $perms->get_permissions('read') /* && $paths->wiki_mode */ && $paths->page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin' && $perms->get_permissions('history_view') ) |
635 if ( $perms->get_permissions('read') /* && $paths->wiki_mode */ && $local_page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin' && $perms->get_permissions('history_view') ) |
577 { |
636 { |
578 $button->assign_vars(array( |
637 $button->assign_vars(array( |
579 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxHistory()); return false; }" title="' . $lang->get('onpage_tip_history') . '" accesskey="h"', |
638 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxHistory()); return false; }" title="' . $lang->get('onpage_tip_history') . '" accesskey="h"', |
580 'PARENTFLAGS' => 'id="mdgToolbar_history"', |
639 'PARENTFLAGS' => 'id="mdgToolbar_history"', |
581 'HREF' => makeUrl($local_page, 'do=history', true), |
640 'HREF' => makeUrl($local_page, 'do=history', true), |
586 |
645 |
587 $menubtn = $this->makeParserText($tplvars['toolbar_menu_button']); |
646 $menubtn = $this->makeParserText($tplvars['toolbar_menu_button']); |
588 |
647 |
589 // Additional actions menu |
648 // Additional actions menu |
590 // Rename button |
649 // Rename button |
591 if ( $perms->get_permissions('read') && $paths->page_exists && ( $perms->get_permissions('rename') && ( $paths->page_protected && $perms->get_permissions('even_when_protected') || !$paths->page_protected ) ) && $local_namespace != 'Special' && $local_namespace != 'Admin' ) |
650 if ( $perms->get_permissions('read') && $local_page_exists && ( $perms->get_permissions('rename') && ( $paths->page_protected && $perms->get_permissions('even_when_protected') || !$paths->page_protected ) ) && $local_namespace != 'Special' && $local_namespace != 'Admin' ) |
592 { |
651 { |
593 $menubtn->assign_vars(array( |
652 $menubtn->assign_vars(array( |
594 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxRename()); return false; }" title="' . $lang->get('onpage_tip_rename') . '" accesskey="r"', |
653 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxRename()); return false; }" title="' . $lang->get('onpage_tip_rename') . '" accesskey="r"', |
595 'HREF' => makeUrl($local_page, 'do=rename', true), |
654 'HREF' => makeUrl($local_page, 'do=rename', true), |
596 'TEXT' => $lang->get('onpage_btn_rename'), |
655 'TEXT' => $lang->get('onpage_btn_rename'), |
597 )); |
656 )); |
598 $this->toolbar_menu .= $menubtn->run(); |
657 $this->toolbar_menu .= $menubtn->run(); |
599 } |
658 } |
600 |
659 |
601 // Vote-to-delete button |
660 // Vote-to-delete button |
602 if ( $paths->wiki_mode && $perms->get_permissions('vote_delete') && $paths->page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin') |
661 if ( $paths->wiki_mode && $perms->get_permissions('vote_delete') && $local_page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin') |
603 { |
662 { |
604 $menubtn->assign_vars(array( |
663 $menubtn->assign_vars(array( |
605 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxDelVote()); return false; }" title="' . $lang->get('onpage_tip_delvote') . '" accesskey="d"', |
664 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxDelVote()); return false; }" title="' . $lang->get('onpage_tip_delvote') . '" accesskey="d"', |
606 'HREF' => makeUrl($local_page, 'do=delvote', true), |
665 'HREF' => makeUrl($local_page, 'do=delvote', true), |
607 'TEXT' => $lang->get('onpage_btn_votedelete'), |
666 'TEXT' => $lang->get('onpage_btn_votedelete'), |
608 )); |
667 )); |
609 $this->toolbar_menu .= $menubtn->run(); |
668 $this->toolbar_menu .= $menubtn->run(); |
610 } |
669 } |
611 |
670 |
612 // Clear-votes button |
671 // Clear-votes button |
613 if ( $perms->get_permissions('read') && $paths->wiki_mode && $paths->page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin' && $perms->get_permissions('vote_reset') && $paths->cpage['delvotes'] > 0) |
672 if ( $perms->get_permissions('read') && $paths->wiki_mode && $local_page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin' && $perms->get_permissions('vote_reset') && $local_cdata['delvotes'] > 0) |
614 { |
673 { |
615 $menubtn->assign_vars(array( |
674 $menubtn->assign_vars(array( |
616 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxResetDelVotes()); return false; }" title="' . $lang->get('onpage_tip_resetvotes') . '" accesskey="y"', |
675 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxResetDelVotes()); return false; }" title="' . $lang->get('onpage_tip_resetvotes') . '" accesskey="y"', |
617 'HREF' => makeUrl($local_page, 'do=resetvotes', true), |
676 'HREF' => makeUrl($local_page, 'do=resetvotes', true), |
618 'TEXT' => $lang->get('onpage_btn_votedelete_reset'), |
677 'TEXT' => $lang->get('onpage_btn_votedelete_reset'), |
619 )); |
678 )); |
620 $this->toolbar_menu .= $menubtn->run(); |
679 $this->toolbar_menu .= $menubtn->run(); |
621 } |
680 } |
622 |
681 |
623 // Printable page button |
682 // Printable page button |
624 if ( $paths->page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin' ) |
683 if ( $local_page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin' ) |
625 { |
684 { |
626 $menubtn->assign_vars(array( |
685 $menubtn->assign_vars(array( |
627 'FLAGS' => 'title="' . $lang->get('onpage_tip_printable') . '"', |
686 'FLAGS' => 'title="' . $lang->get('onpage_tip_printable') . '"', |
628 'HREF' => makeUrl($local_page, 'printable=yes', true), |
687 'HREF' => makeUrl($local_page, 'printable=yes', true), |
629 'TEXT' => $lang->get('onpage_btn_printable'), |
688 'TEXT' => $lang->get('onpage_btn_printable'), |
630 )); |
689 )); |
631 $this->toolbar_menu .= $menubtn->run(); |
690 $this->toolbar_menu .= $menubtn->run(); |
632 } |
691 } |
633 |
692 |
634 // Protect button |
693 // Protect button |
635 if($perms->get_permissions('read') && $paths->wiki_mode && $paths->page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin' && $perms->get_permissions('protect')) |
694 if($perms->get_permissions('read') && $paths->wiki_mode && $local_page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin' && $perms->get_permissions('protect')) |
636 { |
695 { |
637 |
696 |
638 $label = $this->makeParserText($tplvars['toolbar_label']); |
697 $label = $this->makeParserText($tplvars['toolbar_label']); |
639 $label->assign_vars(array('TEXT' => $lang->get('onpage_lbl_protect'))); |
698 $label->assign_vars(array('TEXT' => $lang->get('onpage_lbl_protect'))); |
640 $t0 = $label->run(); |
699 $t0 = $label->run(); |
641 |
700 |
642 $ctmp = ''; |
701 $ctmp = ''; |
643 if ( $paths->cpage['protected'] == 1 ) |
702 if ( $local_cdata['protected'] == 1 ) |
644 { |
703 { |
645 $ctmp=' style="text-decoration: underline;"'; |
704 $ctmp=' style="text-decoration: underline;"'; |
646 } |
705 } |
647 $menubtn->assign_vars(array( |
706 $menubtn->assign_vars(array( |
648 'FLAGS' => 'accesskey="i" onclick="if ( !KILL_SWITCH ) { ajaxProtect(1); return false; }" id="protbtn_1" title="' . $lang->get('onpage_tip_protect_on') . '"'.$ctmp, |
707 'FLAGS' => 'accesskey="i" onclick="if ( !KILL_SWITCH ) { ajaxProtect(1); return false; }" id="protbtn_1" title="' . $lang->get('onpage_tip_protect_on') . '"'.$ctmp, |
753 )); |
812 )); |
754 $this->toolbar_menu .= $menubtn->run(); |
813 $this->toolbar_menu .= $menubtn->run(); |
755 } |
814 } |
756 |
815 |
757 // Delete page button |
816 // Delete page button |
758 if ( $perms->get_permissions('read') && $perms->get_permissions('delete_page') && $paths->page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin' ) |
817 if ( $perms->get_permissions('read') && $perms->get_permissions('delete_page') && $local_page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin' ) |
759 { |
818 { |
760 $s = $lang->get('onpage_btn_deletepage'); |
819 $s = $lang->get('onpage_btn_deletepage'); |
761 if ( $paths->cpage['delvotes'] == 1 ) |
820 if ( $local_cdata['delvotes'] == 1 ) |
762 { |
821 { |
763 $subst = array( |
822 $subst = array( |
764 'num_votes' => $paths->cpage['delvotes'], |
823 'num_votes' => $local_cdata['delvotes'], |
765 'plural' => '' |
824 'plural' => '' |
766 ); |
825 ); |
767 $s .= $lang->get('onpage_btn_deletepage_votes', $subst); |
826 $s .= $lang->get('onpage_btn_deletepage_votes', $subst); |
768 } |
827 } |
769 else if ( $paths->cpage['delvotes'] > 1 ) |
828 else if ( $local_cdata['delvotes'] > 1 ) |
770 { |
829 { |
771 $subst = array( |
830 $subst = array( |
772 'num_votes' => $paths->cpage['delvotes'], |
831 'num_votes' => $local_cdata['delvotes'], |
773 'plural' => $lang->get('meta_plural') |
832 'plural' => $lang->get('meta_plural') |
774 ); |
833 ); |
775 $s .= $lang->get('onpage_btn_deletepage_votes', $subst); |
834 $s .= $lang->get('onpage_btn_deletepage_votes', $subst); |
776 } |
835 } |
777 |
836 |
827 )); |
886 )); |
828 $this->toolbar_menu .= $menubtn->run(); |
887 $this->toolbar_menu .= $menubtn->run(); |
829 } |
888 } |
830 |
889 |
831 // Administer page button |
890 // Administer page button |
832 if ( $session->user_level >= USER_LEVEL_ADMIN && $paths->page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin' ) |
891 if ( $session->user_level >= USER_LEVEL_ADMIN && $local_page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin' ) |
833 { |
892 { |
834 $menubtn->assign_vars(array( |
893 $menubtn->assign_vars(array( |
835 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxAdminPage()); return false; }" title="' . $lang->get('onpage_tip_adminoptions') . '" accesskey="g"', |
894 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxAdminPage()); return false; }" title="' . $lang->get('onpage_tip_adminoptions') . '" accesskey="g"', |
836 'HREF' => makeUrlNS('Special', 'Administration', 'module='.$paths->nslist['Admin'].'PageManager', true), |
895 'HREF' => makeUrlNS('Special', 'Administration', 'module='.$paths->nslist['Admin'].'PageManager', true), |
837 'TEXT' => $lang->get('onpage_btn_admin'), |
896 'TEXT' => $lang->get('onpage_btn_admin'), |
939 |
998 |
940 $urlname_clean = str_replace('\'', '\\\'', str_replace('\\', '\\\\', dirtify_page_id($local_fullpage))); |
999 $urlname_clean = str_replace('\'', '\\\'', str_replace('\\', '\\\\', dirtify_page_id($local_fullpage))); |
941 $urlname_clean = strtr( $urlname_clean, array( '<' => '<', '>' => '>' ) ); |
1000 $urlname_clean = strtr( $urlname_clean, array( '<' => '<', '>' => '>' ) ); |
942 |
1001 |
943 $urlname_jssafe = sanitize_page_id($local_fullpage); |
1002 $urlname_jssafe = sanitize_page_id($local_fullpage); |
|
1003 $physical_urlname_jssafe = sanitize_page_id($paths->fullpage); |
944 |
1004 |
945 // Generate the dynamic javascript vars |
1005 // Generate the dynamic javascript vars |
946 $js_dynamic = ' <script type="text/javascript">// <![CDATA[ |
1006 $js_dynamic = ' <script type="text/javascript">// <![CDATA[ |
947 // This section defines some basic and very important variables that are used later in the static Javascript library. |
1007 // This section defines some basic and very important variables that are used later in the static Javascript library. |
948 // SKIN DEVELOPERS: The template variable for this code block is {JS_DYNAMIC_VARS}. This MUST be inserted BEFORE the tag that links to the main Javascript lib. |
1008 // SKIN DEVELOPERS: The template variable for this code block is {JS_DYNAMIC_VARS}. This MUST be inserted BEFORE the tag that links to the main Javascript lib. |
949 var title=\''. $urlname_jssafe .'\'; |
1009 var title = \''. $urlname_jssafe .'\'; |
950 var page_exists='. ( ( $paths->page_exists) ? 'true' : 'false' ) .'; |
1010 var physical_title = \'' . $physical_urlname_jssafe . '\'; |
951 var scriptPath=\''. scriptPath .'\'; |
1011 var page_exists = '. ( ( $local_page_exists) ? 'true' : 'false' ) .'; |
952 var contentPath=\''.contentPath.'\'; |
1012 var scriptPath = \''. scriptPath .'\'; |
953 var ENANO_SID =\'' . $SID . '\'; |
1013 var contentPath = \''.contentPath.'\'; |
954 var user_level=' . $session->user_level . '; |
1014 var ENANO_SID = \'' . $SID . '\'; |
955 var auth_level=' . $session->auth_level . '; |
1015 var user_level = ' . $session->user_level . '; |
|
1016 var auth_level = ' . $session->auth_level . '; |
956 var USER_LEVEL_GUEST = ' . USER_LEVEL_GUEST . '; |
1017 var USER_LEVEL_GUEST = ' . USER_LEVEL_GUEST . '; |
957 var USER_LEVEL_MEMBER = ' . USER_LEVEL_MEMBER . '; |
1018 var USER_LEVEL_MEMBER = ' . USER_LEVEL_MEMBER . '; |
958 var USER_LEVEL_CHPREF = ' . USER_LEVEL_CHPREF . '; |
1019 var USER_LEVEL_CHPREF = ' . USER_LEVEL_CHPREF . '; |
959 var USER_LEVEL_MOD = ' . USER_LEVEL_MOD . '; |
1020 var USER_LEVEL_MOD = ' . USER_LEVEL_MOD . '; |
960 var USER_LEVEL_ADMIN = ' . USER_LEVEL_ADMIN . '; |
1021 var USER_LEVEL_ADMIN = ' . USER_LEVEL_ADMIN . '; |
|
1022 var disable_redirect = ' . ( isset($_GET['redirect']) && $_GET['redirect'] == 'no' ? 'true' : 'false' ) . '; |
961 var pref_disable_js_fx = ' . ( @$session->user_extra['disable_js_fx'] == 1 ? '1' : '0' ) . '; |
1023 var pref_disable_js_fx = ' . ( @$session->user_extra['disable_js_fx'] == 1 ? '1' : '0' ) . '; |
962 var csrf_token = "' . $session->csrf_token . '"; |
1024 var csrf_token = "' . $session->csrf_token . '"; |
963 var editNotice = \'' . ( (getConfig('wiki_edit_notice')=='1') ? str_replace("\n", "\\\n", RenderMan::render(getConfig('wiki_edit_notice_text'))) : '' ) . '\'; |
1025 var editNotice = \'' . ( (getConfig('wiki_edit_notice')=='1') ? str_replace("\n", "\\\n", RenderMan::render(getConfig('wiki_edit_notice_text'))) : '' ) . '\'; |
964 var prot = ' . ( ($paths->page_protected && !$perms->get_permissions('even_when_protected')) ? 'true' : 'false' ) .'; // No, hacking this var won\'t work, it\'s re-checked on the server |
1026 var prot = ' . ( ($paths->page_protected && !$perms->get_permissions('even_when_protected')) ? 'true' : 'false' ) .'; // No, hacking this var won\'t work, it\'s re-checked on the server |
965 var ENANO_SPECIAL_CREATEPAGE = \''. makeUrl($paths->nslist['Special'].'CreatePage') .'\'; |
1027 var ENANO_SPECIAL_CREATEPAGE = \''. makeUrl($paths->nslist['Special'].'CreatePage') .'\'; |
2036 |
2098 |
2037 $keywords = implode('|', $keywords); |
2099 $keywords = implode('|', $keywords); |
2038 |
2100 |
2039 // Matches |
2101 // Matches |
2040 // 1 2 3 4 56 7 8 9 |
2102 // 1 2 3 4 56 7 8 9 |
2041 $regexp = '/(<!-- ('. $keywords .') ([A-z0-9_-]+) -->)(.*)((<!-- BEGINELSE \\3 -->)(.*))?(<!-- END(IF)? \\3 -->)/isU'; |
2103 $regexp = '/(<!-- ?(' . $keywords . ') ([A-z0-9_-]+) ?-->)([\w\W]*)((<!-- ?BEGINELSE \\3 ?-->)([\w\W]*))?(<!-- ?END(IF)? \\3 ?-->)/isU'; |
2042 |
2104 |
2043 /* |
2105 /* |
2044 The way this works is: match all blocks using the standard form with a different keyword in the block each time, |
2106 The way this works is: match all blocks using the standard form with a different keyword in the block each time, |
2045 and replace them with appropriate PHP logic. Plugin-extensible now. :-) |
2107 and replace them with appropriate PHP logic. Plugin-extensible now. :-) |
2046 */ |
2108 */ |
2047 |
2109 |
2048 profiler_log("[template] compiler matchout start"); |
2110 // This is a workaround for what seems like a PCRE bug |
2049 preg_match_all($regexp, $text, $matches); |
2111 while ( ( profiler_log("[template] compiler matchout start") || true ) && preg_match_all($regexp, $text, $matches) ) |
|
2112 { |
|
2113 |
2050 profiler_log("[template] compiler core loop start"); |
2114 profiler_log("[template] compiler core loop start"); |
2051 for ( $i = 0; $i < count($matches[0]); $i++ ) |
2115 for ( $i = 0; $i < count($matches[0]); $i++ ) |
2052 { |
2116 { |
2053 $start_tag =& $matches[1][$i]; |
2117 $start_tag =& $matches[1][$i]; |
2054 $type =& $matches[2][$i]; |
2118 $type =& $matches[2][$i]; |