2014-09-07 10:48:23 +00:00
|
|
|
<?php
|
2017-04-30 04:01:26 +00:00
|
|
|
|
2014-09-07 10:48:23 +00:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
use Friendica\Core\PConfig;
|
2017-08-26 06:04:21 +00:00
|
|
|
use Friendica\Core\System;
|
2017-04-30 04:07:00 +00:00
|
|
|
|
2017-01-09 12:06:08 +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
|
|
|
|
2017-11-07 02:22:52 +00:00
|
|
|
$colorset = 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
|
|
|
}
|
|
|
|
|
2017-01-09 12:06:08 +00:00
|
|
|
function theme_post(App $a) {
|
2016-12-20 10:56:34 +00:00
|
|
|
if (! local_user()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($_POST['duepuntozero-settings-submit'])){
|
2017-11-07 02:22:52 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2017-01-09 12:06:08 +00:00
|
|
|
function theme_admin(App $a) {
|
2017-11-07 02:22:52 +00:00
|
|
|
$colorset = 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
|
|
|
}
|
|
|
|
|
2017-01-09 12:06:08 +00:00
|
|
|
function theme_admin_post(App $a) {
|
2016-12-20 10:56:34 +00:00
|
|
|
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
|
2017-01-09 12:06:08 +00:00
|
|
|
function clean_form(App $a, &$colorset, $user) {
|
2018-01-15 13:05:12 +00:00
|
|
|
$colorset = [
|
2017-01-09 12:06:08 +00:00
|
|
|
'default' =>t('default'),
|
2016-12-19 13:26:13 +00:00
|
|
|
'greenzero' =>t('greenzero'),
|
|
|
|
'purplezero' =>t('purplezero'),
|
|
|
|
'easterbunny' =>t('easterbunny'),
|
|
|
|
'darkzero' =>t('darkzero'),
|
|
|
|
'comix' =>t('comix'),
|
|
|
|
'slackr' =>t('slackr'),
|
2018-01-15 13:05:12 +00:00
|
|
|
];
|
2016-12-20 10:56:34 +00:00
|
|
|
|
|
|
|
if ($user) {
|
2017-11-07 02:22:52 +00:00
|
|
|
$color = PConfig::get(local_user(), 'duepuntozero', 'colorset');
|
2016-12-20 10:56:34 +00:00
|
|
|
} else {
|
2017-11-07 02:22:52 +00:00
|
|
|
$color = Config::get( 'duepuntozero', 'colorset');
|
2016-12-20 10:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$t = get_markup_template("theme_settings.tpl" );
|
|
|
|
/// @TODO No need for adding string here, $o is not defined
|
2018-01-15 13:05:12 +00:00
|
|
|
$o .= replace_macros($t, [
|
2016-12-20 10:56:34 +00:00
|
|
|
'$submit' => t('Submit'),
|
2017-08-26 07:32:10 +00:00
|
|
|
'$baseurl' => System::baseUrl(),
|
2016-12-19 13:26:13 +00:00
|
|
|
'$title' => t("Theme settings"),
|
2018-01-15 13:05:12 +00:00
|
|
|
'$colorset' => ['duepuntozero_colorset', t('Variations'), $color, '', $colorset],
|
|
|
|
]);
|
2016-12-20 10:56:34 +00:00
|
|
|
|
|
|
|
return $o;
|
2014-09-07 10:48:23 +00:00
|
|
|
}
|