]> 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/default-profile-mm.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 = ((x($_SESSION,'visitor_home')) ? $_SESSION['visitor_home'] : '');
73
74         if(($a->module != 'home') && (! (local_user()))) 
75                 $nav['home'] = array($homelink, t('Home'), "", t('Home Page'));
76
77
78         if(($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user()))
79                 $nav['register'] = array('register',t('Register'), "", t('Create an account'));
80
81         $help_url = $a->get_baseurl($ssl_state) . '/help';
82
83         if(! get_config('system','hide_help'))
84                 $nav['help'] = array($help_url, t('Help'), "", t('Help and documentation'));
85
86         if(count($a->apps)>0)
87                 $nav['apps'] = array('apps', t('Apps'), "", t('Addon applications, utilities, games'));
88
89         $nav['search'] = array('search', t('Search'), "", t('Search site content'));
90
91         $gdirpath = 'directory';
92
93         if(strlen(get_config('system','singleuser'))) {
94                 $gdir = dirname(get_config('system','directory_submit_url'));
95                 if(strlen($gdir))
96                         $gdirpath = $gdir;
97         }
98         elseif(! get_config('system','no_community_page'))
99                 $nav['community'] = array('community', t('Community'), "", t('Conversations on this site'));
100
101         $nav['directory'] = array($gdirpath, t('Directory'), "", t('People directory')); 
102
103         /**
104          *
105          * The following nav links are only show to logged in users
106          *
107          */
108
109         if(local_user()) {
110
111                 $nav['network'] = array('network', t('Network'), "", t('Conversations from your friends'));
112
113                 $nav['home'] = array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations'));
114
115
116                 /* only show friend requests for normal pages. Other page types have automatic friendship. */
117
118                 if($_SESSION['page_flags'] == PAGE_NORMAL) {
119                         $nav['introductions'] = array('notifications/intros',   t('Introductions'), "", t('Friend Requests'));
120                         $nav['notifications'] = array('notifications',  t('Notifications'), "", t('Notifications'));
121                         $nav['notifications']['all']=array('notifications/system', t('See all notifications'), "", "");
122                         $nav['notifications']['mark'] = array('', t('Mark all system notifications seen'), '','');
123
124                 }
125
126                 $nav['messages'] = array('message', t('Messages'), "", t('Private mail'));
127                 $nav['messages']['inbox'] = array('message', t('Inbox'), "", t('Inbox'));
128                 $nav['messages']['outbox']= array('message/sent', t('Outbox'), "", t('Outbox'));
129                 $nav['messages']['new'] = array('message/new', t('New Message'), "", t('New Message'));
130                 
131                 if(is_array($a->identities) && count($a->identities) > 1) {
132                         $nav['manage'] = array('manage', t('Manage'), "", t('Manage other pages'));
133                 }
134
135                 $nav['settings'] = array('settings', t('Settings'),"", t('Account settings'));
136                 $nav['profiles'] = array('profiles', t('Profiles'),"", t('Manage/edit profiles'));
137                 $nav['contacts'] = array('contacts', t('Contacts'),"", t('Manage/edit friends and contacts'));
138         }
139
140         /**
141          * Admin page
142          */
143          if (is_site_admin()){
144                  $nav['admin'] = array('admin/', t('Admin'), "", t('Site setup and configuration'));
145          }
146
147
148         /**
149          *
150          * Provide a banner/logo/whatever
151          *
152          */
153
154         $banner = get_config('system','banner');
155
156         if($banner === false) 
157                 $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>';
158
159
160         $tpl = get_markup_template('nav.tpl');
161
162         $a->page['nav'] .= replace_macros($tpl, array(
163                 '$langselector' => lang_selector(),
164                 '$sitelocation' => $sitelocation,
165                 '$nav' => $nav,
166                 '$banner' =>  $banner,
167                 '$emptynotifications' => t('Nothing new here'),
168                 '$userinfo' => $userinfo,
169                 '$sel' =>       $a->nav_sel,
170                 '$apps' => $a->apps,
171         ));
172
173         call_hooks('page_header', $a->page['nav']);
174 }
175
176 /*
177  * Set a menu item in navbar as selected
178  * 
179  */
180 function nav_set_selected($item){
181         $a = get_app();
182     $a->nav_sel = array(
183                 'community'     => null,
184                 'network'               => null,
185                 'home'                  => null,
186                 'profiles'              => null,
187                 'introductions' => null,
188                 'notifications' => null,
189                 'messages'              => null,
190                 'directory'         => null,
191                 'settings'              => null,
192                 'contacts'              => null,
193                 'manage'        => null,
194                 'register'      => null,
195         );
196         $a->nav_sel[$item] = 'selected';
197 }