4 use Friendica\Core\Config;
5 use Friendica\Core\L10n;
6 use Friendica\Core\PConfig;
7 use Friendica\Core\Renderer;
8 use Friendica\Core\System;
10 require_once 'view/theme/frio/php/Image.php';
12 function theme_post(App $a)
18 if (isset($_POST['frio-settings-submit'])) {
19 PConfig::set(local_user(), 'frio', 'scheme', defaults($_POST, 'frio_scheme', ''));
20 PConfig::set(local_user(), 'frio', 'nav_bg', defaults($_POST, 'frio_nav_bg', ''));
21 PConfig::set(local_user(), 'frio', 'nav_icon_color', defaults($_POST, 'frio_nav_icon_color', ''));
22 PConfig::set(local_user(), 'frio', 'link_color', defaults($_POST, 'frio_link_color', ''));
23 PConfig::set(local_user(), 'frio', 'background_color', defaults($_POST, 'frio_background_color', ''));
24 PConfig::set(local_user(), 'frio', 'contentbg_transp', defaults($_POST, 'frio_contentbg_transp', ''));
25 PConfig::set(local_user(), 'frio', 'background_image', defaults($_POST, 'frio_background_image', ''));
26 PConfig::set(local_user(), 'frio', 'bg_image_option', defaults($_POST, 'frio_bg_image_option', ''));
27 PConfig::set(local_user(), 'frio', 'css_modified', time());
31 function theme_admin_post(App $a)
33 if (!is_site_admin()) {
37 if (isset($_POST['frio-settings-submit'])) {
38 Config::set('frio', 'scheme', defaults($_POST, 'frio_scheme', ''));
39 Config::set('frio', 'nav_bg', defaults($_POST, 'frio_nav_bg', ''));
40 Config::set('frio', 'nav_icon_color', defaults($_POST, 'frio_nav_icon_color', ''));
41 Config::set('frio', 'link_color', defaults($_POST, 'frio_link_color', ''));
42 Config::set('frio', 'background_color', defaults($_POST, 'frio_background_color', ''));
43 Config::set('frio', 'contentbg_transp', defaults($_POST, 'frio_contentbg_transp', ''));
44 Config::set('frio', 'background_image', defaults($_POST, 'frio_background_image', ''));
45 Config::set('frio', 'bg_image_option', defaults($_POST, 'frio_bg_image_option', ''));
46 Config::set('frio', 'login_bg_image', defaults($_POST, 'frio_login_bg_image', ''));
47 Config::set('frio', 'login_bg_color', defaults($_POST, 'frio_login_bg_color', ''));
48 Config::set('frio', 'css_modified', time());
52 function theme_content(App $a)
59 $arr['scheme'] = PConfig::get(local_user(), 'frio', 'scheme', PConfig::get(local_user(), 'frio', 'schema'));
60 $arr['share_string'] = '';
61 $arr['nav_bg'] = PConfig::get(local_user(), 'frio', 'nav_bg');
62 $arr['nav_icon_color'] = PConfig::get(local_user(), 'frio', 'nav_icon_color');
63 $arr['link_color'] = PConfig::get(local_user(), 'frio', 'link_color');
64 $arr['background_color'] = PConfig::get(local_user(), 'frio', 'background_color');
65 $arr['contentbg_transp'] = PConfig::get(local_user(), 'frio', 'contentbg_transp');
66 $arr['background_image'] = PConfig::get(local_user(), 'frio', 'background_image');
67 $arr['bg_image_option'] = PConfig::get(local_user(), 'frio', 'bg_image_option');
69 return frio_form($arr);
72 function theme_admin(App $a)
79 $arr['scheme'] = Config::get('frio', 'scheme', Config::get('frio', 'scheme'));
80 $arr['share_string'] = '';
81 $arr['nav_bg'] = Config::get('frio', 'nav_bg');
82 $arr['nav_icon_color'] = Config::get('frio', 'nav_icon_color');
83 $arr['link_color'] = Config::get('frio', 'link_color');
84 $arr['background_color'] = Config::get('frio', 'background_color');
85 $arr['contentbg_transp'] = Config::get('frio', 'contentbg_transp');
86 $arr['background_image'] = Config::get('frio', 'background_image');
87 $arr['bg_image_option'] = Config::get('frio', 'bg_image_option');
88 $arr['login_bg_image'] = Config::get('frio', 'login_bg_image');
89 $arr['login_bg_color'] = Config::get('frio', 'login_bg_color');
91 return frio_form($arr);
94 function frio_form($arr)
96 require_once 'view/theme/frio/php/scheme.php';
98 $scheme_info = get_scheme_info($arr['scheme']);
99 $disable = $scheme_info['overwrites'];
100 if (!is_array($disable)) {
104 $scheme_choices = [];
105 $scheme_choices['---'] = L10n::t('Custom');
106 $files = glob('view/theme/frio/scheme/*.php');
108 foreach ($files as $file) {
109 $f = basename($file, '.php');
110 if ($f != 'default') {
111 $scheme_name = ucfirst($f);
112 $scheme_choices[$f] = $scheme_name;
117 $background_image_help = '<strong>' . L10n::t('Note') . ': </strong>' . L10n::t('Check image permissions if all users are allowed to see the image');
119 $t = Renderer::getMarkupTemplate('theme_settings.tpl');
121 '$submit' => L10n::t('Submit'),
122 '$title' => L10n::t('Theme settings'),
123 '$scheme' => ['frio_scheme', L10n::t('Select color scheme'), $arr['scheme'], '', $scheme_choices],
124 '$share_string' => ['frio_share_string', L10n::t('Copy or paste schemestring'), $arr['share_string'], L10n::t('You can copy this string to share your theme with others. Pasting here applies the schemestring'), false, false],
125 '$nav_bg' => array_key_exists('nav_bg', $disable) ? '' : ['frio_nav_bg', L10n::t('Navigation bar background color'), $arr['nav_bg'], '', false],
126 '$nav_icon_color' => array_key_exists('nav_icon_color', $disable) ? '' : ['frio_nav_icon_color', L10n::t('Navigation bar icon color '), $arr['nav_icon_color'], '', false],
127 '$link_color' => array_key_exists('link_color', $disable) ? '' : ['frio_link_color', L10n::t('Link color'), $arr['link_color'], '', false],
128 '$background_color' => array_key_exists('background_color', $disable) ? '' : ['frio_background_color', L10n::t('Set the background color'), $arr['background_color'], '', false],
129 '$contentbg_transp' => array_key_exists('contentbg_transp', $disable) ? '' : ['frio_contentbg_transp', L10n::t('Content background opacity'), defaults($arr, 'contentbg_transp', 100), ''],
130 '$background_image' => array_key_exists('background_image', $disable) ? '' : ['frio_background_image', L10n::t('Set the background image'), $arr['background_image'], $background_image_help, false],
131 '$bg_image_options_title' => L10n::t('Background image style'),
132 '$bg_image_options' => Image::get_options($arr),
135 if (array_key_exists('login_bg_image', $arr) && !array_key_exists('login_bg_image', $disable)) {
136 $ctx['$login_bg_image'] = ['frio_login_bg_image', L10n::t('Login page background image'), $arr['login_bg_image'], $background_image_help, false];
139 if (array_key_exists('login_bg_color', $arr) && !array_key_exists('login_bg_color', $disable)) {
140 $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'), false];
143 $o = Renderer::replaceMacros($t, $ctx);