Switch site's theme.

@return void
427162
protected function _change()
    {
        $disabledThemes = plugin()
            ->filter(function ($theme) {
                return $theme->isTheme && !in_array($theme->name, [option('front_theme'), option('back_theme')]);
            })
            ->toArray();

        if (!count($disabledThemes)) {
            $this->err(__d('installer', '<info>There are no disabled themes!</info>'));
            $this->out();

            return;
        }

        $index = 1;
        $this->out();
        foreach ($disabledThemes as $theme) {
            $disabledThemes[$index] = $theme;
            $this->out(
                __d('installer', '[{0, number, integer}] {1} [{2}]', [
                    $index,
                    $theme->humanName,
                    ($theme->isAdmin ? __d('installer', 'backend') : __d('installer', 'frontend')),
                ])
            );
            $index++;
        }
        $this->out();

        $message = __d('installer', "Which theme would you like to activate?\n[Q]uit");
        while (true) {
            $in = $this->in($message);
            if (strtoupper($in) === 'Q') {
                $this->err(__d('installer', 'Operation aborted'));
                break;
            } elseif (intval($in) < 1 || !isset($disabledThemes[intval($in)])) {
                $this->err(__d('installer', 'Invalid option'));
            } else {
                $task = $this->dispatchShell("Installer.themes change -t {$disabledThemes[$in]->name}");

                if ($task === 0) {
                    $this->out(__d('installer', 'Theme changed!'));
                    Plugin::dropCache();
                } else {
                    $this->err(__d('installer', 'Theme could not be changed.'), 2);
                    $this->out();
                }
                break;
            }
        }

        $this->out();
    }
1143676
protected function registerTheme()
    {
        $this->app->singleton(
            'theme', 
            function ($app) {
                $loadDefaultLangPath = base_path('resources/lang');
                $app['path.lang'] = $loadDefaultLangPath;
                return new Manager($app['files']);
            }
        );
    }
752891
public function setTheme($theme)
	{
	    $otheme = $this->options['theme'];
	    
		$this->options['theme'] = $theme;
		
		if ($otheme != $theme) {
		    $this->initViewConfig();
		}
		
		return $this;
	}
206890
public function setTheme($theme)
    {
        if (!is_null($this->theme)) {
            $this->resolved && $this->resetViewPaths();

            $this->dispatcher->fire("antares.theme.unset: {$this->theme}");
            $this->dispatcher->fire(new ThemeUnset($this->theme));
        }


        $this->theme = $theme;
        $this->dispatcher->fire("antares.theme.set: {$this->theme}");
        $this->dispatcher->fire(new ThemeSet($this->theme));

        if ($this->resolved) {
            $this->resolved = false;
            $this->resolving();
        }
    }
354402
public function SetToggle() {
      $Session = Gdn::Session();
      if (!$Session->IsValid())
         return;
      
      $ShowAllCategories = GetIncomingValue('ShowAllCategories', '');
      if ($ShowAllCategories != '') {
         $ShowAllCategories = $ShowAllCategories == 'true' ? TRUE : FALSE;
         $ShowAllCategoriesPref = $Session->GetPreference('ShowAllCategories');
         if ($ShowAllCategories != $ShowAllCategoriesPref)
            $Session->SetPreference('ShowAllCategories', $ShowAllCategories);
            
         Redirect('/'.ltrim(Gdn::Request()->Path(), '/'));
      }
   }
701399
public function change()
    {
        $table = $this->table('calendar_events');
        $hasSource = $table->hasColumn('event_source');
        $hasSourceId = $table->hasColumn('event_source_id');

        if ($hasSource) {
            $table->renameColumn('event_source', 'source');
        }

        if ($hasSourceId) {
            $table->renameColumn('event_source_id', 'source_id');
        }
    }
1214508
protected function setThemeProperties()
    {
        $this->theme_frontend = $this->config('theme', 'frontend');
        $this->theme_backend = $this->config('theme_backend', 'backend');

        if ($this->is_backend) {
            $this->theme = $this->theme_backend;
        } elseif ($this->is_install) {
            $this->theme = $this->theme_frontend;
        } elseif (!empty($this->current_store)) {
            $this->theme_frontend = $this->store->getConfig('theme');
            $this->theme = $this->theme_frontend;
        }

        $this->hook->attach('theme', $this);

        if (empty($this->theme)) {
            $this->response->outputError404();
        }

        $this->current_theme = $this->module->getInfo($this->theme);

        if (empty($this->current_theme)) {
            $this->response->outputError404();
        }

        $this->theme_settings = (array) $this->getModuleSettings($this->theme, null, array());
        $this->templates = $this->getDefaultTemplates();

        if (!empty($this->current_theme['data']['templates'])) {
            $this->templates = array_merge($this->templates, $this->current_theme['data']['templates']);
        }
    }
107724
protected function resolve_theme() {
        global $CFG, $USER, $SESSION;

        if (empty($CFG->themeorder)) {
            $themeorder = array('course', 'category', 'session', 'user', 'cohort', 'site');
        } else {
            $themeorder = $CFG->themeorder;
            // Just in case, make sure we always use the site theme if nothing else matched.
            $themeorder[] = 'site';
        }

        $mnetpeertheme = '';
        if (isloggedin() and isset($CFG->mnet_localhost_id) and $USER->mnethostid != $CFG->mnet_localhost_id) {
            require_once($CFG->dirroot.'/mnet/peer.php');
            $mnetpeer = new mnet_peer();
            $mnetpeer->set_id($USER->mnethostid);
            if ($mnetpeer->force_theme == 1 && $mnetpeer->theme != '') {
                $mnetpeertheme = $mnetpeer->theme;
            }
        }

        $devicetheme = core_useragent::get_device_type_theme($this->devicetypeinuse);

        // The user is using another device than default, and we have a theme for that, we should use it.
        $hascustomdevicetheme = core_useragent::DEVICETYPE_DEFAULT != $this->devicetypeinuse && !empty($devicetheme);

        foreach ($themeorder as $themetype) {

            switch ($themetype) {
                case 'course':
                    if (!empty($CFG->allowcoursethemes) && !empty($this->_course->theme) && !$hascustomdevicetheme) {
                        return $this->_course->theme;
                    }
                break;

                case 'category':
                    if (!empty($CFG->allowcategorythemes) && !$hascustomdevicetheme) {
                        $categories = $this->categories;
                        foreach ($categories as $category) {
                            if (!empty($category->theme)) {
                                return $category->theme;
                            }
                        }
                    }
                break;

                case 'session':
                    if (!empty($SESSION->theme)) {
                        return $SESSION->theme;
                    }
                break;

                case 'user':
                    if (!empty($CFG->allowuserthemes) && !empty($USER->theme) && !$hascustomdevicetheme) {
                        if ($mnetpeertheme) {
                            return $mnetpeertheme;
                        } else {
                            return $USER->theme;
                        }
                    }
                break;

                case 'cohort':
                    if (!empty($CFG->allowcohortthemes) && !empty($USER->cohorttheme) && !$hascustomdevicetheme) {
                        return $USER->cohorttheme;
                    }
                break;

                case 'site':
                    if ($mnetpeertheme) {
                        return $mnetpeertheme;
                    }
                    // First try for the device the user is using.
                    if (!empty($devicetheme)) {
                        return $devicetheme;
                    }
                    // Next try for the default device (as a fallback).
                    $devicetheme = core_useragent::get_device_type_theme(core_useragent::DEVICETYPE_DEFAULT);
                    if (!empty($devicetheme)) {
                        return $devicetheme;
                    }
                    // The default device theme isn't set up - use the overall default theme.
                    return theme_config::DEFAULT_THEME;
            }
        }

        // We should most certainly have resolved a theme by now. Something has gone wrong.
        debugging('Error resolving the theme to use for this page.', DEBUG_DEVELOPER);
        return theme_config::DEFAULT_THEME;
    }
1323919
@Override
	public void installTheme(Theme theme) {
		this.removeCssLinks();
		if (this.currentTheme != null) {
			for (CssLink link : this.currentTheme.getLinks()) {
				link.getLink().removeFromParent();
			}
		}
		this.currentTheme = theme;
		this.resetTheme();
	}
1292439
function() {
			switch(that.settings.position) {
				case 'top':
					that.bar.css('top', 0);
					break;
				case 'bottom':
					that.bar.css('bottom', 0);
					break;
				default:
					that.bar.css('top', 0);
			}
		}
665626
public function prepareTheme()
    {
        $this->viewBuilder()->layout('default');
        if (!empty($this->request->params['prefix']) &&
            strtolower($this->request->params['prefix']) === 'admin'
        ) {
            $this->viewBuilder()->theme(option('back_theme'));
        } else {
            $this->viewBuilder()->theme(option('front_theme'));
        }

        if ($this->request->isAjax()) {
            $this->viewBuilder()->layout('ajax');
        }

        if ($this->request->isHome()) {
            $this->viewBuilder()->layout('home');
        }

        if ($this->request->isDashboard()) {
            $this->viewBuilder()->layout('dashboard');
        }
    }
1303603
function onBeforeSecurityLogin()
    {
        $site = Multisites::inst()->getCurrentSite();

        if ($site && $site->Theme) {
            SSViewer::set_themes([$site->Theme, SSViewer::DEFAULT_THEME]);
        }
    }
1034515
public static function switchToHidden() {
		self::$hiddenInstance = self::$defaultInstance;
		self::$defaultInstance = new MoufManager();
		self::$defaultInstance->configManager = new MoufConfigManager("../../config.php");
		self::$defaultInstance->componentsFileName = "../../mouf/MoufComponents.php";
		//self::$defaultInstance->requireFileName = "MoufAdminRequire.php";
		self::$defaultInstance->adminUiFileName = "../../mouf/MoufUI.php";
		self::$defaultInstance->mainClassName = "MoufAdmin";
		self::$defaultInstance->scope = MoufManager::SCOPE_ADMIN;
	}
257141
public static function init() {

		if ( self::can_switch_themes() ) {
			add_action( 'admin_bar_menu', array( __CLASS__, 'admin_bar_menu' ), 90 );
			add_action( 'wp_ajax_tts_set_theme', array( __CLASS__, 'set_theme' ) );
		}

		load_plugin_textdomain( 'toolbar-theme-switcher', false, dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/lang' );
	}
295056
protected function themeOptionsOverrides() {

		// --------------------------------------------------------------------
		// CSS

		$css = '';
		$this->cssOverrides = apply_filters( 'pb_epub_css_override', $css ) . "\n";

		// --------------------------------------------------------------------
		// Hacks

		$hacks = [];
		$hacks = apply_filters( 'pb_epub_hacks', $hacks );

		// Display chapter numbers?
		if ( isset( $hacks['chapter_numbers'] ) && $hacks['chapter_numbers'] ) {
			$this->numbered = true;
		} else {
			$this->numbered = false;
		}

		if ( isset( $hacks['ebook_compress_images'] ) && $hacks['ebook_compress_images'] ) {
			$this->compressImages = true;
		}

	}
298625
public function change()
    {
        $table = $this->table('languages');
        $table->addColumn('is_rtl', 'boolean', [
            'default' => false,
            'null' => false,
        ]);
        $table->addColumn('trashed', 'datetime', [
            'default' => null,
            'null' => true,
        ]);
        $table->changeColumn('is_active', 'boolean', [
            'default' => true,
            'null' => false,
        ]);
        $table->renameColumn('short_code', 'code');
        $table->removeColumn('description');
        $table->update();
    }
1240295
function set_theme_option() {

		// Load settings
        $optionsframework_settings = get_option( 'optionsframework' );

        // Updates the unique option id in the database if it has changed
        if ( function_exists( 'optionsframework_option_name' ) ) {
			optionsframework_option_name();
        }
        elseif ( has_action( 'optionsframework_option_name' ) ) {
			do_action( 'optionsframework_option_name' );
        }
        // If the developer hasn't explicitly set an option id, we'll use a default
        else {
            $default_themename = get_option( 'stylesheet' );
            $default_themename = preg_replace( "/\W/", "_", strtolower($default_themename ) );
            $default_themename = 'optionsframework_' . $default_themename;
            if ( isset( $optionsframework_settings['id'] ) ) {
				if ( $optionsframework_settings['id'] == $default_themename ) {
					// All good, using default theme id
				} else {
					$optionsframework_settings['id'] = $default_themename;
					update_option( 'optionsframework', $optionsframework_settings );
				}
            }
            else {
				$optionsframework_settings['id'] = $default_themename;
				update_option( 'optionsframework', $optionsframework_settings );
            }
        }

	}