]> git.mxchange.org Git - friendica.git/blob - include/nav.php
Merge pull request #2158 from annando/1512-vier-fonts
[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         /**
15          * Placeholder div for popup panel
16          */
17
18         $a->page['nav'] .= '<div id="panel" style="display: none;"></div>' ;
19
20         $nav_info = nav_info($a);
21
22         /**
23          * Build the page
24          */
25
26         $tpl = get_markup_template('nav.tpl');
27
28         $a->page['nav'] .= replace_macros($tpl, array(
29                 '$baseurl' => $a->get_baseurl(),
30                 '$sitelocation' => $nav_info['sitelocation'],
31                 '$nav' => $nav_info['nav'],
32                 '$banner' =>  $nav_info['banner'],
33                 '$emptynotifications' => t('Nothing new here'),
34                 '$userinfo' => $nav_info['userinfo'],
35                 '$sel' =>       $a->nav_sel,
36                 '$apps' => $a->apps,
37                 '$clear_notifs' => t('Clear notifications')
38         ));
39
40         call_hooks('page_header', $a->page['nav']);
41 }
42
43
44 function nav_info(&$a) {
45
46         $ssl_state = ((local_user()) ? true : false);
47
48         /**
49          *
50          * Our network is distributed, and as you visit friends some of the
51          * sites look exactly the same - it isn't always easy to know where you are.
52          * Display the current site location as a navigation aid.
53          *
54          */
55
56         $myident = ((is_array($a->user) && isset($a->user['nickname'])) ? $a->user['nickname'] . '@' : '');
57
58         $sitelocation = $myident . substr($a->get_baseurl($ssl_state),strpos($a->get_baseurl($ssl_state),'//') + 2 );
59
60
61         // nav links: array of array('href', 'text', 'extra css classes', 'title')
62         $nav = Array();
63
64         /**
65          * Display login or logout
66          */
67
68         $nav['usermenu']=array();
69         $userinfo = null;
70
71         if(local_user()) {
72                 $nav['logout'] = Array('logout',t('Logout'), "", t('End this session'));
73
74                 // user menu
75                 $nav['usermenu'][] = Array('profile/' . $a->user['nickname'], t('Status'), "", t('Your posts and conversations'));
76                 $nav['usermenu'][] = Array('profile/' . $a->user['nickname']. '?tab=profile', t('Profile'), "", t('Your profile page'));
77                 $nav['usermenu'][] = Array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos'));
78                 $nav['usermenu'][] = Array('videos/' . $a->user['nickname'], t('Videos'), "", t('Your videos'));
79                 $nav['usermenu'][] = Array('events/', t('Events'), "", t('Your events'));
80                 $nav['usermenu'][] = Array('notes/', t('Personal notes'), "", t('Your personal notes'));
81
82                 // user info
83                 $r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid']));
84                 $userinfo = array(
85                         'icon' => (count($r) ? $a->get_cached_avatar_image($r[0]['micro']) : $a->get_baseurl($ssl_state)."/images/person-48.jpg"),
86                         'name' => $a->user['username'],
87                 );
88
89         }
90         else {
91                 $nav['login'] = Array('login',t('Login'), ($a->module == 'login'?'selected':''), t('Sign in'));
92         }
93
94
95         /**
96          * "Home" should also take you home from an authenticated remote profile connection
97          */
98
99         $homelink = get_my_url();
100         if(! $homelink)
101                 $homelink = ((x($_SESSION,'visitor_home')) ? $_SESSION['visitor_home'] : '');
102
103         if(($a->module != 'home') && (! (local_user())))
104                 $nav['home'] = array($homelink, t('Home'), "", t('Home Page'));
105
106
107         if(($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user()))
108                 $nav['register'] = array('register',t('Register'), "", t('Create an account'));
109
110         $help_url = $a->get_baseurl($ssl_state) . '/help';
111
112         if(! get_config('system','hide_help'))
113                 $nav['help'] = array($help_url, t('Help'), "", t('Help and documentation'));
114
115         if(count($a->apps)>0)
116                 $nav['apps'] = array('apps', t('Apps'), "", t('Addon applications, utilities, games'));
117
118         $nav['search'] = array('search', t('Search'), "", t('Search site content'));
119
120         $nav['searchoption'] = array(
121                                         t("Full Text"),
122                                         t("Tags"),
123                                         t("Contacts"));
124
125         if (get_config('system','poco_local_search'))
126                 $nav['searchoption'][] = t("Forums");
127
128         $gdirpath = 'directory';
129
130         if(strlen(get_config('system','singleuser'))) {
131                 $gdir = get_config('system','directory');
132                 if(strlen($gdir))
133                         $gdirpath = $gdir;
134         }
135         elseif(get_config('system','community_page_style') == CP_USERS_ON_SERVER)
136                 $nav['community'] = array('community', t('Community'), "", t('Conversations on this site'));
137         elseif(get_config('system','community_page_style') == CP_GLOBAL_COMMUNITY)
138                 $nav['community'] = array('community', t('Community'), "", t('Conversations on the network'));
139
140         $nav['events'] = Array('events', t('Events'), "", t('Events and Calendar'));
141
142         $nav['directory'] = array($gdirpath, t('Directory'), "", t('People directory'));
143
144         $nav['about'] = Array('friendica', t('Information'), "", t('Information about this friendica instance'));
145
146         /**
147          *
148          * The following nav links are only show to logged in users
149          *
150          */
151
152         if(local_user()) {
153
154                 $nav['network'] = array('network', t('Network'), "", t('Conversations from your friends'));
155                 $nav['net_reset'] = array('network/0?f=&order=comment&nets=all', t('Network Reset'), "", t('Load Network page with no filters'));
156
157                 $nav['home'] = array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations'));
158
159                 if(in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_PRVGROUP))) {
160                         /* only show friend requests for normal pages. Other page types have automatic friendship. */
161                         if(in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_PRVGROUP)))
162                                 $nav['introductions'] = array('notifications/intros',   t('Introductions'), "", t('Friend Requests'));
163
164                         if(in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE))) {
165                                 $nav['notifications'] = array('notifications',  t('Notifications'), "", t('Notifications'));
166                                 $nav['notifications']['all']=array('notifications/system', t('See all notifications'), "", "");
167                                 $nav['notifications']['mark'] = array('', t('Mark all system notifications seen'), '','');
168                         }
169                 }
170
171                 $nav['messages'] = array('message', t('Messages'), "", t('Private mail'));
172                 $nav['messages']['inbox'] = array('message', t('Inbox'), "", t('Inbox'));
173                 $nav['messages']['outbox']= array('message/sent', t('Outbox'), "", t('Outbox'));
174                 $nav['messages']['new'] = array('message/new', t('New Message'), "", t('New Message'));
175
176                 if(is_array($a->identities) && count($a->identities) > 1) {
177                         $nav['manage'] = array('manage', t('Manage'), "", t('Manage other pages'));
178                 }
179
180                 $nav['delegations'] = Array('delegate', t('Delegations'), "", t('Delegate Page Management'));
181
182                 $nav['settings'] = array('settings', t('Settings'),"", t('Account settings'));
183
184                 if(feature_enabled(local_user(),'multi_profiles'))
185                         $nav['profiles'] = array('profiles', t('Profiles'),"", t('Manage/Edit Profiles'));
186
187                 $nav['contacts'] = array('contacts', t('Contacts'),"", t('Manage/edit friends and contacts'));
188         }
189
190         /**
191          * Admin page
192          */
193          if (is_site_admin()){
194                  $nav['admin'] = array('admin/', t('Admin'), "", t('Site setup and configuration'));
195          }
196
197
198          $nav['navigation'] = array('navigation/', t('Navigation'), "", t('Site map'));
199
200
201         /**
202          *
203          * Provide a banner/logo/whatever
204          *
205          */
206
207         $banner = get_config('system','banner');
208
209         if($banner === false)
210                 $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>';
211
212         call_hooks('nav_info', $nav);
213
214
215         return array(
216                 'sitelocation' => $sitelocation,
217                 'nav' => $nav,
218                 'banner' => $banner,
219                 'userinfo' => $userinfo,
220         );
221 }
222
223
224 /*
225  * Set a menu item in navbar as selected
226  *
227  */
228 function nav_set_selected($item){
229         $a = get_app();
230     $a->nav_sel = array(
231                 'community'     => null,
232                 'network'               => null,
233                 'home'                  => null,
234                 'profiles'              => null,
235                 'introductions' => null,
236                 'notifications' => null,
237                 'messages'              => null,
238                 'directory'         => null,
239                 'settings'              => null,
240                 'contacts'              => null,
241                 'manage'        => null,
242                 'events'        => null,
243                 'register'      => null,
244         );
245         $a->nav_sel[$item] = 'selected';
246 }