Fixed gh-534 so that the correct comment is made in the module area with the GUI placeholders. First steps towards adding multi languages for both modules and plugins gh-503 gh-493 in JCB. Other small improvments to the date helper methods. Add the otpion to target the admin area with modules.
This commit is contained in:
@ -36,33 +36,43 @@ class JFormFieldLang extends JFormFieldList
|
||||
protected function getOptions()
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$query = $db->getQuery(true);
|
||||
$query->select($db->quoteName(array('a.langtag','a.name'),array('langtag','language_name')));
|
||||
$query->from($db->quoteName('#__componentbuilder_language', 'a'));
|
||||
$query->where($db->quoteName('a.published') . ' >= 1');
|
||||
$query->order('a.langtag ASC');
|
||||
$db->setQuery((string)$query);
|
||||
$items = $db->loadObjectList();
|
||||
// make sure the English GB is added
|
||||
$wasAdded = false;
|
||||
$options = array();
|
||||
if ($items)
|
||||
{
|
||||
$options[] = JHtml::_('select.option', '', 'Select an option');
|
||||
foreach($items as $item)
|
||||
{
|
||||
$options[] = JHtml::_('select.option', trim($item->langtag), $item->language_name . ' (' .$item->langtag.')');
|
||||
if ('en-GB' === trim($item->langtag))
|
||||
$query = $db->getQuery(true);
|
||||
$query->select($db->quoteName(array('a.langtag','a.name'),array('langtag','language_name')));
|
||||
$query->from($db->quoteName('#__componentbuilder_language', 'a'));
|
||||
$query->where($db->quoteName('a.published') . ' >= 1');
|
||||
$query->order('a.langtag ASC');
|
||||
$db->setQuery((string)$query);
|
||||
$items = $db->loadObjectList();
|
||||
// add the main language
|
||||
$main_lang = trim(JComponentHelper::getParams('com_componentbuilder')->get('language', 'en-GB'));
|
||||
// make sure the main language is added
|
||||
$wasAdded = false;
|
||||
$options = array();
|
||||
if ($items)
|
||||
{
|
||||
$wasAdded = true;
|
||||
$options[] = JHtml::_('select.option', '', 'Select an option');
|
||||
foreach($items as $item)
|
||||
{
|
||||
$item->langtag = trim($item->langtag);
|
||||
$options[] = JHtml::_('select.option', $item->langtag, $item->language_name . ' (' .$item->langtag.')');
|
||||
if ($main_lang === $item->langtag)
|
||||
{
|
||||
$wasAdded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// now add it if not already added
|
||||
if (!$wasAdded)
|
||||
{
|
||||
$options[] = JHtml::_('select.option', 'en-GB', 'English GB (en-GB)');
|
||||
}
|
||||
return $options;
|
||||
// now add it if not already added (it must default to $main_lang)
|
||||
if (!$wasAdded)
|
||||
{
|
||||
if ('en-GB' === $main_lang)
|
||||
{
|
||||
$options[] = JHtml::_('select.option', $main_lang, 'English GB (' . $main_lang . ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
$options[] = JHtml::_('select.option', $main_lang, 'Main Language (' . $main_lang . ')');
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user