]> git.mxchange.org Git - friendica.git/blob - view/theme/quattro/config.php
Merge pull request #13794 from annando/simplified-group-display
[friendica.git] / view / theme / quattro / 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 function theme_content(App $a) {
27         if (!DI::userSession()->getLocalUserId()) {
28                 return;
29         }
30
31         $align = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'quattro', 'align' );
32         $color = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'quattro', 'color' );
33         $tfs = DI::pConfig()->get(DI::userSession()->getLocalUserId(),"quattro","tfs");
34         $pfs = DI::pConfig()->get(DI::userSession()->getLocalUserId(),"quattro","pfs");
35
36         return quattro_form($a,$align, $color, $tfs, $pfs);
37 }
38
39 function theme_post(App $a) {
40         if (!DI::userSession()->getLocalUserId()) {
41                 return;
42         }
43
44         if (isset($_POST['quattro-settings-submit'])){
45                 DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'quattro', 'align', $_POST['quattro_align']);
46                 DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'quattro', 'color', $_POST['quattro_color']);
47                 DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'quattro', 'tfs', $_POST['quattro_tfs']);
48                 DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'quattro', 'pfs', $_POST['quattro_pfs']);
49         }
50 }
51
52 function theme_admin(App $a) {
53         $align = DI::config()->get('quattro', 'align' );
54         $color = DI::config()->get('quattro', 'color' );
55         $tfs = DI::config()->get("quattro","tfs");
56         $pfs = DI::config()->get("quattro","pfs");
57
58         return quattro_form($a,$align, $color, $tfs, $pfs);
59 }
60
61 function theme_admin_post(App $a) {
62         if (isset($_POST['quattro-settings-submit'])){
63                 DI::config()->set('quattro', 'align', $_POST['quattro_align']);
64                 DI::config()->set('quattro', 'color', $_POST['quattro_color']);
65                 DI::config()->set('quattro', 'tfs', $_POST['quattro_tfs']);
66                 DI::config()->set('quattro', 'pfs', $_POST['quattro_pfs']);
67         }
68 }
69
70 /// @TODO $a is no longer used here
71 function quattro_form(App $a, $align, $color, $tfs, $pfs) {
72         $colors = [
73                 "dark"  => "Quattro",
74                 "lilac" => "Lilac",
75                 "green" => "Green",
76         ];
77
78         if ($tfs === false) {
79                 $tfs = "20";
80         }
81         if ($pfs === false) {
82                 $pfs = "12";
83         }
84
85         $t = Renderer::getMarkupTemplate("theme_settings.tpl" );
86         $o = Renderer::replaceMacros($t, [
87                 '$submit'  => DI::l10n()->t('Submit'),
88                 '$title'   => DI::l10n()->t("Theme settings"),
89                 '$align'   => ['quattro_align', DI::l10n()->t('Alignment'), $align, '', ['left' => DI::l10n()->t('Left'), 'center' => DI::l10n()->t('Center')]],
90                 '$color'   => ['quattro_color', DI::l10n()->t('Color scheme'), $color, '', $colors],
91                 '$pfs'     => ['quattro_pfs', DI::l10n()->t('Posts font size'), $pfs],
92                 '$tfs'     => ['quattro_tfs', DI::l10n()->t('Textareas font size'), $tfs],
93         ]);
94         return $o;
95 }