Aww crap. NOW it should be together. 1.1.3
authorDan
Fri, 07 Mar 2008 00:19:21 -0500
changeset 491dd0f079e3c52
parent 490 92c217d056af
parent 488 5560ff856dd7
child 492 e07ad77fe9d0
Aww crap. NOW it should be together.
.hgtags
     1.1 --- a/.hgtags	Fri Mar 07 00:17:46 2008 -0500
     1.2 +++ b/.hgtags	Fri Mar 07 00:19:21 2008 -0500
     1.3 @@ -14,4 +14,3 @@
     1.4  3395ecddd831ee2f0229ab3b4a1c9d69f0ab73d7 release
     1.5  d1a95497b68f765f6ca4ed816d07b20b13cee692 rebrand
     1.6  ceff43bbc3d3bc18d7679f88ef6fec2e070bc704 release
     1.7 -1506b9687a1a7179205f5cfc0b4ed8e5a90c5cb0 release
     2.1 --- a/includes/template.php	Fri Mar 07 00:17:46 2008 -0500
     2.2 +++ b/includes/template.php	Fri Mar 07 00:19:21 2008 -0500
     2.3 @@ -56,6 +56,11 @@
     2.4      $this->theme_list = Array();
     2.5      $this->named_theme_list = Array();
     2.6      
     2.7 +    if ( defined('IN_ENANO_UPGRADE') )
     2.8 +    {
     2.9 +      return $this->construct_compat();
    2.10 +    }
    2.11 +    
    2.12      $q = $db->sql_query('SELECT theme_id, theme_name, enabled, default_style, group_policy, group_list FROM ' . table_prefix . 'themes;');
    2.13      if ( !$q )
    2.14        $db->_die('template.php selecting theme list');
    2.15 @@ -99,6 +104,70 @@
    2.16    }
    2.17    
    2.18    /**
    2.19 +   * Failsafe constructor for upgrades.
    2.20 +   */
    2.21 +  
    2.22 +  function construct_compat()
    2.23 +  {
    2.24 +    global $db, $session, $paths, $template, $plugins; // Common objects
    2.25 +    $this->tpl_bool    = Array();
    2.26 +    $this->tpl_strings = Array();
    2.27 +    $this->sidebar_extra = '';
    2.28 +    $this->toolbar_menu = '';
    2.29 +    $this->additional_headers = '';
    2.30 +    $this->plugin_blocks = Array();
    2.31 +    $this->theme_loaded = false;
    2.32 +    
    2.33 +    $this->fading_button = '<div style="background-image: url('.scriptPath.'/images/about-powered-enano-hover.png); background-repeat: no-repeat; width: 88px; height: 31px; margin: 0 auto 5px auto;">
    2.34 +                              <a style="background-image: none; padding-right: 0;" href="http://enanocms.org/" onclick="window.open(this.href); return false;"><img style="border-width: 0;" alt=" " src="'.scriptPath.'/images/about-powered-enano.png" onmouseover="domOpacity(this, 100, 0, 500);" onmouseout="domOpacity(this, 0, 100, 500);" /></a>
    2.35 +                            </div>';
    2.36 +    
    2.37 +    $this->theme_list = Array();
    2.38 +    $this->named_theme_list = Array();
    2.39 +    
    2.40 +    $q = $db->sql_query('SELECT theme_id, theme_name, enabled, default_style FROM ' . table_prefix . 'themes;');
    2.41 +    if ( !$q )
    2.42 +      $db->_die('template.php selecting theme list');
    2.43 +    
    2.44 +    $i = 0;
    2.45 +    while ( $row = $db->fetchrow() )
    2.46 +    {
    2.47 +      $this->theme_list[$i] = $row;
    2.48 +      $i++;
    2.49 +    }
    2.50 +    // List out all CSS files for this theme
    2.51 +    foreach ( $this->theme_list as $i => &$theme )
    2.52 +    {
    2.53 +      $theme['css'] = array();
    2.54 +      $dir = ENANO_ROOT . "/themes/{$theme['theme_id']}/css";
    2.55 +      if ( $dh = @opendir($dir) )
    2.56 +      {
    2.57 +        while ( ( $file = @readdir($dh) ) !== false )
    2.58 +        {
    2.59 +          if ( preg_match('/\.css$/', $file) )
    2.60 +            $theme['css'][] = preg_replace('/\.css$/', '', $file);
    2.61 +        }
    2.62 +        closedir($dh);
    2.63 +      }
    2.64 +      // No CSS files? If so, nuke it.
    2.65 +      if ( count($theme['css']) < 1 )
    2.66 +      {
    2.67 +        unset($this->theme_list[$i]);
    2.68 +      }
    2.69 +    }
    2.70 +    $this->theme_list = array_values($this->theme_list);
    2.71 +    // Create associative array of themes
    2.72 +    foreach ( $this->theme_list as $i => &$theme )
    2.73 +      $this->named_theme_list[ $theme['theme_id'] ] =& $this->theme_list[$i];
    2.74 +    
    2.75 +    $this->default_theme = ( $_ = getConfig('theme_default') ) ? $_ : $this->theme_list[0]['theme_id'];
    2.76 +    // Come up with the default style. If the CSS file specified in default_style exists, we're good, just
    2.77 +    // use that. Otherwise, use the first stylesheet that comes to mind.
    2.78 +    $df_data =& $this->named_theme_list[ $this->default_theme ];
    2.79 +    $this->default_style = ( in_array($df_data['default_style'], $df_data['css']) ) ? $df_data['default_style'] : $df_data['css'][0];
    2.80 +  }
    2.81 +  
    2.82 +  /**
    2.83     * Systematically deletes themes if they're blocked by theme security settings. Called when session->start() finishes.
    2.84     */
    2.85    
    2.86 @@ -109,7 +178,7 @@
    2.87      // For each theme, check ACLs and delete from RAM if not authorized
    2.88      foreach ( $this->theme_list as $i => $theme )
    2.89      {
    2.90 -      if ( !$theme['group_list'] )
    2.91 +      if ( !@$theme['group_list'] )
    2.92          continue;
    2.93        if ( $theme['theme_id'] === getConfig('theme_default') )
    2.94          continue;