2013-02-26 01:09:40 +00:00
|
|
|
<?php /** @file */
|
2010-07-20 12:21:19 +00:00
|
|
|
|
2011-02-22 04:19:33 +00:00
|
|
|
function nav(&$a) {
|
|
|
|
|
2011-01-11 22:20:01 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Build page header and site navigation bars
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-03-15 04:20:20 +00:00
|
|
|
$ssl_state = ((local_user()) ? true : false);
|
|
|
|
|
2010-12-17 00:35:45 +00:00
|
|
|
if(!(x($a->page,'nav')))
|
|
|
|
$a->page['nav'] = '';
|
|
|
|
|
2012-10-25 02:13:29 +00:00
|
|
|
$base = $a->get_baseurl($ssl_state);
|
|
|
|
$a->page['htmlhead'] .= <<< EOT
|
|
|
|
|
|
|
|
<script>$(document).ready(function() {
|
|
|
|
var a;
|
|
|
|
a = $("#nav-search-text").autocomplete({
|
|
|
|
serviceUrl: '$base/acl',
|
|
|
|
minChars: 2,
|
|
|
|
width: 250,
|
2013-11-14 17:03:16 +00:00
|
|
|
id: 'nav-search-text-ac',
|
2012-10-25 02:13:29 +00:00
|
|
|
});
|
2012-12-06 22:15:40 +00:00
|
|
|
a.setOptions({ autoSubmit: true, params: { type: 'x' }});
|
2012-10-25 02:13:29 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|
|
EOT;
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-11 22:20:01 +00:00
|
|
|
/**
|
|
|
|
* Placeholder div for popup panel
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Our network is distributed, and as you visit friends some of the
|
|
|
|
* sites look exactly the same - it isn't always easy to know where you are.
|
|
|
|
* Display the current site location as a navigation aid.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-11-09 02:44:33 +00:00
|
|
|
if(local_user()) {
|
|
|
|
$channel = $a->get_channel();
|
|
|
|
$observer = $a->get_observer();
|
|
|
|
}
|
|
|
|
elseif(remote_user())
|
|
|
|
$observer = $a->get_observer();
|
|
|
|
|
2012-09-26 00:57:20 +00:00
|
|
|
|
2012-12-08 22:18:02 +00:00
|
|
|
$myident = (($channel) ? $channel['xchan_addr'] : '');
|
2011-03-02 04:18:47 +00:00
|
|
|
|
2012-11-09 02:44:33 +00:00
|
|
|
$sitelocation = (($myident) ? $myident : $a->get_hostname());
|
2011-01-11 22:20:01 +00:00
|
|
|
|
|
|
|
|
2011-07-14 10:05:54 +00:00
|
|
|
// nav links: array of array('href', 'text', 'extra css classes', 'title')
|
2011-04-14 07:22:38 +00:00
|
|
|
$nav = Array();
|
|
|
|
|
2011-01-11 22:20:01 +00:00
|
|
|
/**
|
|
|
|
* Display login or logout
|
|
|
|
*/
|
|
|
|
|
2011-07-29 14:23:47 +00:00
|
|
|
$nav['usermenu']=array();
|
|
|
|
$userinfo = null;
|
|
|
|
|
2010-11-09 01:30:00 +00:00
|
|
|
if(local_user()) {
|
2011-07-14 10:05:54 +00:00
|
|
|
$nav['logout'] = Array('logout',t('Logout'), "", t('End this session'));
|
2011-07-29 14:23:47 +00:00
|
|
|
|
|
|
|
// user menu
|
2013-03-05 23:48:56 +00:00
|
|
|
$nav['usermenu'][] = Array('channel/' . $channel['channel_address'], t('Home'), "", t('Your posts and conversations'));
|
2013-01-04 01:36:03 +00:00
|
|
|
$nav['usermenu'][] = Array('profile/' . $channel['channel_address'], t('View Profile'), "", t('Your profile page'));
|
|
|
|
if(feature_enabled(local_user(),'multi_profiles'))
|
2013-02-02 16:28:10 +00:00
|
|
|
$nav['usermenu'][] = Array('profiles', t('Edit Profiles'),"", t('Manage/Edit Profiles'));
|
2012-09-26 00:57:20 +00:00
|
|
|
$nav['usermenu'][] = Array('photos/' . $channel['channel_address'], t('Photos'), "", t('Your photos'));
|
2013-01-04 01:08:36 +00:00
|
|
|
// $nav['usermenu'][] = Array('events/', t('Events'), "", t('Your events'));
|
2011-07-29 14:23:47 +00:00
|
|
|
|
2010-11-09 01:30:00 +00:00
|
|
|
}
|
|
|
|
else {
|
2013-01-27 09:19:24 +00:00
|
|
|
if(! get_account_id())
|
|
|
|
$nav['login'] = Array('login',t('Login'), ($a->module == 'login'?'selected':''), t('Sign in'));
|
|
|
|
else
|
|
|
|
$nav['alogout'] = Array('logout',t('Logout'), "", t('End this session'));
|
|
|
|
|
|
|
|
|
2010-11-09 01:30:00 +00:00
|
|
|
}
|
2010-07-20 12:21:19 +00:00
|
|
|
|
2012-11-09 02:44:33 +00:00
|
|
|
if($observer) {
|
|
|
|
$userinfo = array(
|
|
|
|
'icon' => $observer['xchan_photo_s'],
|
|
|
|
'name' => $observer['xchan_addr'],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-10-10 01:33:33 +00:00
|
|
|
if($observer) {
|
|
|
|
$nav['locked'] = true;
|
2013-01-23 07:08:46 +00:00
|
|
|
$nav['lock'] = array('logout','','lock',
|
|
|
|
sprintf( t('%s - click to logout'), $observer['xchan_addr']));
|
2013-10-10 01:33:33 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$nav['locked'] = false;
|
2013-01-23 07:08:46 +00:00
|
|
|
$nav['lock'] = array('rmagic','','unlock',
|
|
|
|
t('Click to authenticate to your home hub'));
|
2013-10-10 01:33:33 +00:00
|
|
|
}
|
2010-07-05 03:45:56 +00:00
|
|
|
|
2011-01-11 22:20:01 +00:00
|
|
|
/**
|
|
|
|
* "Home" should also take you home from an authenticated remote profile connection
|
|
|
|
*/
|
2011-01-05 09:53:34 +00:00
|
|
|
|
2012-03-30 04:44:30 +00:00
|
|
|
$homelink = get_my_url();
|
2013-07-18 18:01:03 +00:00
|
|
|
if(! $homelink) {
|
|
|
|
$observer = $a->get_observer();
|
|
|
|
$homelink = (($observer) ? $observer['xchan_url'] : '');
|
|
|
|
}
|
2011-01-05 09:53:34 +00:00
|
|
|
|
2010-07-29 01:24:07 +00:00
|
|
|
if(($a->module != 'home') && (! (local_user())))
|
2011-07-14 10:05:54 +00:00
|
|
|
$nav['home'] = array($homelink, t('Home'), "", t('Home Page'));
|
2011-01-11 22:20:01 +00:00
|
|
|
|
|
|
|
|
2013-01-03 21:50:23 +00:00
|
|
|
if(($a->config['system']['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user()))
|
2011-07-14 10:05:54 +00:00
|
|
|
$nav['register'] = array('register',t('Register'), "", t('Create an account'));
|
2010-07-29 01:24:07 +00:00
|
|
|
|
2012-03-15 04:20:20 +00:00
|
|
|
$help_url = $a->get_baseurl($ssl_state) . '/help';
|
2011-04-10 12:55:45 +00:00
|
|
|
|
2011-07-05 03:57:07 +00:00
|
|
|
if(! get_config('system','hide_help'))
|
2011-07-14 10:05:54 +00:00
|
|
|
$nav['help'] = array($help_url, t('Help'), "", t('Help and documentation'));
|
2011-04-14 07:22:38 +00:00
|
|
|
|
2012-10-22 05:11:02 +00:00
|
|
|
if(count($a->get_apps()) > 0)
|
2011-07-14 10:05:54 +00:00
|
|
|
$nav['apps'] = array('apps', t('Apps'), "", t('Addon applications, utilities, games'));
|
2011-02-19 08:56:15 +00:00
|
|
|
|
2011-07-14 10:05:54 +00:00
|
|
|
$nav['search'] = array('search', t('Search'), "", t('Search site content'));
|
2010-07-11 09:52:47 +00:00
|
|
|
|
2011-03-01 03:44:47 +00:00
|
|
|
|
2013-03-05 23:48:56 +00:00
|
|
|
$nav['directory'] = array('directory', t('Directory'), "", t('Channel Locator'));
|
2013-01-19 09:07:35 +00:00
|
|
|
|
2011-01-11 22:20:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* The following nav links are only show to logged in users
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-03-02 11:25:12 +00:00
|
|
|
if(local_user()) {
|
2010-07-05 03:45:56 +00:00
|
|
|
|
2013-10-10 01:33:33 +00:00
|
|
|
$nav['network'] = array('network', t('Matrix'), "", t('Your matrix'));
|
2013-03-05 23:48:56 +00:00
|
|
|
$nav['network']['all']=array('notifications/network', t('See all matrix notifications'), "", "");
|
|
|
|
$nav['network']['mark'] = array('', t('Mark all matrix notifications seen'), '','');
|
2011-04-14 07:22:38 +00:00
|
|
|
|
2013-10-10 01:33:33 +00:00
|
|
|
$nav['home'] = array('channel/' . $channel['channel_address'], t('Channel Home'), "", t('Channel home'));
|
2013-01-07 21:40:58 +00:00
|
|
|
$nav['home']['all']=array('notifications/channel', t('See all channel notifications'), "", "");
|
|
|
|
$nav['home']['mark'] = array('', t('Mark all channel notifications seen'), '','');
|
|
|
|
|
2010-07-05 03:45:56 +00:00
|
|
|
|
2013-03-05 23:48:56 +00:00
|
|
|
$nav['intros'] = array('connections/pending', t('Intros'), "", t('New Connections'));
|
2013-01-07 21:40:58 +00:00
|
|
|
$nav['intros']['all']=array('intro', t('See all channel introductions'), "", "");
|
2012-12-04 03:17:02 +00:00
|
|
|
|
2010-07-20 12:21:19 +00:00
|
|
|
|
2013-03-05 23:48:56 +00:00
|
|
|
$nav['notifications'] = array('notifications/system', t('Notices'), "", t('Notifications'));
|
2012-12-03 04:01:30 +00:00
|
|
|
$nav['notifications']['all']=array('notifications/system', t('See all notifications'), "", "");
|
|
|
|
$nav['notifications']['mark'] = array('', t('Mark all system notifications seen'), '','');
|
|
|
|
|
2013-03-05 23:48:56 +00:00
|
|
|
$nav['messages'] = array('message', t('Mail'), "", t('Private mail'));
|
2013-01-07 21:40:58 +00:00
|
|
|
$nav['messages']['all']=array('message', t('See all private messages'), "", "");
|
|
|
|
$nav['messages']['mark'] = array('', t('Mark all private messages seen'), '','');
|
2012-03-06 23:07:27 +00:00
|
|
|
$nav['messages']['inbox'] = array('message', t('Inbox'), "", t('Inbox'));
|
|
|
|
$nav['messages']['outbox']= array('message/sent', t('Outbox'), "", t('Outbox'));
|
|
|
|
$nav['messages']['new'] = array('message/new', t('New Message'), "", t('New Message'));
|
2013-01-04 01:08:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
$nav['all_events'] = array('events', t('Events'), "", t('Event Calendar'));
|
2013-01-07 21:40:58 +00:00
|
|
|
$nav['all_events']['all']=array('events', t('See all events'), "", "");
|
|
|
|
$nav['all_events']['mark'] = array('', t('Mark all events seen'), '','');
|
2010-07-20 05:52:31 +00:00
|
|
|
|
2012-11-03 09:34:12 +00:00
|
|
|
$nav['manage'] = array('manage', t('Channel Select'), "", t('Manage Your Channels'));
|
2010-07-05 03:45:56 +00:00
|
|
|
|
2012-11-03 09:34:12 +00:00
|
|
|
$nav['settings'] = array('settings', t('Settings'),"", t('Account/Channel Settings'));
|
2012-11-08 02:48:31 +00:00
|
|
|
|
2012-11-03 09:34:12 +00:00
|
|
|
$nav['contacts'] = array('connections', t('Connections'),"", t('Manage/Edit Friends and Connections'));
|
2010-07-05 03:45:56 +00:00
|
|
|
}
|
2010-07-11 09:52:47 +00:00
|
|
|
|
2011-06-13 10:52:52 +00:00
|
|
|
/**
|
|
|
|
* Admin page
|
|
|
|
*/
|
|
|
|
if (is_site_admin()){
|
2012-11-03 09:34:12 +00:00
|
|
|
$nav['admin'] = array('admin/', t('Admin'), "", t('Site Setup and Configuration'));
|
2011-06-13 10:52:52 +00:00
|
|
|
}
|
|
|
|
|
2010-09-26 23:56:45 +00:00
|
|
|
|
2011-01-11 22:20:01 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Provide a banner/logo/whatever
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-09-26 23:56:45 +00:00
|
|
|
$banner = get_config('system','banner');
|
|
|
|
|
2010-11-04 07:19:10 +00:00
|
|
|
if($banner === false)
|
2012-11-03 13:32:27 +00:00
|
|
|
$banner = 'red';
|
2010-12-13 01:40:23 +00:00
|
|
|
|
2011-05-11 11:37:13 +00:00
|
|
|
$tpl = get_markup_template('nav.tpl');
|
2011-04-14 07:22:38 +00:00
|
|
|
|
|
|
|
$a->page['nav'] .= replace_macros($tpl, array(
|
2012-06-29 09:29:29 +00:00
|
|
|
'$baseurl' => $a->get_baseurl(),
|
2013-09-04 01:48:01 +00:00
|
|
|
'$langselector' => ((get_config('system','select_language')) ? lang_selector() : ''),
|
2011-04-14 07:22:38 +00:00
|
|
|
'$sitelocation' => $sitelocation,
|
|
|
|
'$nav' => $nav,
|
|
|
|
'$banner' => $banner,
|
2011-07-29 14:23:47 +00:00
|
|
|
'$emptynotifications' => t('Nothing new here'),
|
|
|
|
'$userinfo' => $userinfo,
|
2012-11-09 02:44:33 +00:00
|
|
|
'$localuser' => local_user(),
|
2011-08-17 16:36:24 +00:00
|
|
|
'$sel' => $a->nav_sel,
|
2012-10-22 05:11:02 +00:00
|
|
|
'$apps' => $a->get_apps(),
|
2013-01-19 09:07:35 +00:00
|
|
|
'$pleasewait' => t('Please wait...')
|
2011-04-14 07:22:38 +00:00
|
|
|
));
|
2010-12-30 22:36:35 +00:00
|
|
|
|
|
|
|
call_hooks('page_header', $a->page['nav']);
|
2011-08-17 16:36:24 +00:00
|
|
|
}
|
2011-02-22 04:19:33 +00:00
|
|
|
|
2011-08-17 16:36:24 +00:00
|
|
|
/*
|
|
|
|
* Set a menu item in navbar as selected
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function nav_set_selected($item){
|
|
|
|
$a = get_app();
|
|
|
|
$a->nav_sel = array(
|
|
|
|
'community' => null,
|
|
|
|
'network' => null,
|
|
|
|
'home' => null,
|
|
|
|
'profiles' => null,
|
2012-12-04 03:17:02 +00:00
|
|
|
'intros' => null,
|
2011-08-17 16:36:24 +00:00
|
|
|
'notifications' => null,
|
|
|
|
'messages' => null,
|
2011-11-12 20:28:21 +00:00
|
|
|
'directory' => null,
|
2011-08-17 16:36:24 +00:00
|
|
|
'settings' => null,
|
|
|
|
'contacts' => null,
|
2011-11-12 20:28:21 +00:00
|
|
|
'manage' => null,
|
|
|
|
'register' => null,
|
2011-08-17 16:36:24 +00:00
|
|
|
);
|
2013-09-18 10:11:46 +00:00
|
|
|
$a->nav_sel[$item] = 'active';
|
2011-02-22 04:19:33 +00:00
|
|
|
}
|