]> git.mxchange.org Git - friendica.git/blob - view/theme/duepuntozero/config.php
Merge pull request #8134 from nupplaphil/task/di_l10n
[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\Renderer;
9 use Friendica\DI;
10
11 function theme_content(App $a)
12 {
13         if (!local_user()) {
14                 return;
15         }
16
17         $colorset = DI::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 {
25         if (! local_user()) {
26                 return;
27         }
28
29         if (isset($_POST['duepuntozero-settings-submit'])) {
30                 DI::pConfig()->set(local_user(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
31         }
32 }
33
34 function theme_admin(App $a)
35 {
36         $colorset = Config::get('duepuntozero', 'colorset');
37         $user = false;
38
39         return clean_form($a, $colorset, $user);
40 }
41
42 function theme_admin_post(App $a)
43 {
44         if (isset($_POST['duepuntozero-settings-submit'])) {
45                 Config::set('duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
46         }
47 }
48
49 /// @TODO $a is no longer used
50 function clean_form(App $a, &$colorset, $user)
51 {
52         $colorset = [
53                 'default'     => DI::l10n()->t('default'),
54                 'greenzero'   => DI::l10n()->t('greenzero'),
55                 'purplezero'  => DI::l10n()->t('purplezero'),
56                 'easterbunny' => DI::l10n()->t('easterbunny'),
57                 'darkzero'    => DI::l10n()->t('darkzero'),
58                 'comix'       => DI::l10n()->t('comix'),
59                 'slackr'      => DI::l10n()->t('slackr'),
60         ];
61
62         if ($user) {
63                 $color = DI::pConfig()->get(local_user(), 'duepuntozero', 'colorset');
64         } else {
65                 $color = Config::get('duepuntozero', 'colorset');
66         }
67
68         $t = Renderer::getMarkupTemplate("theme_settings.tpl");
69         $o = Renderer::replaceMacros($t, [
70                 '$submit'   => DI::l10n()->t('Submit'),
71                 '$title'    => DI::l10n()->t("Theme settings"),
72                 '$colorset' => ['duepuntozero_colorset', DI::l10n()->t('Variations'), $color, '', $colorset],
73         ]);
74
75         return $o;
76 }