includes/template.php
changeset 252 a007145a0ff6
parent 230 f6d144cba8a9
child 253 6c7060d36a23
equal deleted inserted replaced
251:a1ccf990db6b 252:a007145a0ff6
    31   var $fading_button = '';
    31   var $fading_button = '';
    32   
    32   
    33   function __construct()
    33   function __construct()
    34   {
    34   {
    35     global $db, $session, $paths, $template, $plugins; // Common objects
    35     global $db, $session, $paths, $template, $plugins; // Common objects
    36     dc_here('template: initializing all class variables');
       
    37     $this->tpl_bool    = Array();
    36     $this->tpl_bool    = Array();
    38     $this->tpl_strings = Array();
    37     $this->tpl_strings = Array();
    39     $this->sidebar_extra = '';
    38     $this->sidebar_extra = '';
    40     $this->toolbar_menu = '';
    39     $this->toolbar_menu = '';
    41     $this->additional_headers = '';
    40     $this->additional_headers = '';
   134   function init_vars()
   133   function init_vars()
   135   {
   134   {
   136     global $db, $session, $paths, $template, $plugins; // Common objects
   135     global $db, $session, $paths, $template, $plugins; // Common objects
   137     global $email;
   136     global $email;
   138     
   137     
   139     dc_here("template: initializing all variables");
       
   140     
       
   141     if(!$this->theme || !$this->style)
   138     if(!$this->theme || !$this->style)
   142     {
   139     {
   143       $this->load_theme();
   140       $this->load_theme();
   144     }
   141     }
   145     
   142     
   146     if(defined('ENANO_TEMPLATE_LOADED'))
   143     if(defined('ENANO_TEMPLATE_LOADED'))
   147     {
   144     {
   148       dc_here('template: access denied to call template::init_vars(), bailing out');
       
   149       die_semicritical('Illegal call', '<p>$template->load_theme was called multiple times, this is not supposed to happen. Exiting with fatal error.</p>');
   145       die_semicritical('Illegal call', '<p>$template->load_theme was called multiple times, this is not supposed to happen. Exiting with fatal error.</p>');
   150     }
   146     }
   151     
   147     
   152     define('ENANO_TEMPLATE_LOADED', '');
   148     define('ENANO_TEMPLATE_LOADED', '');
   153     
   149     
   154     $tplvars = $this->extract_vars('elements.tpl');
   150     $tplvars = $this->extract_vars('elements.tpl');
   155     
       
   156     dc_here('template: setting all template vars');
       
   157     
   151     
   158     if(isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE'))
   152     if(isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE'))
   159     {
   153     {
   160       $this->add_header('
   154       $this->add_header('
   161         <!--[if lt IE 7]>
   155         <!--[if lt IE 7]>
   241     // Create "xx page" button
   235     // Create "xx page" button
   242     
   236     
   243     $btn_selected = ( isset($tplvars['toolbar_button_selected'])) ? $tplvars['toolbar_button_selected'] : $tplvars['toolbar_button'];
   237     $btn_selected = ( isset($tplvars['toolbar_button_selected'])) ? $tplvars['toolbar_button_selected'] : $tplvars['toolbar_button'];
   244     $parser = $this->makeParserText($btn_selected);
   238     $parser = $this->makeParserText($btn_selected);
   245     
   239     
   246     $parser->assign_vars(array(
   240     if ( !$paths->anonymous_page )
   247         'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxReset()); return false; }" title="View the page contents, all of the page contents, and nothing but the page contents (alt-a)" accesskey="a"',
   241     {
   248         'PARENTFLAGS' => 'id="mdgToolbar_article"',
   242       $parser->assign_vars(array(
   249         'HREF' => makeUrl($paths->page, null, true),
   243           'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxReset()); return false; }" title="View the page contents, all of the page contents, and nothing but the page contents (alt-a)" accesskey="a"',
   250         'TEXT' => $this->namespace_string
   244           'PARENTFLAGS' => 'id="mdgToolbar_article"',
   251       ));
   245           'HREF' => makeUrl($paths->page, null, true),
   252     
   246           'TEXT' => $this->namespace_string
   253     $tb .= $parser->run();
   247         ));
       
   248       
       
   249       $tb .= $parser->run();
       
   250     }
   254     
   251     
   255     $button = $this->makeParserText($tplvars['toolbar_button']);
   252     $button = $this->makeParserText($tplvars['toolbar_button']);
   256     
   253     
   257     // Page toolbar
   254     // Page toolbar
   258     // Comments button
   255     // Comments button
   554       
   551       
   555       $this->toolbar_menu .= '<table border="0" cellspacing="0" cellpadding="0"><tr><td>'.$t0.'</td><td><input type="password" id="mdgPassSetField" size="10" /></td><td>'.$t.'</td></tr></table>';
   552       $this->toolbar_menu .= '<table border="0" cellspacing="0" cellpadding="0"><tr><td>'.$t0.'</td><td><input type="password" id="mdgPassSetField" size="10" /></td><td>'.$t.'</td></tr></table>';
   556     }
   553     }
   557     
   554     
   558     // Manage ACLs button
   555     // Manage ACLs button
   559     if($session->get_permissions('edit_acl') || $session->user_level >= USER_LEVEL_ADMIN)
   556     if ( !$paths->anonymous_page && ( $session->get_permissions('edit_acl') || $session->user_level >= USER_LEVEL_ADMIN ) )
   560     {
   557     {
   561       $menubtn->assign_vars(array(
   558       $menubtn->assign_vars(array(
   562           'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { return ajaxOpenACLManager(); }" title="Manage who can do what with this page (alt-m)" accesskey="m"',
   559           'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { return ajaxOpenACLManager(); }" title="Manage who can do what with this page (alt-m)" accesskey="m"',
   563           'HREF'  => makeUrl($paths->page, 'do=aclmanager', true),
   560           'HREF'  => makeUrl($paths->page, 'do=aclmanager', true),
   564           'TEXT'  => 'manage page access',
   561           'TEXT'  => 'manage page access',
   779     {
   776     {
   780       $this->load_theme($session->theme, $session->style);
   777       $this->load_theme($session->theme, $session->style);
   781     }
   778     }
   782     
   779     
   783     $headers_sent = true;
   780     $headers_sent = true;
   784     dc_here('template: generating and sending the page header');
       
   785     if(!defined('ENANO_HEADERS_SENT'))
   781     if(!defined('ENANO_HEADERS_SENT'))
   786       define('ENANO_HEADERS_SENT', '');
   782       define('ENANO_HEADERS_SENT', '');
   787     if ( !$this->no_headers )
   783     if ( !$this->no_headers )
   788     {
   784     {
   789       $header = ( $simple ) ?
   785       $header = ( $simple ) ?
   811     }
   807     }
   812   }
   808   }
   813   function footer($simple = false)
   809   function footer($simple = false)
   814   {
   810   {
   815     global $db, $session, $paths, $template, $plugins; // Common objects
   811     global $db, $session, $paths, $template, $plugins; // Common objects
   816     dc_here('template: generating and sending the page footer');
       
   817     if(!$this->no_headers) {
   812     if(!$this->no_headers) {
   818       
   813       
   819       if(!defined('ENANO_HEADERS_SENT'))
   814       if(!defined('ENANO_HEADERS_SENT'))
   820         $this->header();
   815         $this->header();
   821       
   816       
   842     else return '';
   837     else return '';
   843   }
   838   }
   844   function getHeader()
   839   function getHeader()
   845   {
   840   {
   846     $headers_sent = true;
   841     $headers_sent = true;
   847     dc_here('template: generating and sending the page header');
       
   848     if(!defined('ENANO_HEADERS_SENT'))
   842     if(!defined('ENANO_HEADERS_SENT'))
   849       define('ENANO_HEADERS_SENT', '');
   843       define('ENANO_HEADERS_SENT', '');
   850     if(!$this->no_headers) return $this->process_template('header.tpl');
   844     if(!$this->no_headers) return $this->process_template('header.tpl');
   851   }
   845   }
   852   function getFooter()
   846   function getFooter()
   853   {
   847   {
   854     global $db, $session, $paths, $template, $plugins; // Common objects
   848     global $db, $session, $paths, $template, $plugins; // Common objects
   855     dc_here('template: generating and sending the page footer');
       
   856     if(!$this->no_headers) {
   849     if(!$this->no_headers) {
   857       global $_starttime;
   850       global $_starttime;
   858       $t = '';
   851       $t = '';
   859       
   852       
   860       if(isset($_GET['sqldbg']) && $session->get_permissions('mod_misc'))
   853       if(isset($_GET['sqldbg']) && $session->get_permissions('mod_misc'))