enumerateThemes () as $theme) { $selected = ($this->getSelectedTheme () == $theme) ? ' selected' : ''; $options .= sprintf ('', $theme, $selected, $theme); } $onchange = "window.location.href = '?switch_theme=' + this.value"; $result = sprintf ('', $onchange, $options); return $result; } protected function enumerateThemes () { if (! isset (self::$cache_themes)) { $themes = array (); foreach (new DirectoryIterator (THEME_DIR) as $file) { if (! $file->isDot ()) { if ($file->isDir ()) { if (file_exists ($file->getPathname () . '/version')) { $themes [] = $file->getFilename (); } } } } self::$cache_themes = $themes; } return self::$cache_themes; } function getSelectedTheme () { if (! isset (self::$cache_current_theme)) { self::$cache_current_theme = Setting_Model::get (Setting_Model::S_THEME); if (Setting_Model::get (Setting_Model::S_READ_ONLY, false)) { if (Zend_Session::sessionExists ()) { $theme = new Zend_Session_Namespace ('theme'); if (isset ($theme->swithch_theme)) { self::$cache_current_theme = $theme->swithch_theme; } } } } return self::$cache_current_theme; } function recognizeThemeSwitch () { if (Setting_Model::get (Setting_Model::S_READ_ONLY, false)) { if ($new_theme = Input::instance ()->get ('switch_theme')) { if (in_array ($new_theme, $this->enumerateThemes ())) { $theme = new Zend_Session_Namespace ('theme'); $theme->swithch_theme = $new_theme; } url::newurl (url::href ()); } } } }