]> git.mxchange.org Git - friendica.git/blob - view/theme/frio/config.php
declare $bang variable in editpost_content()
[friendica.git] / view / theme / frio / config.php
1 <?php
2
3 use Friendica\App;
4 use Friendica\Core\Config;
5 use Friendica\Core\L10n;
6 use Friendica\Core\PConfig;
7 use Friendica\Core\System;
8
9 require_once 'view/theme/frio/php/Image.php';
10
11 function theme_post(App $a) {
12         if (!local_user()) {
13                 return;
14         }
15
16         if (isset($_POST['frio-settings-submit'])) {
17                 PConfig::set(local_user(), 'frio', 'schema',           $_POST["frio_schema"]);
18                 PConfig::set(local_user(), 'frio', 'nav_bg',           $_POST["frio_nav_bg"]);
19                 PConfig::set(local_user(), 'frio', 'nav_icon_color',   $_POST["frio_nav_icon_color"]);
20                 PConfig::set(local_user(), 'frio', 'link_color',       $_POST["frio_link_color"]);
21                 PConfig::set(local_user(), 'frio', 'background_color', $_POST["frio_background_color"]);
22                 PConfig::set(local_user(), 'frio', 'contentbg_transp', $_POST["frio_contentbg_transp"]);
23                 PConfig::set(local_user(), 'frio', 'background_image', $_POST["frio_background_image"]);
24                 PConfig::set(local_user(), 'frio', 'bg_image_option',  $_POST["frio_bg_image_option"]);
25                 PConfig::set(local_user(), 'frio', 'css_modified',     time());
26         }
27 }
28
29 function theme_admin_post(App $a) {
30         if (!local_user()) {
31                 return;
32         }
33
34         if (isset($_POST['frio-settings-submit'])) {
35                 Config::set('frio', 'schema',           $_POST["frio_schema"]);
36                 Config::set('frio', 'nav_bg',           $_POST["frio_nav_bg"]);
37                 Config::set('frio', 'nav_icon_color',   $_POST["frio_nav_icon_color"]);
38                 Config::set('frio', 'link_color',       $_POST["frio_link_color"]);
39                 Config::set('frio', 'background_color', $_POST["frio_background_color"]);
40                 Config::set('frio', 'contentbg_transp', $_POST["frio_contentbg_transp"]);
41                 Config::set('frio', 'background_image', $_POST["frio_background_image"]);
42                 Config::set('frio', 'bg_image_option',  $_POST["frio_bg_image_option"]);
43                 Config::set('frio', 'login_bg_image',   $_POST["frio_login_bg_image"]);
44                 Config::set('frio', 'login_bg_color',   $_POST["frio_login_bg_color"]);
45                 Config::set('frio', 'css_modified',     time());
46         }
47 }
48
49 function theme_content(App $a) {
50         if (!local_user()) {
51                 return;
52         }
53         $arr = [];
54
55         $arr["schema"]           = PConfig::get(local_user(), 'frio', 'schema');
56         $arr["nav_bg"]           = PConfig::get(local_user(), 'frio', 'nav_bg');
57         $arr["nav_icon_color"]   = PConfig::get(local_user(), 'frio', 'nav_icon_color');
58         $arr["link_color"]       = PConfig::get(local_user(), 'frio', 'link_color');
59         $arr["bgcolor"]          = PConfig::get(local_user(), 'frio', 'background_color');
60         $arr["contentbg_transp"] = PConfig::get(local_user(), 'frio', 'contentbg_transp');
61         $arr["background_image"] = PConfig::get(local_user(), 'frio', 'background_image');
62         $arr["bg_image_option"]  = PConfig::get(local_user(), 'frio', 'bg_image_option');
63
64         return frio_form($arr);
65 }
66
67 function theme_admin(App $a) {
68         if (!local_user()) {
69                 return;
70         }
71         $arr = [];
72
73         $arr["schema"]           = Config::get('frio', 'schema');
74         $arr["nav_bg"]           = Config::get('frio', 'nav_bg');
75         $arr["nav_icon_color"]   = Config::get('frio', 'nav_icon_color');
76         $arr["link_color"]       = Config::get('frio', 'link_color');
77         $arr["bgcolor"]          = Config::get('frio', 'background_color');
78         $arr["contentbg_transp"] = Config::get('frio', 'contentbg_transp');
79         $arr["background_image"] = Config::get('frio', 'background_image');
80         $arr["bg_image_option"]  = Config::get('frio', 'bg_image_option');
81         $arr["login_bg_image"]   = Config::get('frio', 'login_bg_image');
82         $arr["login_bg_color"]   = Config::get('frio', 'login_bg_color');
83
84         return frio_form($arr);
85 }
86
87 function frio_form($arr) {
88         require_once("view/theme/frio/php/schema.php");
89
90         $scheme_info = get_schema_info($arr["schema"]);
91         $disable = $scheme_info["overwrites"];
92         if (!is_array($disable)) {
93                 $disable = [];
94         }
95
96         $scheme_choices = [];
97         $scheme_choices["---"] = L10n::t("Default");
98         $files = glob('view/theme/frio/schema/*.php');
99         if ($files) {
100                 foreach ($files as $file) {
101                         $f = basename($file, ".php");
102                         if ($f != 'default') {
103                                 $scheme_name = $f;
104                                 $scheme_choices[$f] = $scheme_name;
105                         }
106                 }
107         }
108
109         $background_image_help = "<strong>" . L10n::t("Note"). ": </strong>".L10n::t("Check image permissions if all users are allowed to visit the image");
110
111         $t = get_markup_template('theme_settings.tpl');
112         $ctx = [
113                 '$submit'           => L10n::t('Submit'),
114                 '$baseurl'          => System::baseUrl(),
115                 '$title'            => L10n::t("Theme settings"),
116                 '$schema'           => ['frio_schema', L10n::t("Select scheme"), $arr["schema"], '', $scheme_choices],
117                 '$nav_bg'           => array_key_exists("nav_bg", $disable) ? "" : ['frio_nav_bg', L10n::t('Navigation bar background color'), $arr['nav_bg']],
118                 '$nav_icon_color'   => array_key_exists("nav_icon_color", $disable) ? "" : ['frio_nav_icon_color', L10n::t('Navigation bar icon color '), $arr['nav_icon_color']],
119                 '$link_color'       => array_key_exists("link_color", $disable) ? "" : ['frio_link_color', L10n::t('Link color'), $arr['link_color'], '', $link_colors],
120                 '$bgcolor'          => array_key_exists("bgcolor", $disable) ? "" : ['frio_background_color', L10n::t('Set the background color'), $arr['bgcolor']],
121                 '$contentbg_transp' => array_key_exists("contentbg_transp", $disable) ? "" : ['frio_contentbg_transp', L10n::t("Content background opacity"), ((isset($arr["contentbg_transp"]) && $arr["contentbg_transp"] != "") ? $arr["contentbg_transp"] : 100)],
122                 '$background_image' => array_key_exists("background_image", $disable) ? "" : ['frio_background_image', L10n::t('Set the background image'), $arr['background_image'], $background_image_help],
123                 '$bg_image_options' => Image::get_options($arr),
124         ];
125
126         if (array_key_exists("login_bg_image", $arr) &&  !array_key_exists("login_bg_image", $disable)) {
127                 $ctx['$login_bg_image']  = ['frio_login_bg_image', L10n::t('Login page background image'), $arr['login_bg_image'], $background_image_help];
128         }
129         if (array_key_exists("login_bg_color", $arr) &&  !array_key_exists("login_bg_color", $disable)) {
130                 $ctx['$login_bg_color']  = ['frio_login_bg_color', L10n::t('Login page background color'), $arr['login_bg_color'], L10n::t('Leave background image and color empty for theme defaults')];
131         }
132
133
134         $o .= replace_macros($t, $ctx);
135
136         return $o;
137 }