]> git.mxchange.org Git - friendica.git/blob - view/theme/duepuntozero/config.php
30eb256237fbc062b5a5c36238d36557f9315a42
[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\System;
11
12 function theme_content(App $a)
13 {
14         if (!local_user()) {
15                 return;
16         }
17
18         $colorset = PConfig::get(local_user(), 'duepuntozero', 'colorset');
19         $user = true;
20
21         return clean_form($a, $colorset, $user);
22 }
23
24 function theme_post(App $a)
25 {
26         if (! local_user()) {
27                 return;
28         }
29
30         if (isset($_POST['duepuntozero-settings-submit'])) {
31                 PConfig::set(local_user(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
32         }
33 }
34
35 function theme_admin(App $a)
36 {
37         $colorset = Config::get('duepuntozero', 'colorset');
38         $user = false;
39
40         return clean_form($a, $colorset, $user);
41 }
42
43 function theme_admin_post(App $a)
44 {
45         if (isset($_POST['duepuntozero-settings-submit'])) {
46                 Config::set('duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
47         }
48 }
49
50 /// @TODO $a is no longer used
51 function clean_form(App $a, &$colorset, $user)
52 {
53         $colorset = [
54                 'default'     => L10n::t('default'),
55                 'greenzero'   => L10n::t('greenzero'),
56                 'purplezero'  => L10n::t('purplezero'),
57                 'easterbunny' => L10n::t('easterbunny'),
58                 'darkzero'    => L10n::t('darkzero'),
59                 'comix'       => L10n::t('comix'),
60                 'slackr'      => L10n::t('slackr'),
61         ];
62
63         if ($user) {
64                 $color = PConfig::get(local_user(), 'duepuntozero', 'colorset');
65         } else {
66                 $color = Config::get('duepuntozero', 'colorset');
67         }
68
69         $t = get_markup_template("theme_settings.tpl");
70         /// @TODO No need for adding string here, $o is not defined
71         $o .= replace_macros($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 }