2012-03-30 13:45:23 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2023-01-01 14:36:24 +00:00
|
|
|
* @copyright Copyright (C) 2010-2023, the Friendica project
|
2022-10-19 05:06:28 +00:00
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
2012-03-30 13:45:23 +00:00
|
|
|
*/
|
|
|
|
|
2017-04-30 04:07:00 +00:00
|
|
|
use Friendica\App;
|
2018-10-31 14:35:50 +00:00
|
|
|
use Friendica\Core\Renderer;
|
2020-01-18 15:50:57 +00:00
|
|
|
use Friendica\DI;
|
2017-04-30 04:07:00 +00:00
|
|
|
|
2017-01-09 12:06:08 +00:00
|
|
|
function theme_content(App $a) {
|
2022-10-20 21:45:14 +00:00
|
|
|
if (!DI::userSession()->getLocalUserId()) {
|
2016-12-20 10:56:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-10-20 21:45:14 +00:00
|
|
|
$align = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'quattro', 'align' );
|
|
|
|
$color = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'quattro', 'color' );
|
|
|
|
$tfs = DI::pConfig()->get(DI::userSession()->getLocalUserId(),"quattro","tfs");
|
|
|
|
$pfs = DI::pConfig()->get(DI::userSession()->getLocalUserId(),"quattro","pfs");
|
2016-12-20 10:56:34 +00:00
|
|
|
|
2012-10-01 12:58:05 +00:00
|
|
|
return quattro_form($a,$align, $color, $tfs, $pfs);
|
2012-04-13 09:21:15 +00:00
|
|
|
}
|
|
|
|
|
2017-01-09 12:06:08 +00:00
|
|
|
function theme_post(App $a) {
|
2022-10-21 06:38:40 +00:00
|
|
|
if (!DI::userSession()->getLocalUserId()) {
|
2012-04-13 09:21:15 +00:00
|
|
|
return;
|
2016-12-20 10:56:34 +00:00
|
|
|
}
|
|
|
|
|
2012-04-13 09:21:15 +00:00
|
|
|
if (isset($_POST['quattro-settings-submit'])){
|
2022-10-20 21:45:14 +00:00
|
|
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'quattro', 'align', $_POST['quattro_align']);
|
|
|
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'quattro', 'color', $_POST['quattro_color']);
|
|
|
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'quattro', 'tfs', $_POST['quattro_tfs']);
|
|
|
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'quattro', 'pfs', $_POST['quattro_pfs']);
|
2012-04-13 09:21:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-09 12:06:08 +00:00
|
|
|
function theme_admin(App $a) {
|
2020-01-19 20:21:13 +00:00
|
|
|
$align = DI::config()->get('quattro', 'align' );
|
|
|
|
$color = DI::config()->get('quattro', 'color' );
|
|
|
|
$tfs = DI::config()->get("quattro","tfs");
|
|
|
|
$pfs = DI::config()->get("quattro","pfs");
|
2012-10-01 12:58:05 +00:00
|
|
|
|
|
|
|
return quattro_form($a,$align, $color, $tfs, $pfs);
|
2012-04-13 09:21:15 +00:00
|
|
|
}
|
|
|
|
|
2017-01-09 12:06:08 +00:00
|
|
|
function theme_admin_post(App $a) {
|
2012-04-13 09:21:15 +00:00
|
|
|
if (isset($_POST['quattro-settings-submit'])){
|
2020-01-19 20:21:53 +00:00
|
|
|
DI::config()->set('quattro', 'align', $_POST['quattro_align']);
|
|
|
|
DI::config()->set('quattro', 'color', $_POST['quattro_color']);
|
|
|
|
DI::config()->set('quattro', 'tfs', $_POST['quattro_tfs']);
|
|
|
|
DI::config()->set('quattro', 'pfs', $_POST['quattro_pfs']);
|
2012-04-13 09:21:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-19 13:26:13 +00:00
|
|
|
/// @TODO $a is no longer used here
|
2017-01-09 12:06:08 +00:00
|
|
|
function quattro_form(App $a, $align, $color, $tfs, $pfs) {
|
2018-01-15 13:05:12 +00:00
|
|
|
$colors = [
|
2016-12-22 10:37:23 +00:00
|
|
|
"dark" => "Quattro",
|
|
|
|
"lilac" => "Lilac",
|
|
|
|
"green" => "Green",
|
2018-01-15 13:05:12 +00:00
|
|
|
];
|
2016-12-22 10:37:23 +00:00
|
|
|
|
|
|
|
if ($tfs === false) {
|
|
|
|
$tfs = "20";
|
|
|
|
}
|
|
|
|
if ($pfs === false) {
|
|
|
|
$pfs = "12";
|
|
|
|
}
|
|
|
|
|
2018-10-31 14:44:06 +00:00
|
|
|
$t = Renderer::getMarkupTemplate("theme_settings.tpl" );
|
2018-10-31 14:35:50 +00:00
|
|
|
$o = Renderer::replaceMacros($t, [
|
2020-01-18 19:52:34 +00:00
|
|
|
'$submit' => DI::l10n()->t('Submit'),
|
|
|
|
'$title' => DI::l10n()->t("Theme settings"),
|
|
|
|
'$align' => ['quattro_align', DI::l10n()->t('Alignment'), $align, '', ['left' => DI::l10n()->t('Left'), 'center' => DI::l10n()->t('Center')]],
|
|
|
|
'$color' => ['quattro_color', DI::l10n()->t('Color scheme'), $color, '', $colors],
|
|
|
|
'$pfs' => ['quattro_pfs', DI::l10n()->t('Posts font size'), $pfs],
|
|
|
|
'$tfs' => ['quattro_tfs', DI::l10n()->t('Textareas font size'), $tfs],
|
2018-01-15 13:05:12 +00:00
|
|
|
]);
|
2012-03-30 13:45:23 +00:00
|
|
|
return $o;
|
|
|
|
}
|