]> git.mxchange.org Git - friendica.git/blob - include/nav.php
Merge remote-tracking branch 'friendika-master/master' into admin
[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')
34         $nav = Array();
35
36         /**
37          * Display login or logout
38          */
39
40         if(local_user()) {
41                 $nav['logout'] = Array('logout',t('Logout'), "");
42         }
43         else {
44                 $nav['login'] = Array('login',t('Login'), ($a->module == 'login'?'nav-selected':''));
45         }
46
47
48         /**
49          * "Home" should also take you home from an authenticated remote profile connection
50          */
51
52         $homelink = ((x($_SESSION,'visitor_home')) ? $_SESSION['visitor_home'] : '');
53
54         if(($a->module != 'home') && (! (local_user()))) 
55                 $nav['home'] = array($homelink, t('Home'), "");
56
57
58         if(($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user()))
59                 $nav['register'] = array('register',t('Register'), "");
60
61         $help_url = $a->get_baseurl() . '/help';
62
63         if(! get_config('system','hide-help'))
64                 $nav['help'] = array($help_url, t('Help'), "");
65
66
67         if($a->apps)
68                 $nav['apps'] = array('apps', t('Apps'), "");
69
70         $nav['search'] = array('search', t('Search'), "");
71
72         $gdirpath = 'directory';
73
74         if(strlen(get_config('system','singleuser'))) {
75                 $gdir = dirname(get_config('system','directory_submit_url'));
76                 if(strlen($gdir))
77                         $gdirpath = $gdir;
78         }
79
80         $nav['directory'] = array($gdirpath, t('Directory'), ""); 
81
82         /**
83          *
84          * The following nav links are only show to logged in users
85          *
86          */
87
88         if(local_user()) {
89
90                 $nav['network'] = array('network', t('Network'), "");
91
92                 $nav['home'] = array('profile/' . $a->user['nickname'], t('Home'), "");
93
94
95                 /* only show friend requests for normal pages. Other page types have automatic friendship. */
96
97                 if($_SESSION['page_flags'] == PAGE_NORMAL) {
98                         $nav['notifications'] = array('notifications',  t('Notifications'), "");
99                 }
100
101                 $nav['messages'] = array('message', t('Messages'), "");
102                 
103                 if(is_array($a->identities) && count($a->identities) > 1) {
104                         $nav['manage'] = array('manage', t('Manage'), "");
105                 }
106
107                 $nav['settings'] = array('settings', t('Settings'),"");
108                 $nav['profiles'] = array('profiles', t('Profiles'),"");
109                 $nav['contacts'] = array('contacts', t('Contacts'),"");
110         }
111
112         /**
113          * Admin page
114          */
115          if (is_site_admin()){
116                  $nav['admin'] = array('admin/', t('Admin'), "");
117          }
118
119
120         /**
121          *
122          * Provide a banner/logo/whatever
123          *
124          */
125
126         $banner = get_config('system','banner');
127
128         if($banner === false) 
129                 $banner .= '<a href="http://project.friendika.com"><img id="logo-img" src="images/friendika-32.png" alt="logo" /></a><span id="logo-text"><a href="http://project.friendika.com">Friendika</a></span>';
130
131
132         $tpl = get_markup_template('nav.tpl');
133
134         $a->page['nav'] .= replace_macros($tpl, array(
135                 '$langselector' => lang_selector(),
136                 '$sitelocation' => $sitelocation,
137                 '$nav' => $nav,
138                 '$banner' =>  $banner,
139         ));
140
141         call_hooks('page_header', $a->page['nav']);
142
143 }