function bookmarks_content(&$a) { if (!local_user()) { notice(t('Permission denied.') . EOL); return; } require_once 'include/menu.php'; require_once 'include/conversation.php'; $channel = $a->get_channel(); $o = profile_tabs($a, true, $channel['channel_address']); $o .= '<h3>' . t('My Bookmarks') . '</h3>'; $x = menu_list(local_user(), '', MENU_BOOKMARK); if ($x) { foreach ($x as $xx) { $y = menu_fetch($xx['menu_name'], local_user(), get_observer_hash()); $o .= menu_render($y, '', true); } } $o .= '<h3>' . t('My Connections Bookmarks') . '</h3>'; $x = menu_list(local_user(), '', MENU_SYSTEM | MENU_BOOKMARK); if ($x) { foreach ($x as $xx) { $y = menu_fetch($xx['menu_name'], local_user(), get_observer_hash()); $o .= menu_render($y, '', true); } } return $o; }
function menu_render($menu, $class = '', $edit = false, $var = array()) { if (!$menu) { return ''; } $channel_id = is_array(App::$profile) ? App::$profile['profile_uid'] : 0; if (!$channel_id && local_channel()) { $channel_id = local_channel(); } $menu_list = menu_list($channel_id); $menu_names = array(); foreach ($menu_list as $menus) { if ($menus['menu_name'] != $menu['menu']['menu_name']) { $menu_names[] = $menus['menu_name']; } } for ($x = 0; $x < count($menu['items']); $x++) { if (in_array($menu['items'][$x]['mitem_link'], $menu_names)) { $m = menu_fetch($menu['items'][$x]['mitem_link'], $channel_id, get_observer_hash()); $submenu = menu_render($m, 'dropdown-menu', $edit = false, array('wrap' => 'none')); $menu['items'][$x]['submenu'] = $submenu; } if ($menu['items'][$x]['mitem_flags'] & MENU_ITEM_ZID) { $menu['items'][$x]['mitem_link'] = zid($menu['items'][$x]['mitem_link']); } if ($menu['items'][$x]['mitem_flags'] & MENU_ITEM_NEWWIN) { $menu['items'][$x]['newwin'] = '1'; } $menu['items'][$x]['mitem_desc'] = bbcode($menu['items'][$x]['mitem_desc']); } $wrap = $var['wrap'] === 'none' ? false : true; $ret = replace_macros(get_markup_template('usermenu.tpl'), array('$menu' => $menu['menu'], '$class' => $class, '$edit' => $edit ? t("Edit") : '', '$id' => $menu['menu']['menu_id'], '$items' => $menu['items'], '$wrap' => $wrap)); return $ret; }
function comanche_menu($name, $class = '') { $channel_id = comanche_get_channel_id(); if ($channel_id) { $m = menu_fetch($name, $channel_id, get_observer_hash()); return menu_render($m, $class); } }
function menu_render($params = array()) { $html = ''; $menu = Registry::get('menu'); // options $parent = isset($params['parent']) ? $params['parent'] : 0; $class = isset($params['class']) ? $params['class'] : 'active'; foreach ($menu as $item) { if ($item->parent == $parent) { $attr = array(); if ($item->active()) { $attr['class'] = $class; } $html .= '<li>'; $html .= Html::link($item->relative_uri(), $item->name, $attr); $html .= menu_render(array('parent' => $item->id)); $html .= '</li>' . PHP_EOL; } } if ($html) { $html = PHP_EOL . '<ul>' . PHP_EOL . $html . '</ul>' . PHP_EOL; } return $html; }
function widget_menu_preview($arr) { if (!get_app()->data['menu_item']) { return; } require_once 'include/menu.php'; return menu_render(get_app()->data['menu_item']); }
/** * @brief Formats a profile for display in the sidebar. * * It is very difficult to templatise the HTML completely * because of all the conditional logic. * * @param array $profile * @param int $block * @param boolean $show_connect * * @return HTML string suitable for sidebar inclusion * Exceptions: Returns empty string if passed $profile is wrong type or not populated */ function profile_sidebar($profile, $block = 0, $show_connect = true) { $a = get_app(); $observer = $a->get_observer(); $o = ''; $location = false; $pdesc = true; $reddress = true; if (!is_array($profile) && !count($profile)) { return $o; } head_set_icon($profile['thumb']); $is_owner = $profile['uid'] == local_channel() ? true : false; if (is_sys_channel($profile['uid'])) { $show_connect = false; } $profile['picdate'] = urlencode($profile['picdate']); call_hooks('profile_sidebar_enter', $profile); require_once 'include/Contact.php'; if ($show_connect) { // This will return an empty string if we're already connected. $connect_url = rconnect_url($profile['uid'], get_observer_hash()); $connect = $connect_url ? t('Connect') : ''; if ($connect_url) { $connect_url = sprintf($connect_url, urlencode($profile['channel_address'] . '@' . $a->get_hostname())); } // premium channel - over-ride if ($profile['channel_pageflags'] & PAGE_PREMIUM) { $connect_url = z_root() . '/connect/' . $profile['channel_address']; } } // show edit profile to yourself if ($is_owner) { $profile['menu'] = array('chg_photo' => t('Change profile photo'), 'entries' => array()); $multi_profiles = feature_enabled(local_channel(), 'multi_profiles'); if ($multi_profiles) { $profile['edit'] = array($a->get_baseurl() . '/profiles', t('Profiles'), "", t('Manage/edit profiles')); $profile['menu']['cr_new'] = t('Create New Profile'); } else { $profile['edit'] = array($a->get_baseurl() . '/profiles/' . $profile['id'], t('Edit Profile'), '', t('Edit Profile')); } $r = q("SELECT * FROM `profile` WHERE `uid` = %d", local_channel()); if ($r) { foreach ($r as $rr) { if (!($multi_profiles || $rr['is_default'])) { continue; } $profile['menu']['entries'][] = array('photo' => $rr['thumb'], 'id' => $rr['id'], 'alt' => t('Profile Image'), 'profile_name' => $rr['profile_name'], 'isdefault' => $rr['is_default'], 'visible_to_everybody' => t('visible to everybody'), 'edit_visibility' => t('Edit visibility')); } } } if (x($profile, 'address') == 1 || x($profile, 'locality') == 1 || x($profile, 'region') == 1 || x($profile, 'postal_code') == 1 || x($profile, 'country_name') == 1) { $location = t('Location:'); } $profile['homepage'] = linkify($profile['homepage'], true); $gender = x($profile, 'gender') == 1 ? t('Gender:') : False; $marital = x($profile, 'marital') == 1 ? t('Status:') : False; $homepage = x($profile, 'homepage') == 1 ? t('Homepage:') : False; $profile['online'] = $profile['online_status'] === 'online' ? t('Online Now') : False; // logger('online: ' . $profile['online']); if (!perm_is_allowed($profile['uid'], is_array($observer) ? $observer['xchan_hash'] : '', 'view_profile')) { $block = true; } if ($profile['hidewall'] && !local_channel() && !remote_channel() || $block) { $location = $reddress = $pdesc = $gender = $marital = $homepage = False; } $firstname = strpos($profile['channel_name'], ' ') ? trim(substr($profile['channel_name'], 0, strpos($profile['channel_name'], ' '))) : $profile['channel_name']; $lastname = $firstname === $profile['channel_name'] ? '' : trim(substr($profile['channel_name'], strlen($firstname))); $diaspora = array('podloc' => z_root(), 'searchable' => $block ? 'false' : 'true', 'nickname' => $profile['channel_address'], 'fullname' => $profile['channel_name'], 'firstname' => $firstname, 'lastname' => $lastname, 'photo300' => z_root() . '/photo/profile/300/' . $profile['uid'] . '.jpg', 'photo100' => z_root() . '/photo/profile/100/' . $profile['uid'] . '.jpg', 'photo50' => z_root() . '/photo/profile/50/' . $profile['uid'] . '.jpg'); $contact_block = contact_block(); $channel_menu = false; $menu = get_pconfig($profile['uid'], 'system', 'channel_menu'); if ($menu && !$block) { require_once 'include/menu.php'; $m = menu_fetch($menu, $profile['uid'], $observer['xchan_hash']); if ($m) { $channel_menu = menu_render($m); } } $menublock = get_pconfig($profile['uid'], 'system', 'channel_menublock'); if ($menublock && !$block) { require_once 'include/comanche.php'; $channel_menu .= comanche_block($menublock); } $tpl = get_markup_template('profile_vcard.tpl'); require_once 'include/widgets.php'; $z = widget_rating(array('target' => $profile['channel_hash'])); $o .= replace_macros($tpl, array('$profile' => $profile, '$connect' => $connect, '$connect_url' => $connect_url, '$location' => $location, '$gender' => $gender, '$pdesc' => $pdesc, '$marital' => $marital, '$homepage' => $homepage, '$chanmenu' => $channel_menu, '$diaspora' => $diaspora, '$reddress' => $reddress, '$rating' => $z, '$contact_block' => $contact_block)); $arr = array('profile' => &$profile, 'entry' => &$o); call_hooks('profile_sidebar', $arr); return $o; }
<span class="menu-text"></span> </a> <!-- ======[ Sidebar ]====== --> <div class="sidebar" id="sidebar"> <?php if ($website_part == 'settings') { ?> <?php echo menu_render('customer.settings'); ?> <?php } else { ?> <?php echo menu_render('customer.main'); ?> <?php } ?> </div> <!-- ======[ /sidebar ]====== --> <!-- ======[ main content ]====== --> <div class="main-content"> <?php if ($website_part == 'dashboard' && $breadcrumbs) { ?> <?php echo $this->template->block('app_breadcrumbs', 'layouts/block/application/breadcrumbs', array('menu' => 'customer.main')); ?>
function menu($s, $class = '') { $channel_id = $this->get_channel_id(); $name = $s; $cnt = preg_match_all("/\\[var=(.*?)\\](.*?)\\[\\/var\\]/ism", $s, $matches, PREG_SET_ORDER); if ($cnt) { foreach ($matches as $mtch) { $var[$mtch[1]] = $mtch[2]; $name = str_replace($mtch[0], '', $name); } } if ($channel_id) { $m = menu_fetch($name, $channel_id, get_observer_hash()); return menu_render($m, $class, $edit = false, $var); } }
/** * @brief Formats a profile for display in the sidebar. * * It is very difficult to templatise the HTML completely * because of all the conditional logic. * * @param array $profile * @param int $block * @param boolean $show_connect * * @return HTML string suitable for sidebar inclusion * Exceptions: Returns empty string if passed $profile is wrong type or not populated */ function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = false) { $observer = App::get_observer(); $o = ''; $location = false; $pdesc = true; $reddress = true; if (!perm_is_allowed($profile['uid'], is_array($observer) ? $observer['xchan_hash'] : '', 'view_profile')) { $block = true; } if (!is_array($profile) && !count($profile)) { return $o; } head_set_icon($profile['thumb']); if (is_sys_channel($profile['uid'])) { $show_connect = false; } $profile['picdate'] = urlencode($profile['picdate']); call_hooks('profile_sidebar_enter', $profile); if ($show_connect) { // This will return an empty string if we're already connected. $connect_url = rconnect_url($profile['uid'], get_observer_hash()); $connect = $connect_url ? t('Connect') : ''; if ($connect_url) { $connect_url = sprintf($connect_url, urlencode(channel_reddress($profile))); } // premium channel - over-ride if ($profile['channel_pageflags'] & PAGE_PREMIUM) { $connect_url = z_root() . '/connect/' . $profile['channel_address']; } } if (x($profile, 'address') == 1 || x($profile, 'locality') == 1 || x($profile, 'region') == 1 || x($profile, 'postal_code') == 1 || x($profile, 'country_name') == 1) { $location = t('Location:'); } $profile['homepage'] = linkify($profile['homepage'], true); $gender = x($profile, 'gender') == 1 ? t('Gender:') : False; $marital = x($profile, 'marital') == 1 ? t('Status:') : False; $homepage = x($profile, 'homepage') == 1 ? t('Homepage:') : False; $profile['online'] = $profile['online_status'] === 'online' ? t('Online Now') : False; // logger('online: ' . $profile['online']); if ($profile['hidewall'] && !local_channel() && !remote_channel() || $block) { $location = $reddress = $pdesc = $gender = $marital = $homepage = False; } $firstname = strpos($profile['channel_name'], ' ') ? trim(substr($profile['channel_name'], 0, strpos($profile['channel_name'], ' '))) : $profile['channel_name']; $lastname = $firstname === $profile['channel_name'] ? '' : trim(substr($profile['channel_name'], strlen($firstname))); $diaspora = array('podloc' => z_root(), 'guid' => $profile['channel_guid'] . str_replace('.', '', App::get_hostname()), 'pubkey' => pemtorsa($profile['channel_pubkey']), 'searchable' => $block ? 'false' : 'true', 'nickname' => $profile['channel_address'], 'fullname' => $profile['channel_name'], 'firstname' => $firstname, 'lastname' => $lastname, 'photo300' => z_root() . '/photo/profile/300/' . $profile['uid'] . '.jpg', 'photo100' => z_root() . '/photo/profile/100/' . $profile['uid'] . '.jpg', 'photo50' => z_root() . '/photo/profile/50/' . $profile['uid'] . '.jpg'); $contact_block = contact_block(); $channel_menu = false; $menu = get_pconfig($profile['uid'], 'system', 'channel_menu'); if ($menu && !$block) { require_once 'include/menu.php'; $m = menu_fetch($menu, $profile['uid'], $observer['xchan_hash']); if ($m) { $channel_menu = menu_render($m); } } $menublock = get_pconfig($profile['uid'], 'system', 'channel_menublock'); if ($menublock && !$block) { $comanche = new Zotlabs\Render\Comanche(); $channel_menu .= $comanche->block($menublock); } if ($zcard) { $tpl = get_markup_template('profile_vcard_short.tpl'); } else { $tpl = get_markup_template('profile_vcard.tpl'); } require_once 'include/widgets.php'; // if(! feature_enabled($profile['uid'],'hide_rating')) $z = widget_rating(array('target' => $profile['channel_hash'])); $o .= replace_macros($tpl, array('$zcard' => $zcard, '$profile' => $profile, '$connect' => $connect, '$connect_url' => $connect_url, '$location' => $location, '$gender' => $gender, '$pdesc' => $pdesc, '$marital' => $marital, '$homepage' => $homepage, '$chanmenu' => $channel_menu, '$diaspora' => $diaspora, '$reddress' => $reddress, '$rating' => $z, '$contact_block' => $contact_block, '$editmenu' => profile_edit_menu($profile['uid']))); $arr = array('profile' => &$profile, 'entry' => &$o); call_hooks('profile_sidebar', $arr); return $o; }
function perform($edit = array()) { global $lr_session; $person = $this->person; if ($edit['username'] && $lr_session->has_permission('person', 'edit', $this->person->user_id, 'username')) { $person->set('username', $edit['username']); } /* EVIL HACK * If this person is currently a 'visitor', it does not have a * member number, so if we move it to another class, it needs * to be given one. We do this by forcing its status to 'new' and * requiring it be reapproved. Ugly hack, but since * we're likely to scrutinize non-player accounts less than player * accounts, it's necessary. */ if ($person->class == 'visitor' && $edit['class'] == 'player') { $person->set('status', 'new'); $person->set('class', 'player'); $status_changed = true; } if ($edit['class'] && $lr_session->has_permission('person', 'edit', $this->person->user_id, 'class')) { $person->set('class', $edit['class']); } if ($edit['status'] && $lr_session->has_permission('person', 'edit', $this->person->user_id, 'status')) { $person->set('status', $edit['status']); } $person->set('email', $edit['email']); $person->set('allow_publish_email', $edit['allow_publish_email']); foreach (array('home_phone', 'work_phone', 'mobile_phone') as $type) { $num = $edit[$type]; if (strlen($num)) { $person->set($type, clean_telephone_number($num)); } else { $person->set($type, null); } $person->set('publish_' . $type, $edit['publish_' . $type] ? 'Y' : 'N'); } if ($lr_session->has_permission('person', 'edit', $this->person->user_id, 'name')) { $person->set('firstname', $edit['firstname']); $person->set('lastname', $edit['lastname']); } $person->set('addr_street', $edit['addr_street']); $person->set('addr_city', $edit['addr_city']); $person->set('addr_prov', $edit['addr_prov']); $person->set('addr_country', $edit['addr_country']); $postcode = $edit['addr_postalcode']; if (strlen($postcode) == 6) { $foo = substr($postcode, 0, 3) . " " . substr($postcode, 3); $postcode = $foo; } $person->set('addr_postalcode', $edit['addr_postalcode']); $person->set('birthdate', $edit['birthdate']); if ($edit['height']) { $person->set('height', $edit['height']); } $person->set('shirtsize', $edit['shirtsize']); $person->set('gender', $edit['gender']); $person->set('skill_level', $edit['skill_level']); $person->set('year_started', $edit['year_started']); if (variable_get('dog_questions', 1)) { $person->set('has_dog', $edit['has_dog']); } $person->set('willing_to_volunteer', $edit['willing_to_volunteer']); $person->set('contact_for_feedback', $edit['contact_for_feedback']); $person->set('show_gravatar', $edit['show_gravatar']); if (!$person->save()) { error_exit("Internal error: couldn't save changes"); } else { /* EVIL HACK * If a user changes their own status from visitor to player, they * will get logged out, so we need to warn them of this fact. */ if ($status_changed) { $result = para("You have requested to change your account status to 'Player'. As such, your account is now being held for one of the administrators to approve. " . 'Once your account is approved, you will receive an email informing you of your new ' . variable_get('app_org_short_name', 'League') . ' member number. ' . 'You will then be able to log in once again with your username and password.'); $this->smarty->assign('title', $this->title); $this->smarty->assign('menu', menu_render('_root')); $this->smarty->assign('content', $result); $this->smarty->display('backwards_compatible.tpl'); exit; } } return true; }
<div class="sidebar active"> <?php echo menu_render('customer.settings'); ?> </div>
function error_exit($error = NULL, $options = array()) { global $smarty; global $log; if (isset($options['header'])) { header($options['header']); $smarty->assign('title', 'Page not Found'); $smarty->assign('error', 'Page not Found'); $smarty->display('404.tpl'); exit; } $smarty->assign('title', 'Error'); $smarty->assign('menu', menu_render('_root')); $error = $error ? $error : "An unknown error has occurred."; if (isset($log)) { $log->logError($error); $log->logDebug(print_r(debug_backtrace(), true)); } $smarty->assign('error', $error); $smarty->display('error.tpl'); exit; }
/** * Returns a rendered menu tree. */ function menu_render($parentKey = '_root', $depth = 0) { global $_menu; $parents = _menu_get_parents($_GET["q"]); foreach ($parents as $key) { $_menu[$key]['expanded'] = true; } $active = _menu_get_active($_GET["q"]); $_menu[$active]['expanded'] = true; $output = ''; if ($_menu[$parentKey]['children']) { usort($_menu[$parentKey]['children'], "_menu_internal_sort"); foreach ($_menu[$parentKey]['children'] as $itemKey) { /* Always expand in this case because otherwise the children * become unreachable. */ $mustExpand = $_menu[$itemKey]['expanded'] || $_menu[$itemKey]['children'] && !array_key_exists('link', $_menu[$itemKey]); if ($mustExpand) { $style = $_menu[$itemKey]['children'] ? 'expanded' : 'leaf'; } else { $style = $_menu[$itemKey]['children'] ? 'collapsed' : 'leaf'; } if ($itemKey == $active) { $style .= ' active'; } $output .= "<li class='{$style}'>" . _menu_render_item($_menu[$itemKey], $itemKey == $active); if ($mustExpand) { $output .= menu_render($itemKey, $depth + 1); } $output .= "</li>"; } $output = "<ul>{$output}</ul>"; } return $output; }
function error_exit($error = NULL) { global $smarty; $smarty->assign('title', 'Error'); $smarty->assign('menu', menu_render('_root')); $error = $error ? $error : "An unknown error has occurred."; $smarty->assign('error', $error); $smarty->display('error.tpl'); exit; }
function menu_render($params = array()) { $html = ''; $menu = Registry::get('menu'); // options $parent = isset($params['parent']) ? $params['parent'] : 0; $class = isset($params['class']) ? $params['class'] : 'active'; $index = isset($params['index']) ? $params['index'] : 0; foreach ($menu as $item) { if ($item->parent == $parent) { $attr = array(); if ($item->active()) { $attr['class'] = $class; } $html .= '<li>'; $html .= Html::link($item->relative_uri(), $item->name, $attr); $html .= menu_render(array('parent' => $item->id, 'index' => $menu->key())); $html .= '</li>' . PHP_EOL; } } // Reset our index before returning $menu->rewind(); $menu->next(); while ($index > 1) { $menu->next(); $index--; } if ($html) { $html = PHP_EOL . '<ul>' . PHP_EOL . $html . '</ul>' . PHP_EOL; } return $html; }
<div class="sidebar active"> <?php echo menu_render('admin.main'); ?> </div>