Changeset 25406 for trunk/admin/include/themes.class.php
- Timestamp:
- Nov 9, 2013, 12:29:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/themes.class.php
r25018 r25406 22 22 // +-----------------------------------------------------------------------+ 23 23 24 /** 25 * class DummyTheme_maintain 26 * used when a theme uses the old procedural declaration of maintenance methods 27 */ 28 class DummyTheme_maintain extends ThemeMaintain 29 { 30 function activate($theme_version, &$errors=array()) 31 { 32 return $this->__call(__FUNCTION__, func_get_args()); 33 } 34 function deactivate() 35 { 36 return $this->__call(__FUNCTION__, func_get_args()); 37 } 38 function delete() 39 { 40 return $this->__call(__FUNCTION__, func_get_args()); 41 } 42 43 function __call($name, $arguments) 44 { 45 if (is_callable('theme_'.$name)) 46 { 47 array_unshift($arguments, $this->theme_id); 48 return call_user_func_array('theme_'.$name, $arguments); 49 } 50 return null; 51 } 52 } 53 54 24 55 class themes 25 56 { … … 39 70 $this->db_themes_by_id[$db_theme['id']] = $db_theme; 40 71 } 72 } 73 74 /** 75 * Returns the maintain class of a theme 76 * or build a new class with the procedural methods 77 * @param string $theme_id 78 */ 79 private static function build_maintain_class($theme_id) 80 { 81 $file_to_include = PHPWG_THEMES_PATH.'/'.$theme_id.'/admin/maintain.inc.php'; 82 $classname = $theme_id.'_maintain'; 83 84 if (file_exists($file_to_include)) 85 { 86 include_once($file_to_include); 87 88 if (class_exists($classname)) 89 { 90 $theme_maintain = new $classname($theme_id); 91 } 92 else 93 { 94 $theme_maintain = new DummyTheme_maintain($theme_id); 95 } 96 } 97 else 98 { 99 $theme_maintain = new DummyTheme_maintain($theme_id); 100 } 101 102 return $theme_maintain; 41 103 } 42 104 … … 56 118 } 57 119 58 $ file_to_include = PHPWG_THEMES_PATH.'/'.$theme_id.'/admin/maintain.inc.php';120 $theme_maintain = self::build_maintain_class($theme_id); 59 121 60 122 $errors = array(); … … 86 148 } 87 149 88 89 150 if ($this->fs_themes[$theme_id]['mobile'] 90 151 and !empty($conf['mobile_theme']) … … 95 156 } 96 157 97 if (file_exists($file_to_include)) 98 { 99 include($file_to_include); 100 if (function_exists('theme_activate')) 101 { 102 theme_activate($theme_id, $this->fs_themes[$theme_id]['version'], $errors); 103 } 104 } 158 $theme_maintain->activate($this->fs_themes[$theme_id]['version'], $errors); 105 159 106 160 if (empty($errors)) … … 142 196 143 197 $query = ' 144 SELECT 145 id 198 SELECT id 146 199 FROM '.THEMES_TABLE.' 147 200 WHERE id != \''.$theme_id.'\' … … 160 213 } 161 214 162 if (file_exists($file_to_include)) 163 { 164 include($file_to_include); 165 if (function_exists('theme_deactivate')) 166 { 167 theme_deactivate($theme_id); 168 } 169 } 215 $theme_maintain->deactivate(); 170 216 171 217 $query = ' … … 204 250 } 205 251 206 if (file_exists($file_to_include)) 207 { 208 include($file_to_include); 209 if (function_exists('theme_delete')) 210 { 211 theme_delete($theme_id); 212 } 213 } 252 $theme_maintain->delete(); 214 253 215 254 deltree(PHPWG_THEMES_PATH.$theme_id, PHPWG_THEMES_PATH . 'trash');
Note: See TracChangeset
for help on using the changeset viewer.