+
+
+ $this->js_append
JSEOF;
- }
-
-
- $this->assign_bool(array(
- 'fixed_menus' => false,
- 'export' => false,
- 'right_sidebar' => true,
- 'enable_uploads' => ( getConfig('enable_uploads') == '1' && $session->get_permissions('upload_files') ) ? true : false,
- 'stupid_mode' => false,
- ));
-
- // Add the e-mail address client code to the header
- $this->add_header($email->jscode());
-
- // Assign our main variables
- $this->assign_vars(array(
- 'SITE_NAME' => htmlspecialchars(getConfig('site_name')),
- 'USERNAME' => $session->username,
- 'SITE_DESC' => htmlspecialchars(getConfig('site_desc')),
- 'SCRIPTPATH' => scriptPath,
- 'CONTENTPATH' => contentPath,
- 'CDNPATH' => cdnPath,
- 'ADMIN_SID_QUES' => $asq,
- 'ADMIN_SID_AMP' => $asa,
- 'ADMIN_SID_AMP_HTML' => $ash,
- 'ADMIN_SID_AUTO' => $as2,
- 'ADMIN_SID_RAW' => ( is_string($session->sid_super) ? $session->sid_super : '' ),
- 'CSRF_TOKEN' => $session->csrf_token,
- 'COPYRIGHT' => RenderMan::parse_internal_links(getConfig('copyright_notice')),
- 'REQUEST_URI' => ( defined('ENANO_CLI') ? '' : $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] ),
- 'SEARCH_ACTION' => makeUrlNS('Special', 'Search'),
- 'INPUT_TITLE' => ( urlSeparator == '&' ? '' : ''),
- 'INPUT_AUTH' => ( $session->sid_super ? '' : ''),
- 'MAIN_PAGE' => get_main_page(),
- 'UNREAD_PMS' => $session->unread_pms,
- 'JS_HEADER' => $js_head,
- 'JS_FOOTER' => $js_foot,
- 'URL_ABOUT_ENANO' => makeUrlNS('Special', 'About_Enano', '', true),
- 'ENANO_VERSION' => enano_version()
- ), true);
-
- $tpl_strings = array();
- foreach ( $paths->nslist as $ns_id => $ns_prefix )
- {
- $tpl_strings[ 'NS_' . strtoupper($ns_id) ] = $ns_prefix;
- }
-
- $this->assign_vars($tpl_strings, true);
- }
-
- /**
- * Init theme vars, like sidebar, global JS, that kind of stuff.
- */
-
- function init_theme_vars()
- {
- global $db, $session, $paths, $template, $plugins; // Common objects
- global $lang;
-
- // allows conditional testing of the theme ID (a bit crude, came from my NSIS days)
- $this->assign_bool(array(
- "theme_is_{$this->theme}" => true
- ));
-
- $this->elements = $this->extract_vars('elements.tpl');
-
- // Generate the code for the Administration and Edit Sidebar buttons
- // Once again, the new template parsing system can be used here
-
- $parser = $this->makeParserText($this->elements['sidebar_button']);
-
- $parser->assign_vars(Array(
- 'HREF'=>makeUrlNS('Special', 'Administration'),
- 'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { void(ajaxStartAdminLogin()); return false; }"',
- 'TEXT'=>$lang->get('sidebar_btn_administration'),
- ));
-
- $admin_link = $parser->run();
-
- $parser->assign_vars(Array(
- 'HREF'=>makeUrlNS('Special', 'EditSidebar'),
- 'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { void(ajaxLoginNavTo(\'Special\', \'EditSidebar\', ' . USER_LEVEL_ADMIN . ')); return false; }"',
- 'TEXT'=>$lang->get('sidebar_btn_editsidebar'),
- ));
-
- $sidebar_link = $parser->run();
-
- $this->assign_vars(array(
- 'ADMIN_LINK' => $admin_link,
- 'SIDEBAR_LINK' => $sidebar_link,
- 'THEME_ID' => $this->theme,
- 'STYLE_ID' => $this->style
- ));
-
- // Add the site description sidebar block
- $this->sidebar_widget($lang->get('sidebar_title_about'), '' . htmlspecialchars(getConfig('site_desc')) . '
');
-
- $this->theme_initted = true;
- }
-
- /**
- * Init page vars, like the toolbar, local JS, etc.
- */
-
- function init_page_vars()
- {
- global $db, $session, $paths, $template, $plugins; // Common objects
- global $lang;
-
- if ( !$this->page )
- {
- $this->page = new PageProcessor($this->page_id, $this->namespace);
- }
-
- $conds = $this->page->ns->get_conds();
-
- $this->assign_bool(array(
- 'in_admin' => ( ( $this->page_id == 'Administration' && $this->namespace == 'Special' ) || $this->namespace == 'Admin' ),
- 'auth_rename' => ( $conds['rename'] )
- ));
-
- // Get the "article" button text (depends on namespace)
- switch ( $this->namespace )
- {
- case "Article":
- default:
- $ns = $lang->get('onpage_lbl_page_article');
- break;
- case "Admin":
- $ns = $lang->get('onpage_lbl_page_admin');
- break;
- case "System":
- $ns = $lang->get('onpage_lbl_page_system');
- break;
- case "File":
- $ns = $lang->get('onpage_lbl_page_file');
- break;
- case "Help":
- $ns = $lang->get('onpage_lbl_page_help');
- break;
- case "User":
- $ns = $lang->get('onpage_lbl_page_user');
- break;
- case "Special":
- $ns = $lang->get('onpage_lbl_page_special');
- break;
- case "Template":
- $ns = $lang->get('onpage_lbl_page_template');
- break;
- case "Project":
- $ns = $lang->get('onpage_lbl_page_project');
- break;
- case "Category":
- $ns = $lang->get('onpage_lbl_page_category');
- break;
- case "API":
- $ns = $lang->get('onpage_lbl_page_external');
- break;
- }
- $this->namespace_string = $ns;
- unset($ns);
- // compatibility
- $local_namespace =& $this->namespace;
- $local_page_id =& $this->page_id;
- $code = $plugins->setHook('page_type_string_set');
- foreach ( $code as $cmd )
- {
- eval($cmd);
- }
- $ns =& $this->namespace_string;
-
- //
- // PAGE TOOLBAR (on-page controls/actions)
- //
-
- $local_page = $paths->get_pathskey($this->page_id, $this->namespace);
- $local_cdata = $this->page->ns->get_cdata();
-
- // Initialize the toolbar
- $tb = '';
- $this->toolbar_menu = '';
-
- // Create "xx page" button
-
- $btn_selected = ( isset($this->elements['toolbar_button_selected'])) ? $this->elements['toolbar_button_selected'] : $this->elements['toolbar_button'];
- $parser = $this->makeParserText($btn_selected);
-
- if ( $conds['article'] )
- {
- $parser->assign_vars(array(
- 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxReset()); return false; }" title="' . $lang->get('onpage_tip_article') . '" accesskey="a"',
- 'PARENTFLAGS' => 'id="mdgToolbar_article"',
- 'HREF' => makeUrl($local_page, null, true),
- 'TEXT' => $this->namespace_string
- ));
-
- $tb .= $parser->run();
- }
-
- $button = $this->makeParserText($this->elements['toolbar_button']);
-
- // Page toolbar
- // Comments button
- if ( $conds['comments'] )
- {
- $cdata = $this->page->ns->get_cdata();
- if ( isset($cdata['comments_approved']) )
- {
- $approval_counts = array(
- COMMENT_APPROVED => $cdata['comments_approved'],
- COMMENT_UNAPPROVED => $cdata['comments_unapproved'],
- COMMENT_SPAM => $cdata['comments_spam']
- );
- $num_comments = $session->check_acl_scope('mod_comments', $this->namespace) && $this->page->perms->get_permissions('mod_comments')
- ? array_sum($approval_counts)
- : $approval_counts[COMMENT_APPROVED];
- }
- else
- {
- $e = $db->sql_query('SELECT approved FROM '.table_prefix.'comments WHERE page_id=\''.$this->page_id.'\' AND namespace=\''.$this->namespace.'\';');
- if ( !$e )
- {
- $db->_die();
- }
- $num_comments = $db->numrows();
- $approval_counts = array(COMMENT_UNAPPROVED => 0, COMMENT_APPROVED => 0, COMMENT_SPAM => 0);
-
- while ( $r = $db->fetchrow() )
- {
- $approval_counts[$r['approved']]++;
- }
- }
-
- $db->free_result();
- // $n = ( $session->check_acl_scope('mod_comments', $this->namespace) && $perms->get_permissions('mod_comments') ) ? (string)$num_comments : (string)$na;
- if ( $session->check_acl_scope('mod_comments', $this->namespace) && $this->page->perms->get_permissions('mod_comments') && ( $approval_counts[COMMENT_UNAPPROVED] + $approval_counts[COMMENT_SPAM] ) > 0 )
- {
- $subst = array(
- 'num_comments' => $num_comments,
- 'num_app' => $approval_counts[COMMENT_APPROVED],
- 'num_unapp' => $approval_counts[COMMENT_UNAPPROVED],
- 'num_spam' => $approval_counts[COMMENT_SPAM]
- );
- $btn_text = $lang->get('onpage_btn_discussion_unapp', $subst);
- }
- else
- {
- $subst = array(
- 'num_comments' => $num_comments
- );
- $btn_text = $lang->get('onpage_btn_discussion', $subst);
- }
-
- $button->assign_vars(array(
- 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxComments()); return false; }" title="' . $lang->get('onpage_tip_comments') . '" accesskey="c"',
- 'PARENTFLAGS' => 'id="mdgToolbar_discussion"',
- 'HREF' => makeUrl($local_page, 'do=comments', true),
- 'TEXT' => $btn_text,
- ));
-
- $tb .= $button->run();
- }
- // Edit button
- if( $conds['edit'] )
- {
- $button->assign_vars(array(
- 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxEditor()); return false; }" title="' . $lang->get('onpage_tip_edit') . '" accesskey="e"',
- 'PARENTFLAGS' => 'id="mdgToolbar_edit"',
- 'HREF' => makeUrl($local_page, 'do=edit', true),
- 'TEXT' => $lang->get('onpage_btn_edit')
- ));
- $tb .= $button->run();
- // View source button
- }
- else if ( $conds['viewsource'] )
- {
- $button->assign_vars(array(
- 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxEditor()); return false; }" title="' . $lang->get('onpage_tip_viewsource') . '" accesskey="e"',
- 'PARENTFLAGS' => 'id="mdgToolbar_edit"',
- 'HREF' => makeUrl($local_page, 'do=viewsource', true),
- 'TEXT' => $lang->get('onpage_btn_viewsource')
- ));
- $tb .= $button->run();
- }
- // History button
- if ( $conds['history'] )
- {
- $button->assign_vars(array(
- 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxHistory()); return false; }" title="' . $lang->get('onpage_tip_history') . '" accesskey="h"',
- 'PARENTFLAGS' => 'id="mdgToolbar_history"',
- 'HREF' => makeUrl($local_page, 'do=history', true),
- 'TEXT' => $lang->get('onpage_btn_history')
- ));
- $tb .= $button->run();
- }
-
- $menubtn = $this->makeParserText($this->elements['toolbar_menu_button']);
-
- // Additional actions menu
- // Rename button
- if ( $conds['rename'] )
- {
- $menubtn->assign_vars(array(
- 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxRename()); return false; }" title="' . $lang->get('onpage_tip_rename') . '" accesskey="r"',
- 'HREF' => makeUrl($local_page, 'do=rename', true),
- 'TEXT' => $lang->get('onpage_btn_rename'),
- ));
- $this->toolbar_menu .= $menubtn->run();
- }
-
- // Vote-to-delete button
- if ( $conds['delvote'] )
- {
- $menubtn->assign_vars(array(
- 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxDelVote()); return false; }" title="' . $lang->get('onpage_tip_delvote') . '" accesskey="d"',
- 'HREF' => makeUrl($local_page, 'do=delvote', true),
- 'TEXT' => $lang->get('onpage_btn_votedelete'),
- ));
- $this->toolbar_menu .= $menubtn->run();
- }
-
- // Clear-votes button
- if ( $conds['resetvotes'] )
- {
- $menubtn->assign_vars(array(
- 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxResetDelVotes()); return false; }" title="' . $lang->get('onpage_tip_resetvotes') . '" accesskey="y"',
- 'HREF' => makeUrl($local_page, 'do=resetvotes', true),
- 'TEXT' => $lang->get('onpage_btn_votedelete_reset'),
- ));
- $this->toolbar_menu .= $menubtn->run();
- }
-
- // Printable page button
- if ( $conds['printable'] )
- {
- $menubtn->assign_vars(array(
- 'FLAGS' => 'title="' . $lang->get('onpage_tip_printable') . '"',
- 'HREF' => makeUrl($local_page, 'printable=yes', true),
- 'TEXT' => $lang->get('onpage_btn_printable'),
- ));
- $this->toolbar_menu .= $menubtn->run();
- }
-
- // Protect button
- if ( $conds['protect'] )
- {
- switch($this->page->ns->cdata['protected'])
- {
- case PROTECT_FULL: $protect_status = $lang->get('onpage_btn_protect_on'); break;
- case PROTECT_SEMI: $protect_status = $lang->get('onpage_btn_protect_semi'); break;
- case PROTECT_NONE: $protect_status = $lang->get('onpage_btn_protect_off'); break;
- }
-
- $label = $this->makeParserText($this->elements['toolbar_label']);
- $label->assign_vars(array('TEXT' => $lang->get('onpage_lbl_protect') . ' ' . "$protect_status"));
- $t0 = $label->run();
-
- $menubtn->assign_vars(array(
- 'FLAGS' => 'accesskey="p" onclick="ajaxProtect(' . $this->page->ns->cdata['protected'] . '); return false;" id="tb_ajax_protect_btn" title="' . $lang->get('onpage_tip_protect') . '"',
- 'HREF' => makeUrl($local_page, 'do=protect', true),
- 'TEXT' => $lang->get('onpage_btn_protect_change')
- ));
- $t1 = $menubtn->run();
-
- $this->toolbar_menu .= '
-
- '.$t0.' |
- '.$t1.' |
-
-
';
- }
-
- // Wiki mode button
- if ( $conds['setwikimode'] )
- {
- // label at start
- $label = $this->makeParserText($this->elements['toolbar_label']);
- $label->assign_vars(array('TEXT' => $lang->get('onpage_lbl_wikimode')));
- $t0 = $label->run();
-
- // on button
- $ctmp = '';
- if ( $local_cdata['wiki_mode'] == 1 )
- {
- $ctmp = ' style="text-decoration: underline;"';
- }
- $menubtn->assign_vars(array(
- 'FLAGS' => $ctmp,
- 'HREF' => makeUrl($local_page, 'do=setwikimode&level=1', true),
- 'TEXT' => $lang->get('onpage_btn_wikimode_on')
- ));
- $t1 = $menubtn->run();
-
- // off button
- $ctmp = '';
- if ( $local_cdata['wiki_mode'] == 0 )
- {
- $ctmp=' style="text-decoration: underline;"';
- }
- $menubtn->assign_vars(array(
- 'FLAGS' => $ctmp,
- 'HREF' => makeUrl($local_page, 'do=setwikimode&level=0', true),
- 'TEXT' => $lang->get('onpage_btn_wikimode_off')
- ));
- $t2 = $menubtn->run();
-
- // global button
- $ctmp = '';
- if ( $local_cdata['wiki_mode'] == 2 )
- {
- $ctmp=' style="text-decoration: underline;"';
- }
- $menubtn->assign_vars(array(
- 'FLAGS' => $ctmp,
- 'HREF' => makeUrl($local_page, 'do=setwikimode&level=2', true),
- 'TEXT' => $lang->get('onpage_btn_wikimode_global')
- ));
- $t3 = $menubtn->run();
-
- // Tack it onto the list of buttons that are already there...
- $this->toolbar_menu .= '
-
- '.$t0.' |
- '.$t1.' |
- '.$t2.' |
- '.$t3.' |
-
-
';
- }
-
- // Clear logs button
- if ( $conds['clearlogs'] )
- {
- $menubtn->assign_vars(array(
- 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxClearLogs()); return false; }" title="' . $lang->get('onpage_tip_flushlogs') . '" accesskey="l"',
- 'HREF' => makeUrl($local_page, 'do=flushlogs', true),
- 'TEXT' => $lang->get('onpage_btn_clearlogs'),
- ));
- $this->toolbar_menu .= $menubtn->run();
- }
-
- // Delete page button
- if ( $conds['delete'] )
- {
- $s = $lang->get('onpage_btn_deletepage');
- if ( $this->page->ns->cdata['delvotes'] == 1 )
- {
- $subst = array(
- 'num_votes' => $this->page->ns->cdata['delvotes'],
- 'plural' => ''
- );
- $s .= $lang->get('onpage_btn_deletepage_votes', $subst);
- }
- else if ( $this->page->ns->cdata['delvotes'] > 1 )
- {
- $subst = array(
- 'num_votes' => $this->page->ns->cdata['delvotes'],
- 'plural' => $lang->get('meta_plural')
- );
- $s .= $lang->get('onpage_btn_deletepage_votes', $subst);
- }
-
- $menubtn->assign_vars(array(
- 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxDeletePage()); return false; }" title="' . $lang->get('onpage_tip_deletepage') . '" accesskey="k"',
- 'HREF' => makeUrl($local_page, 'do=deletepage', true),
- 'TEXT' => $s,
- ));
- $this->toolbar_menu .= $menubtn->run();
-
- }
-
- // Password-protect button
- if ( $conds['password'] )
- {
- // label at start
- $label = $this->makeParserText($this->elements['toolbar_label']);
- $label->assign_vars(array('TEXT' => $lang->get('onpage_lbl_password')));
- $t0 = $label->run();
-
- $menubtn->assign_vars(array(
- 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxSetPassword()); return false; }" title="' . $lang->get('onpage_tip_password') . '"',
- 'HREF' => '#',
- 'TEXT' => $lang->get('onpage_btn_password_set'),
- ));
- $t = $menubtn->run();
-
- $this->toolbar_menu .= '';
- }
-
- // Manage ACLs button
- if ( $conds['acledit'] )
- {
- $menubtn->assign_vars(array(
- 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { var s = ajaxOpenACLManager(); console.debug(s); return false; }" title="' . $lang->get('onpage_tip_aclmanager') . '" accesskey="m"',
- 'HREF' => makeUrl($local_page, 'do=aclmanager', true),
- 'TEXT' => $lang->get('onpage_btn_acl'),
- ));
- $this->toolbar_menu .= $menubtn->run();
- }
-
- // Administer page button
- if ( $conds['adminpage'] )
- {
- $menubtn->assign_vars(array(
- 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxAdminPage()); return false; }" title="' . $lang->get('onpage_tip_adminoptions') . '" accesskey="g"',
- 'HREF' => makeUrlNS('Special', 'Administration', 'module='.$paths->nslist['Admin'].'PageManager', true),
- 'TEXT' => $lang->get('onpage_btn_admin'),
- ));
- $this->toolbar_menu .= $menubtn->run();
- }
-
- if ( strlen($this->toolbar_menu) > 0 )
- {
- $button->assign_vars(array(
- 'FLAGS' => 'id="mdgToolbar_moreoptions" onclick="if ( !KILL_SWITCH ) { return false; }" title="' . $lang->get('onpage_tip_moreoptions') . '"',
- 'PARENTFLAGS' => '',
- 'HREF' => makeUrl($local_page, 'do=moreoptions', true),
- 'TEXT' => $lang->get('onpage_btn_moreoptions')
- ));
- $tb .= $button->run();
- }
-
- // Generate the code for the Log in, Log out, Change theme, Administration, and Edit Sidebar buttons
- // Once again, the new template parsing system can be used here
-
- $parser = $this->makeParserText($this->elements['sidebar_button']);
-
- $parser->assign_vars(Array(
- 'HREF'=>makeUrlNS('Special', "Logout/{$session->csrf_token}/{$local_page}"),
- 'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { mb_logout(); return false; }"',
- 'TEXT'=>$lang->get('sidebar_btn_logout'),
- ));
-
- $logout_link = $parser->run();
-
- $parser->assign_vars(Array(
- 'HREF'=>makeUrlNS('Special', 'Login/' . $local_page),
- 'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { ajaxStartLogin(); return false; }"' . ( $local_page_id == 'Login' && $local_namespace == 'Special' ? ' class="currentpage"' : '' ),
- 'TEXT'=>$lang->get('sidebar_btn_login'),
- ));
-
- $login_link = $parser->run();
-
- $parser->assign_vars(Array(
- 'HREF'=>makeUrlNS('Special', 'ChangeStyle/'.$local_page),
- 'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { ajaxChangeStyle(); return false; }"' . ( $local_page_id == 'ChangeStyle' && $local_namespace == 'Special' ? ' class="currentpage"' : '' ),
- 'TEXT'=>$lang->get('sidebar_btn_changestyle'),
- ));
-
- $theme_link = $parser->run();
-
- // Run hooks
- $code = $plugins->setHook('tpl_compile_toolbar');
- foreach ( $code as $cmd )
- {
- eval($cmd);
- }
-
- //
- // ASSIGN VARIABLES
- //
-
- $this->assign_vars(array(
- 'PAGE_NAME' => htmlspecialchars($this->page->ns->cdata['name']),
- 'PAGE_URLNAME' => $paths->nslist[$this->namespace] . sanitize_page_id($this->page_id),
- 'TOOLBAR' => $tb,
- 'TOOLBAR_EXTRAS' => $this->toolbar_menu,
- 'STYLE_LINK' => makeUrlNS('Special', 'CSS', null, true), //contentPath.$paths->nslist['Special'].'CSS' . $p,
- 'LOGIN_LINK' => $login_link,
- 'LOGOUT_LINK' => $logout_link,
- 'THEME_LINK' => $theme_link
- ), true);
- $this->page_initted = true;
- }
-
- /**
- * Generates and assigns the Javascript system variables
- */
-
- function generate_js_header()
- {
- global $db, $session, $paths, $template, $plugins; // Common objects
- global $lang;
-
- $SID = ($session->sid_super) ? $session->sid_super : '';
-
- $local_page = $paths->get_pathskey($this->page_id, $this->namespace);
- $local_fullpage = $paths->get_pathskey($this->page_id, $this->namespace) . substr($paths->fullpage, strlen($paths->page));
-
- $urlname_clean = str_replace('\'', '\\\'', str_replace('\\', '\\\\', dirtify_page_id($local_fullpage)));
- $urlname_clean = strtr( $urlname_clean, array( '<' => '<', '>' => '>' ) );
-
- $urlname_jssafe = sanitize_page_id($local_fullpage);
- $physical_urlname_jssafe = sanitize_page_id($paths->fullpage);
-
- $protected = is_object($this->page) ? $this->page->ns->cdata['really_protected'] : false;
-
- // Generate the dynamic javascript vars
- // Sorry. I know. This block is a mess.
- $js_dynamic = ' ";
-
- $this->assign_vars(array(
- 'JS_DYNAMIC_VARS' => $js_dynamic,
- 'REPORT_URI' => makeUrl($local_fullpage, 'do=sql_report', true)
- ), true);
- }
-
- /**
- * Fetches, parses, and assigns the sidebar.
- */
-
- function assign_sidebar()
- {
- //
- // COMPILE THE SIDEBAR
- //
-
- // This is done after the big assign_vars() so that sidebar code has access to the newly assigned variables
-
- list($this->tpl_strings['SIDEBAR_LEFT'], $this->tpl_strings['SIDEBAR_RIGHT'], $min) = $this->fetch_sidebar();
- $this->tpl_bool['sidebar_left'] = ( $this->tpl_strings['SIDEBAR_LEFT'] != $min) ? true : false;
- $this->tpl_bool['sidebar_right'] = ( $this->tpl_strings['SIDEBAR_RIGHT'] != $min) ? true : false;
- $this->tpl_bool['right_sidebar'] = $this->tpl_bool['sidebar_right']; // backward compatibility
- }
-
- /**
- * Initializes all variables related to on-page content. This includes sidebars and what have you.
- * @param object Optional PageProcessor object to use for passing metadata and permissions on. If omitted, uses information from $paths and $session.
- * @param bool If true, re-inits even if already initted with this page_id and namespace
- */
-
- function init_vars($page = false, $force_init = false)
- {
- global $db, $session, $paths, $template, $plugins; // Common objects
- global $lang;
-
- $need_shared_init = ( !$this->theme_initted || !$this->page_initted );
-
- if ( $need_shared_init )
- {
- if ( !$this->theme || !$this->style )
- {
- $this->load_theme();
- }
- $code = $plugins->setHook('compile_template', true);
- foreach ( $code as $cmd )
- {
- eval($cmd);
- }
- }
-
- if ( !$this->theme_loaded )
- $this->load_theme();
-
- require(ENANO_ROOT . "/themes/{$this->theme}/theme.cfg");
-
- if ( !$this->page_id || !$this->namespace )
- {
- $this->page_id = $paths->page_id;
- $this->namespace = $paths->namespace;
- }
-
- profiler_log('template: prepped for var set (loaded theme, ran compile_template hook)');
-
- $this->init_global_vars();
- profiler_log('template: global vars set');
-
- if ( !$this->theme_initted )
- $this->init_theme_vars();
-
- profiler_log('template: theme vars set');
-
- if ( !$this->page_initted && !empty($this->namespace) )
- {
- profiler_log('template: page vars set');
- $this->init_page_vars();
- }
- else
- {
- profiler_message('template: skipped setting page vars');
- }
-
- // Perform shared init (combine javascript, etc.)
- if ( $need_shared_init )
- {
- $this->generate_js_header();
- $this->assign_sidebar();
- profiler_log('template: assigned sidebar and JS');
- }
-
- // and finally one string value that needs to be symlinked...
- if ( !isset($this->tpl_strings['ADDITIONAL_HEADERS']) )
- {
- $this->tpl_strings['ADDITIONAL_HEADERS'] =& $this->additional_headers;
- }
-
- // done!
- $code = $plugins->setHook('template_var_init_end');
- foreach ( $code as $cmd )
- {
- eval($cmd);
- }
- }
-
- function header($simple = false)
- {
- global $db, $session, $paths, $template, $plugins; // Common objects
- global $lang;
-
- define('ENANO_HEADERS_SENT', true);
-
- echo $this->getHeader($simple);
- }
-
- function footer($simple = false)
- {
- echo $this->getFooter($simple);
- }
-
- function getHeader($simple = false)
- {
- global $db, $session, $paths, $template, $plugins; // Common objects
- global $lang;
-
- if ( !$this->theme_loaded )
- {
- $this->load_theme($session->theme, $session->style);
- }
-
- if ( !$this->page_initted || !$this->theme_initted )
- $this->init_vars();
-
- // I feel awful doing this.
- if ( preg_match('/^W3C_Validator/', @$_SERVER['HTTP_USER_AGENT']) )
- {
- header('Content-type: application/xhtml+xml');
- }
-
- $header = '';
-
- if ( !$this->no_headers )
- {
- $header = ( $simple ) ?
- $this->process_template('simple-header.tpl') :
- $this->process_template('header.tpl');
- }
- if ( !$simple && $session->user_logged_in && $session->unread_pms > 0 )
- {
- $header .= $this->notify_unread_pms();
- }
- if ( !$simple && $session->sw_timed_out )
- {
- $login_link = makeUrlNS('Special', 'Login/' . $paths->fullpage, 'level=' . $session->user_level, true);
- $header .= '';
- $header .= $lang->get('user_msg_elev_timed_out', array( 'login_link' => $login_link ));
- $header .= '
';
- }
- if ( $this->site_disabled && $session->user_level >= USER_LEVEL_ADMIN && ( $paths->page != $paths->nslist['Special'] . 'Administration' ) )
- {
- $admin_link = makeUrlNS('Special', 'Administration', 'module=' . $paths->nslist['Admin'] . 'GeneralConfig', true);
- $header .= '' . $lang->get('page_sitedisabled_admin_msg_title') . '
- ' . $lang->get('page_sitedisabled_admin_msg_body', array('admin_link' => $admin_link)) . '
-
';
- }
-
- return $header;
- }
-
- function getFooter($simple = false)
- {
- global $db, $session, $paths, $template, $plugins; // Common objects
- global $lang;
- if ( !$this->no_headers )
- {
-
- global $_starttime;
- if(isset($_GET['sqldbg']) && $session->get_permissions('mod_misc'))
- {
- echo '' . $lang->get('page_heading_sql_list') . '
';
- echo htmlspecialchars($db->sql_backtrace());
- echo '
';
- }
-
- $t = ( $simple ) ? $this->process_template('simple-footer.tpl') : $this->process_template('footer.tpl');
-
- $f = microtime_float();
- $f = $f - $_starttime;
- $f = round($f, 2);
-
- $t_loc = $lang->get('page_msg_stats_gentime_short', array('time' => $f));
- $t_loc_long = $lang->get('page_msg_stats_gentime_long', array('time' => $f));
- $q_loc = '' . $lang->get('page_msg_stats_sql', array('nq' => $db->num_queries)) . '';
- $dbg = $t_loc;
- $dbg_long = $t_loc_long;
- if ( $session->user_level >= USER_LEVEL_ADMIN || defined('ENANO_DEBUG') )
- {
- $dbg .= " | $q_loc";
- $dbg_long .= " | $q_loc";
- }
-
- $t = str_replace('[[Stats]]', $dbg, $t);
- $t = str_replace('[[StatsLong]]', $dbg_long, $t);
- $t = str_replace('[[NumQueries]]', (string)$db->num_queries, $t);
- $t = str_replace('[[GenTime]]', (string)$f, $t);
- $t = str_replace('[[NumQueriesLoc]]', $q_loc, $t);
- $t = str_replace('[[GenTimeLoc]]', $t_loc, $t);
- $t = str_replace('[[EnanoPoweredLink]]', $lang->get('page_enano_powered', array('about_uri' => $this->tpl_strings['URL_ABOUT_ENANO'])), $t);
- $t = str_replace('[[EnanoPoweredLinkLong]]', $lang->get('page_enano_powered_long', array('about_uri' => $this->tpl_strings['URL_ABOUT_ENANO'])), $t);
-
- if ( defined('ENANO_PROFILE') )
- {
- $t = str_replace('