]> git.mxchange.org Git - friendica.git/blob - view/theme/duepuntozero/config.php
1a2d231f431d464d6323722d714d3581d6f2fd5a
[friendica.git] / view / theme / duepuntozero / config.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2022, 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\Core\Session;
25 use Friendica\DI;
26
27 function theme_content(App $a)
28 {
29         if (!Session::getLocalUser()) {
30                 return;
31         }
32
33         $colorset = DI::pConfig()->get(Session::getLocalUser(), 'duepuntozero', 'colorset');
34         $user = true;
35
36         return clean_form($a, $colorset, $user);
37 }
38
39 function theme_post(App $a)
40 {
41         if (! Session::getLocalUser()) {
42                 return;
43         }
44
45         if (isset($_POST['duepuntozero-settings-submit'])) {
46                 DI::pConfig()->set(Session::getLocalUser(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
47         }
48 }
49
50 function theme_admin(App $a)
51 {
52         $colorset = DI::config()->get('duepuntozero', 'colorset');
53         $user = false;
54
55         return clean_form($a, $colorset, $user);
56 }
57
58 function theme_admin_post(App $a)
59 {
60         if (isset($_POST['duepuntozero-settings-submit'])) {
61                 DI::config()->set('duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
62         }
63 }
64
65 /// @TODO $a is no longer used
66 function clean_form(App $a, &$colorset, $user)
67 {
68         $colorset = [
69                 'default'     => DI::l10n()->t('default'),
70                 'greenzero'   => DI::l10n()->t('greenzero'),
71                 'purplezero'  => DI::l10n()->t('purplezero'),
72                 'easterbunny' => DI::l10n()->t('easterbunny'),
73                 'darkzero'    => DI::l10n()->t('darkzero'),
74                 'comix'       => DI::l10n()->t('comix'),
75                 'slackr'      => DI::l10n()->t('slackr'),
76         ];
77
78         if ($user) {
79                 $color = DI::pConfig()->get(Session::getLocalUser(), 'duepuntozero', 'colorset');
80         } else {
81                 $color = DI::config()->get('duepuntozero', 'colorset');
82         }
83
84         $t = Renderer::getMarkupTemplate("theme_settings.tpl");
85         $o = Renderer::replaceMacros($t, [
86                 '$submit'   => DI::l10n()->t('Submit'),
87                 '$title'    => DI::l10n()->t("Theme settings"),
88                 '$colorset' => ['duepuntozero_colorset', DI::l10n()->t('Variations'), $color, '', $colorset],
89         ]);
90
91         return $o;
92 }