# HG changeset patch # User Dan # Date 1204867161 18000 # Node ID dd0f079e3c52d5d4e7d41146e47da44374e65666 # Parent 92c217d056aff5fe099ed45cd98750d36f7c1657# Parent 5560ff856dd72421b251a1205f771d8c182d08b2 Aww crap. NOW it should be together. diff -r 92c217d056af -r dd0f079e3c52 .hgtags --- a/.hgtags Fri Mar 07 00:17:46 2008 -0500 +++ b/.hgtags Fri Mar 07 00:19:21 2008 -0500 @@ -14,4 +14,3 @@ 3395ecddd831ee2f0229ab3b4a1c9d69f0ab73d7 release d1a95497b68f765f6ca4ed816d07b20b13cee692 rebrand ceff43bbc3d3bc18d7679f88ef6fec2e070bc704 release -1506b9687a1a7179205f5cfc0b4ed8e5a90c5cb0 release diff -r 92c217d056af -r dd0f079e3c52 includes/template.php --- a/includes/template.php Fri Mar 07 00:17:46 2008 -0500 +++ b/includes/template.php Fri Mar 07 00:19:21 2008 -0500 @@ -56,6 +56,11 @@ $this->theme_list = Array(); $this->named_theme_list = Array(); + if ( defined('IN_ENANO_UPGRADE') ) + { + return $this->construct_compat(); + } + $q = $db->sql_query('SELECT theme_id, theme_name, enabled, default_style, group_policy, group_list FROM ' . table_prefix . 'themes;'); if ( !$q ) $db->_die('template.php selecting theme list'); @@ -99,6 +104,70 @@ } /** + * Failsafe constructor for upgrades. + */ + + function construct_compat() + { + global $db, $session, $paths, $template, $plugins; // Common objects + $this->tpl_bool = Array(); + $this->tpl_strings = Array(); + $this->sidebar_extra = ''; + $this->toolbar_menu = ''; + $this->additional_headers = ''; + $this->plugin_blocks = Array(); + $this->theme_loaded = false; + + $this->fading_button = '
+  +
'; + + $this->theme_list = Array(); + $this->named_theme_list = Array(); + + $q = $db->sql_query('SELECT theme_id, theme_name, enabled, default_style FROM ' . table_prefix . 'themes;'); + if ( !$q ) + $db->_die('template.php selecting theme list'); + + $i = 0; + while ( $row = $db->fetchrow() ) + { + $this->theme_list[$i] = $row; + $i++; + } + // List out all CSS files for this theme + foreach ( $this->theme_list as $i => &$theme ) + { + $theme['css'] = array(); + $dir = ENANO_ROOT . "/themes/{$theme['theme_id']}/css"; + if ( $dh = @opendir($dir) ) + { + while ( ( $file = @readdir($dh) ) !== false ) + { + if ( preg_match('/\.css$/', $file) ) + $theme['css'][] = preg_replace('/\.css$/', '', $file); + } + closedir($dh); + } + // No CSS files? If so, nuke it. + if ( count($theme['css']) < 1 ) + { + unset($this->theme_list[$i]); + } + } + $this->theme_list = array_values($this->theme_list); + // Create associative array of themes + foreach ( $this->theme_list as $i => &$theme ) + $this->named_theme_list[ $theme['theme_id'] ] =& $this->theme_list[$i]; + + $this->default_theme = ( $_ = getConfig('theme_default') ) ? $_ : $this->theme_list[0]['theme_id']; + // Come up with the default style. If the CSS file specified in default_style exists, we're good, just + // use that. Otherwise, use the first stylesheet that comes to mind. + $df_data =& $this->named_theme_list[ $this->default_theme ]; + $this->default_style = ( in_array($df_data['default_style'], $df_data['css']) ) ? $df_data['default_style'] : $df_data['css'][0]; + } + + /** * Systematically deletes themes if they're blocked by theme security settings. Called when session->start() finishes. */ @@ -109,7 +178,7 @@ // For each theme, check ACLs and delete from RAM if not authorized foreach ( $this->theme_list as $i => $theme ) { - if ( !$theme['group_list'] ) + if ( !@$theme['group_list'] ) continue; if ( $theme['theme_id'] === getConfig('theme_default') ) continue;