includes/template.php
changeset 372 5bd429428101
parent 371 dc6026376919
child 377 bb3e6c3bd4f4
equal deleted inserted replaced
371:dc6026376919 372:5bd429428101
   129   function init_vars()
   129   function init_vars()
   130   {
   130   {
   131     global $db, $session, $paths, $template, $plugins; // Common objects
   131     global $db, $session, $paths, $template, $plugins; // Common objects
   132     global $email;
   132     global $email;
   133     global $lang;
   133     global $lang;
       
   134     
       
   135     profiler_log("template: starting var init");
   134     
   136     
   135     if(!$this->theme || !$this->style)
   137     if(!$this->theme || !$this->style)
   136     {
   138     {
   137       $this->load_theme();
   139       $this->load_theme();
   138     }
   140     }
   789     $code = $plugins->setHook('template_var_init_end');
   791     $code = $plugins->setHook('template_var_init_end');
   790     foreach ( $code as $cmd )
   792     foreach ( $code as $cmd )
   791     {
   793     {
   792       eval($cmd);
   794       eval($cmd);
   793     }
   795     }
       
   796     
       
   797     profiler_log("template: finished var init");
   794   }
   798   }
   795   
   799   
   796   function header($simple = false) 
   800   function header($simple = false) 
   797   {
   801   {
   798     global $db, $session, $paths, $template, $plugins; // Common objects
   802     global $db, $session, $paths, $template, $plugins; // Common objects
   832       echo '<div class="usermessage"><b>The site is currently disabled and thus is only accessible to administrators.</b><br />
   836       echo '<div class="usermessage"><b>The site is currently disabled and thus is only accessible to administrators.</b><br />
   833             You can re-enable the site through the <a href="' . $admin_link . '">administration panel</a>.
   837             You can re-enable the site through the <a href="' . $admin_link . '">administration panel</a>.
   834             </div>';
   838             </div>';
   835     }
   839     }
   836   }
   840   }
       
   841   
   837   function footer($simple = false)
   842   function footer($simple = false)
   838   {
   843   {
   839     global $db, $session, $paths, $template, $plugins; // Common objects
   844     global $db, $session, $paths, $template, $plugins; // Common objects
   840     if(!$this->no_headers) {
   845     if ( !$this->no_headers )
       
   846     {
   841       
   847       
   842       if(!defined('ENANO_HEADERS_SENT'))
   848       if(!defined('ENANO_HEADERS_SENT'))
   843         $this->header();
   849         $this->header();
   844       
   850       
   845       global $_starttime;
   851       global $_starttime;
   856       $dbg = 'Time: '.$f.'s  |  Queries: '.$db->num_queries;
   862       $dbg = 'Time: '.$f.'s  |  Queries: '.$db->num_queries;
   857       $t = ( $simple ) ? $this->process_template('simple-footer.tpl') : $this->process_template('footer.tpl');
   863       $t = ( $simple ) ? $this->process_template('simple-footer.tpl') : $this->process_template('footer.tpl');
   858       $t = str_replace('[[Stats]]', $dbg, $t);
   864       $t = str_replace('[[Stats]]', $dbg, $t);
   859       $t = str_replace('[[NumQueries]]', (string)$db->num_queries, $t);
   865       $t = str_replace('[[NumQueries]]', (string)$db->num_queries, $t);
   860       $t = str_replace('[[GenTime]]', (string)$f, $t);
   866       $t = str_replace('[[GenTime]]', (string)$f, $t);
       
   867       
       
   868       if ( defined('ENANO_DEBUG') )
       
   869         $t = str_replace('</body>', '<div id="profile" style="margin: 10px;">' . profiler_make_html() . '</div></body>', $t);
       
   870       
   861       echo $t;
   871       echo $t;
   862       
   872       
   863       ob_end_flush();
   873       ob_end_flush();
   864     }
   874     }
   865     else return '';
   875     else
   866   }
   876     {
       
   877       return '';
       
   878     }
       
   879   }
       
   880   
   867   function getHeader()
   881   function getHeader()
   868   {
   882   {
   869     $headers_sent = true;
   883     $headers_sent = true;
   870     if(!defined('ENANO_HEADERS_SENT'))
   884     if(!defined('ENANO_HEADERS_SENT'))
   871       define('ENANO_HEADERS_SENT', '');
   885       define('ENANO_HEADERS_SENT', '');