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