本文整理汇总了PHP中JLanguage类的典型用法代码示例。如果您正苦于以下问题:PHP JLanguage类的具体用法?PHP JLanguage怎么用?PHP JLanguage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JLanguage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: switchAdminLanguage
/**
* Task to switch the administrator language.
*
* @return void
*/
public function switchAdminLanguage()
{
// Check for request forgeries.
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$cid = $this->input->get('cid', '');
$model = $this->getModel('installed');
// Fetching the language name from the xx-XX.xml
$file = JPATH_ADMINISTRATOR . '/language/' . $cid . '/' . $cid . '.xml';
$info = JInstaller::parseXMLInstallFile($file);
$languageName = $info['name'];
if ($model->switchAdminLanguage($cid)) {
// Switching to the new language for the message
$language = JFactory::getLanguage();
$newLang = JLanguage::getInstance($cid);
JFactory::$language = $newLang;
JFactory::getApplication()->loadLanguage($language = $newLang);
$newLang->load('com_languages', JPATH_ADMINISTRATOR);
$msg = JText::sprintf('COM_LANGUAGES_MSG_SWITCH_ADMIN_LANGUAGE_SUCCESS', $languageName);
$type = 'message';
} else {
$msg = $model->getError();
$type = 'error';
}
$this->setRedirect('index.php?option=com_languages&view=installed', $msg, $type);
}
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:30,代码来源:installed.php
示例2: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 11.1
*/
protected function getInput()
{
$html = array();
$thisid = $this->id;
$values = $this->value;
$class = $this->class;
$languages = JLanguageHelper::getLanguages();
foreach ($languages as $lang) {
$language = new JLanguage($lang->lang_code);
$this->class = $class . ($language->isRTL() ? ' rtl' : ' ltr');
$this->element['label'] = $lang->title;
$this->name = 'jform[' . $this->fieldname . '][' . $lang->lang_code . ']';
$this->id = $thisid . '_' . $lang->lang_code;
$this->value = array_key_exists($lang->lang_code, $values) ? $values[$lang->lang_code] : '';
$html[] = '<div class="control-group">';
$html[] = '<div class="control-label">';
$html[] = parent::getLabel();
$html[] = '</div>';
$html[] = '<div class="controls">';
$html[] = parent::getInput();
$html[] = '</div>';
$html[] = '</div>';
}
return implode($html);
}
开发者ID:smhnaji,项目名称:sdnet,代码行数:32,代码来源:multilang.php
示例3: testGetPaths
/**
* @todo Implement testGetPaths().
*/
public function testGetPaths()
{
$extension1 = '';
$extension2 = 'com_sobi2';
$extension3 = 'joomla';
$lang = new JLanguage('');
// extension = joomla, returns array with language path
$this->assertNotNull($lang->getPaths($extension3));
// No call parameter, returns array with language path
$this->assertNotNull($lang->getPaths());
}
开发者ID:realityking,项目名称:oldunittests,代码行数:14,代码来源:JLanguageTest.php
示例4: getItems
/**
* Gets menu items by attribute
*
* @param string $attributes The field name
* @param string $values The value of the field
* @param boolean $firstonly If true, only returns the first item found
*
* @return array
*
* @since 1.6
*/
public function getItems($attributes, $values, $firstonly = false)
{
$attributes = (array) $attributes;
$values = (array) $values;
if ($this->app->isSite()) {
// Filter by language if not set
if (($key = array_search('language', $attributes)) === false) {
if (JLanguageMultilang::isEnabled()) {
$attributes[] = 'language';
$values[] = array($this->language->getTag(), '*');
}
} elseif ($values[$key] === null) {
unset($attributes[$key]);
unset($values[$key]);
}
// Filter by access level if not set
if (($key = array_search('access', $attributes)) === false) {
$attributes[] = 'access';
$values[] = $this->user->getAuthorisedViewLevels();
} elseif ($values[$key] === null) {
unset($attributes[$key]);
unset($values[$key]);
}
}
// Reset arrays or we get a notice if some values were unset
$attributes = array_values($attributes);
$values = array_values($values);
return parent::getItems($attributes, $values, $firstonly);
}
开发者ID:rhellyer,项目名称:joomla-cms,代码行数:40,代码来源:site.php
示例5: initialise
/**
* Initialise the application.
*
* @access public
*/
function initialise( $options = array())
{
// if a language was specified it has priority
// otherwise use user or default language settings
if (empty($options['language']))
{
$user = & JFactory::getUser();
$lang = $user->getParam( 'language' );
// Make sure that the user's language exists
if ( $lang && JLanguage::exists($lang) ) {
$options['language'] = $lang;
}
else
{
$params = JComponentHelper::getParams('com_extensions');
$client =& JApplicationHelper::getClientInfo($this->getClientId());
$options['language'] = $params->get('language_'.$client->name, 'en-GB');
}
}
// One last check to make sure we have something
if ( ! JLanguage::exists($options['language']) ) {
$options['language'] = 'en-GB';
}
parent::initialise($options);
}
开发者ID:raeldc,项目名称:com_learn,代码行数:34,代码来源:application.php
示例6: listslanguagesType
function listslanguagesType()
{
jimport('joomla.filesystem.folder');
$path = JLanguage::getLanguagePath(JPATH_ROOT);
$dirs = JFolder::folders($path);
$this->languages = array();
foreach ($dirs as $dir) {
if (strlen($dir) != 5 || $dir == "xx-XX") {
continue;
}
$xmlFiles = JFolder::files($path . DS . $dir, '^([-_A-Za-z]*)\\.xml$');
$xmlFile = reset($xmlFiles);
if (empty($xmlFile)) {
continue;
}
$data = JApplicationHelper::parseXMLLangMetaFile($path . DS . $dir . DS . $xmlFile);
$oneLanguage = new stdClass();
$oneLanguage->language = strtolower($dir);
$oneLanguage->name = empty($data['name']) ? $dir : $data['name'];
$this->languages[] = $oneLanguage;
}
if (count($this->languages) < 2) {
return;
}
$this->multipleLang = true;
$this->choice = array();
$this->choice[] = JHTML::_('select.option', 'all', JText::_('ACY_ALL'));
$this->choice[] = JHTML::_('select.option', 'special', JText::_('ACY_CUSTOM'));
$js = "function updateLanguages(){\n\t\t\tchoice = eval('document.adminForm.choice_languages');\n\t\t\tchoiceValue = 'special';\n\t\t\tfor (var i=0; i < choice.length; i++){\n\t\t\t\t if (choice[i].checked){\n\t\t\t\t\t choiceValue = choice[i].value;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\thiddenVar = document.getElementById('hidden_languages');\n\t\t\tif(choiceValue != 'special'){\n\t\t\t\thiddenVar.value = choiceValue;\n\t\t\t\tdocument.getElementById('div_languages').style.display = 'none';\n\t\t\t}else{\n\t\t\t\tdocument.getElementById('div_languages').style.display = 'block';\n\t\t\t\tspecialVar = eval('document.adminForm.special_languages');\n\t\t\t\tfinalValue = '';\n\t\t\t\tfor (var i=0; i < specialVar.length; i++){\n\t\t\t\t\tif (specialVar[i].checked){\n\t\t\t\t\t\t\t finalValue += specialVar[i].value+',';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\thiddenVar.value = finalValue;\n\t\t\t}\n\n\t\t}";
$doc = JFactory::getDocument();
$doc->addScriptDeclaration($js);
}
开发者ID:utopszkij,项目名称:lmp,代码行数:32,代码来源:listslanguages.php
示例7: getItem
public function getItem($id = 'en-GB', $refresh = false, $emptyState = true)
{
if (empty($this->_item)) {
$lang = JLanguage::getInstance($id);
// Load only site language (Email language costants should be only there)
$lang->load('com_citruscart', JPATH_ADMINISTRATOR, $id, true);
$temp_paths = $lang->getPaths('com_citruscart');
foreach ($temp_paths as $p => $k) {
$path = $p;
}
$result = new JObject();
$result->name = $lang->getName();
$result->code = $lang->getTag();
$result->path = $path;
$result->strings = array();
// Load File and Take only the constants that contains "EMAIL_"
$file = new DSCParameter();
$file->loadFile($path);
$strings = $file->toArray();
$result_strings = array();
foreach ($strings as $k => $v) {
// Only if it is a prefix!
if (stripos($k, $this->email_prefix) === 0) {
$result_strings[$k] = $v;
}
}
$result->strings = array('file' => $path, 'strings' => $result_strings);
JFactory::getApplication()->triggerEvent('onPrepare' . $this->getTable()->get('_suffix'), array(&$result));
$this->_item = $result;
}
return $this->_item;
}
开发者ID:joomlacorner,项目名称:citruscart,代码行数:32,代码来源:emails.php
示例8: convertLng
function convertLng($data)
{
session_cache_expire(1800000);
$path = JLanguage::getLanguagePath(JPATH_COMPONENT_ADMINISTRATOR) . DS . $data['lng'] . DS . '*.ini';
$dirs = glob($path);
foreach ($dirs as $file) {
header("Content-type: application/csv");
header("Content-Disposition: attachment; filename=" . basename($file));
header("Pragma: no-cache");
header("Expires: 0");
$arr = file($file);
foreach ($arr as $line) {
$line = str_replace('"', "'", $line);
// dmp($line);
$ex = explode("=", $line);
// dmp($ex);
if (count($ex) > 1) {
echo $ex[0] . "=";
if (count($ex) > 2) {
unset($ex[0]);
$str = '"' . implode("=", $ex);
$str = str_replace("\r\n", "\"\r\n", $str);
echo $str;
} else {
$str = '"' . $ex[1];
$str = str_replace("\r\n", "\"\r\n", $str);
echo $str;
}
}
}
}
}
开发者ID:jmangarret,项目名称:webtuagencia24,代码行数:32,代码来源:mytools.php
示例9: getList
public static function getList(&$params)
{
$lang = JFactory::getLanguage();
$languages = JLanguageHelper::getLanguages();
$db = JFactory::getDBO();
$app = JFactory::getApplication();
$query = $db->getQuery(true);
$query->select('id');
$query->select('language');
$query->from($db->nameQuote('#__menu'));
$query->where('home=1');
$db->setQuery($query);
$homes = $db->loadObjectList('language');
foreach ($languages as $i => &$language) {
// Do not display language without frontend UI
if (!JLanguage::exists($language->lang_code)) {
unset($languages[$i]);
} elseif (!isset($homes[$language->lang_code])) {
unset($languages[$i]);
} else {
if ($app->getLanguageFilter()) {
$language->active = $language->lang_code == $lang->getTag();
if ($app->getCfg('sef') == '1') {
$itemid = isset($homes[$language->lang_code]) ? $homes[$language->lang_code]->id : $homes['*']->id;
$language->link = JRoute::_('index.php?lang=' . $language->sef . '&Itemid=' . $itemid);
} else {
$language->link = 'index.php?lang=' . $language->sef;
}
} else {
$language->link = 'index.php';
}
}
}
return $languages;
}
开发者ID:akksi,项目名称:jcg,代码行数:35,代码来源:helper.php
示例10: initialise
/**
* Initialise the application.
*
* @param array An optional associative array of configuration settings.
*/
function initialise($options = array())
{
$config =& JFactory::getConfig();
// if a language was specified it has priority
// otherwise use user or default language settings
if (empty($options['language'])) {
$user =& JFactory::getUser();
$lang = $user->getParam('admin_language');
// Make sure that the user's language exists
if ($lang && JLanguage::exists($lang)) {
$options['language'] = $lang;
} else {
$params = JComponentHelper::getParams('com_languages');
$client =& JApplicationHelper::getClientInfo($this->getClientId());
$options['language'] = $params->get($client->name, $config->getValue('config.language', 'en-GB'));
}
}
// One last check to make sure we have something
if (!JLanguage::exists($options['language'])) {
$lang = $config->getValue('config.language', 'en-GB');
if (JLanguage::exists($lang)) {
$options['language'] = $lang;
} else {
$options['language'] = 'en-GB';
// as a last ditch fail to english
}
}
parent::initialise($options);
}
开发者ID:joebushi,项目名称:joomla,代码行数:34,代码来源:application.php
示例11: getInput
/**
* Method to get the field input.
*
* @return string The field input.
*/
protected function getInput()
{
$attributes = '';
if ($v = (string) $this->element['onchange']) {
$attributes .= ' onchange="' . $v . '"';
}
$params = JComponentHelper::getParams('com_localise');
$reference = $params->get('reference', 'en-GB');
$admin = JLanguage::getKnownLanguages(LOCALISEPATH_ADMINISTRATOR);
$site = JLanguage::getKnownLanguages(LOCALISEPATH_SITE);
if (JFolder::exists(LOCALISEPATH_INSTALLATION)) {
$install = JLanguage::getKnownLanguages(LOCALISEPATH_INSTALLATION);
} else {
$install = array();
}
$languages = array_merge($admin, $site, $install);
$attributes .= ' class="' . (string) $this->element['class'] . ($this->value == $reference ? ' iconlist-16-reference"' : '"');
foreach ($languages as $i => $language) {
$languages[$i] = JArrayHelper::toObject($language);
}
JArrayHelper::sortObjects($languages, 'name');
$options = array();
foreach ($this->element->children() as $option) {
$options[] = JHtml::_('select.option', $option->attributes('value'), JText::_(trim($option)), array('option.attr' => 'attributes', 'attr' => ''));
}
foreach ($languages as $language) {
$options[] = JHtml::_('select.option', $language->tag, $language->name, array('option.attr' => 'attributes', 'attr' => 'class="' . ($language->tag == $reference ? 'iconlist-16-reference" title="' . JText::_('COM_LOCALISE_TOOLTIP_FIELD_LANGUAGE_REFERENCE') . '"' : '"')));
}
$return = JHtml::_('select.genericlist', $options, $this->name, array('id' => $this->id, 'list.select' => $this->value, 'option.attr' => 'attributes', 'list.attr' => $attributes));
return $return;
}
开发者ID:ForAEdesWeb,项目名称:AEW4,代码行数:36,代码来源:language.php
示例12: setFile
/**
*
*
*
*/
protected function setFile()
{
$params = JComponentHelper::getParams('com_languages');
$frontend_lang = $params->get('site', 'en-GB');
$language = JLanguage::getInstance($frontend_lang);
// get language file for edit
$language = JFactory::getLanguage();
$language->load('com_jdownloads');
$lang_file = JLanguage::getLanguagePath(JPATH_SITE);
$lang_file .= DS . $frontend_lang . DS . $frontend_lang . '.com_jdownloads.ini';
@chmod($lang_file, 0755);
clearstatcache();
if (is_writable($lang_file) == false) {
$language_writable = false;
} else {
$language_writable = true;
}
if ($language_writable) {
$f = fopen($lang_file, "r");
$language_text = fread($f, filesize($lang_file));
$this->languagetext = htmlspecialchars($language_text);
} else {
$this->languagetext = '';
}
$this->languagefile = $lang_file;
$this->languagefile_writable = $language_writable;
}
开发者ID:ashanrupasinghe,项目名称:dnp,代码行数:32,代码来源:view.html.php
示例13: language
function language()
{
$this->setLayout('default');
$code = JRequest::getString('code');
if (empty($code)) {
acymailing::display('Code not specified', 'error');
return;
}
$file = null;
$file->name = $code;
$path = JLanguage::getLanguagePath(JPATH_ROOT) . DS . $code . DS . $code . '.com_acymailing.ini';
$file->path = $path;
jimport('joomla.filesystem.file');
$showLatest = true;
$loadLatest = false;
if (JFile::exists($path)) {
$file->content = JFile::read($path);
if (empty($file->content)) {
acymailing::display('File not found : ' . $path, 'error');
}
} else {
$loadLatest = true;
acymailing::display(JText::_('LOAD_ENGLISH_1') . '<br/>' . JText::_('LOAD_ENGLISH_2') . '<br/>' . JText::_('LOAD_ENGLISH_3'), 'info');
$file->content = JFile::read(JLanguage::getLanguagePath(JPATH_ROOT) . DS . 'en-GB' . DS . 'en-GB.com_acymailing.ini');
}
if ($loadLatest or JRequest::getString('task') == 'latest') {
$doc =& JFactory::getDocument();
$doc->addScript(ACYMAILING_UPDATEURL . 'languageload&code=' . JRequest::getString('code'));
$showLatest = false;
} elseif (JRequest::getString('task') == 'save') {
$showLatest = false;
}
$this->assignRef('showLatest', $showLatest);
$this->assignRef('file', $file);
}
开发者ID:rlee1962,项目名称:diylegalcenter,代码行数:35,代码来源:view.html.php
示例14: parseLang
public function parseLang($vars)
{
if (Mijosef::getConfig()->multilang == 0) {
return;
}
if (empty($vars['lang'])) {
$lang = JRequest::getWord('lang', '');
if (empty($lang)) {
return;
}
$vars['lang'] = $lang;
}
$languages = JLanguageHelper::getLanguages('sef');
$lang_code = $languages[$vars['lang']]->lang_code;
// if current language, don't bother
if ($lang_code == JFactory::getLanguage()->getTag()) {
//self::checkHomepage($vars['lang']);
return;
}
// Create a cookie
$conf = JFactory::getConfig();
$cookie_domain = $conf->get('config.cookie_domain', '');
$cookie_path = $conf->get('config.cookie_path', '/');
setcookie(JUtility::getHash('language'), $lang_code, time() + 365 * 86400, $cookie_path, $cookie_domain);
// set the request var
JRequest::setVar('language', $lang_code);
// set current language
jimport('joomla.language.language');
$conf = JFactory::getConfig();
$debug = $conf->get('debug_lang');
$lang = JLanguage::getInstance($lang_code, $debug);
JFactory::$language = $lang;
self::$_lang = $vars['lang'];
}
开发者ID:affiliatelk,项目名称:ecc,代码行数:34,代码来源:language.php
示例15: initialise
/**
* Initialise the application.
*
* @param array $options An optional associative array of configuration settings.
*
* @return void
* @since 1.5
*/
public function initialise($options = array())
{
$config = JFactory::getConfig();
// if a language was specified it has priority
// otherwise use user or default language settings
if (empty($options['language'])) {
$user = JFactory::getUser();
$lang = $user->getParam('admin_language');
// Make sure that the user's language exists
if ($lang && JLanguage::exists($lang)) {
$options['language'] = $lang;
} else {
$params = JComponentHelper::getParams('com_languages');
$client = JApplicationHelper::getClientInfo($this->getClientId());
$options['language'] = $params->get($client->name, $config->get('language', 'es-LA'));
}
}
// One last check to make sure we have something
if (!JLanguage::exists($options['language'])) {
$lang = $config->get('language', 'es-LA');
if (JLanguage::exists($lang)) {
$options['language'] = $lang;
} else {
$options['language'] = 'es-LA';
// as a last ditch fail to english
}
}
// Execute the parent initialise method.
parent::initialise($options);
// Load Library language
$lang = JFactory::getLanguage();
$lang->load('lib_joomla', JPATH_ADMINISTRATOR, null, false, true);
}
开发者ID:networksoft,项目名称:seekerplus2.com,代码行数:41,代码来源:application.php
示例16: __construct
function __construct(& $subject, $config) {
// Check if Kunena API exists
$api = JPATH_ADMINISTRATOR . '/components/com_kunena/api.php';
if (! is_file ( $api ))
return false;
jimport ( 'joomla.application.component.helper' );
// Check if Kunena component is installed/enabled
if (! JComponentHelper::isEnabled ( 'com_kunena', true )) {
return false;
}
// Load Kunena API
require_once $api;
// Fix Joomla 1.5 bugs and bad performance
$version = new JVersion();
if ($version->RELEASE == '1.5') {
$lang = JFactory::getLanguage();
if (JFactory::getApplication()->isAdmin()) {
$lang->load('com_kunena.menu', JPATH_ADMINISTRATOR);
} else {
$filename = JLanguage::getLanguagePath( JPATH_BASE, $lang->_lang)."/{$lang->_lang}.com_kunena.ini";
$lang->_paths['com_kunena'][$filename] = 1;
}
}
parent::__construct ( $subject, $config );
}
开发者ID:rich20,项目名称:Kunena,代码行数:29,代码来源:kunena.php
示例17: detectLanguage
/**
* Tries to detect the language.
*
* @return string locale
* @since 1.5
*/
public static function detectLanguage()
{
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$systemLangs = JLanguage::getKnownLanguages();
$browserLangs = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
foreach ($browserLangs as $browserLang) {
// slice out the part before ; on first step, the part before - on second, place into array
$browserLang = substr($browserLang, 0, strcspn($browserLang, ';'));
$primary_browserLang = substr($browserLang, 0, 2);
foreach ($systemLangs as $systemLang => $metadata) {
// take off 3 letters iso code languages as they can't match browsers' languages and default them to en
$Jinstall_lang = $metadata['tag'];
if (strlen($Jinstall_lang) < 6) {
if (strtolower($browserLang) == strtolower(substr($metadata['tag'], 0, strlen($browserLang)))) {
return $systemLang;
} else {
if ($primary_browserLang == substr($metadata['tag'], 0, 2)) {
$primaryDetectedLang = $systemLang;
}
}
}
}
if (isset($primaryDetectedLang)) {
return $primaryDetectedLang;
}
}
}
return 'en-GB';
}
开发者ID:joebushi,项目名称:joomla,代码行数:35,代码来源:helper.php
示例18: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
parent::setUp();
$this->saveFactoryState();
JFactory::$language = JLanguage::getInstance('en-GB');
$this->object = new JDocumentHTML();
}
开发者ID:SysBind,项目名称:joomla-cms,代码行数:11,代码来源:JDocumentHTMLTest.php
示例19: installMessage
function installMessage()
{
$db = JFactory::getDBO();
$lang = JFactory::getLanguage();
$currentlang = $lang->getTag();
$objectReadxmlDetail = new JSNISReadXmlDetails();
$infoXmlDetail = $objectReadxmlDetail->parserXMLDetails();
$langSupport = $infoXmlDetail['langs'];
$registry = new JRegistry();
$newStrings = array();
$path = null;
$realLang = null;
$queries = array();
if (array_key_exists($currentlang, $langSupport)) {
$path = JLanguage::getLanguagePath(JPATH_BASE, $currentlang);
$realLang = $currentlang;
} else {
$filepath = JPATH_ROOT . DS . 'administrator' . DS . 'language';
$foldersLang = $this->getFolder($filepath);
foreach ($foldersLang as $value) {
if (in_array($value, $langSupport) == true) {
$path = JLanguage::getLanguagePath(JPATH_BASE, $value);
$realLang = $value;
break;
}
}
}
$filename = $path . DS . $realLang . '.com_imageshow.ini';
$objJNSUtils = JSNISFactory::getObj('classes.jsn_is_utils');
$content = $objJNSUtils->readFileToString($filename);
if ($content) {
$registry->loadString($content);
$newStrings = $registry->toArray();
if (count($newStrings)) {
if (count($infoXmlDetail['menu'])) {
$queries[] = 'TRUNCATE TABLE #__jsn_imageshow_messages';
foreach ($infoXmlDetail['menu'] as $value) {
$index = 1;
while (isset($newStrings['MESSAGE_' . $value . '_' . $index . '_PRIMARY'])) {
$queries[] = 'INSERT INTO #__jsn_imageshow_messages (msg_screen, published, ordering) VALUES (\'' . $value . '\', 1, ' . $index . ')';
$index++;
}
}
}
}
if (count($queries)) {
foreach ($queries as $query) {
$query = trim($query);
if ($query != '') {
$db->setQuery($query);
$db->query();
}
}
}
}
return true;
}
开发者ID:jdrzaic,项目名称:joomla-dummy,代码行数:57,代码来源:jsn_is_installermessage.php
示例20: getList
public static function getList(&$params)
{
$user = JFactory::getUser();
$lang = JFactory::getLanguage();
$app = JFactory::getApplication();
$menu = $app->getMenu();
// Get menu home items
$homes = array();
foreach ($menu->getMenu() as $item) {
if ($item->home) {
$homes[$item->language] = $item;
}
}
// Load associations
$assoc = isset($app->menu_associations) ? $app->menu_associations : 0;
if ($assoc) {
$active = $menu->getActive();
if ($active) {
$associations = MenusHelper::getAssociations($active->id);
}
}
$levels = $user->getAuthorisedViewLevels();
$languages = JLanguageHelper::getLanguages();
// Filter allowed languages
foreach ($languages as $i => &$language) {
// Do not display language without frontend UI
if (!JLanguage::exists($language->lang_code)) {
unset($languages[$i]);
} elseif (!isset($homes[$language->lang_code])) {
unset($languages[$i]);
} elseif (isset($language->access) && $language->access && !in_array($language->access, $levels)) {
unset($languages[$i]);
} else {
$language->active = $language->lang_code == $lang->getTag();
if ($app->getLanguageFilter()) {
if (isset($associations[$language->lang_code]) && $menu->getItem($associations[$language->lang_code])) {
$itemid = $associations[$language->lang_code];
if ($app->getCfg('sef') == '1') {
$language->link = JRoute::_('index.php?lang=' . $language->sef . '&Itemid=' . $itemid);
} else {
$language->link = 'index.php?lang=' . $language->sef . '&Itemid=' . $itemid;
}
} else {
if ($app->getCfg('sef') == '1') {
$itemid = isset($homes[$language->lang_code]) ? $homes[$language->lang_code]->id : $homes['*']->id;
$language->link = JRoute::_('index.php?lang=' . $language->sef . '&Itemid=' . $itemid);
} else {
$language->link = 'index.php?lang=' . $language->sef;
}
}
} else {
$language->link = JRoute::_('&Itemid=' . $homes['*']->id);
}
}
}
return $languages;
}
开发者ID:jimyb3,项目名称:mathematicalteachingsite,代码行数:57,代码来源:helper.php
注:本文中的JLanguage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论