当前位置: 首页>>代码示例>>PHP>>正文


PHP Locales::getLocaleCodesArray方法代码示例

本文整理汇总了PHP中Locales::getLocaleCodesArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Locales::getLocaleCodesArray方法的具体用法?PHP Locales::getLocaleCodesArray怎么用?PHP Locales::getLocaleCodesArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Locales的用法示例。


在下文中一共展示了Locales::getLocaleCodesArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
//.........这里部分代码省略.........
开发者ID:richjoslin,项目名称:rivety,代码行数:101,代码来源:Admin.php

示例2: init

 function init()
 {
     $params = array('username' => null);
     $modules_table = new Modules("core");
     $roles_table = new Roles();
     $enabled_modules = $modules_table->getEnabledModules();
     foreach ($enabled_modules as $enabled_module) {
         $this->view->{"module_" . $enabled_module} = true;
     }
     if (!empty($_SERVER['HTTPS'])) {
         $this->view->is_ssl = true;
         $this->_is_ssl = true;
     } else {
         $this->view->is_ssl = false;
         $this->_is_ssl = false;
     }
     $this->_uri = $_SERVER['REQUEST_URI'];
     $this->_host_id = Zend_Registry::get('host_id');
     $this->view->host_id = $this->_host_id;
     $this->view->session_id = Zend_Session::getId();
     $this->view->site_url = Bolts_Registry::get('site_url');
     $this->view->site_name = Bolts_Registry::get('site_name');
     $this->registry = Zend_Registry::getInstance();
     $this->session = new Zend_Session_Namespace('Default');
     $this->_mca = $this->_request->getModuleName() . "_" . $this->_request->getControllerName() . "_" . $this->_request->getActionName();
     $this->view->mca = str_replace("_", "-", $this->_mca);
     $this->view->controller_name = $this->_request->getControllerName();
     $this->module_name = $this->_request->getModuleName();
     $this->view->module_name = $this->_request->getModuleName();
     $this->view->action_name = $this->_request->getActionName();
     $this->_auth = Zend_Auth::getInstance();
     if ($this->_auth->hasIdentity()) {
         $this->_identity = $this->_auth->getIdentity();
         $this->view->isLoggedIn = true;
         $params['username'] = $this->_identity->username;
         $users_table = new Users();
         $loggedInUser = $users_table->fetchByUsername($this->_identity->username);
         if (!is_null($loggedInUser)) {
             $this->_loggedInUser = $loggedInUser;
             $this->view->loggedInUser = $loggedInUser->toArray();
         }
         $this->view->loggedInUsername = $this->_identity->username;
         $this->view->loggedInFullName = $this->_identity->full_name;
         $loggedInRoleIds = $roles_table->getRoleIdsByUsername($this->_identity->username);
         $this->view->loggedInRoleIds = $loggedInRoleIds;
         foreach ($loggedInRoleIds as $role_id) {
             $role = $roles_table->fetchRow('id = ' . $role_id);
             if ((bool) $role->isadmin) {
                 $this->view->isAdmin = true;
                 $this->_identity->isAdmin = true;
             }
         }
     } else {
         $this->_identity = null;
         $this->view->isLoggedIn = false;
     }
     $appNamespace = new Zend_Session_Namespace('Bolts_Temp');
     $this->view->last_login = $appNamespace->last_login;
     $this->_Bolts_plugin = Bolts_Plugin::getInstance();
     $this->_theme_locations = Zend_Registry::get('theme_locations');
     // Theme filter block: Allow plugin's to alter the current theme based on request, locale, etc.
     $theme_params = array('request' => $this->_request, 'admin' => array('current_theme' => $this->_theme_locations['admin']['current_theme']), 'frontend' => array('current_theme' => $this->_theme_locations['frontend']['current_theme']));
     $theme_params = $this->_Bolts_plugin->doFilter('current_themes', $theme_params);
     // FILTER HOOK
     if (file_exists($theme_params['admin']['current_theme']['path'])) {
         $this->_theme_locations['admin']['current_theme'] = $theme_params['admin']['current_theme'];
     }
     if (file_exists($theme_params['frontend']['current_theme']['path'])) {
         $this->_theme_locations['frontend']['current_theme'] = $theme_params['frontend']['current_theme'];
         $template_path = $this->_theme_locations['frontend']['current_theme']['path'] . "/modules/" . $this->getRequest()->getModuleName();
         $this->view->setScriptPath($template_path);
     }
     // Theme filter block: End.
     $this->view->theme_path = $this->_theme_locations['frontend']['current_theme']['path'];
     $this->view->theme_url = $this->_theme_locations['frontend']['current_theme']['url'];
     $this->view->theme_global_path = $this->_theme_locations['frontend']['current_theme']['path'] . "/global";
     $this->view->theme_global = $this->view->theme_global_path;
     $this->view->theme_controller_path = $this->_theme_locations['frontend']['current_theme']['path'] . '/modules/' . $this->getRequest()->getModuleName() . "/" . $this->getRequest()->getControllerName();
     $this->view->theme_module_path = $this->_theme_locations['frontend']['current_theme']['path'] . '/modules/' . $this->getRequest()->getModuleName();
     $this->view->default_theme_path = $this->_theme_locations['frontend']['default_theme']['path'];
     $this->view->default_theme_url = $this->_theme_locations['frontend']['default_theme']['url'];
     $this->view->default_theme_global_path = $this->_theme_locations['frontend']['default_theme']['path'] . "/global";
     $this->view->default_theme_controller_path = $this->_theme_locations['frontend']['default_theme']['path'] . '/modules/' . $this->getRequest()->getModuleName() . "/" . $this->getRequest()->getControllerName();
     $this->view->default_theme_module_path = $this->_theme_locations['frontend']['default_theme']['path'] . '/modules/' . $this->getRequest()->getModuleName();
     Bolts_Log::report("Current path " . $this->_mca, null, Zend_Log::INFO);
     $this->view->isAdminController = false;
     $this->view->title_prefix = Bolts_Registry::get('title_prefix');
     $locale_is_valid = true;
     $default_locale_code = str_replace('_', '-', trim(strtolower(Bolts_Registry::get('default_locale'))));
     $this->locale_code = $default_locale_code;
     if (Bolts_Registry::get('enable_localization') == '1') {
         // to set the locale code, look in the URL, not in the cookie
         // the only thing that should check the cookie is the home page and optionally the locale chooser page
         $locales_table = new Locales();
         $db_locales_full = $locales_table->getLocaleCodesArray(true);
         $db_locales = array_keys($db_locales_full);
         // Get the locales allowed in the config
         $allowed_locales = explode(',', Bolts_Registry::get('allowed_locales'));
         if (!empty($allowed_locales) && (bool) array_filter($allowed_locales)) {
             $allowed_locales = array_map('trim', $allowed_locales);
//.........这里部分代码省略.........
开发者ID:jaybill,项目名称:Bolts,代码行数:101,代码来源:Abstract.php


注:本文中的Locales::getLocaleCodesArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。