本文整理汇总了PHP中JLanguageHelper::createLanguageList方法的典型用法代码示例。如果您正苦于以下问题:PHP JLanguageHelper::createLanguageList方法的具体用法?PHP JLanguageHelper::createLanguageList怎么用?PHP JLanguageHelper::createLanguageList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JLanguageHelper
的用法示例。
在下文中一共展示了JLanguageHelper::createLanguageList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLanguageList
/**
* Get an HTML select list of the available languages.
*
* @return string
*/
public static function getLanguageList()
{
$languages = array();
$languages = JLanguageHelper::createLanguageList(null, JPATH_ADMINISTRATOR, false, true);
array_unshift($languages, JHtml::_('select.option', '', JText::_('JDEFAULT')));
return JHtml::_('select.genericlist', $languages, 'lang', ' class="inputbox"', 'value', 'text', null);
}
示例2: testCreateLanguageList
/**
* @todo Implement testCreateLanguageList().
*/
public function testCreateLanguageList()
{
// This method creates a list consisting of the name and value of language
$actualLanguage = 'en-GB';
$basePath = '../../administrator/';
$caching = false;
$option1 = array(
'text' => 'English (United Kingdom)',
'value' => 'en-GB',
'selected' => 'selected="selected"'
);
$option2 = array(
'text' => 'XXTestLang',
'value' => 'xx-XX'
);
$listCompareEqual1 = array(
0 => $option1,
1 => $option2
);
$help = new JLanguageHelper('');
$list = $help->createLanguageList($actualLanguage,$basePath,$caching);
$this->assertThat(
$listCompareEqual1,
$this->equalTo($list)
);
$this->assertNotEquals(
$listCompareEqual1[1]['text'],
$list[0]['text']
);
}
示例3: getInput
protected function getInput()
{
$this->params = $this->element->attributes();
$size = (int) $this->get('size');
$multiple = $this->get('multiple');
$client = $this->get('client', 'SITE');
jimport('joomla.language.helper');
$langs = JLanguageHelper::createLanguageList($this->value, constant('JPATH_' . strtoupper($client)), true);
$options = array();
foreach ($langs as $lang)
{
if ($lang['value'])
{
$option = new stdClass;
$option->value = $lang['value'];
$option->text = $lang['text'] . ' [' . $lang['value'] . ']';
$options[] = $option;
}
}
require_once JPATH_PLUGINS . '/system/nnframework/helpers/html.php';
return nnHtml::selectlist($options, $this->name, $this->value, $this->id, $size, $multiple);
}
示例4: display
function display($tpl = null)
{
JHTML::_('behavior.keepalive');
require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'models' . DS . 'categories.php';
$model = new K2ModelCategories();
$categories = $model->categoriesTree(NULL, false, false);
$options = array();
$options[] = JHTML::_('select.optgroup', JText::_('K2MART_CREATE_NEW_K2_CATEGORY'));
$options[] = JHTML::_('select.option', 0, JText::_('K2MART_TYPE_CATEGORY_NAME'));
$options[] = JHTML::_('select.optgroup', JText::_('K2MART_USE_EXISTING_K2_CATEGORY'));
foreach ($categories as $category) {
$options[] = JHTML::_('select.option', $category->value, $category->text);
}
$lists['category'] = JHTML::_('select.genericlist', $options, 'catid', 'class="inputbox"', 'value', 'text', 0);
$vmLanguages = vmConfig::get('active_languages', array());
if (count($vmLanguages) > 1) {
jimport('joomla.language.helper');
$languages = JLanguageHelper::createLanguageList(NULL, constant('JPATH_SITE'), true);
foreach ($languages as $key => &$language) {
if (!in_array($language['value'], $vmLanguages)) {
unset($languages[$key]);
}
}
$lists['language'] = JHTML::_('select.genericlist', $languages, 'vmlang', '', 'value', 'text', NULL, 'vmlang');
}
$this->assignRef('lists', $lists);
$this->loadHelper('html');
K2martHTMLHelper::title('K2MART_VIRTUEMART_MIGRATOR');
K2martHTMLHelper::toolbar();
K2martHTMLHelper::subMenu();
parent::display($tpl);
}
示例5: getOptions
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 11.1
*/
protected function getOptions()
{
// Initialize some field attributes.
$client = (string) $this->element['client'];
if ($client != 'site' && $client != 'administrator') {
$client = 'site';
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), JLanguageHelper::createLanguageList($this->value, constant('JPATH_' . strtoupper($client)), true, true));
// Set the default value active language
if ($langParams = JComponentHelper::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 = JFactory::getLanguage();
$this->value = $lang->getTag();
break;
default:
break;
}
}
return $options;
}
示例6: _getOptions
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function _getOptions()
{
jimport('joomla.language.helper');
$client = (string) $this->_element->attributes()->client;
$options = array_merge(parent::_getOptions(), JLanguageHelper::createLanguageList($this->value, constant('JPATH_' . strtoupper($client)), true));
return $options;
}
示例7: testCreateLanguageList
/**
* Test...
*
* @return void
*/
public function testCreateLanguageList()
{
$option = array('text' => 'English (United Kingdom)', 'value' => 'en-GB', 'selected' => 'selected="selected"');
$listCompareEqual = array(0 => $option);
$list = JLanguageHelper::createLanguageList('en-GB', __DIR__ . '/data', false);
$this->assertEquals($listCompareEqual, $list);
}
示例8: getOptions
/**
* Method to get the field options.
*
* @return array The field option objects.
* @since 1.6
*/
protected function getOptions()
{
// Initialise variables.
$app = JFactory::getApplication();
// Detect the native language.
$native = JLanguageHelper::detectLanguage();
if (empty($native)) {
$native = 'en-GB';
}
// Get a forced language if it exists.
$forced = $app->getLocalise();
if (!empty($forced['language'])) {
$native = $forced['language'];
}
// If a language is already set in the session, use this instead
$session = JFactory::getSession()->get('setup.options', array());
if (!empty($session['language'])) {
$native = $session['language'];
}
// Get the list of available languages.
$options = JLanguageHelper::createLanguageList($native);
if (!$options || JError::isError($options)) {
$options = array();
}
// Set the default value from the native language.
$this->value = $native;
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
示例9: getOptions
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 1.6
*/
protected function getOptions()
{
$app = JFactory::getApplication();
// Detect the native language.
$native = JLanguageHelper::detectLanguage();
if (empty($native)) {
$native = 'en-GB';
}
// Get a forced language if it exists.
$forced = $app->getLocalise();
if (!empty($forced['language'])) {
$native = $forced['language'];
}
// If a language is already set in the session, use this instead
$model = new InstallationModelSetup();
$options = $model->getOptions();
if (isset($options['language'])) {
$native = $options['language'];
}
// Get the list of available languages.
$options = JLanguageHelper::createLanguageList($native);
if (!$options || $options instanceof Exception) {
$options = array();
} else {
usort($options, array($this, '_sortLanguages'));
}
// Set the default value from the native language.
$this->value = $native;
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
示例10: getInput
function getInput($name, $id, $value, $params, $children, $j15 = 0)
{
$this->params = $params;
$size = $this->def('size');
$multiple = $this->def('multiple');
$client = $this->def('client', 'SITE');
$control = $name . '';
$attribs = 'class="inputbox"';
if ($multiple) {
if (!is_array($value)) {
$value = explode(',', $value);
}
$attribs .= ' multiple="multiple"';
$control .= '[]';
}
jimport('joomla.language.helper');
$options = JLanguageHelper::createLanguageList($value, constant('JPATH_' . strtoupper($client)), true);
foreach ($options as $i => $option) {
if ($option['value']) {
$options[$i]['text'] = $option['text'] . ' [' . $option['value'] . ']';
}
}
if ($size) {
$attribs .= ' size="' . $size . '"';
} else {
$attribs .= ' size="' . (count($options) > 10 ? 10 : count($options)) . '"';
}
$list = JHTML::_('select.genericlist', $options, $control, $attribs, 'value', 'text', $value, $id);
return $list;
}
示例11: fetchElement
public function fetchElement($name, $value, &$node, $control_name)
{
$client = $node->attributes('client');
jimport('joomla.language.helper');
$languages = JLanguageHelper::createLanguageList($value, constant('JPATH_' . strtoupper($client)), true);
array_unshift($languages, JHtml::_('select.option', '', JText::_('JOPTION_SELECT_LANGUAGE')));
return JHtml::_('select.genericlist', $languages, $control_name . '[' . $name . ']', array('id' => $control_name . $name, 'list.attr' => 'class="inputbox"', 'list.select' => $value));
}
示例12: getLanguageList
/**
* Get an HTML select list of the available languages.
*
* @return string
*/
public static function getLanguageList()
{
jimport('joomla.language.helper');
$languages = array();
$languages = JLanguageHelper::createLanguageList(null);
array_unshift($languages, JHtml::_('select.option', '', JText::_('Default')));
return JHtml::_('select.genericlist', $languages, 'lang', ' class="inputbox"', 'value', 'text', null);
}
示例13: getLanguageList
/**
* Get an HTML select list of the available languages.
*
* @return string
*/
public static function getLanguageList()
{
$languages = JLanguageHelper::createLanguageList(null, JPATH_ADMINISTRATOR, false, true);
if (count($languages) <= 1) {
return '';
}
array_unshift($languages, JHtml::_('select.option', '', JText::_('JDEFAULTLANGUAGE')));
return JHtml::_('select.genericlist', $languages, 'lang', ' class="advancedSelect"', 'value', 'text', null);
}
示例14: fetchElement
/**
* Fetch the language list element
*
* @param string $name Element name
* @param string $value Element value
* @param JXMLElement &$node JXMLElement node object containing the settings for the element
* @param string $control_name Control name
*
* @return string
*
* @deprecated 12.1 Use JFormFieldLanguage
* @note When updating note that JFormFieldLanguage has no s.
* @since 11.1
*/
public function fetchElement($name, $value, &$node, $control_name)
{
// Deprecation warning.
JLog::add('JElementLanguages::fetchElement() is deprecated.', JLog::WARNING, 'deprecated');
$client = $node->attributes('client');
$languages = JLanguageHelper::createLanguageList($value, constant('JPATH_' . strtoupper($client)), true);
array_unshift($languages, JHtml::_('select.option', '', JText::_('JOPTION_SELECT_LANGUAGE')));
return JHtml::_('select.genericlist', $languages, $control_name . '[' . $name . ']', array('id' => $control_name . $name, 'list.attr' => 'class="inputbox"', 'list.select' => $value));
}
示例15: testCreateLanguageList
/**
* Test...
*
* @covers JLanguageHelper::createLanguageList
* @todo Implement testCreateLanguageList().
*
* @return void
*/
public function testCreateLanguageList()
{
// This method creates a list consisting of the name and value of language
$actualLanguage = 'en-GB';
$option = array('text' => 'English (United Kingdom)', 'value' => 'en-GB', 'selected' => 'selected="selected"');
$listCompareEqual = array(0 => $option);
$list = JLanguageHelper::createLanguageList('en-GB', __DIR__ . '/data', false);
$this->assertEquals($listCompareEqual, $list);
}