2014-09-07 06:48:23 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Theme settings
|
|
|
|
*/
|
|
|
|
|
2017-04-30 00:07:00 -04:00
|
|
|
use Friendica\App;
|
2017-11-06 21:22:52 -05:00
|
|
|
use Friendica\Core\Config;
|
2018-01-22 07:29:50 -05:00
|
|
|
use Friendica\Core\L10n;
|
2017-11-06 21:22:52 -05:00
|
|
|
use Friendica\Core\PConfig;
|
2018-10-31 10:35:50 -04:00
|
|
|
use Friendica\Core\Renderer;
|
2017-08-26 02:04:21 -04:00
|
|
|
use Friendica\Core\System;
|
2017-04-30 00:07:00 -04:00
|
|
|
|
2018-01-22 07:29:50 -05:00
|
|
|
function theme_content(App $a)
|
|
|
|
{
|
2016-12-20 05:56:34 -05:00
|
|
|
if (!local_user()) {
|
|
|
|
return;
|
|
|
|
}
|
2014-09-07 06:48:23 -04:00
|
|
|
|
2018-01-22 07:29:50 -05:00
|
|
|
$colorset = PConfig::get(local_user(), 'duepuntozero', 'colorset');
|
2016-12-20 05:56:34 -05:00
|
|
|
$user = true;
|
2014-09-07 06:48:23 -04:00
|
|
|
|
2016-12-20 05:56:34 -05:00
|
|
|
return clean_form($a, $colorset, $user);
|
2014-09-07 06:48:23 -04:00
|
|
|
}
|
|
|
|
|
2018-01-22 07:29:50 -05:00
|
|
|
function theme_post(App $a)
|
|
|
|
{
|
2016-12-20 05:56:34 -05:00
|
|
|
if (! local_user()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-01-22 07:29:50 -05:00
|
|
|
if (isset($_POST['duepuntozero-settings-submit'])) {
|
2017-11-06 21:22:52 -05:00
|
|
|
PConfig::set(local_user(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
|
2016-12-20 05:56:34 -05:00
|
|
|
}
|
2014-09-07 06:48:23 -04:00
|
|
|
}
|
|
|
|
|
2018-01-22 07:29:50 -05:00
|
|
|
function theme_admin(App $a)
|
|
|
|
{
|
|
|
|
$colorset = Config::get('duepuntozero', 'colorset');
|
2016-12-20 05:56:34 -05:00
|
|
|
$user = false;
|
2014-09-07 06:48:23 -04:00
|
|
|
|
2016-12-20 05:56:34 -05:00
|
|
|
return clean_form($a, $colorset, $user);
|
2014-09-07 06:48:23 -04:00
|
|
|
}
|
|
|
|
|
2018-01-22 07:29:50 -05:00
|
|
|
function theme_admin_post(App $a)
|
|
|
|
{
|
|
|
|
if (isset($_POST['duepuntozero-settings-submit'])) {
|
2017-11-06 21:22:52 -05:00
|
|
|
Config::set('duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
|
2016-12-20 05:56:34 -05:00
|
|
|
}
|
2014-09-07 06:48:23 -04:00
|
|
|
}
|
|
|
|
|
2016-12-19 08:26:13 -05:00
|
|
|
/// @TODO $a is no longer used
|
2018-01-22 07:29:50 -05:00
|
|
|
function clean_form(App $a, &$colorset, $user)
|
|
|
|
{
|
2018-01-15 08:05:12 -05:00
|
|
|
$colorset = [
|
2018-01-22 07:29:50 -05: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'),
|
2018-01-15 08:05:12 -05:00
|
|
|
];
|
2016-12-20 05:56:34 -05:00
|
|
|
|
|
|
|
if ($user) {
|
2017-11-06 21:22:52 -05:00
|
|
|
$color = PConfig::get(local_user(), 'duepuntozero', 'colorset');
|
2016-12-20 05:56:34 -05:00
|
|
|
} else {
|
2018-01-22 07:29:50 -05:00
|
|
|
$color = Config::get('duepuntozero', 'colorset');
|
2016-12-20 05:56:34 -05:00
|
|
|
}
|
|
|
|
|
2018-01-22 07:29:50 -05:00
|
|
|
$t = get_markup_template("theme_settings.tpl");
|
2018-10-31 10:35:50 -04:00
|
|
|
$o = Renderer::replaceMacros($t, [
|
2018-01-22 07:29:50 -05:00
|
|
|
'$submit' => L10n::t('Submit'),
|
2017-08-26 03:32:10 -04:00
|
|
|
'$baseurl' => System::baseUrl(),
|
2018-01-22 07:29:50 -05:00
|
|
|
'$title' => L10n::t("Theme settings"),
|
|
|
|
'$colorset' => ['duepuntozero_colorset', L10n::t('Variations'), $color, '', $colorset],
|
2018-01-15 08:05:12 -05:00
|
|
|
]);
|
2016-12-20 05:56:34 -05:00
|
|
|
|
|
|
|
return $o;
|
2014-09-07 06:48:23 -04:00
|
|
|
}
|