mirror of
https://github.com/friendica/friendica
synced 2024-12-23 07:20:15 +00:00
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
This commit is contained in:
parent
abc0616d33
commit
43638fa29b
3 changed files with 55 additions and 44 deletions
|
@ -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 = '<a href="https://friendi.ca"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="https://friendi.ca">Friendica</a></span>';
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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}}
|
||||
<header>
|
||||
{{* {{$langselector}} *}}
|
||||
|
||||
<div id="site-location">{{$sitelocation}}</div>
|
||||
<div id="banner" class="hidden-sm hidden-xs">
|
||||
{{* show on remote/visitor connections an other logo which symols that fact*}}
|
||||
{{* show on remote/visitor connections an other logo which symbols that fact*}}
|
||||
{{if $nav.remote}}
|
||||
<a href="{{$baseurl}}">
|
||||
<div id="remote-logo-img" aria-label="{{$home}}"></div>
|
||||
|
@ -141,7 +141,6 @@
|
|||
{{if $nav.search}}
|
||||
<li id="search-box" class="hidden-xs">
|
||||
<form class="navbar-form" role="search" method="get" action="{{$nav.search.0}}">
|
||||
<!-- <img class="hidden-xs" src="{{$nav.userinfo.icon}}" alt="{{$nav.userinfo.name}}" style="max-width:33px; max-height:33px; min-width:33px; min-height:33px; width:33px; height:33px;"> -->
|
||||
<div class="form-group form-group-search">
|
||||
<input accesskey="s" id="nav-search-input-field" class="form-control form-search"
|
||||
type="text" name="q" data-toggle="tooltip" title="{{$search_hint}}"
|
||||
|
@ -154,17 +153,17 @@
|
|||
{{/if}}
|
||||
|
||||
{{* The user dropdown menu *}}
|
||||
{{if $nav.userinfo}}
|
||||
{{if $userinfo}}
|
||||
<li id="nav-user-linkmenu" class="dropdown account nav-menu hidden-xs">
|
||||
<button accesskey="u" id="main-menu" class="btn-link dropdown-toggle nav-avatar"
|
||||
data-toggle="dropdown" type="button" aria-haspopup="true" aria-expanded="false"
|
||||
aria-controls="nav-user-menu">
|
||||
<div aria-hidden="true" class="user-title pull-left hidden-xs hidden-sm hidden-md">
|
||||
<strong>{{$nav.userinfo.name}}</strong><br>
|
||||
<strong>{{$userinfo.name}}</strong><br>
|
||||
{{if $nav.remote}}<span class="trunctate">{{$nav.remote}}</span>{{/if}}
|
||||
</div>
|
||||
|
||||
<img id="avatar" src="{{$nav.userinfo.icon}}" alt="{{$nav.userinfo.name}}">
|
||||
<img id="avatar" src="{{$userinfo.icon}}" alt="{{$userinfo.name}}">
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
|
||||
|
@ -300,9 +299,9 @@
|
|||
{{/if}}
|
||||
{{/if}}
|
||||
<li role="presentation" class="list-group-item">
|
||||
<img src="{{$nav.userinfo.icon}}" alt="{{$nav.userinfo.name}}"
|
||||
<img src="{{$userinfo.icon}}" alt="{{$userinfo.name}}"
|
||||
style="max-width:15px; max-height:15px; min-width:15px; min-height:15px; width:15px; height:15px;">
|
||||
{{$nav.userinfo.name}}{{if $nav.remote}} ({{$nav.remote}}){{/if}}
|
||||
{{$userinfo.name}}{{if $nav.remote}} ({{$nav.remote}}){{/if}}
|
||||
</li>
|
||||
{{foreach $nav.usermenu as $usermenu}}
|
||||
<li role="menuitem" class="list-group-item"><a role="menuitem" class="{{$usermenu.2}}"
|
||||
|
@ -369,11 +368,8 @@
|
|||
</div><!-- end of div for navbar width-->
|
||||
</div><!-- /.container -->
|
||||
</nav><!-- /.navbar -->
|
||||
{{/if}}
|
||||
|
||||
|
||||
{{* The navbar for users which are not logged in *}}
|
||||
{{if $nav.userinfo == ''}}
|
||||
{{else}}
|
||||
{{* The navbar for users which are not logged in *}}
|
||||
<nav class="navbar navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header pull-left">
|
||||
|
@ -402,14 +398,12 @@
|
|||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
{{/if}}
|
||||
|
||||
{{* provide a a search input for mobile view, which expands by pressing the search icon *}}
|
||||
<div id="search-mobile" class="hidden-lg hidden-md hidden-sm collapse row well">
|
||||
<div class="col-xs-12">
|
||||
<form class="navbar-form" role="search" method="get" action="{{$nav.search.0}}">
|
||||
<!-- <img class="hidden-xs" src="{{$nav.userinfo.icon}}" alt="{{$nav.userinfo.name}}" style="max-width:33px; max-height:33px; min-width:33px; min-height:33px; width:33px; height:33px;"> -->
|
||||
<div class="form-group form-group-search">
|
||||
<input id="nav-search-input-field-mobile" class="form-control form-search" type="text" name="q"
|
||||
data-toggle="tooltip" title="{{$search_hint}}" placeholder="{{$nav.search.1}}">
|
||||
|
|
|
@ -186,10 +186,11 @@ function frio_contact_photo_menu(App $a, &$args)
|
|||
* Some links will point to the local pages because the user would expect
|
||||
* local page (these pages are: search, community, help, apps, directory).
|
||||
*
|
||||
* @param App $a The App class
|
||||
* @param array $nav The original nav menu
|
||||
* @param App $a The App class
|
||||
* @param array $nav_info The original nav info array: nav, banner, userinfo, sitelocation
|
||||
* @throws Exception
|
||||
*/
|
||||
function frio_remote_nav(App $a, array &$nav)
|
||||
function frio_remote_nav(App $a, array &$nav_info)
|
||||
{
|
||||
// get the homelink from $_XSESSION
|
||||
$homelink = Model\Profile::getMyURL();
|
||||
|
@ -204,16 +205,16 @@ function frio_remote_nav(App $a, array &$nav)
|
|||
$remoteUser = Contact::selectFirst($fields, ['uid' => $a->user['uid'], 'self' => true]);
|
||||
} elseif (!local_user() && remote_user()) {
|
||||
$remoteUser = Contact::getById(remote_user(), $fields);
|
||||
$nav['remote'] = DI::l10n()->t('Guest');
|
||||
$nav_info['nav']['remote'] = DI::l10n()->t('Guest');
|
||||
} elseif (Model\Profile::getMyURL()) {
|
||||
$remoteUser = Contact::getByURL($homelink, null, $fields);
|
||||
$nav['remote'] = DI::l10n()->t('Visitor');
|
||||
$nav_info['nav']['remote'] = DI::l10n()->t('Visitor');
|
||||
} else {
|
||||
$remoteUser = null;
|
||||
}
|
||||
|
||||
if (DBA::isResult($remoteUser)) {
|
||||
$nav['userinfo'] = [
|
||||
$nav_info['userinfo'] = [
|
||||
'icon' => Contact::getMicro($remoteUser),
|
||||
'name' => $remoteUser['name'],
|
||||
];
|
||||
|
@ -222,19 +223,19 @@ function frio_remote_nav(App $a, array &$nav)
|
|||
|
||||
if (!local_user() && !empty($server_url) && !is_null($remoteUser)) {
|
||||
// user menu
|
||||
$nav['usermenu'][] = [$server_url . '/profile/' . $remoteUser['nick'], DI::l10n()->t('Status'), '', DI::l10n()->t('Your posts and conversations')];
|
||||
$nav['usermenu'][] = [$server_url . '/profile/' . $remoteUser['nick'] . '/profile', DI::l10n()->t('Profile'), '', DI::l10n()->t('Your profile page')];
|
||||
$nav['usermenu'][] = [$server_url . '/photos/' . $remoteUser['nick'], DI::l10n()->t('Photos'), '', DI::l10n()->t('Your photos')];
|
||||
$nav['usermenu'][] = [$server_url . '/videos/' . $remoteUser['nick'], DI::l10n()->t('Videos'), '', DI::l10n()->t('Your videos')];
|
||||
$nav['usermenu'][] = [$server_url . '/events/', DI::l10n()->t('Events'), '', DI::l10n()->t('Your events')];
|
||||
$nav_info['nav']['usermenu'][] = [$server_url . '/profile/' . $remoteUser['nick'], DI::l10n()->t('Status'), '', DI::l10n()->t('Your posts and conversations')];
|
||||
$nav_info['nav']['usermenu'][] = [$server_url . '/profile/' . $remoteUser['nick'] . '/profile', DI::l10n()->t('Profile'), '', DI::l10n()->t('Your profile page')];
|
||||
$nav_info['nav']['usermenu'][] = [$server_url . '/photos/' . $remoteUser['nick'], DI::l10n()->t('Photos'), '', DI::l10n()->t('Your photos')];
|
||||
$nav_info['nav']['usermenu'][] = [$server_url . '/videos/' . $remoteUser['nick'], DI::l10n()->t('Videos'), '', DI::l10n()->t('Your videos')];
|
||||
$nav_info['nav']['usermenu'][] = [$server_url . '/events/', DI::l10n()->t('Events'), '', DI::l10n()->t('Your events')];
|
||||
|
||||
// navbar links
|
||||
$nav['network'] = [$server_url . '/network', DI::l10n()->t('Network'), '', DI::l10n()->t('Conversations from your friends')];
|
||||
$nav['events'] = [$server_url . '/events', DI::l10n()->t('Events'), '', DI::l10n()->t('Events and Calendar')];
|
||||
$nav['messages'] = [$server_url . '/message', DI::l10n()->t('Messages'), '', DI::l10n()->t('Private mail')];
|
||||
$nav['settings'] = [$server_url . '/settings', DI::l10n()->t('Settings'), '', DI::l10n()->t('Account settings')];
|
||||
$nav['contacts'] = [$server_url . '/contact', DI::l10n()->t('Contacts'), '', DI::l10n()->t('Manage/edit friends and contacts')];
|
||||
$nav['sitename'] = DI::config()->get('config', 'sitename');
|
||||
$nav_info['nav']['network'] = [$server_url . '/network', DI::l10n()->t('Network'), '', DI::l10n()->t('Conversations from your friends')];
|
||||
$nav_info['nav']['events'] = [$server_url . '/events', DI::l10n()->t('Events'), '', DI::l10n()->t('Events and Calendar')];
|
||||
$nav_info['nav']['messages'] = [$server_url . '/message', DI::l10n()->t('Messages'), '', DI::l10n()->t('Private mail')];
|
||||
$nav_info['nav']['settings'] = [$server_url . '/settings', DI::l10n()->t('Settings'), '', DI::l10n()->t('Account settings')];
|
||||
$nav_info['nav']['contacts'] = [$server_url . '/contact', DI::l10n()->t('Contacts'), '', DI::l10n()->t('Manage/edit friends and contacts')];
|
||||
$nav_info['nav']['sitename'] = DI::config()->get('config', 'sitename');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue