From 43638fa29b6257aa32bf34890c0e4bc631b17d23 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 10 May 2021 19:03:33 -0400 Subject: [PATCH] Fix undefined variables in nav.tpl - Reworked the nav_info hook to include the rest of the array keys defined in Nav::getInfo - Replaced the theme-specific template variable nav.userinfo with the regular userinfo in frio nav.tpl - Initialized all the nav array keys --- src/Content/Nav.php | 38 ++++++++++++++++++++++--------- view/theme/frio/templates/nav.tpl | 26 ++++++++------------- view/theme/frio/theme.php | 35 ++++++++++++++-------------- 3 files changed, 55 insertions(+), 44 deletions(-) diff --git a/src/Content/Nav.php b/src/Content/Nav.php index 01eac6733..db3fa7863 100644 --- a/src/Content/Nav.php +++ b/src/Content/Nav.php @@ -144,9 +144,9 @@ class Nav * array 'userinfo' => Array of user information (name, icon) * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - private static function getInfo(App $a) + private static function getInfo(App $a): array { - $ssl_state = ((local_user()) ? true : false); + $ssl_state = (bool) local_user(); /* * Our network is distributed, and as you visit friends some of the @@ -158,13 +158,27 @@ class Nav $sitelocation = $myident . substr(DI::baseUrl()->get($ssl_state), strpos(DI::baseUrl()->get($ssl_state), '//') + 2); - // nav links: array of array('href', 'text', 'extra css classes', 'title') - $nav = []; + $nav = [ + 'admin' => null, + 'apps' => null, + 'community' => null, + 'home' => null, + 'events' => null, + 'login' => null, + 'logout' => null, + 'langselector' => null, + 'messages' => null, + 'network' => null, + 'notifications' => null, + 'remote' => null, + 'search' => null, + 'usermenu' => [], + ]; // Display login or logout - $nav['usermenu'] = []; $userinfo = null; + // nav links: array of array('href', 'text', 'extra css classes', 'title') if (Session::isAuthenticated()) { $nav['logout'] = ['logout', DI::l10n()->t('Logout'), '', DI::l10n()->t('End this session')]; } else { @@ -297,13 +311,15 @@ class Nav $banner = 'logoFriendica'; } - Hook::callAll('nav_info', $nav); - - return [ + $nav_info = [ + 'banner' => $banner, + 'nav' => $nav, 'sitelocation' => $sitelocation, - 'nav' => $nav, - 'banner' => $banner, - 'userinfo' => $userinfo, + 'userinfo' => $userinfo, ]; + + Hook::callAll('nav_info', $nav_info); + + return $nav_info; } } diff --git a/view/theme/frio/templates/nav.tpl b/view/theme/frio/templates/nav.tpl index 8e1b25757..915e5e9fc 100644 --- a/view/theme/frio/templates/nav.tpl +++ b/view/theme/frio/templates/nav.tpl @@ -1,11 +1,11 @@ -{{* we have modified the navmenu (look at function frio_remote_nav() ) to have remote links. $nav.userinfo is a new variable and replaces the original $userinfo variable *}} -{{if $nav.userinfo}} +{{* we have modified the navmenu (look at function frio_remote_nav() ) to have remote links. *}} +{{if $userinfo}}
{{* {{$langselector}} *}}
{{$sitelocation}}