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