9 * Build page header and site navigation bars
13 if (!(x($a->page,'nav')))
16 $a->page['htmlhead'] .= replace_macros(get_markup_template('nav_head.tpl'), array());
19 * Placeholder div for popup panel
22 $a->page['nav'] .= '<div id="panel" style="display: none;"></div>' ;
24 $nav_info = nav_info($a);
30 $tpl = get_markup_template('nav.tpl');
32 $a->page['nav'] .= replace_macros($tpl, array(
33 '$baseurl' => App::get_baseurl(),
34 '$sitelocation' => $nav_info['sitelocation'],
35 '$nav' => $nav_info['nav'],
36 '$banner' => $nav_info['banner'],
37 '$emptynotifications' => t('Nothing new here'),
38 '$userinfo' => $nav_info['userinfo'],
39 '$sel' => $a->nav_sel,
41 '$clear_notifs' => t('Clear notifications'),
42 '$search_hint' => t('@name, !forum, #tags, content')
45 call_hooks('page_header', $a->page['nav']);
49 * @brief Prepares a list of navigation links
52 * @return array Navigation links
53 * string 'sitelocation' => The webbie (username@site.com)
54 * array 'nav' => Array of links used in the nav menu
55 * string 'banner' => Formatted html link with banner image
56 * array 'userinfo' => Array of user information (name, icon)
58 function nav_info(App $a)
60 $ssl_state = ((local_user()) ? true : false);
63 * Our network is distributed, and as you visit friends some of the
64 * sites look exactly the same - it isn't always easy to know where you are.
65 * Display the current site location as a navigation aid.
68 $myident = ((is_array($a->user) && isset($a->user['nickname'])) ? $a->user['nickname'] . '@' : '');
70 $sitelocation = $myident . substr(App::get_baseurl($ssl_state), strpos(App::get_baseurl($ssl_state), '//') + 2 );
72 // nav links: array of array('href', 'text', 'extra css classes', 'title')
75 // Display login or logout
76 $nav['usermenu'] = array();
80 $nav['logout'] = array('logout', t('Logout'), '', t('End this session'));
83 $nav['usermenu'][] = array('profile/' . $a->user['nickname'], t('Status'), '', t('Your posts and conversations'));
84 $nav['usermenu'][] = array('profile/' . $a->user['nickname'] . '?tab=profile', t('Profile'), '', t('Your profile page'));
85 $nav['usermenu'][] = array('photos/' . $a->user['nickname'], t('Photos'), '', t('Your photos'));
86 $nav['usermenu'][] = array('videos/' . $a->user['nickname'], t('Videos'), '', t('Your videos'));
87 $nav['usermenu'][] = array('events/', t('Events'), '', t('Your events'));
88 $nav['usermenu'][] = array('notes/', t('Personal notes'), '', t('Your personal notes'));
91 $r = dba::select('contact', array('micro'), array('uid' => $a->user['uid'], 'self' => true), array('limit' => 1));
93 'icon' => (dbm::is_result($r) ? $a->remove_baseurl($r['micro']) : 'images/person-48.jpg'),
94 'name' => $a->user['username'],
97 $nav['login'] = array('login', t('Login'), ($a->module == 'login' ? 'selected' : ''), t('Sign in'));
100 // "Home" should also take you home from an authenticated remote profile connection
101 $homelink = get_my_url();
103 $homelink = ((x($_SESSION,'visitor_home')) ? $_SESSION['visitor_home'] : '');
106 if (($a->module != 'home') && (! (local_user()))) {
107 $nav['home'] = array($homelink, t('Home'), '', t('Home Page'));
110 if (($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user())) {
111 $nav['register'] = array('register', t('Register'), '', t('Create an account'));
116 if (! get_config('system', 'hide_help')) {
117 $nav['help'] = array($help_url, t('Help'), '', t('Help and documentation'));
120 if (count($a->apps) > 0) {
121 $nav['apps'] = array('apps', t('Apps'), '', t('Addon applications, utilities, games'));
124 if (local_user() OR !get_config('system', 'local_search')) {
125 $nav['search'] = array('search', t('Search'), '', t('Search site content'));
127 $nav['searchoption'] = array(
132 if (get_config('system', 'poco_local_search')) {
133 $nav['searchoption'][] = t('Forums');
137 $gdirpath = 'directory';
139 if (strlen(get_config('system', 'singleuser'))) {
140 $gdir = get_config('system', 'directory');
142 $gdirpath = zrl($gdir, true);
144 } elseif (get_config('system', 'community_page_style') == CP_USERS_ON_SERVER) {
145 $nav['community'] = array('community', t('Community'), '', t('Conversations on this site'));
146 } elseif (get_config('system', 'community_page_style') == CP_GLOBAL_COMMUNITY) {
147 $nav['community'] = array('community', t('Community'), '', t('Conversations on the network'));
151 $nav['events'] = array('events', t('Events'), '', t('Events and Calendar'));
154 $nav['directory'] = array($gdirpath, t('Directory'), '', t('People directory'));
156 $nav['about'] = array('friendica', t('Information'), '', t('Information about this friendica instance'));
158 // The following nav links are only show to logged in users
160 $nav['network'] = array('network', t('Network'), '', t('Conversations from your friends'));
161 $nav['net_reset'] = array('network/0?f=&order=comment&nets=all', t('Network Reset'), '', t('Load Network page with no filters'));
163 $nav['home'] = array('profile/' . $a->user['nickname'], t('Home'), '', t('Your posts and conversations'));
165 if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_PRVGROUP))) {
166 // only show friend requests for normal pages. Other page types have automatic friendship.
167 if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_PRVGROUP))) {
168 $nav['introductions'] = array('notifications/intros', t('Introductions'), '', t('Friend Requests'));
170 if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE))) {
171 $nav['notifications'] = array('notifications', t('Notifications'), '', t('Notifications'));
172 $nav['notifications']['all'] = array('notifications/system', t('See all notifications'), '', '');
173 $nav['notifications']['mark'] = array('', t('Mark as seen'), '', t('Mark all system notifications seen'));
177 $nav['messages'] = array('message', t('Messages'), '', t('Private mail'));
178 $nav['messages']['inbox'] = array('message', t('Inbox'), '', t('Inbox'));
179 $nav['messages']['outbox'] = array('message/sent', t('Outbox'), '', t('Outbox'));
180 $nav['messages']['new'] = array('message/new', t('New Message'), '', t('New Message'));
182 if (is_array($a->identities) && count($a->identities) > 1) {
183 $nav['manage'] = array('manage', t('Manage'), '', t('Manage other pages'));
186 $nav['delegations'] = array('delegate', t('Delegations'), '', t('Delegate Page Management'));
188 $nav['settings'] = array('settings', t('Settings'), '', t('Account settings'));
190 if (feature_enabled(local_user(), 'multi_profiles')) {
191 $nav['profiles'] = array('profiles', t('Profiles'), '', t('Manage/Edit Profiles'));
194 $nav['contacts'] = array('contacts', t('Contacts'), '', t('Manage/edit friends and contacts'));
197 // Show the link to the admin configuration page if user is admin
198 if (is_site_admin()) {
199 $nav['admin'] = array('admin/', t('Admin'), '', t('Site setup and configuration'));
202 $nav['navigation'] = array('navigation/', t('Navigation'), '', t('Site map'));
204 // Provide a banner/logo/whatever
205 $banner = get_config('system', 'banner');
206 if ($banner === false) {
207 $banner = '<a href="http://friendica.com"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="http://friendica.com">Friendica</a></span>';
210 call_hooks('nav_info', $nav);
213 'sitelocation' => $sitelocation,
216 'userinfo' => $userinfo,
221 * Set a menu item in navbar as selected
224 function nav_set_selected($item){
231 'introductions' => null,
232 'notifications' => null,
241 $a->nav_sel[$item] = 'selected';