function parse($p1, $p2 = '', $fulltag) { global $_CONF, $LANG01, $LANG04; $retval = ''; if (COM_isAnonUser()) { $options = array('hide_forgotpw_link' => false, 'form_action' => $_CONF['site_url'] . '/users.php'); $options['title'] = $LANG04[65]; // log in to {site_name} $options['message'] = $LANG04[66]; // please enter your user name and password below $retval .= '<div class="uk-navbar-content uk-navbar-flip uk-hidden-small">'; $retval .= '<button class="uk-button uk-button-success" type="button" data-uk-modal="{target:\'#modalOpen\'}">' . $LANG01[58] . '</button></div>'; $retval .= '<div id="modalOpen" class="uk-modal">'; $retval .= '<div class="uk-modal-dialog uk-modal-dialog-medium"><a href="#" class="uk-modal-close uk-close"></a>'; $retval .= SEC_loginForm($options); $retval .= '</div></div>'; } else { $retval .= '<ul class="uk-navbar-nav tm-navbar-nav uk-navbar-flip">'; $retval .= '<li class="uk-parent uk-hidden-small" data-uk-dropdown>'; $retval .= '<a href="#">My Account <i class="uk-icon-caret-down"></i></a>'; $retval .= '<div class="uk-dropdown tm-dropdown uk-dropdown-navbar">'; $retval .= '<ul class="uk-nav uk-nav-navbar tm-nav-navbar">'; $userMenu = getUserMenu(); foreach ($userMenu as $option) { $retval .= '<li><a href="' . $option['url'] . '">' . $option['label'] . '</a></li>'; } $retval .= '</ul></div></li></ul>'; } return $retval; }
protected function loadHeader($title = '') { //城市列表 $city_model = M("City"); $city = getCurrentDealCity(); $this->assign("page_title", $title); if ($title) { $title .= "_" . $city['city'] . '_小米团'; } else { $title = $city['city'] . '_小米团'; } $this->assign("title", $title); $city_list = $city_model->select(); $this->assign("city", $city); $this->assign("city_list", $city_list); //菜单什么的 //用户信息 $user_info = session("user_info"); $this->assign("user_info", $user_info); $this->assign('nav_menu', getNavMenu()); $this->assign('user_menu', getUserMenu()); }
function _parseElement() { global $_SP_CONF, $_USER, $_TABLES, $LANG01, $_CONF, $_GROUPS; $returnArray = array(); $childArray = array(); $item_array = array(); if ($this->active != 1 && $this->id != 0) { return NULL; } if ($this->group_id == 998 && !COM_isAnonUser()) { return NULL; } if (isset($_REQUEST['topic'])) { $topic = COM_applyFilter($_REQUEST['topic']); } else { $topic = ''; } if (COM_isAnonUser()) { $anon = 1; } else { $anon = 0; } $allowed = true; if ($this->group_id != 998 && $this->id != 0 && !SEC_inGroup($this->group_id)) { return NULL; } if ($this->group_id == 1 && !isset($_GROUPS['Root'])) { return NULL; } switch ($this->type) { case ET_SUB_MENU: $this->replace_macros(); break; case ET_FUSION_ACTION: switch ($this->subtype) { case 0: // home $this->url = $_CONF['site_url'] . '/'; break; case 1: // contribute if ($anon && ($_CONF['loginrequired'] || $_CONF['submitloginrequired'])) { return NULL; } if (empty($topic)) { $this->url = $_CONF['site_url'] . '/submit.php?type=story'; } else { $this->url = $_CONF['site_url'] . '/submit.php?type=story&topic=' . $topic; } $label = $LANG01[71]; break; case 2: // directory if ($anon && ($_CONF['loginrequired'] || $_CONF['directoryloginrequired'])) { return NULL; } $this->url = $_CONF['site_url'] . '/directory.php'; if (!empty($topic)) { $this->url = COM_buildUrl($this->url . '?topic=' . urlencode($topic)); } break; case 3: // prefs if ($anon && ($_CONF['loginrequired'] || $_CONF['profileloginrequired'])) { return NULL; } $this->url = $_CONF['site_url'] . '/usersettings.php?mode=edit'; break; case 4: // search if ($anon && ($_CONF['loginrequired'] || $_CONF['searchloginrequired'])) { return NULL; } $this->url = $_CONF['site_url'] . '/search.php'; break; case 5: // stats if (!SEC_hasRights('stats.view')) { return NULL; } $this->url = $_CONF['site_url'] . '/stats.php'; break; default: // unknown? $this->url = $_CONF['site_url'] . '/'; break; } break; case ET_FUSION_MENU: $this->url = ''; switch ($this->subtype) { case USER_MENU: // if anonymous user - show login entry if (COM_isAnonUser()) { $this->label = $LANG01[58]; $this->url = $_CONF['site_url'] . '/users.php'; $this->target = ''; break; } // logged-in user see My Account entry $item_array = getUserMenu(); $this->label = $LANG01[47]; break; case ADMIN_MENU: $this->url = $_CONF['site_admin_url']; $item_array = getAdminMenu(); break; case TOPIC_MENU: $item_array = getTopicMenu(); break; case STATICPAGE_MENU: $item_array = array(); $order = ''; if (!empty($_SP_CONF['sort_menu_by'])) { $order = ' ORDER BY '; if ($_SP_CONF['sort_menu_by'] == 'date') { $order .= 'sp_date DESC'; } else { if ($_SP_CONF['sort_menu_by'] == 'label') { $order .= 'sp_label'; } else { if ($_SP_CONF['sort_menu_by'] == 'title') { $order .= 'sp_title'; } else { // default to "sort by id" $order .= 'sp_id'; } } } } $result = DB_query('SELECT sp_id, sp_label FROM ' . $_TABLES['staticpage'] . ' WHERE sp_onmenu = 1 AND sp_status = 1' . COM_getPermSql('AND') . $order); $nrows = DB_numRows($result); $menuitems = array(); for ($i = 0; $i < $nrows; $i++) { $A = DB_fetchArray($result); $url = COM_buildURL($_CONF['site_url'] . '/page.php?page=' . $A['sp_id']); $label = $A['sp_label']; $item_array[] = array('label' => $label, 'url' => $url); } break; case PLUGIN_MENU: $item_array = array(); $plugin_menu = PLG_getMenuItems(); if (count($plugin_menu) == 0) { $this->access = 0; } else { for ($i = 1; $i <= count($plugin_menu); $i++) { $url = current($plugin_menu); $label = key($plugin_menu); $item_array[] = array('label' => $label, 'url' => $url); next($plugin_menu); } } break; case HEADER_MENU: default: } break; case ET_PLUGIN: $plugin_menus = _mbPLG_getMenuItems(); if (isset($plugin_menus[$this->subtype])) { $this->url = $plugin_menus[$this->subtype]; } else { $this->access = 0; $allowed = 0; } break; case ET_STATICPAGE: $this->url = COM_buildURL($_CONF['site_url'] . '/page.php?page=' . $this->subtype); break; case ET_URL: $this->replace_macros(); break; case ET_PHP: $functionName = $this->subtype; if (function_exists($functionName)) { $item_array = $functionName(); } break; case ET_TOPIC: $this->url = $_CONF['site_url'] . '/index.php?topic=' . $this->subtype; break; default: break; } if ($this->id != 0 && $this->group_id == 998 && SEC_inGroup('Root')) { return NULL; } if ($allowed == 0 || $this->access == 0) { return NULL; } if ($this->type == ET_FUSION_MENU || $this->type == ET_PHP) { $childArray = $item_array; } else { if (!empty($this->children)) { $howmany = $this->getChildcount(); if ($howmany > 0) { $children = $this->getChildren(); foreach ($children as $child) { $elementArray = $child->_parseElement(); if ($elementArray != NULL) { $childArray[] = $elementArray; } } } } else { $childArray = NULL; } } $returnArray = array('label' => $this->label, 'url' => $this->url, 'target' => $this->target, 'children' => is_array($childArray) ? $childArray : NULL); return $returnArray; }
<ul class="nav navbar-nav"> <?php echo getMaimMenu(); ?> <?php if (is_user_logged_in()) { ?> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> Моя акк <span class="caret"></span></a> <ul class="dropdown-menu"> <?php echo getUserMenu(); ?> </ul> </li> <?php } else { ?> <li><a href="<?php echo get_permalink(11); ?> " >Вход</a></li> <?php
/** * Shows the user their menu options * * This shows the average Joe User their menu options. This is the user block on the left side * * @param string $help Help file to show * @param string $title Title of Menu * @param string $position Side being shown on 'left', 'right'. Though blank works not likely. * @see function COM_adminMenu * */ function COM_userMenu($help = '', $title = '', $position = '') { global $_TABLES, $_USER, $_CONF, $LANG01, $LANG04, $LANG29, $_BLOCK_TEMPLATE; $retval = ''; if (!COM_isAnonUser()) { if (empty($title)) { $title = DB_getItem($_TABLES['blocks'], 'title', "name='user_block'"); } // what's our current URL? $thisUrl = COM_getCurrentURL(); $retval .= COM_startBlock($title, $help, COM_getBlockTemplate('user_block', 'header', $position), 'user_block'); $menuData = getUserMenu(); $retval .= '<div id="usermenu"><ul class="uk-list uk-list-space">'; foreach ($menuData as $item) { $retval .= '<li><a href="' . $item['url'] . '">' . $item['label'] . '</a></li>'; } $retval .= '</ul></div>'; $retval .= COM_endBlock(COM_getBlockTemplate('user_block', 'footer')); } else { $retval .= COM_startBlock($LANG01[47], $help, COM_getBlockTemplate('login_block', 'header', $position), 'login_block'); $login = new Template($_CONF['path_layout']); $login->set_file('form', 'loginform.thtml'); $login->set_var('lang_username', $LANG01[21]); $login->set_var('lang_password', $LANG01[57]); $login->set_var('lang_forgetpassword', $LANG01[119]); $login->set_var('lang_login', $LANG01[58]); if ($_CONF['disable_new_user_registration'] == 1) { $login->set_var('lang_signup', ''); } else { $login->set_var('lang_signup', $LANG01[59]); } // 3rd party remote authentication. if ($_CONF['user_login_method']['3rdparty'] && !$_CONF['usersubmission']) { $modules = SEC_collectRemoteAuthenticationModules(); if (count($modules) == 0) { $login->set_var('services', ''); } else { if (!$_CONF['user_login_method']['standard'] && count($modules) == 1) { $select = '<input type="hidden" name="service" value="' . $modules[0] . '"/>' . $modules[0]; } else { // Build select $select = '<select name="service" id="service">'; if ($_CONF['user_login_method']['standard']) { $select .= '<option value="">' . $_CONF['site_name'] . '</option>'; } foreach ($modules as $service) { $select .= '<option value="' . $service . '">' . $service . '</option>'; } $select .= '</select>'; } $login->set_file('services', 'blockservices.thtml'); $login->set_var('lang_service', $LANG04[121]); $login->set_var('select_service', $select); $login->parse('output', 'services'); $login->set_var('services', $login->finish($login->get_var('output'))); } } else { $login->set_var('services', ''); } // OpenID remote authentication. if ($_CONF['user_login_method']['openid'] && $_CONF['usersubmission'] == 0 && !$_CONF['disable_new_user_registration']) { $login->set_file('openid_login', 'loginform_openid.thtml'); $login->set_var('lang_openid_login', $LANG01[128]); $login->set_var('input_field_size', 16); $login->set_var('app_url', $_CONF['site_url'] . '/users.php'); $login->parse('output', 'openid_login'); $login->set_var('openid_login', $login->finish($login->get_var('output'))); } else { $login->set_var('openid_login', ''); } // OAuth remote authentication. if ($_CONF['user_login_method']['oauth']) { $modules = SEC_collectRemoteOAuthModules(); if (count($modules) == 0) { $login->set_var('oauth_login', ''); } else { $html_oauth = ''; foreach ($modules as $service) { $login->set_file('oauth_login', 'loginform_oauth_block.thtml'); $login->set_var('oauth_service', $service); // for sign in image $login->set_var('oauth_sign_in_image', $_CONF['site_url'] . '/images/login-with-' . $service . '.png'); $login->set_var('oauth_sign_in_image_style', ''); $login->set_var('oauth_service_display', ucwords($service)); $login->parse('output', 'oauth_login'); $html_oauth .= $login->finish($login->get_var('output')); } $login->set_var('oauth_login', $html_oauth); } } else { $login->set_var('oauth_login', ''); } $retval .= $login->finish($login->parse('output', 'form')); $retval .= COM_endBlock(COM_getBlockTemplate('login_block', 'footer', $position)); } return $retval; }