123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- defined('GNUSOCIAL') || die();
- class ChooseThemePlugin extends Plugin
- {
- const PLUGIN_VERSION = '0.1.0';
- public function onRouterInitialized(URLMapper $m)
- {
- $m->connect('main/choosethemesettings', ['action' => 'choosethemesettings']);
- }
- public function onPluginVersion(array &$versions): bool
- {
- $versions[] = ['name' => 'ChooseTheme',
- 'version' => self::PLUGIN_VERSION,
- 'author' => 'Knut Erik "abjectio" Hollund',
- 'homepage' => 'https://gitlab.com/kollektivet0x242/gsp-choosetheme',
- 'rawdescription' =>
-
- _m('Allowing user to select the preferred theme.')];
- return true;
- }
-
- public function onEndAccountSettingsNav(Action $action): bool
- {
- $action_name = $action->getActionName();
- $action->menuItem(
- common_local_url('choosethemesettings'),
-
- _m('MENU', 'Theme'),
-
- _m('Choose Theme'),
- $action_name === 'themesettings'
- );
- return true;
- }
- public function onStartShowStylesheets(Action $action)
- {
-
- 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;
- }
- }
|