97 $df_data =& $this->named_theme_list[ $this->default_theme ]; |
102 $df_data =& $this->named_theme_list[ $this->default_theme ]; |
98 $this->default_style = ( in_array($df_data['default_style'], $df_data['css']) ) ? $df_data['default_style'] : $df_data['css'][0]; |
103 $this->default_style = ( in_array($df_data['default_style'], $df_data['css']) ) ? $df_data['default_style'] : $df_data['css'][0]; |
99 } |
104 } |
100 |
105 |
101 /** |
106 /** |
|
107 * Failsafe constructor for upgrades. |
|
108 */ |
|
109 |
|
110 function construct_compat() |
|
111 { |
|
112 global $db, $session, $paths, $template, $plugins; // Common objects |
|
113 $this->tpl_bool = Array(); |
|
114 $this->tpl_strings = Array(); |
|
115 $this->sidebar_extra = ''; |
|
116 $this->toolbar_menu = ''; |
|
117 $this->additional_headers = ''; |
|
118 $this->plugin_blocks = Array(); |
|
119 $this->theme_loaded = false; |
|
120 |
|
121 $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;"> |
|
122 <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> |
|
123 </div>'; |
|
124 |
|
125 $this->theme_list = Array(); |
|
126 $this->named_theme_list = Array(); |
|
127 |
|
128 $q = $db->sql_query('SELECT theme_id, theme_name, enabled, default_style FROM ' . table_prefix . 'themes;'); |
|
129 if ( !$q ) |
|
130 $db->_die('template.php selecting theme list'); |
|
131 |
|
132 $i = 0; |
|
133 while ( $row = $db->fetchrow() ) |
|
134 { |
|
135 $this->theme_list[$i] = $row; |
|
136 $i++; |
|
137 } |
|
138 // List out all CSS files for this theme |
|
139 foreach ( $this->theme_list as $i => &$theme ) |
|
140 { |
|
141 $theme['css'] = array(); |
|
142 $dir = ENANO_ROOT . "/themes/{$theme['theme_id']}/css"; |
|
143 if ( $dh = @opendir($dir) ) |
|
144 { |
|
145 while ( ( $file = @readdir($dh) ) !== false ) |
|
146 { |
|
147 if ( preg_match('/\.css$/', $file) ) |
|
148 $theme['css'][] = preg_replace('/\.css$/', '', $file); |
|
149 } |
|
150 closedir($dh); |
|
151 } |
|
152 // No CSS files? If so, nuke it. |
|
153 if ( count($theme['css']) < 1 ) |
|
154 { |
|
155 unset($this->theme_list[$i]); |
|
156 } |
|
157 } |
|
158 $this->theme_list = array_values($this->theme_list); |
|
159 // Create associative array of themes |
|
160 foreach ( $this->theme_list as $i => &$theme ) |
|
161 $this->named_theme_list[ $theme['theme_id'] ] =& $this->theme_list[$i]; |
|
162 |
|
163 $this->default_theme = ( $_ = getConfig('theme_default') ) ? $_ : $this->theme_list[0]['theme_id']; |
|
164 // Come up with the default style. If the CSS file specified in default_style exists, we're good, just |
|
165 // use that. Otherwise, use the first stylesheet that comes to mind. |
|
166 $df_data =& $this->named_theme_list[ $this->default_theme ]; |
|
167 $this->default_style = ( in_array($df_data['default_style'], $df_data['css']) ) ? $df_data['default_style'] : $df_data['css'][0]; |
|
168 } |
|
169 |
|
170 /** |
102 * Systematically deletes themes if they're blocked by theme security settings. Called when session->start() finishes. |
171 * Systematically deletes themes if they're blocked by theme security settings. Called when session->start() finishes. |
103 */ |
172 */ |
104 |
173 |
105 function process_theme_acls() |
174 function process_theme_acls() |
106 { |
175 { |
107 global $db, $session, $paths, $template, $plugins; // Common objects |
176 global $db, $session, $paths, $template, $plugins; // Common objects |
108 |
177 |
109 // For each theme, check ACLs and delete from RAM if not authorized |
178 // For each theme, check ACLs and delete from RAM if not authorized |
110 foreach ( $this->theme_list as $i => $theme ) |
179 foreach ( $this->theme_list as $i => $theme ) |
111 { |
180 { |
112 if ( !$theme['group_list'] ) |
181 if ( !@$theme['group_list'] ) |
113 continue; |
182 continue; |
114 if ( $theme['theme_id'] === getConfig('theme_default') ) |
183 if ( $theme['theme_id'] === getConfig('theme_default') ) |
115 continue; |
184 continue; |
116 switch ( $theme['group_policy'] ) |
185 switch ( $theme['group_policy'] ) |
117 { |
186 { |