本文整理汇总了PHP中Navigation::getNavTree方法的典型用法代码示例。如果您正苦于以下问题:PHP Navigation::getNavTree方法的具体用法?PHP Navigation::getNavTree怎么用?PHP Navigation::getNavTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Navigation
的用法示例。
在下文中一共展示了Navigation::getNavTree方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editroleAction
function editroleAction()
{
$request = new RivetyCore_Request($this->getRequest());
if ($request->has('id'))
{
$role_id = $request->id;
$nav_table = new Navigation($role_id,$this->locale_code);
$roles_table = new Roles();
$role = $roles_table->fetchRow("id = " . $role_id);
if (!is_null($role)) $this->view->role = $role->toArray();
else die("Invalid role.");
// nav_items is already used in the main admin nav
$this->view->nav_items_to_edit = $nav_table->getNavTree();
}
else
{
$this->_forward('default', 'auth', 'missing'); return;
}
}
示例2: init
function init()
{
parent::init();
$this->view->isAdminController = true;
$template_path = $this->_theme_locations['admin']['current_theme']['path'] . "/tpl_controllers/" . $this->getRequest()->getModuleName();
$this->view->setScriptPath($template_path);
$this->view->base_path = substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], "/"));
$this->view->admin_theme_path = $this->_theme_locations['admin']['current_theme']['path'];
$this->view->admin_theme_url = $this->_theme_locations['admin']['current_theme']['url'];
$this->view->admin_theme_global_path = $this->_theme_locations['admin']['current_theme']['path']."/tpl_common";
$this->view->admin_theme_controller_path = $this->_theme_locations['admin']['current_theme']['path'].'/tpl_controllers/'.$this->getRequest()->getControllerName();
$this->view->admin_theme_module_path = $this->_theme_locations['admin']['current_theme']['path'].'/tpl_controllers';
$this->view->default_admin_theme_path = $this->_theme_locations['admin']['default_theme']['path'];
$this->view->default_admin_theme_url = $this->_theme_locations['admin']['default_theme']['url'];
$this->view->default_admin_theme_global_path = $this->_theme_locations['admin']['default_theme']['path']."/tpl_common";
$this->view->default_admin_theme_controller_path = $this->_theme_locations['admin']['default_theme']['path'].'/tpl_controllers/'.$this->getRequest()->getControllerName();
$this->view->default_admin_theme_module_path = $this->_theme_locations['admin']['default_theme']['path'].'/tpl_controllers';
$request = $this->getRequest();
if ($request->has('dev') && $request->dev == true) $this->view->isDeveloper = true;
$this->view->current_path = $this->_theme_locations['admin']['current_theme']['path'] . "/tpl_controllers/" . $this->getRequest()->getControllerName();
$roles_table = new Roles();
$locale_table = new Locales();
if ($this->_identity->isAdmin)
{
$bypass = array();
$globalRoles = explode(",", RivetyCore_Registry::get('global_role_shortnames'));
$inherited_roles = array();
foreach ($this->my_roles as $role => $value) {
$ids = $roles_table->getAllAncestors($value['id']);
$inherited_roles = array_merge($inherited_roles, $ids, array($value['id']));
$all_shortnames = array(array("id" => $value['id'], "shortname" => $value['shortname']));
foreach ($ids as $bp) {
$all_shortnames[] = array("id" => $bp, "shortname" => $roles_table->getShortnameById($bp));
}
$all_locales = $locale_table->getLocaleCodesArray(true);
foreach ($all_shortnames as $sn) {
if (array_key_exists(strtolower(substr($sn['shortname'], -5)),$all_locales) && strtolower(substr($sn['shortname'], -5)) == strtolower($this->locale_code)) {
$bypass[] = $sn['id']; // if current locale, get other locale restricted roles for that locale for navigation
}
if (strtolower(substr($sn['shortname'], -6)) == "global" || in_array($sn['shortname'],$globalRoles) || in_array($sn['id'],$globalRoles)) {
$bypass[] = $sn['id'];
}
}
}
$inherited_roles = array_unique($inherited_roles);
sort($inherited_roles);
$this->view->all_roles = array_unique($inherited_roles);
$bypass = array_unique($bypass);
sort($bypass);
$this->view->bypass = $bypass;
if (@RivetyCore_ResourceCheck::isAllowed("locale_specific_admin_role", "default", $this->_identity->username)) {
$this->_bumpRegionalAccess($bypass);
}
// This variable is set in $this->_bumpRegionalAccess()
if (isset($this->restricted_role_id) && count($this->restricted_role_id) > 0) {
$restr = array();
foreach ($this->restricted_role_id as $role ) {
$restr[] = $role['id'];
}
$tmp_ids = array_unique($restr);
$nav_parent_role_ids = array();
foreach($tmp_ids as $nav_role){
$nav_parent_role_ids = array_merge($nav_parent_role_ids, $roles_table->getAllAncestors($nav_role));
}
$nav_role_ids = array_merge($nav_parent_role_ids, $tmp_ids, $bypass);
$unique_ids = array_unique($nav_role_ids);
$nav_table = new Navigation($unique_ids, $this->locale_code);
$cache = new RivetyCore_Cache();
$cache_name = 'navigation_admin_'.$this->locale_code.'-'.md5(implode($unique_ids,"-")); // MD5 The Unique IDs to shorten the cache name
$cache_tags = array('navigation', 'admin_navigation', $this->locale_code);
$nav_items_temp = $cache->load($cache_name);
if ($nav_items_temp === false || !isset($nav_items_temp)) {
$nav_items_temp = array();
foreach ($unique_ids as $nav_role_id) {
$nav_items_temp = array_merge($nav_items_temp, $nav_table->getNavTree($nav_role_id));
}
$cache->save($nav_items_temp, $cache_name, $cache_tags);
}
$navparams = array('nav_items' => $nav_items_temp, 'request' => $this->_request, 'locale_code' => $this->locale_code);
$navparams = $this->_rivety_plugin->doFilter('controller_nav', $navparams); // FILTER HOOK
$this->view->nav_items = $navparams['nav_items'];
$this->view->access = $this->restricted_role_id;
//.........这里部分代码省略.........
示例3: init
//.........这里部分代码省略.........
$this->view->format_date = "%e %b %Y, %l:%M:%S";
$this->view->format_datetime = "%A %e %B %Y à %l:%M:%S%p";
$this->view->format_datetime_small = "%e %b %Y, %l:%M%p";
break;
default:
$this->view->format_date = Bolts_Registry::get('format_date');
$this->view->format_datetime = Bolts_Registry::get('format_datetime');
$this->view->format_datetime_small = Bolts_Registry::get('format_datetime_small');
break;
}
$this->view->current_year = date("Y");
// SAVED FOR FUTURE USE - changing the language pack based on locale
// $locale_table = new Locales();
// $locale_data = $locale_table->fetchByLocaleCode($this->view->locale_code);
// if (count($locale_data) > 0) {
// $this->locale_data = $locale_data['0'];
// $this->view->locale_data = $this->locale_data;
// $lan_pk = $this->locale_data['language_code'].'_'.$this->locale_data['country_code'].'.UTF-8';
// setlocale(LC_ALL, $lan_pk);
// setlocale(LC_NUMERIC, 'en_US.UTF-8');
// setlocale(LC_COLLATE, 'en_US.UTF-8');
// }
// this is a way to force the browser to reload some scripts
if (Bolts_Registry::get('uncache_css_js_version')) {
$this->view->uncache_version = "?v=" . Bolts_Registry::get('uncache_css_js_version');
}
if (Bolts_Registry::get('uncache_flash_version')) {
$this->view->uncache_flash = "?v=" . Bolts_Registry::get('uncache_flash_version');
}
// Set the content type to UTF-8
header('Content-type: text/html; charset=UTF-8');
// get navigation items from database or cache
// check for role of identity, if we don't have one, use guest.
// TODO - move this to the place where role is determined, there should only be one place
if ($this->_auth->hasIdentity()) {
$tmp_ids = $loggedInRoleIds;
$this->my_roles = $roles_table->fetchRolesByUsername($this->_identity->username)->toArray();
$username = $this->_identity->username;
$this->view->username = $username;
} else {
$tmp_ids = array($roles_table->getIdByShortname("guest"));
$this->my_roles = array(0 => array("id" => "1", "shortname" => "guest", "description" => "Guest", "is_admin" => "0", "isguest" => "1", "isdefault" => "0"));
}
$this->view->my_roles = $this->my_roles;
// find the parent roles, add the parent role IDs to the nav_role_ids for inheritance.
$nav_parent_role_ids = array();
foreach ($tmp_ids as $nav_role) {
$nav_parent_role_ids = array_merge($nav_parent_role_ids, $roles_table->getAllAncestors($nav_role));
}
$nav_role_ids = array();
$nav_role_ids = array_merge($nav_parent_role_ids, $tmp_ids);
$unique_ids = array_unique($nav_role_ids);
sort($unique_ids);
$nav_table = new Navigation($unique_ids, $this->locale_code);
$cache_name = 'navigation_' . $this->locale_code . '-' . md5(implode($unique_ids, "-"));
// MD5 The Unique IDs to shorten the cache name
$cache_tags = array('navigation', $this->locale_code);
$nav_items_temp = false;
if (Bolts_Registry::get('enable_navigation_cache') == '1') {
$nav_items_temp = Bolts_Cache::load($cache_name);
}
if ($nav_items_temp === false || !isset($nav_items_temp)) {
$nav_items_temp = array();
foreach ($unique_ids as $nav_role_id) {
$nav_items_temp = array_merge($nav_items_temp, $nav_table->getNavTree($nav_role_id));
}
if (Bolts_Registry::get('enable_navigation_cache') == '1') {
Bolts_Cache::save($nav_items_temp, $cache_name, $cache_tags);
}
}
$navparams = array('nav_items' => $nav_items_temp, 'request' => $this->_request, 'locale_code' => $this->locale_code);
$navparams = $this->_Bolts_plugin->doFilter('controller_nav', $navparams);
// FILTER HOOK
$this->view->nav_items = $navparams['nav_items'];
// TODO - Rich fix this
// // VIEW STATES
// if (!$this->session->view_states) {
// $this->session->view_states = array();
// }
// // TODO - allow use of regular expressions such as /auth/*
// $last_visited_pages_filter = explode('|', Bolts_Registry::get('last_visited_pages_filter'));
// if (!in_array($this->_uri, $last_visited_pages_filter)) {
// $this->session->view_states['last_visited'] = $this->_uri;
// }
// $this->view->view_states = $this->session->view_states;
// CONTROLLER INIT HOOK
$params['request'] = $this->_request;
$params['locale_code'] = $this->locale_code;
$params['session'] = $this->session;
$additional = $this->_Bolts_plugin->doFilter('controller_init', $params);
// FILTER HOOK
unset($additional['request']);
// we don't want to send the request to the view
if (isset($additional['filter_redirect'])) {
$this->_redirect($additional['filter_redirect']);
}
foreach ($additional as $key => $value) {
$this->view->{$key} = $value;
}
}