]> git.mxchange.org Git - friendica.git/blob - include/nav.php
don't use load_view_file() except in email templates and install of htconfig - to...
[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(strlen($a->apps)) {
68                 $nav['apps'] = array('apps', t('Apps'), "");
69         }
70
71         $nav['search'] = array('search', t('Search'), "");
72
73         $gdirpath = 'directory';
74
75         if(strlen(get_config('system','singleuser'))) {
76                 $gdir = dirname(get_config('system','directory_submit_url'));
77                 if(strlen($gdir))
78                         $gdirpath = $gdir;
79         }
80
81         $nav['directory'] = array($gdirpath, t('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'), "");
92
93                 $nav['home'] = array('profile/' . $a->user['nickname'], t('Home'), "");
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'), "");
100                 }
101
102                 $nav['messages'] = array('message', t('Messages'), "");
103                 
104                 if(is_array($a->identities) && count($a->identities) > 1) {
105                         $nav['manage'] = array('manage', t('Manage'), "");
106                 }
107
108                 $nav['settings'] = array('settings', t('Settings'),"");
109                 $nav['profiles'] = array('profiles', t('Profiles'),"");
110                 $nav['contacts'] = array('contacts', t('Contacts'),"");
111
112                 
113         }
114
115
116         /**
117          *
118          * Provide a banner/logo/whatever
119          *
120          */
121
122         $banner = get_config('system','banner');
123
124         if($banner === false) 
125                 $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>';
126
127
128         $tpl = file_get_contents('view/nav.tpl');
129
130         $a->page['nav'] .= replace_macros($tpl, array(
131                 '$langselector' => lang_selector(),
132                 '$sitelocation' => $sitelocation,
133                 '$nav' => $nav,
134                 '$banner' =>  $banner,
135         ));
136
137         call_hooks('page_header', $a->page['nav']);
138
139 }