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