3 * @file include/nav.php
6 use Friendica\Content\Feature;
7 use Friendica\Core\Config;
8 use Friendica\Core\System;
9 use Friendica\Database\DBM;
10 use Friendica\Model\Profile;
12 function nav(App $a) {
16 * Build page header and site navigation bars
20 if (!(x($a->page,'nav')))
23 $a->page['htmlhead'] .= replace_macros(get_markup_template('nav_head.tpl'), array());
26 * Placeholder div for popup panel
29 $a->page['nav'] .= '<div id="panel" style="display: none;"></div>' ;
31 $nav_info = nav_info($a);
37 $tpl = get_markup_template('nav.tpl');
39 $a->page['nav'] .= replace_macros($tpl, array(
40 '$baseurl' => System::baseUrl(),
41 '$sitelocation' => $nav_info['sitelocation'],
42 '$nav' => $nav_info['nav'],
43 '$banner' => $nav_info['banner'],
44 '$emptynotifications' => t('Nothing new here'),
45 '$userinfo' => $nav_info['userinfo'],
46 '$sel' => $a->nav_sel,
48 '$clear_notifs' => t('Clear notifications'),
49 '$search_hint' => t('@name, !forum, #tags, content')
52 call_hooks('page_header', $a->page['nav']);
56 * @brief Prepares a list of navigation links
59 * @return array Navigation links
60 * string 'sitelocation' => The webbie (username@site.com)
61 * array 'nav' => Array of links used in the nav menu
62 * string 'banner' => Formatted html link with banner image
63 * array 'userinfo' => Array of user information (name, icon)
65 function nav_info(App $a)
67 $ssl_state = ((local_user()) ? true : false);
70 * Our network is distributed, and as you visit friends some of the
71 * sites look exactly the same - it isn't always easy to know where you are.
72 * Display the current site location as a navigation aid.
75 $myident = ((is_array($a->user) && isset($a->user['nickname'])) ? $a->user['nickname'] . '@' : '');
77 $sitelocation = $myident . substr(System::baseUrl($ssl_state), strpos(System::baseUrl($ssl_state), '//') + 2 );
79 // nav links: array of array('href', 'text', 'extra css classes', 'title')
82 // Display login or logout
83 $nav['usermenu'] = array();
87 $nav['logout'] = array('logout', t('Logout'), '', t('End this session'));
90 $nav['usermenu'][] = array('profile/' . $a->user['nickname'], t('Status'), '', t('Your posts and conversations'));
91 $nav['usermenu'][] = array('profile/' . $a->user['nickname'] . '?tab=profile', t('Profile'), '', t('Your profile page'));
92 $nav['usermenu'][] = array('photos/' . $a->user['nickname'], t('Photos'), '', t('Your photos'));
93 $nav['usermenu'][] = array('videos/' . $a->user['nickname'], t('Videos'), '', t('Your videos'));
94 $nav['usermenu'][] = array('events/', t('Events'), '', t('Your events'));
95 $nav['usermenu'][] = array('notes/', t('Personal notes'), '', t('Your personal notes'));
98 $contact = dba::selectFirst('contact', ['micro'], ['uid' => $a->user['uid'], 'self' => true]);
100 'icon' => (DBM::is_result($contact) ? $a->remove_baseurl($contact['micro']) : 'images/person-48.jpg'),
101 'name' => $a->user['username'],
104 $nav['login'] = array('login', t('Login'), ($a->module == 'login' ? 'selected' : ''), t('Sign in'));
107 // "Home" should also take you home from an authenticated remote profile connection
108 $homelink = Profile::getMyURL();
110 $homelink = ((x($_SESSION, 'visitor_home')) ? $_SESSION['visitor_home'] : '');
113 if (($a->module != 'home') && (! (local_user()))) {
114 $nav['home'] = array($homelink, t('Home'), '', t('Home Page'));
117 if (($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user())) {
118 $nav['register'] = array('register', t('Register'), '', t('Create an account'));
123 if (!Config::get('system', 'hide_help')) {
124 $nav['help'] = array($help_url, t('Help'), '', t('Help and documentation'));
127 if (count($a->apps) > 0) {
128 $nav['apps'] = array('apps', t('Apps'), '', t('Addon applications, utilities, games'));
131 if (local_user() || !Config::get('system', 'local_search')) {
132 $nav['search'] = array('search', t('Search'), '', t('Search site content'));
134 $nav['searchoption'] = array(
139 if (Config::get('system', 'poco_local_search')) {
140 $nav['searchoption'][] = t('Forums');
144 $gdirpath = 'directory';
146 if (strlen(Config::get('system', 'singleuser'))) {
147 $gdir = Config::get('system', 'directory');
149 $gdirpath = Profile::zrl($gdir, true);
153 if (local_user() || Config::get('system', 'community_page_style') != CP_NO_COMMUNITY_PAGE) {
154 $nav['community'] = array('community', t('Community'), '', t('Conversations on this and other servers'));
158 $nav['events'] = array('events', t('Events'), '', t('Events and Calendar'));
161 $nav['directory'] = array($gdirpath, t('Directory'), '', t('People directory'));
163 $nav['about'] = array('friendica', t('Information'), '', t('Information about this friendica instance'));
165 // The following nav links are only show to logged in users
167 $nav['network'] = array('network', t('Network'), '', t('Conversations from your friends'));
168 $nav['net_reset'] = array('network/0?f=&order=comment&nets=all', t('Network Reset'), '', t('Load Network page with no filters'));
170 $nav['home'] = array('profile/' . $a->user['nickname'], t('Home'), '', t('Your posts and conversations'));
172 if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_PRVGROUP))) {
173 // only show friend requests for normal pages. Other page types have automatic friendship.
174 if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_PRVGROUP))) {
175 $nav['introductions'] = array('notifications/intros', t('Introductions'), '', t('Friend Requests'));
177 if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE))) {
178 $nav['notifications'] = array('notifications', t('Notifications'), '', t('Notifications'));
179 $nav['notifications']['all'] = array('notifications/system', t('See all notifications'), '', '');
180 $nav['notifications']['mark'] = array('', t('Mark as seen'), '', t('Mark all system notifications seen'));
184 $nav['messages'] = array('message', t('Messages'), '', t('Private mail'));
185 $nav['messages']['inbox'] = array('message', t('Inbox'), '', t('Inbox'));
186 $nav['messages']['outbox'] = array('message/sent', t('Outbox'), '', t('Outbox'));
187 $nav['messages']['new'] = array('message/new', t('New Message'), '', t('New Message'));
189 if (is_array($a->identities) && count($a->identities) > 1) {
190 $nav['manage'] = array('manage', t('Manage'), '', t('Manage other pages'));
193 $nav['delegations'] = array('delegate', t('Delegations'), '', t('Delegate Page Management'));
195 $nav['settings'] = array('settings', t('Settings'), '', t('Account settings'));
197 if (Feature::isEnabled(local_user(), 'multi_profiles')) {
198 $nav['profiles'] = array('profiles', t('Profiles'), '', t('Manage/Edit Profiles'));
201 $nav['contacts'] = array('contacts', t('Contacts'), '', t('Manage/edit friends and contacts'));
204 // Show the link to the admin configuration page if user is admin
205 if (is_site_admin()) {
206 $nav['admin'] = array('admin/', t('Admin'), '', t('Site setup and configuration'));
209 $nav['navigation'] = array('navigation/', t('Navigation'), '', t('Site map'));
211 // Provide a banner/logo/whatever
212 $banner = Config::get('system', 'banner');
213 if (is_null($banner)) {
214 $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>';
217 call_hooks('nav_info', $nav);
220 'sitelocation' => $sitelocation,
223 'userinfo' => $userinfo,
228 * Set a menu item in navbar as selected
231 function nav_set_selected($item){
239 'introductions' => null,
240 'notifications' => null,
249 $a->nav_sel[$item] = 'selected';