]> git.mxchange.org Git - friendica.git/blob - view/theme/vier/config.php
old boot.php functions replaced in various places
[friendica.git] / view / theme / vier / config.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2022, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 use Friendica\App;
23 use Friendica\Core\Renderer;
24 use Friendica\Core\Session;
25 use Friendica\DI;
26
27 require_once __DIR__ . '/theme.php';
28
29 function theme_content(App $a)
30 {
31         if (!Session::getLocalUser()) {
32                 return;
33         }
34
35         if (!function_exists('get_vier_config')) {
36                 return;
37         }
38
39         $style = DI::pConfig()->get(Session::getLocalUser(), 'vier', 'style');
40
41         if ($style == "") {
42                 $style = DI::config()->get('vier', 'style');
43         }
44
45         if ($style == "") {
46                 $style = "plus";
47         }
48
49         $show_pages = get_vier_config('show_pages', true);
50         $show_profiles = get_vier_config('show_profiles', true);
51         $show_helpers = get_vier_config('show_helpers', true);
52         $show_services = get_vier_config('show_services', true);
53         $show_friends = get_vier_config('show_friends', true);
54         $show_lastusers = get_vier_config('show_lastusers', true);
55
56         return vier_form($a,$style, $show_pages, $show_profiles, $show_helpers,
57                         $show_services, $show_friends, $show_lastusers);
58 }
59
60 function theme_post(App $a)
61 {
62         if (! Session::getLocalUser()) {
63                 return;
64         }
65
66         if (isset($_POST['vier-settings-submit'])) {
67                 DI::pConfig()->set(Session::getLocalUser(), 'vier', 'style', $_POST['vier_style']);
68                 DI::pConfig()->set(Session::getLocalUser(), 'vier', 'show_pages', $_POST['vier_show_pages']);
69                 DI::pConfig()->set(Session::getLocalUser(), 'vier', 'show_profiles', $_POST['vier_show_profiles']);
70                 DI::pConfig()->set(Session::getLocalUser(), 'vier', 'show_helpers', $_POST['vier_show_helpers']);
71                 DI::pConfig()->set(Session::getLocalUser(), 'vier', 'show_services', $_POST['vier_show_services']);
72                 DI::pConfig()->set(Session::getLocalUser(), 'vier', 'show_friends', $_POST['vier_show_friends']);
73                 DI::pConfig()->set(Session::getLocalUser(), 'vier', 'show_lastusers', $_POST['vier_show_lastusers']);
74         }
75 }
76
77
78 function theme_admin(App $a) {
79
80         if (!function_exists('get_vier_config'))
81                 return;
82
83         $style = DI::config()->get('vier', 'style');
84
85         $helperlist = DI::config()->get('vier', 'helperlist');
86
87         if ($helperlist == "")
88                 $helperlist = "https://forum.friendi.ca/profile/helpers";
89
90         $t = Renderer::getMarkupTemplate("theme_admin_settings.tpl");
91         $o = Renderer::replaceMacros($t, [
92                 '$helperlist' => ['vier_helperlist', DI::l10n()->t('Comma separated list of helper forums'), $helperlist, '', ''],
93                 ]);
94
95         $show_pages = get_vier_config('show_pages', true, true);
96         $show_profiles = get_vier_config('show_profiles', true, true);
97         $show_helpers = get_vier_config('show_helpers', true, true);
98         $show_services = get_vier_config('show_services', true, true);
99         $show_friends = get_vier_config('show_friends', true, true);
100         $show_lastusers = get_vier_config('show_lastusers', true, true);
101         $o .= vier_form($a,$style, $show_pages, $show_profiles, $show_helpers, $show_services,
102                         $show_friends, $show_lastusers);
103
104         return $o;
105 }
106
107 function theme_admin_post(App $a) {
108         if (isset($_POST['vier-settings-submit'])){
109                 DI::config()->set('vier', 'style', $_POST['vier_style']);
110                 DI::config()->set('vier', 'show_pages', $_POST['vier_show_pages']);
111                 DI::config()->set('vier', 'show_profiles', $_POST['vier_show_profiles']);
112                 DI::config()->set('vier', 'show_helpers', $_POST['vier_show_helpers']);
113                 DI::config()->set('vier', 'show_services', $_POST['vier_show_services']);
114                 DI::config()->set('vier', 'show_friends', $_POST['vier_show_friends']);
115                 DI::config()->set('vier', 'show_lastusers', $_POST['vier_show_lastusers']);
116                 DI::config()->set('vier', 'helperlist', $_POST['vier_helperlist']);
117         }
118 }
119
120 /// @TODO $a is no longer used
121 function vier_form(App $a, $style, $show_pages, $show_profiles, $show_helpers, $show_services, $show_friends, $show_lastusers) {
122         $styles = [
123                 "breathe"=>"Breathe",
124                 "netcolour"=>"Coloured Networks",
125                 "dark"=>"Dark",
126                 "flat"=>"Flat",
127                 "plus"=>"Plus",
128                 "plusminus"=>"Plus Minus",
129                 "shadow"=>"Shadow"
130         ];
131
132         $show_or_not = ['0' => DI::l10n()->t("don't show"), '1' => DI::l10n()->t("show"),];
133
134         $t = Renderer::getMarkupTemplate("theme_settings.tpl");
135         $o = Renderer::replaceMacros($t, [
136                 '$submit' => DI::l10n()->t('Submit'),
137                 '$title' => DI::l10n()->t("Theme settings"),
138                 '$style' => ['vier_style', DI::l10n()->t('Set style'), $style, '', $styles],
139                 '$show_pages' => ['vier_show_pages', DI::l10n()->t('Community Pages'), $show_pages, '', $show_or_not],
140                 '$show_profiles' => ['vier_show_profiles', DI::l10n()->t('Community Profiles'), $show_profiles, '', $show_or_not],
141                 '$show_helpers' => ['vier_show_helpers', DI::l10n()->t('Help or @NewHere ?'), $show_helpers, '', $show_or_not],
142                 '$show_services' => ['vier_show_services', DI::l10n()->t('Connect Services'), $show_services, '', $show_or_not],
143                 '$show_friends' => ['vier_show_friends', DI::l10n()->t('Find Friends'), $show_friends, '', $show_or_not],
144                 '$show_lastusers' => ['vier_show_lastusers', DI::l10n()->t('Last users'), $show_lastusers, '', $show_or_not]
145         ]);
146         return $o;
147 }