]> git.mxchange.org Git - friendica.git/blob - view/theme/duepuntozero/config.php
Merge remote-tracking branch 'upstream/develop' into diasppora-delivery
[friendica.git] / view / theme / duepuntozero / config.php
1 <?php
2 /**
3  * Theme settings
4  */
5
6 use Friendica\App;
7 use Friendica\Core\Config;
8 use Friendica\Core\L10n;
9 use Friendica\Core\PConfig;
10 use Friendica\Core\Renderer;
11 use Friendica\Core\System;
12
13 function theme_content(App $a)
14 {
15         if (!local_user()) {
16                 return;
17         }
18
19         $colorset = PConfig::get(local_user(), 'duepuntozero', 'colorset');
20         $user = true;
21
22         return clean_form($a, $colorset, $user);
23 }
24
25 function theme_post(App $a)
26 {
27         if (! local_user()) {
28                 return;
29         }
30
31         if (isset($_POST['duepuntozero-settings-submit'])) {
32                 PConfig::set(local_user(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
33         }
34 }
35
36 function theme_admin(App $a)
37 {
38         $colorset = Config::get('duepuntozero', 'colorset');
39         $user = false;
40
41         return clean_form($a, $colorset, $user);
42 }
43
44 function theme_admin_post(App $a)
45 {
46         if (isset($_POST['duepuntozero-settings-submit'])) {
47                 Config::set('duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
48         }
49 }
50
51 /// @TODO $a is no longer used
52 function clean_form(App $a, &$colorset, $user)
53 {
54         $colorset = [
55                 'default'     => L10n::t('default'),
56                 'greenzero'   => L10n::t('greenzero'),
57                 'purplezero'  => L10n::t('purplezero'),
58                 'easterbunny' => L10n::t('easterbunny'),
59                 'darkzero'    => L10n::t('darkzero'),
60                 'comix'       => L10n::t('comix'),
61                 'slackr'      => L10n::t('slackr'),
62         ];
63
64         if ($user) {
65                 $color = PConfig::get(local_user(), 'duepuntozero', 'colorset');
66         } else {
67                 $color = Config::get('duepuntozero', 'colorset');
68         }
69
70         $t = Renderer::getMarkupTemplate("theme_settings.tpl");
71         $o = Renderer::replaceMacros($t, [
72                 '$submit'   => L10n::t('Submit'),
73                 '$baseurl'  => System::baseUrl(),
74                 '$title'    => L10n::t("Theme settings"),
75                 '$colorset' => ['duepuntozero_colorset', L10n::t('Variations'), $color, '', $colorset],
76         ]);
77
78         return $o;
79 }