]> git.mxchange.org Git - friendica.git/blob - include/nav.php
string update
[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
120                 }
121
122                 $nav['messages'] = array('message', t('Messages'), "", t('Private mail'));
123                 
124                 if(is_array($a->identities) && count($a->identities) > 1) {
125                         $nav['manage'] = array('manage', t('Manage'), "", t('Manage other pages'));
126                 }
127
128                 $nav['settings'] = array('settings', t('Settings'),"", t('Account settings'));
129                 $nav['profiles'] = array('profiles', t('Profiles'),"", t('Manage/edit profiles'));
130                 $nav['contacts'] = array('contacts', t('Contacts'),"", t('Manage/edit friends and contacts'));
131         }
132
133         /**
134          * Admin page
135          */
136          if (is_site_admin()){
137                  $nav['admin'] = array('admin/', t('Admin'), "", t('Site setup and configuration'));
138          }
139
140
141         /**
142          *
143          * Provide a banner/logo/whatever
144          *
145          */
146
147         $banner = get_config('system','banner');
148
149         if($banner === false) 
150                 $banner .= '<a href="http://friendica.com"><img id="logo-img" src="images/friendika-32.png" alt="logo" /></a><span id="logo-text"><a href="http://friendica.com">Friendica</a></span>';
151
152
153         $tpl = get_markup_template('nav.tpl');
154
155         $a->page['nav'] .= replace_macros($tpl, array(
156                 '$langselector' => lang_selector(),
157                 '$sitelocation' => $sitelocation,
158                 '$nav' => $nav,
159                 '$banner' =>  $banner,
160                 '$emptynotifications' => t('Nothing new here'),
161                 '$userinfo' => $userinfo,
162                 '$sel' =>       $a->nav_sel,
163                 '$apps' => $a->apps,
164         ));
165
166         call_hooks('page_header', $a->page['nav']);
167 }
168
169 /*
170  * Set a menu item in navbar as selected
171  * 
172  */
173 function nav_set_selected($item){
174         $a = get_app();
175     $a->nav_sel = array(
176                 'community'     => null,
177                 'network'               => null,
178                 'home'                  => null,
179                 'profiles'              => null,
180                 'introductions' => null,
181                 'notifications' => null,
182                 'messages'              => null,
183                 'directory'         => null,
184                 'settings'              => null,
185                 'contacts'              => null,
186                 'manage'        => null,
187                 'register'      => null,
188         );
189         $a->nav_sel[$item] = 'selected';
190 }