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