3 * @file src/Content/Nav.php
5 namespace Friendica\Content;
8 use Friendica\Content\Feature;
9 use Friendica\Core\Config;
10 use Friendica\Core\System;
11 use Friendica\Database\DBM;
12 use Friendica\Model\Profile;
20 * Build page header and site navigation bars
24 if (!(x($a->page, 'nav'))) {
28 $a->page['htmlhead'] .= replace_macros(get_markup_template('nav_head.tpl'), array());
31 * Placeholder div for popup panel
34 $a->page['nav'] .= '<div id="panel" style="display: none;"></div>' ;
36 $nav_info = nav_info($a);
42 $tpl = get_markup_template('nav.tpl');
44 $a->page['nav'] .= replace_macros($tpl, array(
45 '$baseurl' => System::baseUrl(),
46 '$sitelocation' => $nav_info['sitelocation'],
47 '$nav' => $nav_info['nav'],
48 '$banner' => $nav_info['banner'],
49 '$emptynotifications' => t('Nothing new here'),
50 '$userinfo' => $nav_info['userinfo'],
51 '$sel' => $a->nav_sel,
53 '$clear_notifs' => t('Clear notifications'),
54 '$search_hint' => t('@name, !forum, #tags, content')
57 call_hooks('page_header', $a->page['nav']);
61 * @brief Prepares a list of navigation links
64 * @return array Navigation links
65 * string 'sitelocation' => The webbie (username@site.com)
66 * array 'nav' => Array of links used in the nav menu
67 * string 'banner' => Formatted html link with banner image
68 * array 'userinfo' => Array of user information (name, icon)
70 function nav_info(App $a)
72 $ssl_state = ((local_user()) ? true : false);
75 * Our network is distributed, and as you visit friends some of the
76 * sites look exactly the same - it isn't always easy to know where you are.
77 * Display the current site location as a navigation aid.
80 $myident = ((is_array($a->user) && isset($a->user['nickname'])) ? $a->user['nickname'] . '@' : '');
82 $sitelocation = $myident . substr(System::baseUrl($ssl_state), strpos(System::baseUrl($ssl_state), '//') + 2);
84 // nav links: array of array('href', 'text', 'extra css classes', 'title')
87 // Display login or logout
88 $nav['usermenu'] = array();
92 $nav['logout'] = array('logout', t('Logout'), '', t('End this session'));
95 $nav['usermenu'][] = array('profile/' . $a->user['nickname'], t('Status'), '', t('Your posts and conversations'));
96 $nav['usermenu'][] = array('profile/' . $a->user['nickname'] . '?tab=profile', t('Profile'), '', t('Your profile page'));
97 $nav['usermenu'][] = array('photos/' . $a->user['nickname'], t('Photos'), '', t('Your photos'));
98 $nav['usermenu'][] = array('videos/' . $a->user['nickname'], t('Videos'), '', t('Your videos'));
99 $nav['usermenu'][] = array('events/', t('Events'), '', t('Your events'));
100 $nav['usermenu'][] = array('notes/', t('Personal notes'), '', t('Your personal notes'));
103 $contact = dba::selectFirst('contact', ['micro'], ['uid' => $a->user['uid'], 'self' => true]);
105 'icon' => (DBM::is_result($contact) ? $a->remove_baseurl($contact['micro']) : 'images/person-48.jpg'),
106 'name' => $a->user['username'],
109 $nav['login'] = array('login', t('Login'), ($a->module == 'login' ? 'selected' : ''), t('Sign in'));
112 // "Home" should also take you home from an authenticated remote profile connection
113 $homelink = Profile::getMyURL();
115 $homelink = ((x($_SESSION, 'visitor_home')) ? $_SESSION['visitor_home'] : '');
118 if (($a->module != 'home') && (! (local_user()))) {
119 $nav['home'] = array($homelink, t('Home'), '', t('Home Page'));
122 if (($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user())) {
123 $nav['register'] = array('register', t('Register'), '', t('Create an account'));
128 if (!Config::get('system', 'hide_help')) {
129 $nav['help'] = array($help_url, t('Help'), '', t('Help and documentation'));
132 if (count($a->apps) > 0) {
133 $nav['apps'] = array('apps', t('Apps'), '', t('Addon applications, utilities, games'));
136 if (local_user() || !Config::get('system', 'local_search')) {
137 $nav['search'] = array('search', t('Search'), '', t('Search site content'));
139 $nav['searchoption'] = array(
144 if (Config::get('system', 'poco_local_search')) {
145 $nav['searchoption'][] = t('Forums');
149 $gdirpath = 'directory';
151 if (strlen(Config::get('system', 'singleuser'))) {
152 $gdir = Config::get('system', 'directory');
154 $gdirpath = Profile::zrl($gdir, true);
158 if (local_user() || Config::get('system', 'community_page_style') != CP_NO_COMMUNITY_PAGE) {
159 $nav['community'] = array('community', t('Community'), '', t('Conversations on this and other servers'));
163 $nav['events'] = array('events', t('Events'), '', t('Events and Calendar'));
166 $nav['directory'] = array($gdirpath, t('Directory'), '', t('People directory'));
168 $nav['about'] = array('friendica', t('Information'), '', t('Information about this friendica instance'));
170 // The following nav links are only show to logged in users
172 $nav['network'] = array('network', t('Network'), '', t('Conversations from your friends'));
173 $nav['net_reset'] = array('network/0?f=&order=comment&nets=all', t('Network Reset'), '', t('Load Network page with no filters'));
175 $nav['home'] = array('profile/' . $a->user['nickname'], t('Home'), '', t('Your posts and conversations'));
177 if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_PRVGROUP))) {
178 // only show friend requests for normal pages. Other page types have automatic friendship.
179 if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_PRVGROUP))) {
180 $nav['introductions'] = array('notifications/intros', t('Introductions'), '', t('Friend Requests'));
182 if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE))) {
183 $nav['notifications'] = array('notifications', t('Notifications'), '', t('Notifications'));
184 $nav['notifications']['all'] = array('notifications/system', t('See all notifications'), '', '');
185 $nav['notifications']['mark'] = array('', t('Mark as seen'), '', t('Mark all system notifications seen'));
189 $nav['messages'] = array('message', t('Messages'), '', t('Private mail'));
190 $nav['messages']['inbox'] = array('message', t('Inbox'), '', t('Inbox'));
191 $nav['messages']['outbox'] = array('message/sent', t('Outbox'), '', t('Outbox'));
192 $nav['messages']['new'] = array('message/new', t('New Message'), '', t('New Message'));
194 if (is_array($a->identities) && count($a->identities) > 1) {
195 $nav['manage'] = array('manage', t('Manage'), '', t('Manage other pages'));
198 $nav['delegations'] = array('delegate', t('Delegations'), '', t('Delegate Page Management'));
200 $nav['settings'] = array('settings', t('Settings'), '', t('Account settings'));
202 if (Feature::isEnabled(local_user(), 'multi_profiles')) {
203 $nav['profiles'] = array('profiles', t('Profiles'), '', t('Manage/Edit Profiles'));
206 $nav['contacts'] = array('contacts', t('Contacts'), '', t('Manage/edit friends and contacts'));
209 // Show the link to the admin configuration page if user is admin
210 if (is_site_admin()) {
211 $nav['admin'] = array('admin/', t('Admin'), '', t('Site setup and configuration'));
214 $nav['navigation'] = array('navigation/', t('Navigation'), '', t('Site map'));
216 // Provide a banner/logo/whatever
217 $banner = Config::get('system', 'banner');
218 if (is_null($banner)) {
219 $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>';
222 call_hooks('nav_info', $nav);
225 'sitelocation' => $sitelocation,
228 'userinfo' => $userinfo,
233 * Set a menu item in navbar as selected
236 function nav_set_selected($item)
245 'introductions' => null,
246 'notifications' => null,
255 $a->nav_sel[$item] = 'selected';