2014-09-07 10:48:23 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Theme settings
|
|
|
|
*/
|
|
|
|
|
2017-04-30 04:07:00 +00:00
|
|
|
use Friendica\App;
|
2017-11-07 02:22:52 +00:00
|
|
|
use Friendica\Core\Config;
|
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
|
|
|
|
2018-01-22 12:29:50 +00:00
|
|
|
function theme_content(App $a)
|
|
|
|
{
|
2016-12-20 10:56:34 +00:00
|
|
|
if (!local_user()) {
|
|
|
|
return;
|
|
|
|
}
|
2014-09-07 10:48:23 +00:00
|
|
|
|
2020-01-18 15:50:57 +00:00
|
|
|
$colorset = DI::pConfig()->get(local_user(), 'duepuntozero', 'colorset');
|
2016-12-20 10:56:34 +00:00
|
|
|
$user = true;
|
2014-09-07 10:48:23 +00:00
|
|
|
|
2016-12-20 10:56:34 +00:00
|
|
|
return clean_form($a, $colorset, $user);
|
2014-09-07 10:48:23 +00:00
|
|
|
}
|
|
|
|
|
2018-01-22 12:29:50 +00:00
|
|
|
function theme_post(App $a)
|
|
|
|
{
|
2016-12-20 10:56:34 +00:00
|
|
|
if (! local_user()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-01-22 12:29:50 +00:00
|
|
|
if (isset($_POST['duepuntozero-settings-submit'])) {
|
2020-01-18 15:54:50 +00:00
|
|
|
DI::pConfig()->set(local_user(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
|
2016-12-20 10:56:34 +00:00
|
|
|
}
|
2014-09-07 10:48:23 +00:00
|
|
|
}
|
|
|
|
|
2018-01-22 12:29:50 +00:00
|
|
|
function theme_admin(App $a)
|
|
|
|
{
|
2020-01-19 20:21:13 +00:00
|
|
|
$colorset = DI::config()->get('duepuntozero', 'colorset');
|
2016-12-20 10:56:34 +00:00
|
|
|
$user = false;
|
2014-09-07 10:48:23 +00:00
|
|
|
|
2016-12-20 10:56:34 +00:00
|
|
|
return clean_form($a, $colorset, $user);
|
2014-09-07 10:48:23 +00:00
|
|
|
}
|
|
|
|
|
2018-01-22 12:29:50 +00:00
|
|
|
function theme_admin_post(App $a)
|
|
|
|
{
|
|
|
|
if (isset($_POST['duepuntozero-settings-submit'])) {
|
2017-11-07 02:22:52 +00:00
|
|
|
Config::set('duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
|
2016-12-20 10:56:34 +00:00
|
|
|
}
|
2014-09-07 10:48:23 +00:00
|
|
|
}
|
|
|
|
|
2016-12-19 13:26:13 +00:00
|
|
|
/// @TODO $a is no longer used
|
2018-01-22 12:29:50 +00:00
|
|
|
function clean_form(App $a, &$colorset, $user)
|
|
|
|
{
|
2018-01-15 13:05:12 +00:00
|
|
|
$colorset = [
|
2020-01-18 19:52:34 +00: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 13:05:12 +00:00
|
|
|
];
|
2016-12-20 10:56:34 +00:00
|
|
|
|
|
|
|
if ($user) {
|
2020-01-18 15:50:57 +00:00
|
|
|
$color = DI::pConfig()->get(local_user(), 'duepuntozero', 'colorset');
|
2016-12-20 10:56:34 +00:00
|
|
|
} else {
|
2020-01-19 20:21:13 +00:00
|
|
|
$color = DI::config()->get('duepuntozero', 'colorset');
|
2016-12-20 10:56:34 +00:00
|
|
|
}
|
|
|
|
|
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"),
|
|
|
|
'$colorset' => ['duepuntozero_colorset', DI::l10n()->t('Variations'), $color, '', $colorset],
|
2018-01-15 13:05:12 +00:00
|
|
|
]);
|
2016-12-20 10:56:34 +00:00
|
|
|
|
|
|
|
return $o;
|
2014-09-07 10:48:23 +00:00
|
|
|
}
|