2014-09-07 12:48:23 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2023-01-01 15:36:24 +01:00
|
|
|
* @copyright Copyright (C) 2010-2023, the Friendica project
|
2022-10-19 07:06:28 +02: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/>.
|
|
|
|
*
|
2014-09-07 12:48:23 +02:00
|
|
|
*/
|
|
|
|
|
2017-04-30 06:07:00 +02:00
|
|
|
use Friendica\App;
|
2018-10-31 15:35:50 +01:00
|
|
|
use Friendica\Core\Renderer;
|
2020-01-18 16:50:57 +01:00
|
|
|
use Friendica\DI;
|
2017-04-30 06:07:00 +02:00
|
|
|
|
2018-01-22 13:29:50 +01:00
|
|
|
function theme_content(App $a)
|
|
|
|
{
|
2022-10-20 23:45:14 +02:00
|
|
|
if (!DI::userSession()->getLocalUserId()) {
|
2016-12-20 11:56:34 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-09-07 12:48:23 +02:00
|
|
|
|
2022-10-20 23:45:14 +02:00
|
|
|
$colorset = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'duepuntozero', 'colorset');
|
2016-12-20 11:56:34 +01:00
|
|
|
$user = true;
|
2014-09-07 12:48:23 +02:00
|
|
|
|
2016-12-20 11:56:34 +01:00
|
|
|
return clean_form($a, $colorset, $user);
|
2014-09-07 12:48:23 +02:00
|
|
|
}
|
|
|
|
|
2018-01-22 13:29:50 +01:00
|
|
|
function theme_post(App $a)
|
|
|
|
{
|
2022-10-20 23:45:14 +02:00
|
|
|
if (!DI::userSession()->getLocalUserId()) {
|
2016-12-20 11:56:34 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-01-22 13:29:50 +01:00
|
|
|
if (isset($_POST['duepuntozero-settings-submit'])) {
|
2022-10-20 23:45:14 +02:00
|
|
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
|
2016-12-20 11:56:34 +01:00
|
|
|
}
|
2014-09-07 12:48:23 +02:00
|
|
|
}
|
|
|
|
|
2018-01-22 13:29:50 +01:00
|
|
|
function theme_admin(App $a)
|
|
|
|
{
|
2020-01-19 21:21:13 +01:00
|
|
|
$colorset = DI::config()->get('duepuntozero', 'colorset');
|
2016-12-20 11:56:34 +01:00
|
|
|
$user = false;
|
2014-09-07 12:48:23 +02:00
|
|
|
|
2016-12-20 11:56:34 +01:00
|
|
|
return clean_form($a, $colorset, $user);
|
2014-09-07 12:48:23 +02:00
|
|
|
}
|
|
|
|
|
2018-01-22 13:29:50 +01:00
|
|
|
function theme_admin_post(App $a)
|
|
|
|
{
|
|
|
|
if (isset($_POST['duepuntozero-settings-submit'])) {
|
2020-01-19 21:21:53 +01:00
|
|
|
DI::config()->set('duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
|
2016-12-20 11:56:34 +01:00
|
|
|
}
|
2014-09-07 12:48:23 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 14:26:13 +01:00
|
|
|
/// @TODO $a is no longer used
|
2018-01-22 13:29:50 +01:00
|
|
|
function clean_form(App $a, &$colorset, $user)
|
|
|
|
{
|
2018-01-15 14:05:12 +01:00
|
|
|
$colorset = [
|
2020-01-18 20:52:34 +01:00
|
|
|
'default' => DI::l10n()->t('default'),
|
|
|
|
'greenzero' => DI::l10n()->t('greenzero'),
|
|
|
|
'purplezero' => DI::l10n()->t('purplezero'),
|
|
|
|
'easterbunny' => DI::l10n()->t('easterbunny'),
|
|
|
|
'darkzero' => DI::l10n()->t('darkzero'),
|
|
|
|
'comix' => DI::l10n()->t('comix'),
|
|
|
|
'slackr' => DI::l10n()->t('slackr'),
|
2018-01-15 14:05:12 +01:00
|
|
|
];
|
2016-12-20 11:56:34 +01:00
|
|
|
|
|
|
|
if ($user) {
|
2022-10-20 23:45:14 +02:00
|
|
|
$color = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'duepuntozero', 'colorset');
|
2016-12-20 11:56:34 +01:00
|
|
|
} else {
|
2020-01-19 21:21:13 +01:00
|
|
|
$color = DI::config()->get('duepuntozero', 'colorset');
|
2016-12-20 11:56:34 +01:00
|
|
|
}
|
|
|
|
|
2018-10-31 15:44:06 +01:00
|
|
|
$t = Renderer::getMarkupTemplate("theme_settings.tpl");
|
2018-10-31 15:35:50 +01:00
|
|
|
$o = Renderer::replaceMacros($t, [
|
2020-01-18 20:52:34 +01:00
|
|
|
'$submit' => DI::l10n()->t('Submit'),
|
|
|
|
'$title' => DI::l10n()->t("Theme settings"),
|
|
|
|
'$colorset' => ['duepuntozero_colorset', DI::l10n()->t('Variations'), $color, '', $colorset],
|
2018-01-15 14:05:12 +01:00
|
|
|
]);
|
2016-12-20 11:56:34 +01:00
|
|
|
|
|
|
|
return $o;
|
2014-09-07 12:48:23 +02:00
|
|
|
}
|