/** @file */ function nav(&$a) { /** * * Build page header and site navigation bars * */ if (!x($a->page, 'nav')) { $a->page['nav'] = ''; } $base = z_root(); $a->page['htmlhead'] .= <<<EOT <script>\$(document).ready(function() { \t\$("#nav-search-text").search_autocomplete('{$base}/acl'); }); </script> EOT; if (local_channel()) { $channel = $a->get_channel(); $observer = $a->get_observer(); $prof = q("select id from profile where uid = %d and is_default = 1", intval($channel['channel_id'])); $chans = q("select channel_name, channel_id from channel where channel_account_id = %d and not ( channel_pageflags & %d )>0 order by channel_name ", intval(get_account_id()), intval(PAGE_REMOVED)); } elseif (remote_channel()) { $observer = $a->get_observer(); } $myident = $channel ? $channel['xchan_addr'] : ''; $sitelocation = $myident ? $myident : $a->get_hostname(); /** * * Provide a banner/logo/whatever * */ $banner = get_config('system', 'banner'); if ($banner === false) { $banner = get_config('system', 'sitename'); } $a->page['header'] .= replace_macros(get_markup_template('hdr.tpl'), array('$baseurl' => $a->get_baseurl(), '$sitelocation' => $sitelocation, '$banner' => $banner)); // nav links: array of array('href', 'text', 'extra css classes', 'title') $nav = array(); /** * Display login or logout */ $nav['usermenu'] = array(); $userinfo = null; $nav['loginmenu'] = array(); if (local_channel()) { if ($chans && count($chans) > 1 && feature_enabled(local_channel(), 'nav_channel_select')) { $nav['channels'] = $chans; } $nav['logout'] = array('logout', t('Logout'), "", t('End this session'), 'logout_nav_btn'); // user menu $nav['usermenu'][] = array('channel/' . $channel['channel_address'], t('Home'), "", t('Your posts and conversations'), 'channel_nav_btn'); $nav['usermenu'][] = array('profile/' . $channel['channel_address'], t('View Profile'), "", t('Your profile page'), 'profile_nav_btn'); if (feature_enabled(local_channel(), 'multi_profiles')) { $nav['usermenu'][] = array('profiles', t('Edit Profiles'), "", t('Manage/Edit profiles'), 'profiles_nav_btn'); } else { $nav['usermenu'][] = array('profiles/' . $prof[0]['id'], t('Edit Profile'), "", t('Edit your profile'), 'profiles_nav_btn'); } $nav['usermenu'][] = array('photos/' . $channel['channel_address'], t('Photos'), "", t('Your photos'), 'photos_nav_btn'); $nav['usermenu'][] = array('cloud/' . $channel['channel_address'], t('Files'), "", t('Your files'), 'cloud_nav_btn'); require_once 'include/chat.php'; $has_chats = chatroom_list_count(local_channel()); if ($has_chats) { $nav['usermenu'][] = array('chat/' . $channel['channel_address'], t('Chat'), "", t('Your chatrooms'), 'chat_nav_btn'); } require_once 'include/menu.php'; $has_bookmarks = menu_list_count(local_channel(), '', MENU_BOOKMARK) + menu_list_count(local_channel(), '', MENU_SYSTEM | MENU_BOOKMARK); if ($has_bookmarks) { $nav['usermenu'][] = array('bookmarks', t('Bookmarks'), "", t('Your bookmarks'), 'bookmarks_nav_btn'); } if (feature_enabled($channel['channel_id'], 'webpages')) { $nav['usermenu'][] = array('webpages/' . $channel['channel_address'], t('Webpages'), "", t('Your webpages'), 'webpages_nav_btn'); } } else { if (!get_account_id()) { $nav['loginmenu'][] = array('login', t('Login'), '', t('Sign in'), 'login_nav_btn'); } else { $nav['alogout'] = array('logout', t('Logout'), "", t('End this session'), 'logout_nav_btn'); } } if ($observer) { $userinfo = array('icon' => $observer['xchan_photo_m'], 'name' => $observer['xchan_addr']); } if ($observer) { $nav['lock'] = array('logout', '', 'lock', sprintf(t('%s - click to logout'), $observer['xchan_addr'])); } else { $nav['loginmenu'][] = array('rmagic', t('Remote authentication'), '', t('Click to authenticate to your home hub'), 'rmagic_nav_btn'); } /** * "Home" should also take you home from an authenticated remote profile connection */ $homelink = get_my_url(); if (!$homelink) { $observer = $a->get_observer(); $homelink = $observer ? $observer['xchan_url'] : ''; } if ($a->module != 'home' && !local_channel()) { $nav['home'] = array($homelink, t('Home'), "", t('Home Page'), 'home_nav_btn'); } if ($a->config['system']['register_policy'] == REGISTER_OPEN && !local_channel() && !remote_channel()) { $nav['register'] = array('register', t('Register'), "", t('Create an account'), 'register_nav_btn'); } $help_url = z_root() . '/help?f=&cmd=' . $a->cmd; if (!get_config('system', 'hide_help')) { $nav['help'] = array($help_url, t('Help'), "", t('Help and documentation'), 'help_nav_btn'); } $nav['apps'] = array('apps', t('Apps'), "", t('Applications, utilities, links, games'), 'apps_nav_btn'); $nav['search'] = array('search', t('Search'), "", t('Search site content')); $nav['directory'] = array('directory', t('Directory'), "", t('Channel Directory'), 'directory_nav_btn'); /** * * The following nav links are only show to logged in users * */ if (local_channel()) { $nav['network'] = array('network', t('Matrix'), "", t('Your matrix'), 'network_nav_btn'); $nav['network']['mark'] = array('', t('Mark all matrix notifications seen'), '', ''); $nav['home'] = array('channel/' . $channel['channel_address'], t('Channel Home'), "", t('Channel home'), 'home_nav_btn'); $nav['home']['mark'] = array('', t('Mark all channel notifications seen'), '', ''); $nav['intros'] = array('connections/ifpending', t('Connections'), "", t('Connections'), 'connections_nav_btn'); $nav['notifications'] = array('notifications/system', t('Notices'), "", t('Notifications'), 'notifications_nav_btn'); $nav['notifications']['all'] = array('notifications/system', t('See all notifications'), "", ""); $nav['notifications']['mark'] = array('', t('Mark all system notifications seen'), '', ''); $nav['messages'] = array('message', t('Mail'), "", t('Private mail'), 'mail_nav_btn'); $nav['messages']['all'] = array('message', t('See all private messages'), "", ""); $nav['messages']['mark'] = array('', t('Mark all private messages seen'), '', ''); $nav['messages']['inbox'] = array('message', t('Inbox'), "", t('Inbox')); $nav['messages']['outbox'] = array('message/sent', t('Outbox'), "", t('Outbox')); $nav['messages']['new'] = array('mail/new', t('New Message'), "", t('New Message')); $nav['all_events'] = array('events', t('Events'), "", t('Event Calendar'), 'events_nav_btn'); $nav['all_events']['all'] = array('events', t('See all events'), "", ""); $nav['all_events']['mark'] = array('', t('Mark all events seen'), '', ''); $nav['manage'] = array('manage', t('Channel Manager'), "", t('Manage Your Channels'), 'manage_nav_btn'); $nav['settings'] = array('settings', t('Settings'), "", t('Account/Channel Settings'), 'settings_nav_btn'); } /** * Admin page */ if (is_site_admin()) { $nav['admin'] = array('admin/', t('Admin'), "", t('Site Setup and Configuration'), 'admin_nav_btn'); } /** * * Provide a banner/logo/whatever * */ $banner = get_config('system', 'banner'); if ($banner === false) { $banner = get_config('system', 'sitename'); } $x = array('nav' => $nav, 'usermenu' => $userinfo); call_hooks('nav', $x); // Not sure the best place to put this on the page. So I'm implementing it but leaving it // turned off until somebody discovers this and figures out a good location for it. $powered_by = ''; // $powered_by = '<strong>red<img class="smiley" src="' . $a->get_baseurl() . '/images/rm-16.png" alt="r#" />matrix</strong>'; $tpl = get_markup_template('nav.tpl'); $a->page['nav'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(), '$sitelocation' => $sitelocation, '$nav' => $x['nav'], '$banner' => $banner, '$emptynotifications' => t('Loading...'), '$userinfo' => $x['usermenu'], '$localuser' => local_channel(), '$sel' => $a->nav_sel, '$powered_by' => $powered_by, '$help' => t('@name, #tag, content'), '$pleasewait' => t('Please wait...'))); call_hooks('page_header', $a->page['nav']); }
/** * @brief * * @param App $a * @param boolean $is_owner default false * @param string $nickname default null * @return void|string */ function profile_tabs($a, $is_owner = false, $nickname = null) { // Don't provide any profile tabs if we're running as the sys channel if ($a->is_sys) { return; } $channel = $a->get_channel(); if (is_null($nickname)) { $nickname = $channel['channel_address']; } $uid = $a->profile['profile_uid'] ? $a->profile['profile_uid'] : local_channel(); if (get_pconfig($uid, 'system', 'noprofiletabs')) { return; } if (x($_GET, 'tab')) { $tab = notags(trim($_GET['tab'])); } $url = $a->get_baseurl() . '/channel/' . $nickname; $pr = $a->get_baseurl() . '/profile/' . $nickname; $tabs = array(array('label' => t('Channel'), 'url' => $url, 'sel' => argv(0) == 'channel' ? 'active' : '', 'title' => t('Status Messages and Posts'), 'id' => 'status-tab')); $p = get_all_perms($uid, get_observer_hash()); if ($p['view_profile']) { $tabs[] = array('label' => t('About'), 'url' => $pr, 'sel' => argv(0) == 'profile' ? 'active' : '', 'title' => t('Profile Details'), 'id' => 'profile-tab'); } if ($p['view_photos']) { $tabs[] = array('label' => t('Photos'), 'url' => $a->get_baseurl() . '/photos/' . $nickname, 'sel' => argv(0) == 'photos' ? 'active' : '', 'title' => t('Photo Albums'), 'id' => 'photo-tab'); } if ($p['view_storage']) { $tabs[] = array('label' => t('Files'), 'url' => $a->get_baseurl() . '/cloud/' . $nickname . (get_observer_hash() ? '' : '?f=&davguest=1'), 'sel' => argv(0) == 'cloud' || argv(0) == 'sharedwithme' ? 'active' : '', 'title' => t('Files and Storage'), 'id' => 'files-tab'); } if ($p['chat']) { require_once 'include/chat.php'; $has_chats = chatroom_list_count($uid); if ($has_chats) { $tabs[] = array('label' => t('Chatrooms'), 'url' => $a->get_baseurl() . '/chat/' . $nickname, 'sel' => argv(0) == 'chat' ? 'active' : '', 'title' => t('Chatrooms'), 'id' => 'chat-tab'); } } require_once 'include/menu.php'; $has_bookmarks = menu_list_count(local_channel(), '', MENU_BOOKMARK) + menu_list_count(local_channel(), '', MENU_SYSTEM | MENU_BOOKMARK); if ($is_owner && $has_bookmarks) { $tabs[] = array('label' => t('Bookmarks'), 'url' => $a->get_baseurl() . '/bookmarks', 'sel' => argv(0) == 'bookmarks' ? 'active' : '', 'title' => t('Saved Bookmarks'), 'id' => 'bookmarks-tab'); } if ($is_owner && feature_enabled($uid, 'webpages')) { $tabs[] = array('label' => t('Webpages'), 'url' => $a->get_baseurl() . '/webpages/' . $nickname, 'sel' => argv(0) == 'webpages' ? 'active' : '', 'title' => t('Manage Webpages'), 'id' => 'webpages-tab'); } else { /** * @FIXME we probably need a listing of events that were created by * this channel and are visible to the observer */ } $arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $tab ? $tab : false, 'tabs' => $tabs); call_hooks('profile_tabs', $arr); $tpl = get_markup_template('common_tabs.tpl'); return replace_macros($tpl, array('$tabs' => $arr['tabs'])); }
/** * @brief * * @param App $a * @param boolean $is_owner default false * @param string $nickname default null * @return void|string */ function profile_tabs($a, $is_owner = false, $nickname = null) { // Don't provide any profile tabs if we're running as the sys channel if (App::$is_sys) { return; } $channel = App::get_channel(); if (is_null($nickname)) { $nickname = $channel['channel_address']; } $uid = App::$profile['profile_uid'] ? App::$profile['profile_uid'] : local_channel(); if ($uid == local_channel()) { $cal_link = ''; } else { $cal_link = '/cal/' . $nickname; } if (get_pconfig($uid, 'system', 'noprofiletabs')) { return; } if (x($_GET, 'tab')) { $tab = notags(trim($_GET['tab'])); } $url = z_root() . '/channel/' . $nickname; $pr = z_root() . '/profile/' . $nickname; $tabs = array(array('label' => t('Channel'), 'url' => $url, 'sel' => argv(0) == 'channel' ? 'active' : '', 'title' => t('Status Messages and Posts'), 'id' => 'status-tab')); $p = get_all_perms($uid, get_observer_hash()); if ($p['view_profile']) { $tabs[] = array('label' => t('About'), 'url' => $pr, 'sel' => argv(0) == 'profile' ? 'active' : '', 'title' => t('Profile Details'), 'id' => 'profile-tab'); } if ($p['view_storage']) { $tabs[] = array('label' => t('Photos'), 'url' => z_root() . '/photos/' . $nickname, 'sel' => argv(0) == 'photos' ? 'active' : '', 'title' => t('Photo Albums'), 'id' => 'photo-tab'); $tabs[] = array('label' => t('Files'), 'url' => z_root() . '/cloud/' . $nickname, 'sel' => argv(0) == 'cloud' || argv(0) == 'sharedwithme' ? 'active' : '', 'title' => t('Files and Storage'), 'id' => 'files-tab'); } if ($p['view_stream'] && $cal_link) { $tabs[] = array('label' => t('Events'), 'url' => z_root() . $cal_link, 'sel' => argv(0) == 'cal' || argv(0) == 'events' ? 'active' : '', 'title' => t('Events'), 'id' => 'event-tab'); } if ($p['chat'] && feature_enabled($uid, 'ajaxchat')) { $has_chats = Zotlabs\Lib\Chatroom::list_count($uid); if ($has_chats) { $tabs[] = array('label' => t('Chatrooms'), 'url' => z_root() . '/chat/' . $nickname, 'sel' => argv(0) == 'chat' ? 'active' : '', 'title' => t('Chatrooms'), 'id' => 'chat-tab'); } } require_once 'include/menu.php'; $has_bookmarks = menu_list_count(local_channel(), '', MENU_BOOKMARK) + menu_list_count(local_channel(), '', MENU_SYSTEM | MENU_BOOKMARK); if ($is_owner && $has_bookmarks) { $tabs[] = array('label' => t('Bookmarks'), 'url' => z_root() . '/bookmarks', 'sel' => argv(0) == 'bookmarks' ? 'active' : '', 'title' => t('Saved Bookmarks'), 'id' => 'bookmarks-tab'); } if ($p['write_pages'] && feature_enabled($uid, 'webpages')) { $tabs[] = array('label' => t('Webpages'), 'url' => z_root() . '/webpages/' . $nickname, 'sel' => argv(0) == 'webpages' ? 'active' : '', 'title' => t('Manage Webpages'), 'id' => 'webpages-tab'); } if (feature_enabled($uid, 'wiki') && !UNO) { $tabs[] = array('label' => t('Wiki'), 'url' => z_root() . '/wiki/' . $nickname, 'sel' => argv(0) == 'wiki' ? 'active' : '', 'title' => t('Wiki'), 'id' => 'wiki-tab'); } $arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $tab ? $tab : false, 'tabs' => $tabs); call_hooks('profile_tabs', $arr); $tpl = get_markup_template('common_tabs.tpl'); return replace_macros($tpl, array('$tabs' => $arr['tabs'])); }