includes/template.php
changeset 593 4f9bec0d65c1
parent 592 27377179fe58
child 594 738c61b498a6
equal deleted inserted replaced
592:27377179fe58 593:4f9bec0d65c1
    81     while ( $row = $db->fetchrow() )
    81     while ( $row = $db->fetchrow() )
    82     {
    82     {
    83       $this->theme_list[$i] = $row;
    83       $this->theme_list[$i] = $row;
    84       $i++;
    84       $i++;
    85     }
    85     }
    86     // List out all CSS files for this theme
       
    87     foreach ( $this->theme_list as $i => &$theme )
       
    88     {
       
    89       $theme['css'] = $this->get_theme_css_files($theme['theme_id']);
       
    90     }
       
    91     unset($theme);
    86     unset($theme);
    92     $this->theme_list = array_values($this->theme_list);
    87     $this->theme_list = array_values($this->theme_list);
    93     // Create associative array of themes
    88     // Create associative array of themes
    94     foreach ( $this->theme_list as $i => &$theme )
    89     foreach ( $this->theme_list as $i => &$theme )
    95       $this->named_theme_list[ $theme['theme_id'] ] =& $this->theme_list[$i];
    90       $this->named_theme_list[ $theme['theme_id'] ] =& $this->theme_list[$i];
    96     
    91     
    97     $this->default_theme = ( $_ = getConfig('theme_default') ) ? $_ : $this->theme_list[0]['theme_id'];
    92     $this->default_theme = ( $_ = getConfig('theme_default') ) ? $_ : $this->theme_list[0]['theme_id'];
       
    93     $this->named_theme_list[ $this->default_theme ]['css'] = $this->get_theme_css_files($this->default_theme);
    98     // Come up with the default style. If the CSS file specified in default_style exists, we're good, just
    94     // Come up with the default style. If the CSS file specified in default_style exists, we're good, just
    99     // use that. Otherwise, use the first stylesheet that comes to mind.
    95     // use that. Otherwise, use the first stylesheet that comes to mind.
   100     $df_data =& $this->named_theme_list[ $this->default_theme ];
    96     $df_data =& $this->named_theme_list[ $this->default_theme ];
   101     $this->default_style = ( in_array($df_data['default_style'], $df_data['css']) ) ? $df_data['default_style'] : $df_data['css'][0];
    97     $this->default_style = ( in_array($df_data['default_style'], $df_data['css']) ) ? $df_data['default_style'] : $df_data['css'][0];
   102   }
    98   }
  1392     
  1388     
  1393     $cache_file = ENANO_ROOT . '/cache/' . $this->theme . '-' . str_replace('/', '-', $file) . '.php';
  1389     $cache_file = ENANO_ROOT . '/cache/' . $this->theme . '-' . str_replace('/', '-', $file) . '.php';
  1394     if ( file_exists($cache_file) )
  1390     if ( file_exists($cache_file) )
  1395     {
  1391     {
  1396       // this is about the time of the breaking change to cache file format
  1392       // this is about the time of the breaking change to cache file format
  1397       if ( filemtime($cache_file) > 1215038089 )
  1393       if ( ($m = filemtime($cache_file)) > 1215038089 )
  1398       {
  1394       {
  1399         $result = @include($cache_file);
  1395         $result = @include($cache_file);
  1400         if ( isset($md5) )
  1396         if ( isset($md5) )
  1401         {
  1397         {
  1402           if ( $md5 == md5_file(ENANO_ROOT . "/themes/{$this->theme}/$file") )
  1398           if ( $m >= filemtime(ENANO_ROOT . "/themes/{$this->theme}/$file") )
  1403           {
  1399           {
  1404             $result = $this->compile_template_text_post($result);
  1400             $result = $this->compile_template_text_post($result);
  1405             return $result;
  1401             return $result;
  1406           }
  1402           }
  1407         }
  1403         }