You are here

public function sweaver_plugin_themeswitch::sweaver_menu_callback in Sweaver 7

Same name and namespace in other branches
  1. 6 plugins/sweaver_plugin_themeswitch/sweaver_plugin_themeswitch.inc \sweaver_plugin_themeswitch::sweaver_menu_callback()

Frontend themeswitch.

Overrides sweaver_plugin::sweaver_menu_callback

File

plugins/sweaver_plugin_themeswitch/sweaver_plugin_themeswitch.inc, line 94
Themeswitch plugin.

Class

sweaver_plugin_themeswitch
@file Themeswitch plugin.

Code

public function sweaver_menu_callback() {
  $theme = arg(1);
  $theme_default = variable_get('theme_default', 'garland');
  $all_themes = sweaver_get_all_themes();
  if (!empty($theme) && isset($all_themes[$theme]) && $all_themes[$theme]->status == 1) {
    if ($theme != $theme_default) {
      sweaver_session(NULL, 'sweaver_theme', TRUE);
      sweaver_session($theme, 'sweaver_theme');
    }
    else {

      // Reset session variable because it's the default.
      sweaver_session(NULL, 'sweaver_theme', TRUE);
    }

    // Let other modules act on the themeswitch.
    $arguments = array(
      'switched_theme' => $theme,
      'default_theme' => $theme_default,
    );
    module_invoke_all('sweaver_action', 'theme_switch', $arguments);
    sweaver_session(t('You have switched to @switched_theme.', array(
      '@switched_theme' => $all_themes[$theme]->info['name'],
    )));
  }

  // Go back to previous page.
  drupal_goto();
}