2014-02-23 14:57:27 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2024-01-02 20:57:26 +00:00
|
|
|
* @copyright Copyright (C) 2010-2024, the Friendica project
|
2022-10-19 05:06:28 +00:00
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
2014-02-23 14:57:27 +00:00
|
|
|
*/
|
|
|
|
|
2017-04-30 04:07:00 +00:00
|
|
|
use Friendica\App;
|
2018-10-31 14:35:50 +00:00
|
|
|
use Friendica\Core\Renderer;
|
2020-01-18 15:50:57 +00:00
|
|
|
use Friendica\DI;
|
2014-02-23 14:57:27 +00:00
|
|
|
|
2019-10-06 12:46:56 +00:00
|
|
|
require_once __DIR__ . '/theme.php';
|
|
|
|
|
2018-01-22 12:29:50 +00:00
|
|
|
function theme_content(App $a)
|
|
|
|
{
|
2022-10-20 21:45:14 +00:00
|
|
|
if (!DI::userSession()->getLocalUserId()) {
|
2014-02-23 14:57:27 +00:00
|
|
|
return;
|
2016-12-20 10:56:34 +00:00
|
|
|
}
|
2014-02-23 14:57:27 +00:00
|
|
|
|
2016-12-20 10:56:34 +00:00
|
|
|
if (!function_exists('get_vier_config')) {
|
2015-10-05 15:38:57 +00:00
|
|
|
return;
|
2016-12-20 10:56:34 +00:00
|
|
|
}
|
2015-10-05 15:38:57 +00:00
|
|
|
|
2022-10-20 21:45:14 +00:00
|
|
|
$style = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'vier', 'style');
|
2014-02-23 14:57:27 +00:00
|
|
|
|
2016-12-20 10:56:34 +00:00
|
|
|
if ($style == "") {
|
2020-01-19 20:21:13 +00:00
|
|
|
$style = DI::config()->get('vier', 'style');
|
2016-12-20 10:56:34 +00:00
|
|
|
}
|
2014-06-15 22:00:05 +00:00
|
|
|
|
2016-12-20 10:56:34 +00:00
|
|
|
if ($style == "") {
|
2015-02-21 08:44:13 +00:00
|
|
|
$style = "plus";
|
2016-12-20 10:56:34 +00:00
|
|
|
}
|
2015-02-21 08:44:13 +00:00
|
|
|
|
2015-10-04 12:40:02 +00: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 10:55:55 +00:00
|
|
|
|
|
|
|
return vier_form($a,$style, $show_pages, $show_profiles, $show_helpers,
|
|
|
|
$show_services, $show_friends, $show_lastusers);
|
2014-02-23 14:57:27 +00:00
|
|
|
}
|
|
|
|
|
2018-01-22 12:29:50 +00:00
|
|
|
function theme_post(App $a)
|
|
|
|
{
|
2022-10-21 06:38:45 +00:00
|
|
|
if (!DI::userSession()->getLocalUserId()) {
|
2014-02-23 14:57:27 +00:00
|
|
|
return;
|
2016-12-20 10:56:34 +00:00
|
|
|
}
|
2014-02-23 14:57:27 +00:00
|
|
|
|
2018-01-22 12:29:50 +00:00
|
|
|
if (isset($_POST['vier-settings-submit'])) {
|
2022-10-20 21:45:14 +00:00
|
|
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'vier', 'style', $_POST['vier_style']);
|
|
|
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'vier', 'show_pages', $_POST['vier_show_pages']);
|
|
|
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'vier', 'show_profiles', $_POST['vier_show_profiles']);
|
|
|
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'vier', 'show_helpers', $_POST['vier_show_helpers']);
|
|
|
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'vier', 'show_services', $_POST['vier_show_services']);
|
|
|
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'vier', 'show_friends', $_POST['vier_show_friends']);
|
|
|
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'vier', 'show_lastusers', $_POST['vier_show_lastusers']);
|
2014-02-23 14:57:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-09 12:06:08 +00:00
|
|
|
function theme_admin(App $a) {
|
2015-10-05 15:38:57 +00:00
|
|
|
|
|
|
|
if (!function_exists('get_vier_config'))
|
|
|
|
return;
|
|
|
|
|
2020-01-19 20:21:13 +00:00
|
|
|
$style = DI::config()->get('vier', 'style');
|
2015-10-03 10:55:55 +00:00
|
|
|
|
2020-01-19 20:21:13 +00:00
|
|
|
$helperlist = DI::config()->get('vier', 'helperlist');
|
2015-10-03 10:55:55 +00:00
|
|
|
|
|
|
|
if ($helperlist == "")
|
2017-10-12 13:59:13 +00:00
|
|
|
$helperlist = "https://forum.friendi.ca/profile/helpers";
|
2015-10-03 10:55:55 +00:00
|
|
|
|
2018-10-31 14:44:06 +00:00
|
|
|
$t = Renderer::getMarkupTemplate("theme_admin_settings.tpl");
|
2018-10-31 14:35:50 +00:00
|
|
|
$o = Renderer::replaceMacros($t, [
|
2023-05-30 13:15:17 +00:00
|
|
|
'$helperlist' => ['vier_helperlist', DI::l10n()->t('Comma separated list of helper groups'), $helperlist, '', ''],
|
2018-01-15 13:05:12 +00:00
|
|
|
]);
|
2015-10-03 10:55:55 +00:00
|
|
|
|
2015-10-04 12:40:02 +00: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 10:55:55 +00:00
|
|
|
$o .= vier_form($a,$style, $show_pages, $show_profiles, $show_helpers, $show_services,
|
|
|
|
$show_friends, $show_lastusers);
|
|
|
|
|
|
|
|
return $o;
|
2014-02-23 14:57:27 +00:00
|
|
|
}
|
|
|
|
|
2017-01-09 12:06:08 +00:00
|
|
|
function theme_admin_post(App $a) {
|
2014-02-23 14:57:27 +00:00
|
|
|
if (isset($_POST['vier-settings-submit'])){
|
2020-01-19 20:21:53 +00:00
|
|
|
DI::config()->set('vier', 'style', $_POST['vier_style']);
|
|
|
|
DI::config()->set('vier', 'show_pages', $_POST['vier_show_pages']);
|
|
|
|
DI::config()->set('vier', 'show_profiles', $_POST['vier_show_profiles']);
|
|
|
|
DI::config()->set('vier', 'show_helpers', $_POST['vier_show_helpers']);
|
|
|
|
DI::config()->set('vier', 'show_services', $_POST['vier_show_services']);
|
|
|
|
DI::config()->set('vier', 'show_friends', $_POST['vier_show_friends']);
|
|
|
|
DI::config()->set('vier', 'show_lastusers', $_POST['vier_show_lastusers']);
|
|
|
|
DI::config()->set('vier', 'helperlist', $_POST['vier_helperlist']);
|
2014-02-23 14:57:27 +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 vier_form(App $a, $style, $show_pages, $show_profiles, $show_helpers, $show_services, $show_friends, $show_lastusers) {
|
2018-01-15 13:05:12 +00:00
|
|
|
$styles = [
|
2015-02-21 08:44:13 +00:00
|
|
|
"breathe"=>"Breathe",
|
2014-06-14 22:19:38 +00:00
|
|
|
"netcolour"=>"Coloured Networks",
|
2017-11-26 19:46:20 +00:00
|
|
|
"dark"=>"Dark",
|
|
|
|
"flat"=>"Flat",
|
|
|
|
"plus"=>"Plus",
|
|
|
|
"plusminus"=>"Plus Minus",
|
|
|
|
"shadow"=>"Shadow"
|
2018-01-15 13:05:12 +00:00
|
|
|
];
|
2015-10-03 10:55:55 +00:00
|
|
|
|
2020-01-18 19:52:34 +00:00
|
|
|
$show_or_not = ['0' => DI::l10n()->t("don't show"), '1' => DI::l10n()->t("show"),];
|
2015-10-03 10:55:55 +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"),
|
|
|
|
'$style' => ['vier_style', DI::l10n()->t('Set style'), $style, '', $styles],
|
|
|
|
'$show_pages' => ['vier_show_pages', DI::l10n()->t('Community Pages'), $show_pages, '', $show_or_not],
|
|
|
|
'$show_profiles' => ['vier_show_profiles', DI::l10n()->t('Community Profiles'), $show_profiles, '', $show_or_not],
|
|
|
|
'$show_helpers' => ['vier_show_helpers', DI::l10n()->t('Help or @NewHere ?'), $show_helpers, '', $show_or_not],
|
|
|
|
'$show_services' => ['vier_show_services', DI::l10n()->t('Connect Services'), $show_services, '', $show_or_not],
|
|
|
|
'$show_friends' => ['vier_show_friends', DI::l10n()->t('Find Friends'), $show_friends, '', $show_or_not],
|
|
|
|
'$show_lastusers' => ['vier_show_lastusers', DI::l10n()->t('Last users'), $show_lastusers, '', $show_or_not]
|
2018-01-15 13:05:12 +00:00
|
|
|
]);
|
2014-02-23 14:57:27 +00:00
|
|
|
return $o;
|
|
|
|
}
|