2012-03-30 15:45:23 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Theme settings
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
2017-01-09 13:06:08 +01:00
|
|
|
function theme_content(App $a) {
|
2016-12-20 11:56:34 +01:00
|
|
|
if (!local_user()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-01-18 16:50:57 +01:00
|
|
|
$align = DI::pConfig()->get(local_user(), 'quattro', 'align' );
|
|
|
|
$color = DI::pConfig()->get(local_user(), 'quattro', 'color' );
|
|
|
|
$tfs = DI::pConfig()->get(local_user(),"quattro","tfs");
|
|
|
|
$pfs = DI::pConfig()->get(local_user(),"quattro","pfs");
|
2016-12-20 11:56:34 +01:00
|
|
|
|
2012-10-01 14:58:05 +02:00
|
|
|
return quattro_form($a,$align, $color, $tfs, $pfs);
|
2012-04-13 11:21:15 +02:00
|
|
|
}
|
|
|
|
|
2017-01-09 13:06:08 +01:00
|
|
|
function theme_post(App $a) {
|
2016-12-20 11:56:34 +01:00
|
|
|
if (! local_user()) {
|
2012-04-13 11:21:15 +02:00
|
|
|
return;
|
2016-12-20 11:56:34 +01:00
|
|
|
}
|
|
|
|
|
2012-04-13 11:21:15 +02:00
|
|
|
if (isset($_POST['quattro-settings-submit'])){
|
2020-01-18 16:54:50 +01:00
|
|
|
DI::pConfig()->set(local_user(), 'quattro', 'align', $_POST['quattro_align']);
|
|
|
|
DI::pConfig()->set(local_user(), 'quattro', 'color', $_POST['quattro_color']);
|
|
|
|
DI::pConfig()->set(local_user(), 'quattro', 'tfs', $_POST['quattro_tfs']);
|
|
|
|
DI::pConfig()->set(local_user(), 'quattro', 'pfs', $_POST['quattro_pfs']);
|
2012-04-13 11:21:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-09 13:06:08 +01:00
|
|
|
function theme_admin(App $a) {
|
2020-01-19 21:21:13 +01:00
|
|
|
$align = DI::config()->get('quattro', 'align' );
|
|
|
|
$color = DI::config()->get('quattro', 'color' );
|
|
|
|
$tfs = DI::config()->get("quattro","tfs");
|
|
|
|
$pfs = DI::config()->get("quattro","pfs");
|
2012-10-01 14:58:05 +02:00
|
|
|
|
|
|
|
return quattro_form($a,$align, $color, $tfs, $pfs);
|
2012-04-13 11:21:15 +02:00
|
|
|
}
|
|
|
|
|
2017-01-09 13:06:08 +01:00
|
|
|
function theme_admin_post(App $a) {
|
2012-04-13 11:21:15 +02:00
|
|
|
if (isset($_POST['quattro-settings-submit'])){
|
2020-01-19 21:21:53 +01:00
|
|
|
DI::config()->set('quattro', 'align', $_POST['quattro_align']);
|
|
|
|
DI::config()->set('quattro', 'color', $_POST['quattro_color']);
|
|
|
|
DI::config()->set('quattro', 'tfs', $_POST['quattro_tfs']);
|
|
|
|
DI::config()->set('quattro', 'pfs', $_POST['quattro_pfs']);
|
2012-04-13 11:21:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-19 14:26:13 +01:00
|
|
|
/// @TODO $a is no longer used here
|
2017-01-09 13:06:08 +01:00
|
|
|
function quattro_form(App $a, $align, $color, $tfs, $pfs) {
|
2018-01-15 14:05:12 +01:00
|
|
|
$colors = [
|
2016-12-22 11:37:23 +01:00
|
|
|
"dark" => "Quattro",
|
|
|
|
"lilac" => "Lilac",
|
|
|
|
"green" => "Green",
|
2018-01-15 14:05:12 +01:00
|
|
|
];
|
2016-12-22 11:37:23 +01:00
|
|
|
|
|
|
|
if ($tfs === false) {
|
|
|
|
$tfs = "20";
|
|
|
|
}
|
|
|
|
if ($pfs === false) {
|
|
|
|
$pfs = "12";
|
|
|
|
}
|
|
|
|
|
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"),
|
|
|
|
'$align' => ['quattro_align', DI::l10n()->t('Alignment'), $align, '', ['left' => DI::l10n()->t('Left'), 'center' => DI::l10n()->t('Center')]],
|
|
|
|
'$color' => ['quattro_color', DI::l10n()->t('Color scheme'), $color, '', $colors],
|
|
|
|
'$pfs' => ['quattro_pfs', DI::l10n()->t('Posts font size'), $pfs],
|
|
|
|
'$tfs' => ['quattro_tfs', DI::l10n()->t('Textareas font size'), $tfs],
|
2018-01-15 14:05:12 +01:00
|
|
|
]);
|
2012-03-30 15:45:23 +02:00
|
|
|
return $o;
|
|
|
|
}
|