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