本文整理汇总了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";
}