]> git.mxchange.org Git - friendica.git/blob - view/theme/duepuntozero/config.php
Merge pull request #13668 from annando/issue-8542
[friendica.git] / view / theme / duepuntozero / config.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2023, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 use Friendica\App;
23 use Friendica\Core\Renderer;
24 use Friendica\DI;
25
26 function theme_content(App $a)
27 {
28         if (!DI::userSession()->getLocalUserId()) {
29                 return;
30         }
31
32         $colorset = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'duepuntozero', 'colorset');
33         $user = true;
34
35         return clean_form($a, $colorset, $user);
36 }
37
38 function theme_post(App $a)
39 {
40         if (!DI::userSession()->getLocalUserId()) {
41                 return;
42         }
43
44         if (isset($_POST['duepuntozero-settings-submit'])) {
45                 DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
46         }
47 }
48
49 function theme_admin(App $a)
50 {
51         $colorset = DI::config()->get('duepuntozero', 'colorset');
52         $user = false;
53
54         return clean_form($a, $colorset, $user);
55 }
56
57 function theme_admin_post(App $a)
58 {
59         if (isset($_POST['duepuntozero-settings-submit'])) {
60                 DI::config()->set('duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
61         }
62 }
63
64 /// @TODO $a is no longer used
65 function clean_form(App $a, &$colorset, $user)
66 {
67         $colorset = [
68                 'default'     => DI::l10n()->t('default'),
69                 'greenzero'   => DI::l10n()->t('greenzero'),
70                 'purplezero'  => DI::l10n()->t('purplezero'),
71                 'easterbunny' => DI::l10n()->t('easterbunny'),
72                 'darkzero'    => DI::l10n()->t('darkzero'),
73                 'comix'       => DI::l10n()->t('comix'),
74                 'slackr'      => DI::l10n()->t('slackr'),
75         ];
76
77         if ($user) {
78                 $color = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'duepuntozero', 'colorset');
79         } else {
80                 $color = DI::config()->get('duepuntozero', 'colorset');
81         }
82
83         $t = Renderer::getMarkupTemplate("theme_settings.tpl");
84         $o = Renderer::replaceMacros($t, [
85                 '$submit'   => DI::l10n()->t('Submit'),
86                 '$title'    => DI::l10n()->t("Theme settings"),
87                 '$colorset' => ['duepuntozero_colorset', DI::l10n()->t('Variations'), $color, '', $colorset],
88         ]);
89
90         return $o;
91 }