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' => App::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 * @brief Prepares a list of navigation links
50 * @return array Navigation links
51 * string 'sitelocation' => The webbie (username@site.com)
52 * array 'nav' => Array of links used in the nav menu
53 * string 'banner' => Formatted html link with banner image
54 * array 'userinfo' => Array of user information (name, icon)
56 function nav_info(App $a)
58 $ssl_state = ((local_user()) ? true : false);
61 * Our network is distributed, and as you visit friends some of the
62 * sites look exactly the same - it isn't always easy to know where you are.
63 * Display the current site location as a navigation aid.
66 $myident = ((is_array($a->user) && isset($a->user['nickname'])) ? $a->user['nickname'] . '@' : '');
68 $sitelocation = $myident . substr(App::get_baseurl($ssl_state), strpos(App::get_baseurl($ssl_state), '//') + 2 );
70 // nav links: array of array('href', 'text', 'extra css classes', 'title')
73 // Display login or logout
74 $nav['usermenu'] = array();
78 $nav['logout'] = array('logout', t('Logout'), '', t('End this session'));
81 $nav['usermenu'][] = array('profile/' . $a->user['nickname'], t('Status'), '', t('Your posts and conversations'));
82 $nav['usermenu'][] = array('profile/' . $a->user['nickname'] . '?tab=profile', t('Profile'), '', t('Your profile page'));
83 $nav['usermenu'][] = array('photos/' . $a->user['nickname'], t('Photos'), '', t('Your photos'));
84 $nav['usermenu'][] = array('videos/' . $a->user['nickname'], t('Videos'), '', t('Your videos'));
85 $nav['usermenu'][] = array('events/', t('Events'), '', t('Your events'));
86 $nav['usermenu'][] = array('notes/', t('Personal notes'), '', t('Your personal notes'));
89 $r = q("SELECT `micro` FROM `contact` WHERE `uid` = %d AND `self` = 1", intval($a->user['uid']));
91 'icon' => (dbm::is_result($r) ? $a->remove_baseurl($r[0]['micro']) : 'images/person-48.jpg'),
92 'name' => $a->user['username'],
95 $nav['login'] = array('login', t('Login'), ($a->module == 'login' ? 'selected' : ''), t('Sign in'));
98 // "Home" should also take you home from an authenticated remote profile connection
99 $homelink = get_my_url();
101 $homelink = ((x($_SESSION,'visitor_home')) ? $_SESSION['visitor_home'] : '');
104 if (($a->module != 'home') && (! (local_user()))) {
105 $nav['home'] = array($homelink, t('Home'), '', t('Home Page'));
108 if (($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user())) {
109 $nav['register'] = array('register', t('Register'), '', t('Create an account'));
114 if (! get_config('system', 'hide_help')) {
115 $nav['help'] = array($help_url, t('Help'), '', t('Help and documentation'));
118 if (count($a->apps) > 0) {
119 $nav['apps'] = array('apps', t('Apps'), '', t('Addon applications, utilities, games'));
122 if (local_user() OR !get_config('system', 'local_search')) {
123 $nav['search'] = array('search', t('Search'), '', t('Search site content'));
125 $nav['searchoption'] = array(
130 if (get_config('system', 'poco_local_search')) {
131 $nav['searchoption'][] = t('Forums');
135 $gdirpath = 'directory';
137 if (strlen(get_config('system', 'singleuser'))) {
138 $gdir = get_config('system', 'directory');
140 $gdirpath = zrl($gdir, true);
142 } elseif (get_config('system', 'community_page_style') == CP_USERS_ON_SERVER) {
143 $nav['community'] = array('community', t('Community'), '', t('Conversations on this site'));
144 } elseif (get_config('system', 'community_page_style') == CP_GLOBAL_COMMUNITY) {
145 $nav['community'] = array('community', t('Community'), '', t('Conversations on the network'));
149 $nav['events'] = array('events', t('Events'), '', t('Events and Calendar'));
152 $nav['directory'] = array($gdirpath, t('Directory'), '', t('People directory'));
154 $nav['about'] = array('friendica', t('Information'), '', t('Information about this friendica instance'));
156 // The following nav links are only show to logged in users
158 $nav['network'] = array('network', t('Network'), '', t('Conversations from your friends'));
159 $nav['net_reset'] = array('network/0?f=&order=comment&nets=all', t('Network Reset'), '', t('Load Network page with no filters'));
161 $nav['home'] = array('profile/' . $a->user['nickname'], t('Home'), '', t('Your posts and conversations'));
163 if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_PRVGROUP))) {
164 // only show friend requests for normal pages. Other page types have automatic friendship.
165 if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_PRVGROUP))) {
166 $nav['introductions'] = array('notifications/intros', t('Introductions'), '', t('Friend Requests'));
168 if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE))) {
169 $nav['notifications'] = array('notifications', t('Notifications'), '', t('Notifications'));
170 $nav['notifications']['all'] = array('notifications/system', t('See all notifications'), '', '');
171 $nav['notifications']['mark'] = array('', t('Mark as seen'), '', t('Mark all system notifications seen'));
175 $nav['messages'] = array('message', t('Messages'), '', t('Private mail'));
176 $nav['messages']['inbox'] = array('message', t('Inbox'), '', t('Inbox'));
177 $nav['messages']['outbox'] = array('message/sent', t('Outbox'), '', t('Outbox'));
178 $nav['messages']['new'] = array('message/new', t('New Message'), '', t('New Message'));
180 if (is_array($a->identities) && count($a->identities) > 1) {
181 $nav['manage'] = array('manage', t('Manage'), '', t('Manage other pages'));
184 $nav['delegations'] = array('delegate', t('Delegations'), '', t('Delegate Page Management'));
186 $nav['settings'] = array('settings', t('Settings'), '', t('Account settings'));
188 if (feature_enabled(local_user(), 'multi_profiles')) {
189 $nav['profiles'] = array('profiles', t('Profiles'), '', t('Manage/Edit Profiles'));
192 $nav['contacts'] = array('contacts', t('Contacts'), '', t('Manage/edit friends and contacts'));
195 // Show the link to the admin configuration page if user is admin
196 if (is_site_admin()) {
197 $nav['admin'] = array('admin/', t('Admin'), '', t('Site setup and configuration'));
200 $nav['navigation'] = array('navigation/', t('Navigation'), '', t('Site map'));
202 // Provide a banner/logo/whatever
203 $banner = get_config('system', 'banner');
204 if ($banner === false) {
205 $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>';
208 call_hooks('nav_info', $nav);
211 'sitelocation' => $sitelocation,
214 'userinfo' => $userinfo,
219 * Set a menu item in navbar as selected
222 function nav_set_selected($item){
229 'introductions' => null,
230 'notifications' => null,
239 $a->nav_sel[$item] = 'selected';