]> git.mxchange.org Git - friendica.git/blob - include/nav.php
Merge branch 'master' of git://github.com/friendica/friendica
[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                 '$langselector' => lang_selector(),
31                 '$sitelocation' => $nav_info['sitelocation'],
32                 '$nav' => $nav_info['nav'],
33                 '$banner' =>  $nav_info['banner'],
34                 '$emptynotifications' => t('Nothing new here'),
35                 '$userinfo' => $nav_info['userinfo'],
36                 '$sel' =>       $a->nav_sel,
37                 '$apps' => $a->apps,
38                 '$clear_notifs' => t('Clear notifications')
39         ));
40
41         call_hooks('page_header', $a->page['nav']);
42 }
43
44
45 function nav_info(&$a) {
46
47         $ssl_state = ((local_user()) ? true : false);
48
49         /**
50          *
51          * Our network is distributed, and as you visit friends some of the 
52          * sites look exactly the same - it isn't always easy to know where you are.
53          * Display the current site location as a navigation aid.
54          *
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
62         // nav links: array of array('href', 'text', 'extra css classes', 'title')
63         $nav = Array();
64
65         /**
66          * Display login or logout
67          */
68
69         $nav['usermenu']=array();
70         $userinfo = null;
71
72         if(local_user()) {
73                 $nav['logout'] = Array('logout',t('Logout'), "", t('End this session'));
74
75                 // user menu
76                 $nav['usermenu'][] = Array('profile/' . $a->user['nickname'], t('Status'), "", t('Your posts and conversations'));
77                 $nav['usermenu'][] = Array('profile/' . $a->user['nickname']. '?tab=profile', t('Profile'), "", t('Your profile page'));
78                 $nav['usermenu'][] = Array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos'));
79                 $nav['usermenu'][] = Array('events/', t('Events'), "", t('Your events'));
80                 $nav['usermenu'][] = Array('notes/', t('Personal notes'), "", t('Your personal photos'));
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         $gdirpath = 'directory';
121
122         if(strlen(get_config('system','singleuser'))) {
123                 $gdir = dirname(get_config('system','directory_submit_url'));
124                 if(strlen($gdir))
125                         $gdirpath = $gdir;
126         }
127         elseif(! get_config('system','no_community_page'))
128                 $nav['community'] = array('community', t('Community'), "", t('Conversations on this site'));
129
130         $nav['directory'] = array($gdirpath, t('Directory'), "", t('People directory')); 
131
132         /**
133          *
134          * The following nav links are only show to logged in users
135          *
136          */
137
138         if(local_user()) {
139
140                 $nav['network'] = array('network', t('Network'), "", t('Conversations from your friends'));
141                 $nav['net_reset'] = array('network/0?f=&order=comment&nets=all', t('Network Reset'), "", t('Load Network page with no filters'));
142
143                 $nav['home'] = array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations'));
144
145
146                 /* only show friend requests for normal pages. Other page types have automatic friendship. */
147
148                 if($_SESSION['page_flags'] == PAGE_NORMAL || $_SESSION['page_flags'] == PAGE_PRVGROUP) {
149                         $nav['introductions'] = array('notifications/intros',   t('Introductions'), "", t('Friend Requests'));
150                         $nav['notifications'] = array('notifications',  t('Notifications'), "", t('Notifications'));
151                         $nav['notifications']['all']=array('notifications/system', t('See all notifications'), "", "");
152                         $nav['notifications']['mark'] = array('', t('Mark all system notifications seen'), '','');
153
154                 }
155
156                 $nav['messages'] = array('message', t('Messages'), "", t('Private mail'));
157                 $nav['messages']['inbox'] = array('message', t('Inbox'), "", t('Inbox'));
158                 $nav['messages']['outbox']= array('message/sent', t('Outbox'), "", t('Outbox'));
159                 $nav['messages']['new'] = array('message/new', t('New Message'), "", t('New Message'));
160
161                 if(is_array($a->identities) && count($a->identities) > 1) {
162                         $nav['manage'] = array('manage', t('Manage'), "", t('Manage other pages'));
163                 }
164
165                 $nav['delegations'] = Array('delegate', t('Delegations'), "", t('Delegate Page Management'));
166
167                 $nav['settings'] = array('settings', t('Settings'),"", t('Account settings'));
168                 if(feature_enabled(local_user(),'multi_profiles'))
169                         $nav['profiles'] = array('profiles', t('Profiles'),"", t('Manage/Edit Profiles'));
170
171                 $nav['contacts'] = array('contacts', t('Contacts'),"", t('Manage/edit friends and contacts'));
172         }
173
174         /**
175          * Admin page
176          */
177          if (is_site_admin()){
178                  $nav['admin'] = array('admin/', t('Admin'), "", t('Site setup and configuration'));
179          }
180
181
182          $nav['navigation'] = array('navigation/', t('Navigation'), "", t('Site map'));
183
184
185         /**
186          *
187          * Provide a banner/logo/whatever
188          *
189          */
190
191         $banner = get_config('system','banner');
192
193         if($banner === false) 
194                 $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>';
195
196
197         return array(
198                 'sitelocation' => $sitelocation,
199                 'nav' => $nav,
200                 'banner' => $banner,
201                 'userinfo' => $userinfo,
202         );
203 }
204
205
206 /*
207  * Set a menu item in navbar as selected
208  * 
209  */
210 function nav_set_selected($item){
211         $a = get_app();
212     $a->nav_sel = array(
213                 'community'     => null,
214                 'network'               => null,
215                 'home'                  => null,
216                 'profiles'              => null,
217                 'introductions' => null,
218                 'notifications' => null,
219                 'messages'              => null,
220                 'directory'         => null,
221                 'settings'              => null,
222                 'contacts'              => null,
223                 'manage'        => null,
224                 'register'      => null,
225         );
226         $a->nav_sel[$item] = 'selected';
227 }