2014-02-23 09:57:27 -05: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;
|
2018-10-31 10:35:50 -04:00
|
|
|
use Friendica\Core\Renderer;
|
2020-01-18 10:50:57 -05:00
|
|
|
use Friendica\DI;
|
2014-02-23 09:57:27 -05:00
|
|
|
|
2019-10-06 08:46:56 -04:00
|
|
|
require_once __DIR__ . '/theme.php';
|
|
|
|
|
2018-01-22 07:29:50 -05:00
|
|
|
function theme_content(App $a)
|
|
|
|
{
|
2016-12-20 05:56:34 -05:00
|
|
|
if (!local_user()) {
|
2014-02-23 09:57:27 -05:00
|
|
|
return;
|
2016-12-20 05:56:34 -05:00
|
|
|
}
|
2014-02-23 09:57:27 -05:00
|
|
|
|
2016-12-20 05:56:34 -05:00
|
|
|
if (!function_exists('get_vier_config')) {
|
2015-10-05 11:38:57 -04:00
|
|
|
return;
|
2016-12-20 05:56:34 -05:00
|
|
|
}
|
2015-10-05 11:38:57 -04:00
|
|
|
|
2020-01-18 10:50:57 -05:00
|
|
|
$style = DI::pConfig()->get(local_user(), 'vier', 'style');
|
2014-02-23 09:57:27 -05:00
|
|
|
|
2016-12-20 05:56:34 -05:00
|
|
|
if ($style == "") {
|
2017-11-06 21:22:52 -05:00
|
|
|
$style = Config::get('vier', 'style');
|
2016-12-20 05:56:34 -05:00
|
|
|
}
|
2014-06-15 18:00:05 -04:00
|
|
|
|
2016-12-20 05:56:34 -05:00
|
|
|
if ($style == "") {
|
2015-02-21 03:44:13 -05:00
|
|
|
$style = "plus";
|
2016-12-20 05:56:34 -05:00
|
|
|
}
|
2015-02-21 03:44:13 -05:00
|
|
|
|
2015-10-04 08:40:02 -04:00
|
|
|
$show_pages = get_vier_config('show_pages', true);
|
|
|
|
$show_profiles = get_vier_config('show_profiles', true);
|
|
|
|
$show_helpers = get_vier_config('show_helpers', true);
|
|
|
|
$show_services = get_vier_config('show_services', true);
|
|
|
|
$show_friends = get_vier_config('show_friends', true);
|
|
|
|
$show_lastusers = get_vier_config('show_lastusers', true);
|
2015-10-03 06:55:55 -04:00
|
|
|
|
|
|
|
return vier_form($a,$style, $show_pages, $show_profiles, $show_helpers,
|
|
|
|
$show_services, $show_friends, $show_lastusers);
|
2014-02-23 09:57:27 -05: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()) {
|
2014-02-23 09:57:27 -05:00
|
|
|
return;
|
2016-12-20 05:56:34 -05:00
|
|
|
}
|
2014-02-23 09:57:27 -05:00
|
|
|
|
2018-01-22 07:29:50 -05:00
|
|
|
if (isset($_POST['vier-settings-submit'])) {
|
2020-01-18 10:54:50 -05:00
|
|
|
DI::pConfig()->set(local_user(), 'vier', 'style', $_POST['vier_style']);
|
|
|
|
DI::pConfig()->set(local_user(), 'vier', 'show_pages', $_POST['vier_show_pages']);
|
|
|
|
DI::pConfig()->set(local_user(), 'vier', 'show_profiles', $_POST['vier_show_profiles']);
|
|
|
|
DI::pConfig()->set(local_user(), 'vier', 'show_helpers', $_POST['vier_show_helpers']);
|
|
|
|
DI::pConfig()->set(local_user(), 'vier', 'show_services', $_POST['vier_show_services']);
|
|
|
|
DI::pConfig()->set(local_user(), 'vier', 'show_friends', $_POST['vier_show_friends']);
|
|
|
|
DI::pConfig()->set(local_user(), 'vier', 'show_lastusers', $_POST['vier_show_lastusers']);
|
2014-02-23 09:57:27 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-09 07:06:08 -05:00
|
|
|
function theme_admin(App $a) {
|
2015-10-05 11:38:57 -04:00
|
|
|
|
|
|
|
if (!function_exists('get_vier_config'))
|
|
|
|
return;
|
|
|
|
|
2017-11-06 21:22:52 -05:00
|
|
|
$style = Config::get('vier', 'style');
|
2015-10-03 06:55:55 -04:00
|
|
|
|
2017-11-06 21:22:52 -05:00
|
|
|
$helperlist = Config::get('vier', 'helperlist');
|
2015-10-03 06:55:55 -04:00
|
|
|
|
|
|
|
if ($helperlist == "")
|
2017-10-12 09:59:13 -04:00
|
|
|
$helperlist = "https://forum.friendi.ca/profile/helpers";
|
2015-10-03 06:55:55 -04:00
|
|
|
|
2018-10-31 10:44:06 -04:00
|
|
|
$t = Renderer::getMarkupTemplate("theme_admin_settings.tpl");
|
2018-10-31 10:35:50 -04:00
|
|
|
$o = Renderer::replaceMacros($t, [
|
2018-01-22 07:29:50 -05:00
|
|
|
'$helperlist' => ['vier_helperlist', L10n::t('Comma separated list of helper forums'), $helperlist, '', ''],
|
2018-01-15 08:05:12 -05:00
|
|
|
]);
|
2015-10-03 06:55:55 -04:00
|
|
|
|
2015-10-04 08:40:02 -04:00
|
|
|
$show_pages = get_vier_config('show_pages', true, true);
|
|
|
|
$show_profiles = get_vier_config('show_profiles', true, true);
|
|
|
|
$show_helpers = get_vier_config('show_helpers', true, true);
|
|
|
|
$show_services = get_vier_config('show_services', true, true);
|
|
|
|
$show_friends = get_vier_config('show_friends', true, true);
|
|
|
|
$show_lastusers = get_vier_config('show_lastusers', true, true);
|
2015-10-03 06:55:55 -04:00
|
|
|
$o .= vier_form($a,$style, $show_pages, $show_profiles, $show_helpers, $show_services,
|
|
|
|
$show_friends, $show_lastusers);
|
|
|
|
|
|
|
|
return $o;
|
2014-02-23 09:57:27 -05:00
|
|
|
}
|
|
|
|
|
2017-01-09 07:06:08 -05:00
|
|
|
function theme_admin_post(App $a) {
|
2014-02-23 09:57:27 -05:00
|
|
|
if (isset($_POST['vier-settings-submit'])){
|
2017-11-06 21:22:52 -05:00
|
|
|
Config::set('vier', 'style', $_POST['vier_style']);
|
|
|
|
Config::set('vier', 'show_pages', $_POST['vier_show_pages']);
|
|
|
|
Config::set('vier', 'show_profiles', $_POST['vier_show_profiles']);
|
|
|
|
Config::set('vier', 'show_helpers', $_POST['vier_show_helpers']);
|
|
|
|
Config::set('vier', 'show_services', $_POST['vier_show_services']);
|
|
|
|
Config::set('vier', 'show_friends', $_POST['vier_show_friends']);
|
|
|
|
Config::set('vier', 'show_lastusers', $_POST['vier_show_lastusers']);
|
|
|
|
Config::set('vier', 'helperlist', $_POST['vier_helperlist']);
|
2014-02-23 09:57:27 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-19 08:26:13 -05:00
|
|
|
/// @TODO $a is no longer used
|
2017-01-09 07:06:08 -05:00
|
|
|
function vier_form(App $a, $style, $show_pages, $show_profiles, $show_helpers, $show_services, $show_friends, $show_lastusers) {
|
2018-01-15 08:05:12 -05:00
|
|
|
$styles = [
|
2015-02-21 03:44:13 -05:00
|
|
|
"breathe"=>"Breathe",
|
2014-06-14 18:19:38 -04:00
|
|
|
"netcolour"=>"Coloured Networks",
|
2017-11-26 14:46:20 -05:00
|
|
|
"dark"=>"Dark",
|
|
|
|
"flat"=>"Flat",
|
|
|
|
"plus"=>"Plus",
|
|
|
|
"plusminus"=>"Plus Minus",
|
|
|
|
"shadow"=>"Shadow"
|
2018-01-15 08:05:12 -05:00
|
|
|
];
|
2015-10-03 06:55:55 -04:00
|
|
|
|
2018-01-22 07:29:50 -05:00
|
|
|
$show_or_not = ['0' => L10n::t("don't show"), '1' => L10n::t("show"),];
|
2015-10-03 06:55:55 -04:00
|
|
|
|
2018-10-31 10:44:06 -04:00
|
|
|
$t = Renderer::getMarkupTemplate("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'),
|
|
|
|
'$title' => L10n::t("Theme settings"),
|
|
|
|
'$style' => ['vier_style', L10n::t('Set style'), $style, '', $styles],
|
|
|
|
'$show_pages' => ['vier_show_pages', L10n::t('Community Pages'), $show_pages, '', $show_or_not],
|
|
|
|
'$show_profiles' => ['vier_show_profiles', L10n::t('Community Profiles'), $show_profiles, '', $show_or_not],
|
|
|
|
'$show_helpers' => ['vier_show_helpers', L10n::t('Help or @NewHere ?'), $show_helpers, '', $show_or_not],
|
|
|
|
'$show_services' => ['vier_show_services', L10n::t('Connect Services'), $show_services, '', $show_or_not],
|
|
|
|
'$show_friends' => ['vier_show_friends', L10n::t('Find Friends'), $show_friends, '', $show_or_not],
|
|
|
|
'$show_lastusers' => ['vier_show_lastusers', L10n::t('Last users'), $show_lastusers, '', $show_or_not]
|
2018-01-15 08:05:12 -05:00
|
|
|
]);
|
2014-02-23 09:57:27 -05:00
|
|
|
return $o;
|
|
|
|
}
|