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