7 * Build page header and site navigation bars
11 if(!(x($a->page,'nav')))
14 $a->page['htmlhead'] .= replace_macros(get_markup_template('nav_head.tpl'), array());
17 * Placeholder div for popup panel
20 $a->page['nav'] .= '<div id="panel" style="display: none;"></div>' ;
22 $nav_info = nav_info($a);
28 $tpl = get_markup_template('nav.tpl');
30 $a->page['nav'] .= replace_macros($tpl, array(
31 '$baseurl' => $a->get_baseurl(),
32 '$sitelocation' => $nav_info['sitelocation'],
33 '$nav' => $nav_info['nav'],
34 '$banner' => $nav_info['banner'],
35 '$emptynotifications' => t('Nothing new here'),
36 '$userinfo' => $nav_info['userinfo'],
37 '$sel' => $a->nav_sel,
39 '$clear_notifs' => t('Clear notifications'),
40 '$search_hint' => t('@name, !forum, #tags, content')
43 call_hooks('page_header', $a->page['nav']);
47 function nav_info(&$a)
49 $ssl_state = ((local_user()) ? true : false);
52 * Our network is distributed, and as you visit friends some of the
53 * sites look exactly the same - it isn't always easy to know where you are.
54 * Display the current site location as a navigation aid.
57 $myident = ((is_array($a->user) && isset($a->user['nickname'])) ? $a->user['nickname'] . '@' : '');
59 $sitelocation = $myident . substr($a->get_baseurl($ssl_state),strpos($a->get_baseurl($ssl_state),'//') + 2 );
61 // nav links: array of array('href', 'text', 'extra css classes', 'title')
64 // Display login or logout
65 $nav['usermenu'] = array();
69 $nav['logout'] = array('logout', t('Logout'), '', t('End this session'));
72 $nav['usermenu'][] = array('profile/' . $a->user['nickname'], t('Status'), '', t('Your posts and conversations'));
73 $nav['usermenu'][] = array('profile/' . $a->user['nickname'] . '?tab=profile', t('Profile'), '', t('Your profile page'));
74 $nav['usermenu'][] = array('photos/' . $a->user['nickname'], t('Photos'), '', t('Your photos'));
75 $nav['usermenu'][] = array('videos/' . $a->user['nickname'], t('Videos'), '', t('Your videos'));
76 $nav['usermenu'][] = array('events/', t('Events'), '', t('Your events'));
77 $nav['usermenu'][] = array('notes/', t('Personal notes'), '', t('Your personal notes'));
80 $r = q("SELECT `micro` FROM `contact` WHERE `uid` = %d AND `self` = 1", intval($a->user['uid']));
82 'icon' => (count($r) ? $a->remove_baseurl($r[0]['micro']) : 'images/person-48.jpg'),
83 'name' => $a->user['username'],
86 $nav['login'] = array('login', t('Login'), ($a->module == 'login' ? 'selected' : ''), t('Sign in'));
89 // "Home" should also take you home from an authenticated remote profile connection
90 $homelink = get_my_url();
92 $homelink = ((x($_SESSION,'visitor_home')) ? $_SESSION['visitor_home'] : '');
95 if (($a->module != 'home') && (! (local_user()))) {
96 $nav['home'] = array($homelink, t('Home'), '', t('Home Page'));
99 if (($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user())) {
100 $nav['register'] = array('register', t('Register'), '', t('Create an account'));
105 if (! get_config('system', 'hide_help')) {
106 $nav['help'] = array($help_url, t('Help'), '', t('Help and documentation'));
109 if (count($a->apps) > 0) {
110 $nav['apps'] = array('apps', t('Apps'), '', t('Addon applications, utilities, games'));
113 if (local_user() OR !get_config('system', 'local_search')) {
114 $nav['search'] = array('search', t('Search'), '', t('Search site content'));
116 $nav['searchoption'] = array(
121 if (get_config('system', 'poco_local_search')) {
122 $nav['searchoption'][] = t('Forums');
126 $gdirpath = 'directory';
128 if (strlen(get_config('system', 'singleuser'))) {
129 $gdir = get_config('system', 'directory');
131 $gdirpath = zrl($gdir, true);
133 } elseif (get_config('system', 'community_page_style') == CP_USERS_ON_SERVER) {
134 $nav['community'] = array('community', t('Community'), '', t('Conversations on this site'));
135 } elseif (get_config('system', 'community_page_style') == CP_GLOBAL_COMMUNITY) {
136 $nav['community'] = array('community', t('Community'), '', t('Conversations on the network'));
140 $nav['events'] = array('events', t('Events'), '', t('Events and Calendar'));
143 $nav['directory'] = array($gdirpath, t('Directory'), '', t('People directory'));
145 $nav['about'] = array('friendica', t('Information'), '', t('Information about this friendica instance'));
147 // The following nav links are only show to logged in users
149 $nav['network'] = array('network', t('Network'), '', t('Conversations from your friends'));
150 $nav['net_reset'] = array('network/0?f=&order=comment&nets=all', t('Network Reset'), '', t('Load Network page with no filters'));
152 $nav['home'] = array('profile/' . $a->user['nickname'], t('Home'), '', t('Your posts and conversations'));
154 if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_PRVGROUP))) {
155 // only show friend requests for normal pages. Other page types have automatic friendship.
156 if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_PRVGROUP))) {
157 $nav['introductions'] = array('notifications/intros', t('Introductions'), '', t('Friend Requests'));
159 if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE))) {
160 $nav['notifications'] = array('notifications', t('Notifications'), '', t('Notifications'));
161 $nav['notifications']['all'] = array('notifications/system', t('See all notifications'), '', '');
162 $nav['notifications']['mark'] = array('', t('Mark as seen'), '', t('Mark all system notifications seen'));
166 $nav['messages'] = array('message', t('Messages'), '', t('Private mail'));
167 $nav['messages']['inbox'] = array('message', t('Inbox'), '', t('Inbox'));
168 $nav['messages']['outbox'] = array('message/sent', t('Outbox'), '', t('Outbox'));
169 $nav['messages']['new'] = array('message/new', t('New Message'), '', t('New Message'));
171 if (is_array($a->identities) && count($a->identities) > 1) {
172 $nav['manage'] = array('manage', t('Manage'), '', t('Manage other pages'));
175 $nav['delegations'] = array('delegate', t('Delegations'), '', t('Delegate Page Management'));
177 $nav['settings'] = array('settings', t('Settings'), '', t('Account settings'));
179 if (feature_enabled(local_user(), 'multi_profiles')) {
180 $nav['profiles'] = array('profiles', t('Profiles'), '', t('Manage/Edit Profiles'));
183 $nav['contacts'] = array('contacts', t('Contacts'), '', t('Manage/edit friends and contacts'));
186 if (is_site_admin()) {
187 $nav['admin'] = array('admin/', t('Admin'), '', t('Site setup and configuration'));
190 $nav['navigation'] = array('navigation/', t('Navigation'), '', t('Site map'));
192 // Provide a banner/logo/whatever
193 $banner = get_config('system', 'banner');
194 if ($banner === false) {
195 $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>';
198 call_hooks('nav_info', $nav);
201 'sitelocation' => $sitelocation,
204 'userinfo' => $userinfo,
210 * Set a menu item in navbar as selected
213 function nav_set_selected($item){
220 'introductions' => null,
221 'notifications' => null,
230 $a->nav_sel[$item] = 'selected';