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