Esempio n. 1
1
 /**
  * Configures a theme to be active for the current user's session.
  */
 public function get_preview_theme()
 {
     $theme_name = $this->handler_vars['theme_name'];
     $theme_dir = $this->handler_vars['theme_dir'];
     if (isset($theme_name) && isset($theme_dir)) {
         if (Themes::get_theme_dir() == $theme_dir) {
             Themes::cancel_preview();
             Session::notice(_t("Ended the preview of the theme '%s'", array($theme_name)));
         } else {
             if (Themes::preview_theme($theme_name, $theme_dir)) {
                 Session::notice(_t("Previewing theme '%s'", array($theme_name)));
             }
         }
     }
     Utils::redirect(URL::get('admin', 'page=themes'));
 }
Esempio n. 2
0
 /**
  * function activate_theme
  * Updates the database with the name of the new theme to use
  * @param string the name of the theme
  **/
 public static function activate_theme($theme_name, $theme_dir)
 {
     $ok = Themes::validate_theme($theme_dir);
     $ok = Plugins::filter('activate_theme', $ok, $theme_name);
     // Allow plugins to reject activation
     if ($ok) {
         Themes::cancel_preview();
         $old_active_theme = Themes::create();
         Plugins::act_id('theme_deactivated', $old_active_theme->plugin_id(), $old_active_theme->name, $old_active_theme);
         // For the theme itself to react to its deactivation
         Plugins::act('theme_deactivated_any', $old_active_theme->name, $old_active_theme);
         // For any plugin to react to its deactivation
         Options::set('theme_name', $theme_name);
         Options::set('theme_dir', $theme_dir);
         $new_active_theme = Themes::create($theme_name);
         // Set version of theme if it wasn't installed before
         $versions = Options::get('pluggable_versions');
         if (!isset($versions[get_class($new_active_theme)])) {
             $versions[get_class($new_active_theme)] = $new_active_theme->get_version();
             Options::set('pluggable_versions', $versions);
         }
         // Run activation hooks for theme activation
         Plugins::act_id('theme_activated', $new_active_theme->plugin_id(), $theme_name, $new_active_theme);
         // For the theme itself to react to its activation
         Plugins::act('theme_activated_any', $theme_name, $new_active_theme);
         // For any plugin to react to its activation
         EventLog::log(_t('Activated Theme: %s', array($theme_name)), 'notice', 'theme', 'habari');
     }
     return $ok;
 }