X-Git-Url: https://git.mxchange.org/?p=quix0rs-gnu-social.git;a=blobdiff_plain;f=plugins%2FChooseTheme%2FChooseThemePlugin.php;fp=plugins%2FChooseTheme%2FChooseThemePlugin.php;h=b54e3d09a6929f0fc97c2a0e69dcdd2e6bea488a;hp=0000000000000000000000000000000000000000;hb=4160a3fb730113f3d712bd777884c4b0482f6df1;hpb=abd90bbdf562614755802885dfb5673645df8575 diff --git a/plugins/ChooseTheme/ChooseThemePlugin.php b/plugins/ChooseTheme/ChooseThemePlugin.php new file mode 100644 index 0000000000..b54e3d09a6 --- /dev/null +++ b/plugins/ChooseTheme/ChooseThemePlugin.php @@ -0,0 +1,74 @@ +. + * + * @author Knut Erik Hollund + * @copyright 2015 kollektivet0x242. http://www.kollektivet0x242.no + * + * @license GNU Affero General Public License http://www.gnu.org/licenses/ + */ + +class ChooseThemePlugin extends Plugin { + + public function onRouterInitialized(URLMapper $m) { + $m->connect('main/choosethemesettings', array('action' => 'choosethemesettings')); + } + + public function onPluginVersion(array &$versions) { + + $versions[] = array('name' => 'ChooseTheme', + 'version' => '0.1', + 'author' => 'Knut Erik "abjectio" Hollund', + 'homepage' => 'https://gitlab.com/kollektivet0x242/gsp-choosetheme', + 'rawdescription' => + // TRANS: Plugin description. + _m('Allowing user to select the preferred theme.')); + return true; + } + + /** + * Menu item for ChooseTheme + * + * @param Action $action action being executed + * + * @return boolean hook return + */ + function onEndAccountSettingsNav(Action $action) { + $action_name = $action->getActionName(); + + $action->menuItem(common_local_url('choosethemesettings'), + // TRANS: Poll plugin menu item on user settings page. + _m('MENU', 'Theme'), + // TRANS: Poll plugin tooltip for user settings menu item. + _m('Choose Theme'), + $action_name === 'themesettings'); + + return true; + } + + + function onStartShowStylesheets(Action $action) { + + //get the theme and set the current config for site and theme. + if($action->getScoped() instanceof Profile) { + $site_theme = common_config('site','theme'); + $user_theme = $action->getScoped()->getPref('chosen_theme', 'theme', $site_theme); + common_config_set('site', 'theme', $user_theme); + } + return true; + } +}