From b4d71f1855ab38965f8bdbfa7854fc51802305fa Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 24 Mar 2024 09:11:46 -0400 Subject: [PATCH 1/2] Remove duplicated '$baseurl' template variable declarations - This variable is declared for all templates in Renderer --- src/Content/Conversation.php | 3 --- src/Module/Moderation/Blocklist/Contact.php | 2 -- src/Module/Moderation/Blocklist/Server/Add.php | 1 - src/Module/Moderation/Blocklist/Server/Import.php | 1 - src/Module/Moderation/Blocklist/Server/Index.php | 1 - src/Module/Moderation/Reports.php | 2 -- src/Module/Moderation/Users/Active.php | 1 - src/Module/Settings/Channels.php | 1 - 8 files changed, 12 deletions(-) diff --git a/src/Content/Conversation.php b/src/Content/Conversation.php index 6edef06fc6..776ce3e80a 100644 --- a/src/Content/Conversation.php +++ b/src/Content/Conversation.php @@ -332,7 +332,6 @@ class Conversation $tpl = Renderer::getMarkupTemplate('jot-header.tpl'); $this->page['htmlhead'] .= Renderer::replaceMacros($tpl, [ '$newpost' => 'true', - '$baseurl' => $this->baseURL, '$geotag' => $geotag, '$nickname' => $x['nickname'], '$ispublic' => $this->l10n->t('Visible to everybody'), @@ -405,7 +404,6 @@ class Conversation '$posttype' => $notes_cid ? ItemModel::PT_PERSONAL_NOTE : ItemModel::PT_ARTICLE, '$content' => $x['content'] ?? '', '$post_id' => $x['post_id'] ?? '', - '$baseurl' => $this->baseURL, '$defloc' => $x['default_location'], '$visitor' => $x['visitor'], '$pvisit' => $notes_cid ? 'none' : $x['visitor'], @@ -591,7 +589,6 @@ class Conversation } $o = Renderer::replaceMacros($page_template, [ - '$baseurl' => $this->baseURL, '$return_path' => $this->args->getQueryString(), '$live_update' => $live_update_div, '$remove' => $this->l10n->t('remove'), diff --git a/src/Module/Moderation/Blocklist/Contact.php b/src/Module/Moderation/Blocklist/Contact.php index 253f1dba04..d726b4d9b3 100644 --- a/src/Module/Moderation/Blocklist/Contact.php +++ b/src/Module/Moderation/Blocklist/Contact.php @@ -124,8 +124,6 @@ class Contact extends BaseModeration '$form_security_token' => self::getFormSecurityToken('moderation_contactblock'), // values // - '$baseurl' => $this->baseUrl, - '$contacts' => $contacts, '$total_contacts' => $this->tt('%s total blocked contact', '%s total blocked contacts', $total), '$paginate' => $pager->renderFull($total), diff --git a/src/Module/Moderation/Blocklist/Server/Add.php b/src/Module/Moderation/Blocklist/Server/Add.php index 9a56a7516f..6f498ac29a 100644 --- a/src/Module/Moderation/Blocklist/Server/Add.php +++ b/src/Module/Moderation/Blocklist/Server/Add.php @@ -138,7 +138,6 @@ class Add extends BaseModeration '$newreason' => ['reason', $this->t('Block reason'), $request['reason'] ?? '', $this->t('The reason why you blocked this server domain pattern. This reason will be shown publicly in the server information page.'), $this->t('Required'), '', ''], '$pattern' => $pattern, '$gservers' => $gservers, - '$baseurl' => $this->baseUrl, '$form_security_token' => self::getFormSecurityToken('moderation_blocklist_add') ]); } diff --git a/src/Module/Moderation/Blocklist/Server/Import.php b/src/Module/Moderation/Blocklist/Server/Import.php index 10c1f36ee6..1131855c08 100644 --- a/src/Module/Moderation/Blocklist/Server/Import.php +++ b/src/Module/Moderation/Blocklist/Server/Import.php @@ -130,7 +130,6 @@ class Import extends \Friendica\Module\BaseModeration '$mode_append' => ['mode', $this->t('Append'), 'append', $this->t('Imports patterns from the file that weren\'t already existing in the current blocklist.'), 'checked="checked"'], '$mode_replace' => ['mode', $this->t('Replace'), 'replace', $this->t('Replaces the current blocklist by the imported patterns.')], '$blocklist' => $this->blocklist, - '$baseurl' => $this->baseUrl, '$form_security_token' => self::getFormSecurityToken('moderation_blocklist_import') ]); } diff --git a/src/Module/Moderation/Blocklist/Server/Index.php b/src/Module/Moderation/Blocklist/Server/Index.php index 3b6dc735dd..466748ea1f 100644 --- a/src/Module/Moderation/Blocklist/Server/Index.php +++ b/src/Module/Moderation/Blocklist/Server/Index.php @@ -115,7 +115,6 @@ class Index extends BaseModeration '$listfile' => ['listfile', $this->t('Server domain pattern blocklist CSV file'), '', '', $this->t('Required'), '', 'file'], '$newdomain' => ['pattern', $this->t('Server Domain Pattern'), '', $this->t('The domain pattern of the new server to add to the blocklist. Do not include the protocol.'), $this->t('Required'), '', ''], '$entries' => $blocklistform, - '$baseurl' => $this->baseUrl, '$form_security_token' => self::getFormSecurityToken('moderation_blocklist'), '$form_security_token_import' => self::getFormSecurityToken('moderation_blocklist_import'), diff --git a/src/Module/Moderation/Reports.php b/src/Module/Moderation/Reports.php index 8c0f6cde66..c9aa92df9c 100644 --- a/src/Module/Moderation/Reports.php +++ b/src/Module/Moderation/Reports.php @@ -95,8 +95,6 @@ class Reports extends BaseModeration '$th_reports' => [$this->t('Created'), $this->t('Photo'), $this->t('Name'), $this->t('Comment'), $this->t('Category')], // values // - '$baseurl' => $this->baseUrl, - '$reports' => $reports, '$total_reports' => $this->tt('%s total report', '%s total reports', $total), '$paginate' => $pager->renderFull($total), diff --git a/src/Module/Moderation/Users/Active.php b/src/Module/Moderation/Users/Active.php index e90baf8c68..f3bed0f989 100644 --- a/src/Module/Moderation/Users/Active.php +++ b/src/Module/Moderation/Users/Active.php @@ -150,7 +150,6 @@ class Active extends BaseUsers '$form_security_token' => self::getFormSecurityToken('moderation_users_active'), // values // - '$baseurl' => $this->baseUrl, '$query_string' => $this->args->getQueryString(), '$users' => $users, diff --git a/src/Module/Settings/Channels.php b/src/Module/Settings/Channels.php index 34c9aabd01..c2b6cc4e64 100644 --- a/src/Module/Settings/Channels.php +++ b/src/Module/Settings/Channels.php @@ -228,7 +228,6 @@ class Channels extends BaseSettings 'confirm_delete' => $this->t('Delete entry from the channel list?'), ], '$entries' => $channels, - '$baseurl' => $this->baseUrl, '$form_security_token' => self::getFormSecurityToken('settings_channels'), ]); From e293de04f57f419cc4581dd4b31970ef4d36e1f2 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 24 Mar 2024 09:20:58 -0400 Subject: [PATCH 2/2] Add '$VERSION' template variable to make Friendica version available in templates - constant() Smarty function is deprecated - Remove unused site-wide template variable '$APP' - Address https://github.com/friendica/friendica/issues/14027#issuecomment-2016469408 --- src/Core/Renderer.php | 7 +- src/Module/Admin/Federation.php | 1 - src/Module/Admin/Summary.php | 2 +- view/templates/admin/federation.tpl | 4 +- view/templates/admin/summary.tpl | 8 +- view/templates/calendar/calendar_head.tpl | 8 +- view/templates/head.tpl | 46 ++++---- view/templates/jot-header.tpl | 2 +- view/templates/media/browser.tpl | 4 +- view/templates/msg-header.tpl | 2 +- .../templates/settings/profile/index_head.tpl | 2 +- .../settings/profile/photo/crop_head.tpl | 4 +- view/theme/frio/templates/admin/site.tpl | 2 +- view/theme/frio/templates/admin/storage.tpl | 2 +- view/theme/frio/templates/admin/summary.tpl | 4 +- .../frio/templates/calendar/calendar_head.tpl | 2 +- view/theme/frio/templates/circle_edit.tpl | 2 +- view/theme/frio/templates/contacts-head.tpl | 2 +- view/theme/frio/templates/head.tpl | 104 +++++++++--------- view/theme/frio/templates/jot-header.tpl | 6 +- .../moderation/blocklist/contact.tpl | 4 +- .../templates/moderation/users/active.tpl | 4 +- .../templates/moderation/users/blocked.tpl | 4 +- .../templates/moderation/users/deleted.tpl | 4 +- .../frio/templates/moderation/users/index.tpl | 4 +- .../templates/moderation/users/pending.tpl | 4 +- .../templates/notifications/notifications.tpl | 4 +- view/theme/frio/templates/photos_head.tpl | 2 +- view/theme/frio/templates/theme_settings.tpl | 4 +- .../frio/templates/threaded_conversation.tpl | 4 +- 30 files changed, 127 insertions(+), 125 deletions(-) diff --git a/src/Core/Renderer.php b/src/Core/Renderer.php index 7f15d60df0..11a7d0a2d6 100644 --- a/src/Core/Renderer.php +++ b/src/Core/Renderer.php @@ -75,8 +75,11 @@ class Renderer { DI::profiler()->startRecording('rendering'); - // pass $baseurl to all templates if it isn't set - $vars = array_merge(['$baseurl' => DI::baseUrl(), '$APP' => DI::app()], $vars); + // Default template variables + $vars = array_merge([ + '$baseurl' => DI::baseUrl(), + '$VERSION' => \Friendica\App::VERSION, + ], $vars); $t = self::getTemplateEngine(); diff --git a/src/Module/Admin/Federation.php b/src/Module/Admin/Federation.php index f6b77aeb66..9240453948 100644 --- a/src/Module/Admin/Federation.php +++ b/src/Module/Admin/Federation.php @@ -221,7 +221,6 @@ class Federation extends BaseAdmin '$page' => DI::l10n()->t('Federation Statistics'), '$intro' => $intro, '$counts' => $counts, - '$version' => App::VERSION, '$legendtext' => DI::l10n()->tt('Currently this node is aware of %2$s node (%3$s active users last month, %4$s active users last six months, %5$s registered users in total) from the following platforms:', 'Currently this node is aware of %2$s nodes (%3$s active users last month, %4$s active users last six months, %5$s registered users in total) from the following platforms:', $total, number_format($total), number_format($month), number_format($halfyear), number_format($users)), ]); } diff --git a/src/Module/Admin/Summary.php b/src/Module/Admin/Summary.php index 4939bc39cc..638af8842a 100644 --- a/src/Module/Admin/Summary.php +++ b/src/Module/Admin/Summary.php @@ -196,7 +196,7 @@ class Summary extends BaseAdmin '$title' => DI::l10n()->t('Administration'), '$page' => DI::l10n()->t('Summary'), '$queues' => $queues, - '$version' => [DI::l10n()->t('Version'), App::VERSION], + '$version_label' => DI::l10n()->t('Version'), '$platform' => App::PLATFORM, '$codename' => App::CODENAME, '$build' => DI::config()->get('system', 'build'), diff --git a/view/templates/admin/federation.tpl b/view/templates/admin/federation.tpl index 7757691ea5..6a006ebc34 100644 --- a/view/templates/admin/federation.tpl +++ b/view/templates/admin/federation.tpl @@ -1,4 +1,4 @@ - +

{{$title}} - {{$page}}

@@ -115,7 +115,7 @@
    {{foreach $c[1] as $v}}
  • - {{if ($c[0]['platform']==='Friendica' and $version===$v['version']) }} + {{if $c[0]['platform'] === 'Friendica' && $VERSION === $v['version']}} {{$v['version']}} {{else}} {{$v['version']}} diff --git a/view/templates/admin/summary.tpl b/view/templates/admin/summary.tpl index 9e69b67326..b2447912f8 100644 --- a/view/templates/admin/summary.tpl +++ b/view/templates/admin/summary.tpl @@ -16,16 +16,16 @@
    {{$addons.0}}
    - + {{foreach $addons.1 as $p}}
    {{$p}}
    {{/foreach}} - +
    -
    {{$version.0}}
    -
    {{$platform}} '{{$codename}}' {{$version.1}} - {{$build}} +
    {{$version_label}}
    +
    {{$platform}} '{{$codename}}' {{$VERSION}} - {{$build}}
    diff --git a/view/templates/calendar/calendar_head.tpl b/view/templates/calendar/calendar_head.tpl index a326d397bb..e57513d702 100644 --- a/view/templates/calendar/calendar_head.tpl +++ b/view/templates/calendar/calendar_head.tpl @@ -1,7 +1,7 @@ - - - - + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + - + - + + - + + diff --git a/view/templates/settings/profile/photo/crop_head.tpl b/view/templates/settings/profile/photo/crop_head.tpl index f92933fc10..bb31b69e46 100644 --- a/view/templates/settings/profile/photo/crop_head.tpl +++ b/view/templates/settings/profile/photo/crop_head.tpl @@ -1,2 +1,2 @@ - - + + diff --git a/view/theme/frio/templates/admin/site.tpl b/view/theme/frio/templates/admin/site.tpl index 8942b6e372..41e5e03957 100644 --- a/view/theme/frio/templates/admin/site.tpl +++ b/view/theme/frio/templates/admin/site.tpl @@ -17,7 +17,7 @@ }); }); - +

    {{$title}} - {{$page}}

    diff --git a/view/theme/frio/templates/admin/storage.tpl b/view/theme/frio/templates/admin/storage.tpl index 76c405860e..7068954e77 100644 --- a/view/theme/frio/templates/admin/storage.tpl +++ b/view/theme/frio/templates/admin/storage.tpl @@ -1,4 +1,4 @@ - +

    {{$title}} - {{$page}}

    diff --git a/view/theme/frio/templates/admin/summary.tpl b/view/theme/frio/templates/admin/summary.tpl index 78c4f6e35c..2b9f6b0624 100644 --- a/view/theme/frio/templates/admin/summary.tpl +++ b/view/theme/frio/templates/admin/summary.tpl @@ -31,8 +31,8 @@ {{* The Friendica version. *}}

    -
    {{$version.0}}
    -
    {{$platform}} '{{$codename}}' {{$version.1}} - {{$build}}
    +
    {{$version_label}}
    +
    {{$platform}} '{{$codename}}' {{$VERSION}} - {{$build}}
    {{* Server Settings. *}} diff --git a/view/theme/frio/templates/calendar/calendar_head.tpl b/view/theme/frio/templates/calendar/calendar_head.tpl index 98fc92f1ad..e6fe9da235 100644 --- a/view/theme/frio/templates/calendar/calendar_head.tpl +++ b/view/theme/frio/templates/calendar/calendar_head.tpl @@ -1,5 +1,5 @@ - + +
    {{if $editable == 1}} diff --git a/view/theme/frio/templates/contacts-head.tpl b/view/theme/frio/templates/contacts-head.tpl index 0af30ded55..45438cdbd2 100644 --- a/view/theme/frio/templates/contacts-head.tpl +++ b/view/theme/frio/templates/contacts-head.tpl @@ -1,2 +1,2 @@ - + diff --git a/view/theme/frio/templates/head.tpl b/view/theme/frio/templates/head.tpl index 5003cb5a1b..5c73df7d57 100644 --- a/view/theme/frio/templates/head.tpl +++ b/view/theme/frio/templates/head.tpl @@ -6,56 +6,56 @@ {{* All needed css files - Note: css must be inserted before js files *}} - - + - - - - {{* own css files *}} - - {{foreach $stylesheets as $stylesheetUrl => $media}} @@ -81,74 +81,74 @@ {{* The js files we use *}} - - + - + - + src="view/asset/textcomplete/dist/textcomplete.min.js?v={{$VERSION}}"> + - + - - + + - + + src="view/theme/frio/frameworks/bootstrap/js/bootstrap.min.js?v={{$VERSION}}"> + src="view/theme/frio/frameworks/jasny/js/jasny-bootstrap.custom.js?v={{$VERSION}}"> + src="view/theme/frio/frameworks/ekko-lightbox/ekko-lightbox.min.js?v={{$VERSION}}"> + src="view/theme/frio/frameworks/flexMenu/flexmenu.custom.js?v={{$VERSION}}"> + src="view/theme/frio/frameworks/autosize/autosize.min.js?v={{$VERSION}}"> + src="view/theme/frio/frameworks/sticky-kit/jquery.sticky-kit.min.js?v={{$VERSION}}"> {{* own js files *}} - - + + {{if ! $block_public}} - + {{/if}} - - - + + + - - - + + + - - + + + - + +

    {{$title}} - {{$page}}

    diff --git a/view/theme/frio/templates/moderation/users/active.tpl b/view/theme/frio/templates/moderation/users/active.tpl index fd61ea50fb..4ba099ddb1 100644 --- a/view/theme/frio/templates/moderation/users/active.tpl +++ b/view/theme/frio/templates/moderation/users/active.tpl @@ -1,5 +1,5 @@ - - + +

    {{$title}} - {{$page}} ({{$count}})

    diff --git a/view/theme/frio/templates/moderation/users/blocked.tpl b/view/theme/frio/templates/moderation/users/blocked.tpl index f2dbc386d0..7e78c1c49f 100644 --- a/view/theme/frio/templates/moderation/users/blocked.tpl +++ b/view/theme/frio/templates/moderation/users/blocked.tpl @@ -1,5 +1,5 @@ - - + +

    {{$title}} - {{$page}} ({{$count}})

    diff --git a/view/theme/frio/templates/moderation/users/deleted.tpl b/view/theme/frio/templates/moderation/users/deleted.tpl index d8501d616f..d191facfa3 100644 --- a/view/theme/frio/templates/moderation/users/deleted.tpl +++ b/view/theme/frio/templates/moderation/users/deleted.tpl @@ -1,5 +1,5 @@ - - + +

    {{$title}} - {{$page}} ({{$count}})

    diff --git a/view/theme/frio/templates/moderation/users/index.tpl b/view/theme/frio/templates/moderation/users/index.tpl index b03d2a540d..ea8279dd60 100644 --- a/view/theme/frio/templates/moderation/users/index.tpl +++ b/view/theme/frio/templates/moderation/users/index.tpl @@ -1,5 +1,5 @@ - - + +

    {{$title}} - {{$page}} ({{$count}})

    diff --git a/view/theme/frio/templates/moderation/users/pending.tpl b/view/theme/frio/templates/moderation/users/pending.tpl index 4960ff00b4..bcded294dd 100644 --- a/view/theme/frio/templates/moderation/users/pending.tpl +++ b/view/theme/frio/templates/moderation/users/pending.tpl @@ -1,5 +1,5 @@ - - + +

    {{$title}} - {{$page}} ({{$count}})

    diff --git a/view/theme/frio/templates/notifications/notifications.tpl b/view/theme/frio/templates/notifications/notifications.tpl index 5a327a063c..58122b516b 100644 --- a/view/theme/frio/templates/notifications/notifications.tpl +++ b/view/theme/frio/templates/notifications/notifications.tpl @@ -1,5 +1,5 @@ - - + +
    {{include file="section_title.tpl" title=$header}} diff --git a/view/theme/frio/templates/photos_head.tpl b/view/theme/frio/templates/photos_head.tpl index 4b460b9dda..657394f53b 100644 --- a/view/theme/frio/templates/photos_head.tpl +++ b/view/theme/frio/templates/photos_head.tpl @@ -1,5 +1,5 @@ - + diff --git a/view/theme/frio/templates/theme_settings.tpl b/view/theme/frio/templates/theme_settings.tpl index 0e10070684..2d6d781c4b 100644 --- a/view/theme/frio/templates/theme_settings.tpl +++ b/view/theme/frio/templates/theme_settings.tpl @@ -1,5 +1,5 @@ - - + +
    diff --git a/view/theme/frio/templates/threaded_conversation.tpl b/view/theme/frio/templates/threaded_conversation.tpl index 6eb687d87b..ca65045578 100644 --- a/view/theme/frio/templates/threaded_conversation.tpl +++ b/view/theme/frio/templates/threaded_conversation.tpl @@ -1,5 +1,5 @@ -{{if !$update}}{{/if}} -{{if $mode == display}}{{/if}} +{{if !$update}}{{/if}} +{{if $mode == display}}{{/if}} {{$live_update nofilter}} {{foreach $threads as $thread}}