]> git.mxchange.org Git - friendica.git/blob - include/nav.php
Fix Issue #2803 - Hovercard view profile link and public directory link
[friendica.git] / include / nav.php
1 <?php
2
3 function nav(&$a) {
4
5         /*
6          *
7          * Build page header and site navigation bars
8          *
9          */
10
11         if(!(x($a->page,'nav')))
12                 $a->page['nav'] = '';
13
14         $a->page['htmlhead'] .= replace_macros(get_markup_template('nav_head.tpl'), array());
15
16         /*
17          * Placeholder div for popup panel
18          */
19
20         $a->page['nav'] .= '<div id="panel" style="display: none;"></div>' ;
21
22         $nav_info = nav_info($a);
23
24         /*
25          * Build the page
26          */
27
28         $tpl = get_markup_template('nav.tpl');
29
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,
38                 '$apps' => $a->apps,
39                 '$clear_notifs' => t('Clear notifications'),
40                 '$search_hint' => t('@name, !forum, #tags, content')
41         ));
42
43         call_hooks('page_header', $a->page['nav']);
44 }
45
46
47 function nav_info(&$a)
48 {
49         $ssl_state = ((local_user()) ? true : false);
50
51         /*
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.
55          */
56
57         $myident = ((is_array($a->user) && isset($a->user['nickname'])) ? $a->user['nickname'] . '@' : '');
58
59         $sitelocation = $myident . substr($a->get_baseurl($ssl_state),strpos($a->get_baseurl($ssl_state),'//') + 2 );
60
61         // nav links: array of array('href', 'text', 'extra css classes', 'title')
62         $nav = array();
63
64         // Display login or logout
65         $nav['usermenu'] = array();
66         $userinfo = null;
67
68         if (local_user()) {
69                 $nav['logout'] = array('logout', t('Logout'), '', t('End this session'));
70
71                 // user menu
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'));
78
79                 // user info
80                 $r = q("SELECT `micro` FROM `contact` WHERE `uid` = %d AND `self` = 1", intval($a->user['uid']));
81                 $userinfo = array(
82                         'icon' => (count($r) ? $a->remove_baseurl($r[0]['micro']) : 'images/person-48.jpg'),
83                         'name' => $a->user['username'],
84                 );
85         } else {
86                 $nav['login'] = array('login', t('Login'), ($a->module == 'login' ? 'selected' : ''), t('Sign in'));
87         }
88
89     // "Home" should also take you home from an authenticated remote profile connection
90         $homelink = get_my_url();
91         if (! $homelink) {
92                 $homelink = ((x($_SESSION,'visitor_home')) ? $_SESSION['visitor_home'] : '');
93         }
94
95         if (($a->module != 'home') && (! (local_user()))) {
96                 $nav['home'] = array($homelink, t('Home'), '', t('Home Page'));
97         }
98
99         if (($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user())) {
100                 $nav['register'] = array('register', t('Register'), '', t('Create an account'));
101         }
102
103         $help_url = 'help';
104
105         if (! get_config('system', 'hide_help')) {
106                 $nav['help'] = array($help_url, t('Help'), '', t('Help and documentation'));
107         }
108
109         if (count($a->apps) > 0) {
110                 $nav['apps'] = array('apps', t('Apps'), '', t('Addon applications, utilities, games'));
111         }
112
113         if (local_user() OR !get_config('system', 'local_search')) {
114                 $nav['search'] = array('search', t('Search'), '', t('Search site content'));
115
116                 $nav['searchoption'] = array(
117                                                 t('Full Text'),
118                                                 t('Tags'),
119                                                 t('Contacts'));
120
121                 if (get_config('system', 'poco_local_search')) {
122                         $nav['searchoption'][] = t('Forums');
123                 }
124         }
125
126         $gdirpath = 'directory';
127
128         if (strlen(get_config('system', 'singleuser'))) {
129                 $gdir = get_config('system', 'directory');
130                 if(strlen($gdir)) {
131                         $gdirpath = zrl($gdir, true);
132                 }
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'));
137         }
138
139         if (local_user()) {
140                 $nav['events'] = array('events', t('Events'), '', t('Events and Calendar'));
141         }
142
143         $nav['directory'] = array($gdirpath, t('Directory'), '', t('People directory'));
144
145         $nav['about'] = array('friendica', t('Information'), '', t('Information about this friendica instance'));
146
147         // The following nav links are only show to logged in users
148         if (local_user()) {
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'));
151
152                 $nav['home'] = array('profile/' . $a->user['nickname'], t('Home'), '', t('Your posts and conversations'));
153
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'));
158                         }
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'));
163                         }
164                 }
165
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'));
170
171                 if (is_array($a->identities) && count($a->identities) > 1) {
172                         $nav['manage'] = array('manage', t('Manage'), '', t('Manage other pages'));
173                 }
174
175                 $nav['delegations'] = array('delegate', t('Delegations'), '', t('Delegate Page Management'));
176
177                 $nav['settings'] = array('settings', t('Settings'), '', t('Account settings'));
178
179                 if (feature_enabled(local_user(), 'multi_profiles')) {
180                         $nav['profiles'] = array('profiles', t('Profiles'), '', t('Manage/Edit Profiles'));
181                 }
182
183                 $nav['contacts'] = array('contacts', t('Contacts'), '', t('Manage/edit friends and contacts'));
184         }
185
186         if (is_site_admin()) {
187                 $nav['admin'] = array('admin/', t('Admin'), '', t('Site setup and configuration'));
188         }
189
190         $nav['navigation'] = array('navigation/', t('Navigation'), '', t('Site map'));
191
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>';
196         }
197
198         call_hooks('nav_info', $nav);
199
200         return array(
201                 'sitelocation' => $sitelocation,
202                 'nav' => $nav,
203                 'banner' => $banner,
204                 'userinfo' => $userinfo,
205         );
206 }
207
208
209 /**
210  * Set a menu item in navbar as selected
211  *
212  */
213 function nav_set_selected($item){
214         $a = get_app();
215         $a->nav_sel = array(
216                 'community'     => null,
217                 'network'       => null,
218                 'home'          => null,
219                 'profiles'      => null,
220                 'introductions' => null,
221                 'notifications' => null,
222                 'messages'      => null,
223                 'directory'     => null,
224                 'settings'      => null,
225                 'contacts'      => null,
226                 'manage'        => null,
227                 'events'        => null,
228                 'register'      => null,
229         );
230         $a->nav_sel[$item] = 'selected';
231 }