當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FlexicontentHelperRoute::add_url_lang方法代碼示例

本文整理匯總了PHP中FlexicontentHelperRoute::add_url_lang方法的典型用法代碼示例。如果您正苦於以下問題:PHP FlexicontentHelperRoute::add_url_lang方法的具體用法?PHP FlexicontentHelperRoute::add_url_lang怎麽用?PHP FlexicontentHelperRoute::add_url_lang使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在FlexicontentHelperRoute的用法示例。


在下文中一共展示了FlexicontentHelperRoute::add_url_lang方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _buildLanguageLookup

	/**
	 * Get language data
	 */
	protected static function _buildLanguageLookup()
	{
		if( self::$lang_lookup !== null ) return;
		
		// Create map of: item language code to SEF URL language code
		// We don't use helper function so that we also get non-published ones
		$db = JFactory::getDbo();
		$query = $db->getQuery(true)
			->select('a.sef AS sef')
			->select('a.lang_code AS lang_code')
			->from('#__languages AS a');

		$db->setQuery($query);
		$langs = $db->loadObjectList();
		foreach ($langs as $lang)
		{
			self::$lang_lookup[$lang->lang_code] = $lang->sef;
		}
		
		// Get configuration whether to remove SEF language code from URL
		$plugin = JPluginHelper::getPlugin('system', 'languagefilter');
		if (!empty($plugin)) {
			$pluginParams = FLEXI_J16GE ? new JRegistry($plugin->params) : new JParameter($plugin->params);
			self::$add_url_lang = ! $pluginParams->get('remove_default_prefix', 0);
		} else {
			self::$add_url_lang = 1;
		}
		
		// No need to do more work since we will not add language code to the URLs
		if ( !self::$add_url_lang ) return;
		
		// Get user's access levels
		$user	= JFactory::getUser();
		$levels = JAccess::getAuthorisedViewLevels($user->id);
		
		// Get home page menu items according to language, and 
		$menus = JFactory::getApplication()->getMenu('site', array());
		
		// Get content languages and filter them to include only inteface languages
		$content_langs = JLanguageHelper::getLanguages();
		$interface_langs = array();
		
		foreach ($content_langs as $i => &$language)
		{
			// Do not display language without frontend UI
			if (!JLanguage::exists($language->lang_code))
				continue;
			
			// Do not display language without specific home menu
			elseif (!$menus->getDefault($language->lang_code))
				continue;
			
			// Do not display language without authorized access level
			elseif (isset($language->access) && $language->access && !in_array($language->access, $levels))
				continue;
			
			self::$interface_langs[$language->lang_code] = $language;
		}
		// DEBUG print the filtered languages
		//foreach (self::$interface_langs as $lang_code => $lang) echo $lang->title.'['.$lang_code.']'."<br/>\n";
	}
開發者ID:kosmosby,項目名稱:medicine-prof,代碼行數:64,代碼來源:route.php


注:本文中的FlexicontentHelperRoute::add_url_lang方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。