]> git.mxchange.org Git - friendica.git/blob - view/theme/vier/config.php
Update remote_friends_common.tpl
[friendica.git] / view / theme / vier / config.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2023, 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\DI;
25
26 require_once __DIR__ . '/theme.php';
27
28 function theme_content(App $a)
29 {
30         if (!DI::userSession()->getLocalUserId()) {
31                 return;
32         }
33
34         if (!function_exists('get_vier_config')) {
35                 return;
36         }
37
38         $style = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'vier', 'style');
39
40         if ($style == "") {
41                 $style = DI::config()->get('vier', 'style');
42         }
43
44         if ($style == "") {
45                 $style = "plus";
46         }
47
48         $show_pages = get_vier_config('show_pages', true);
49         $show_profiles = get_vier_config('show_profiles', true);
50         $show_helpers = get_vier_config('show_helpers', true);
51         $show_services = get_vier_config('show_services', true);
52         $show_friends = get_vier_config('show_friends', true);
53         $show_lastusers = get_vier_config('show_lastusers', true);
54
55         return vier_form($a,$style, $show_pages, $show_profiles, $show_helpers,
56                         $show_services, $show_friends, $show_lastusers);
57 }
58
59 function theme_post(App $a)
60 {
61         if (!DI::userSession()->getLocalUserId()) {
62                 return;
63         }
64
65         if (isset($_POST['vier-settings-submit'])) {
66                 DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'vier', 'style', $_POST['vier_style']);
67                 DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'vier', 'show_pages', $_POST['vier_show_pages']);
68                 DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'vier', 'show_profiles', $_POST['vier_show_profiles']);
69                 DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'vier', 'show_helpers', $_POST['vier_show_helpers']);
70                 DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'vier', 'show_services', $_POST['vier_show_services']);
71                 DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'vier', 'show_friends', $_POST['vier_show_friends']);
72                 DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'vier', 'show_lastusers', $_POST['vier_show_lastusers']);
73         }
74 }
75
76
77 function theme_admin(App $a) {
78
79         if (!function_exists('get_vier_config'))
80                 return;
81
82         $style = DI::config()->get('vier', 'style');
83
84         $helperlist = DI::config()->get('vier', 'helperlist');
85
86         if ($helperlist == "")
87                 $helperlist = "https://forum.friendi.ca/profile/helpers";
88
89         $t = Renderer::getMarkupTemplate("theme_admin_settings.tpl");
90         $o = Renderer::replaceMacros($t, [
91                 '$helperlist' => ['vier_helperlist', DI::l10n()->t('Comma separated list of helper groups'), $helperlist, '', ''],
92                 ]);
93
94         $show_pages = get_vier_config('show_pages', true, true);
95         $show_profiles = get_vier_config('show_profiles', true, true);
96         $show_helpers = get_vier_config('show_helpers', true, true);
97         $show_services = get_vier_config('show_services', true, true);
98         $show_friends = get_vier_config('show_friends', true, true);
99         $show_lastusers = get_vier_config('show_lastusers', true, true);
100         $o .= vier_form($a,$style, $show_pages, $show_profiles, $show_helpers, $show_services,
101                         $show_friends, $show_lastusers);
102
103         return $o;
104 }
105
106 function theme_admin_post(App $a) {
107         if (isset($_POST['vier-settings-submit'])){
108                 DI::config()->set('vier', 'style', $_POST['vier_style']);
109                 DI::config()->set('vier', 'show_pages', $_POST['vier_show_pages']);
110                 DI::config()->set('vier', 'show_profiles', $_POST['vier_show_profiles']);
111                 DI::config()->set('vier', 'show_helpers', $_POST['vier_show_helpers']);
112                 DI::config()->set('vier', 'show_services', $_POST['vier_show_services']);
113                 DI::config()->set('vier', 'show_friends', $_POST['vier_show_friends']);
114                 DI::config()->set('vier', 'show_lastusers', $_POST['vier_show_lastusers']);
115                 DI::config()->set('vier', 'helperlist', $_POST['vier_helperlist']);
116         }
117 }
118
119 /// @TODO $a is no longer used
120 function vier_form(App $a, $style, $show_pages, $show_profiles, $show_helpers, $show_services, $show_friends, $show_lastusers) {
121         $styles = [
122                 "breathe"=>"Breathe",
123                 "netcolour"=>"Coloured Networks",
124                 "dark"=>"Dark",
125                 "flat"=>"Flat",
126                 "plus"=>"Plus",
127                 "plusminus"=>"Plus Minus",
128                 "shadow"=>"Shadow"
129         ];
130
131         $show_or_not = ['0' => DI::l10n()->t("don't show"), '1' => DI::l10n()->t("show"),];
132
133         $t = Renderer::getMarkupTemplate("theme_settings.tpl");
134         $o = Renderer::replaceMacros($t, [
135                 '$submit' => DI::l10n()->t('Submit'),
136                 '$title' => DI::l10n()->t("Theme settings"),
137                 '$style' => ['vier_style', DI::l10n()->t('Set style'), $style, '', $styles],
138                 '$show_pages' => ['vier_show_pages', DI::l10n()->t('Community Pages'), $show_pages, '', $show_or_not],
139                 '$show_profiles' => ['vier_show_profiles', DI::l10n()->t('Community Profiles'), $show_profiles, '', $show_or_not],
140                 '$show_helpers' => ['vier_show_helpers', DI::l10n()->t('Help or @NewHere ?'), $show_helpers, '', $show_or_not],
141                 '$show_services' => ['vier_show_services', DI::l10n()->t('Connect Services'), $show_services, '', $show_or_not],
142                 '$show_friends' => ['vier_show_friends', DI::l10n()->t('Find Friends'), $show_friends, '', $show_or_not],
143                 '$show_lastusers' => ['vier_show_lastusers', DI::l10n()->t('Last users'), $show_lastusers, '', $show_or_not]
144         ]);
145         return $o;
146 }