- md5
- df9e2ada2b7ab50ed65892c9dbe70de8
- sha1
- 8b44478b8c98a41babc932812a54e50afeb3c6d5
- sha256
- 7dc5b8475b7ca0e2dbe7e37a2ba8f16a36b394f0b2df37f7dcd9c3f94b24999e
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
\defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\LanguageHelper;
/**
* Form Field class for the Joomla Platform.
* Supports a list of installed application languages
*
* @see \Joomla\CMS\Form\Field\ContentlanguageField for a select list of content languages.
* @since 1.7.0
*/
class LanguageField extends ListField
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'Language';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 1.7.0
*/
protected function getOptions()
{
// Initialize some field attributes.
$client = (string) $this->element['client'];
if ($client != 'site' && $client != 'administrator')
{
$client = 'site';
}
// Make sure the languages are sorted base on locale instead of random sorting
$languages = LanguageHelper::createLanguageList($this->value, \constant('JPATH_' . strtoupper($client)), true, true);
if (\count($languages) > 1)
{
usort(
$languages,
function ($a, $b)
{
return strcmp($a['value'], $b['value']);
}
);
}
// Merge any additional options in the XML definition.
$options = array_merge(
parent::getOptions(),
$languages
);
// Set the default value active language
if ($langParams = ComponentHelper::getParams('com_languages'))
{
switch ((string) $this->value)
{
case 'site':
case 'frontend':
case '0':
$this->value = $langParams->get('site', 'en-GB');
break;
case 'admin':
case 'administrator':
case 'backend':
case '1':
$this->value = $langParams->get('administrator', 'en-GB');
break;
case 'active':
case 'auto':
$lang = Factory::getLanguage();
$this->value = $lang->getTag();
break;
default:
break;
}
}
return $options;
}
}
No other release has this exact content. See every version of this file.