From d15ebb6fd381e94c6f8eefd223df4c5a709ed3fc Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 11 Mar 2022 22:40:27 -0500 Subject: [PATCH 1/2] Normalize base URL usage in admin templates --- mod/ping.php | 4 ++-- src/Module/Admin/Logs/View.php | 9 +++++---- src/Module/Admin/Site.php | 2 +- src/Module/Admin/Themes/Details.php | 2 +- src/Module/Admin/Themes/Embed.php | 3 ++- src/Module/Admin/Themes/Index.php | 2 +- src/Module/Register.php | 4 ++-- view/templates/admin/logs/view.tpl | 2 +- view/templates/admin/summary.tpl | 2 +- view/theme/frio/templates/admin/logs/view.tpl | 6 +++--- view/theme/frio/templates/admin/summary.tpl | 2 +- 11 files changed, 20 insertions(+), 18 deletions(-) diff --git a/mod/ping.php b/mod/ping.php index 81aa9ec62..1afab5f72 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -283,7 +283,7 @@ function ping_init(App $a) foreach ($regs as $reg) { $notif = [ 'id' => 0, - 'href' => DI::baseUrl() . '/admin/users/pending', + 'href' => DI::baseUrl()->get(true) . '/admin/users/pending', 'name' => $reg['name'], 'url' => $reg['url'], 'photo' => $reg['micro'], @@ -296,7 +296,7 @@ function ping_init(App $a) } else { $notif = [ 'id' => 0, - 'href' => DI::baseUrl() . '/admin/users/pending', + 'href' => DI::baseUrl()->get(true) . '/admin/users/pending', 'name' => $regs[0]['name'], 'url' => $regs[0]['url'], 'photo' => $regs[0]['micro'], diff --git a/src/Module/Admin/Logs/View.php b/src/Module/Admin/Logs/View.php index 1104212f6..d56e02061 100644 --- a/src/Module/Admin/Logs/View.php +++ b/src/Module/Admin/Logs/View.php @@ -21,9 +21,9 @@ namespace Friendica\Module\Admin\Logs; -use Friendica\DI; use Friendica\Core\Renderer; use Friendica\Core\Theme; +use Friendica\DI; use Friendica\Module\BaseAdmin; use Psr\Log\LogLevel; @@ -80,9 +80,10 @@ class View extends BaseAdmin } } return Renderer::replaceMacros($t, [ - '$title' => DI::l10n()->t('Administration'), - '$page' => DI::l10n()->t('View Logs'), - '$l10n' => [ + '$baseurl' => DI::baseUrl()->get(true), + '$title' => DI::l10n()->t('Administration'), + '$page' => DI::l10n()->t('View Logs'), + '$l10n' => [ 'Search' => DI::l10n()->t('Search'), 'Search_in_logs' => DI::l10n()->t('Search in logs'), 'Show_all' => DI::l10n()->t('Show all'), diff --git a/src/Module/Admin/Site.php b/src/Module/Admin/Site.php index 0f440f253..4c5c38ea5 100644 --- a/src/Module/Admin/Site.php +++ b/src/Module/Admin/Site.php @@ -526,7 +526,7 @@ class Site extends BaseAdmin '$touch_icon' => ['touch_icon', DI::l10n()->t('Touch icon'), DI::config()->get('system', 'touch_icon'), DI::l10n()->t('Link to an icon that will be used for tablets and mobiles.')], '$additional_info' => ['additional_info', DI::l10n()->t('Additional Info'), $additional_info, DI::l10n()->t('For public servers: you can add additional information here that will be listed at %s/servers.', Search::getGlobalDirectory())], '$language' => ['language', DI::l10n()->t('System language'), DI::config()->get('system', 'language'), '', $lang_choices], - '$theme' => ['theme', DI::l10n()->t('System theme'), DI::config()->get('system', 'theme'), DI::l10n()->t('Default system theme - may be over-ridden by user profiles - Change default theme settings'), $theme_choices], + '$theme' => ['theme', DI::l10n()->t('System theme'), DI::config()->get('system', 'theme'), DI::l10n()->t('Default system theme - may be over-ridden by user profiles - Change default theme settings', DI::baseUrl()->get(true) . '/admin/themes'), $theme_choices], '$theme_mobile' => ['theme_mobile', DI::l10n()->t('Mobile system theme'), DI::config()->get('system', 'mobile-theme', '---'), DI::l10n()->t('Theme for mobile devices'), $theme_choices_mobile], '$ssl_policy' => ['ssl_policy', DI::l10n()->t('SSL link policy'), DI::config()->get('system', 'ssl_policy'), DI::l10n()->t('Determines whether generated links should be forced to use SSL'), $ssl_choices], '$force_ssl' => ['force_ssl', DI::l10n()->t('Force SSL'), DI::config()->get('system', 'force_ssl'), DI::l10n()->t('Force all Non-SSL requests to SSL - Attention: on some systems it could lead to endless loops.')], diff --git a/src/Module/Admin/Themes/Details.php b/src/Module/Admin/Themes/Details.php index 25724dc72..dc6bf5818 100644 --- a/src/Module/Admin/Themes/Details.php +++ b/src/Module/Admin/Themes/Details.php @@ -76,7 +76,7 @@ class Details extends BaseAdmin require_once "view/theme/$theme/config.php"; if (function_exists('theme_admin')) { - $admin_form = ''; + $admin_form = ''; } } diff --git a/src/Module/Admin/Themes/Embed.php b/src/Module/Admin/Themes/Embed.php index 132a35b67..439e78e64 100644 --- a/src/Module/Admin/Themes/Embed.php +++ b/src/Module/Admin/Themes/Embed.php @@ -24,6 +24,7 @@ namespace Friendica\Module\Admin\Themes; use Friendica\App; use Friendica\Core\L10n; use Friendica\Core\Renderer; +use Friendica\DI; use Friendica\Module\BaseAdmin; use Friendica\Module\Response; use Friendica\Util\Profiler; @@ -94,7 +95,7 @@ class Embed extends BaseAdmin $t = Renderer::getMarkupTemplate('admin/addons/embed.tpl'); return Renderer::replaceMacros($t, [ - '$action' => '/admin/themes/' . $theme . '/embed?mode=minimal', + '$action' => DI::baseUrl()->get(true) . '/admin/themes/' . $theme . '/embed?mode=minimal', '$form' => $admin_form, '$form_security_token' => self::getFormSecurityToken("admin_theme_settings"), ]); diff --git a/src/Module/Admin/Themes/Index.php b/src/Module/Admin/Themes/Index.php index 9677ce30f..cf0ddcfc6 100644 --- a/src/Module/Admin/Themes/Index.php +++ b/src/Module/Admin/Themes/Index.php @@ -37,7 +37,7 @@ class Index extends BaseAdmin // reload active themes if (!empty($_GET['action'])) { - self::checkFormSecurityTokenRedirectOnError(DI::baseUrl()->get() . '/admin/themes', 'admin_themes', 't'); + self::checkFormSecurityTokenRedirectOnError('/admin/themes', 'admin_themes', 't'); switch ($_GET['action']) { case 'reload': diff --git a/src/Module/Register.php b/src/Module/Register.php index d415abf74..9c09baef8 100644 --- a/src/Module/Register.php +++ b/src/Module/Register.php @@ -380,11 +380,11 @@ class Register extends BaseModule 'type' => Model\Notification\Type::SYSTEM, 'event' => 'SYSTEM_REGISTER_REQUEST', 'uid' => $admin['uid'], - 'link' => $base_url . '/admin/users/', + 'link' => DI::baseUrl()->get(true) . '/admin/users/', 'source_name' => $user['username'], 'source_mail' => $user['email'], 'source_nick' => $user['nickname'], - 'source_link' => $base_url . '/admin/users/', + 'source_link' => DI::baseUrl()->get(true) . '/admin/users/', 'source_photo' => User::getAvatarUrl($user, Proxy::SIZE_THUMB), 'show_in_notification_page' => false ]); diff --git a/view/templates/admin/logs/view.tpl b/view/templates/admin/logs/view.tpl index 97b5c0625..50e166f1b 100644 --- a/view/templates/admin/logs/view.tpl +++ b/view/templates/admin/logs/view.tpl @@ -11,7 +11,7 @@

- {{$l10n.Show_all}} + {{$l10n.Show_all}}

diff --git a/view/templates/admin/summary.tpl b/view/templates/admin/summary.tpl index 121eb833b..2421658d6 100644 --- a/view/templates/admin/summary.tpl +++ b/view/templates/admin/summary.tpl @@ -34,7 +34,7 @@
{{$addons.0}}
{{foreach $addons.1 as $p}} -
{{$p}}
+
{{$p}}
{{/foreach}} diff --git a/view/theme/frio/templates/admin/logs/view.tpl b/view/theme/frio/templates/admin/logs/view.tpl index cab888268..d47c0361d 100755 --- a/view/theme/frio/templates/admin/logs/view.tpl +++ b/view/theme/frio/templates/admin/logs/view.tpl @@ -18,7 +18,7 @@
- {{$l10n.Show_all}} + {{$l10n.Show_all}}
@@ -33,7 +33,7 @@