friendica_2021-01/view/theme/duepuntozero/config.php

80 lines
1.7 KiB
PHP
Raw Normal View History

<?php
/**
* Theme settings
*/
use Friendica\App;
use Friendica\Core\Config;
2018-01-22 13:29:50 +01:00
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
2017-08-26 08:04:21 +02:00
use Friendica\Core\System;
2018-01-22 13:29:50 +01:00
function theme_content(App $a)
{
if (!local_user()) {
return;
}
2018-01-22 13:29:50 +01:00
$colorset = PConfig::get(local_user(), 'duepuntozero', 'colorset');
$user = true;
return clean_form($a, $colorset, $user);
}
2018-01-22 13:29:50 +01:00
function theme_post(App $a)
{
if (! local_user()) {
return;
}
2018-01-22 13:29:50 +01:00
if (isset($_POST['duepuntozero-settings-submit'])) {
PConfig::set(local_user(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
}
}
2018-01-22 13:29:50 +01:00
function theme_admin(App $a)
{
$colorset = Config::get('duepuntozero', 'colorset');
$user = false;
return clean_form($a, $colorset, $user);
}
2018-01-22 13:29:50 +01:00
function theme_admin_post(App $a)
{
if (isset($_POST['duepuntozero-settings-submit'])) {
Config::set('duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
}
}
/// @TODO $a is no longer used
2018-01-22 13:29:50 +01:00
function clean_form(App $a, &$colorset, $user)
{
$colorset = [
2018-01-22 13:29:50 +01:00
'default' => L10n::t('default'),
'greenzero' => L10n::t('greenzero'),
'purplezero' => L10n::t('purplezero'),
'easterbunny' => L10n::t('easterbunny'),
'darkzero' => L10n::t('darkzero'),
'comix' => L10n::t('comix'),
'slackr' => L10n::t('slackr'),
];
if ($user) {
$color = PConfig::get(local_user(), 'duepuntozero', 'colorset');
} else {
2018-01-22 13:29:50 +01:00
$color = Config::get('duepuntozero', 'colorset');
}
2018-01-22 13:29:50 +01:00
$t = get_markup_template("theme_settings.tpl");
/// @TODO No need for adding string here, $o is not defined
$o .= replace_macros($t, [
2018-01-22 13:29:50 +01:00
'$submit' => L10n::t('Submit'),
'$baseurl' => System::baseUrl(),
2018-01-22 13:29:50 +01:00
'$title' => L10n::t("Theme settings"),
'$colorset' => ['duepuntozero_colorset', L10n::t('Variations'), $color, '', $colorset],
]);
return $o;
}