当前位置: 首页>>代码示例>>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;未经允许,请勿转载。