3 * ChooseTheme - GNU social plugin enabling user to select a preferred theme
4 * Copyright (C) 2015, kollektivet0x242.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * @author Knut Erik Hollund <knut.erik@unlike.no>
20 * @copyright 2015 kollektivet0x242. http://www.kollektivet0x242.no
22 * @license GNU Affero General Public License http://www.gnu.org/licenses/
25 class ChooseThemePlugin extends Plugin {
27 public function onRouterInitialized(URLMapper $m) {
28 $m->connect('main/choosethemesettings', array('action' => 'choosethemesettings'));
31 public function onPluginVersion(array &$versions) {
33 $versions[] = array('name' => 'ChooseTheme',
35 'author' => 'Knut Erik "abjectio" Hollund',
36 'homepage' => 'https://gitlab.com/kollektivet0x242/gsp-choosetheme',
38 // TRANS: Plugin description.
39 _m('Allowing user to select the preferred theme.'));
44 * Menu item for ChooseTheme
46 * @param Action $action action being executed
48 * @return boolean hook return
50 function onEndAccountSettingsNav(Action $action) {
51 $action_name = $action->getActionName();
53 $action->menuItem(common_local_url('choosethemesettings'),
54 // TRANS: Poll plugin menu item on user settings page.
56 // TRANS: Poll plugin tooltip for user settings menu item.
58 $action_name === 'themesettings');
64 function onStartShowStylesheets(Action $action) {
66 //get the theme and set the current config for site and theme.
67 if($action->getScoped() instanceof Profile) {
68 $site_theme = common_config('site','theme');
69 $user_theme = $action->getScoped()->getPref('chosen_theme', 'theme', $site_theme);
70 common_config_set('site', 'theme', $user_theme);