]> git.mxchange.org Git - friendica.git/blob - include/nav.php
Merge pull request #163 from fabrixxm/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         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         if(local_user()) {
41                 $nav['logout'] = Array('logout',t('Logout'), "", t('End this session'));
42         }
43         else {
44                 $nav['login'] = Array('login',t('Login'), ($a->module == 'login'?'nav-selected':''), t('Sign in'));
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'), "", t('Home Page'));
56
57
58         if(($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user()))
59                 $nav['register'] = array('register',t('Register'), "", t('Create an account'));
60
61         $help_url = $a->get_baseurl() . '/help';
62
63         if(! get_config('system','hide_help'))
64                 $nav['help'] = array($help_url, t('Help'), "", t('Help and documentation'));
65
66         if($a->apps)
67                 $nav['apps'] = array('apps', t('Apps'), "", t('Addon applications, utilities, games'));
68
69         $nav['search'] = array('search', t('Search'), "", t('Search site content'));
70
71         $gdirpath = 'directory';
72
73         if(strlen(get_config('system','singleuser'))) {
74                 $gdir = dirname(get_config('system','directory_submit_url'));
75                 if(strlen($gdir))
76                         $gdirpath = $gdir;
77         }
78         elseif(! get_config('system','no_community_page'))
79                 $nav['community'] = array('community', t('Community'), "", t('Conversations on this site'));
80
81         $nav['directory'] = array($gdirpath, t('Directory'), "", t('People directory')); 
82
83         /**
84          *
85          * The following nav links are only show to logged in users
86          *
87          */
88
89         if(local_user()) {
90
91                 $nav['network'] = array('network', t('Network'), "", t('Conversations from your friends'));
92
93                 $nav['home'] = array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations'));
94
95
96                 /* only show friend requests for normal pages. Other page types have automatic friendship. */
97
98                 if($_SESSION['page_flags'] == PAGE_NORMAL) {
99                         $nav['notifications'] = array('notifications',  t('Notifications'), "", t('Friend requests'));
100                 }
101
102                 $nav['messages'] = array('message', t('Messages'), "", t('Private mail'));
103                 
104                 if(is_array($a->identities) && count($a->identities) > 1) {
105                         $nav['manage'] = array('manage', t('Manage'), "", t('Manage other pages'));
106                 }
107
108                 $nav['settings'] = array('settings', t('Settings'),"", t('Account settings'));
109                 $nav['profiles'] = array('profiles', t('Profiles'),"", t('Manage/edit profiles'));
110                 $nav['contacts'] = array('contacts', t('Contacts'),"", t('Manage/edit friends and contacts'));
111         }
112
113         /**
114          * Admin page
115          */
116          if (is_site_admin()){
117                  $nav['admin'] = array('admin/', t('Admin'), "", t('Site setup and configuration'));
118          }
119
120
121         /**
122          *
123          * Provide a banner/logo/whatever
124          *
125          */
126
127         $banner = get_config('system','banner');
128
129         if($banner === false) 
130                 $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>';
131
132
133         $tpl = get_markup_template('nav.tpl');
134
135         $a->page['nav'] .= replace_macros($tpl, array(
136                 '$langselector' => lang_selector(),
137                 '$sitelocation' => $sitelocation,
138                 '$nav' => $nav,
139                 '$banner' =>  $banner,
140         ));
141
142         call_hooks('page_header', $a->page['nav']);
143
144 }