diff --git a/administrator/components/com_associations/helpers/associations.php b/administrator/components/com_associations/helpers/associations.php index 38b9193b8a2cf..f9d957c8347b3 100644 --- a/administrator/components/com_associations/helpers/associations.php +++ b/administrator/components/com_associations/helpers/associations.php @@ -10,6 +10,7 @@ defined('_JEXEC') or die; use Joomla\Registry\Registry; +use Joomla\CMS\Language\LanguageHelper; /** * Associations component helper. @@ -177,7 +178,7 @@ public static function getAssociationHtmlList($extensionName, $typeName, $itemId $titleFieldName = self::getTypeFieldName($extensionName, $typeName, 'title'); // Get all content languages. - $languages = self::getContentLanguages(); + $languages = LanguageHelper::getContentLanguages(array(0, 1)); $canEditReference = self::allowEdit($extensionName, $typeName, $itemId); $canCreate = self::allowAdd($extensionName, $typeName); @@ -444,18 +445,7 @@ private static function getEnabledExtensions() */ public static function getContentLanguages() { - $db = JFactory::getDbo(); - - // Get all content languages. - $query = $db->getQuery(true) - ->select($db->quoteName(array('sef', 'lang_code', 'image', 'title', 'published'))) - ->from($db->quoteName('#__languages')) - ->where($db->quoteName('published') . ' != -2') - ->order($db->quoteName('ordering') . ' ASC'); - - $db->setQuery($query); - - return $db->loadObjectList('lang_code'); + return LanguageHelper::getContentLanguages(array(0, 1)); } /** diff --git a/administrator/components/com_associations/models/fields/itemlanguage.php b/administrator/components/com_associations/models/fields/itemlanguage.php index 459a91a7c2c6f..d7e9566fccf66 100644 --- a/administrator/components/com_associations/models/fields/itemlanguage.php +++ b/administrator/components/com_associations/models/fields/itemlanguage.php @@ -10,6 +10,7 @@ defined('JPATH_BASE') or die; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Language\LanguageHelper; JLoader::register('AssociationsHelper', JPATH_ADMINISTRATOR . '/components/com_associations/helpers/associations.php'); JFormHelper::loadFieldClass('list'); @@ -57,7 +58,7 @@ protected function getOptions() $canCreate = AssociationsHelper::allowAdd($extensionName, $typeName); // Gets existing languages. - $existingLanguages = AssociationsHelper::getContentLanguages(); + $existingLanguages = LanguageHelper::getContentLanguages(array(0, 1)); $options = array(); diff --git a/libraries/src/Language/LanguageHelper.php b/libraries/src/Language/LanguageHelper.php index d40ab54c0faa2..aa238b5da0927 100644 --- a/libraries/src/Language/LanguageHelper.php +++ b/libraries/src/Language/LanguageHelper.php @@ -323,17 +323,17 @@ public static function getInstalledLanguages($clientId = null, $processMetaData /** * Get a list of content languages. * - * @param boolean $checkPublished Check if the content language is published. - * @param boolean $checkInstalled Check if the content language is installed. - * @param string $pivot The pivot of the returning array. - * @param string $orderField Field to order the results. - * @param string $orderDirection Direction to order the results. + * @param array $publishedStates Array with the content language published states. Empty array for all. + * @param boolean $checkInstalled Check if the content language is installed. + * @param string $pivot The pivot of the returning array. + * @param string $orderField Field to order the results. + * @param string $orderDirection Direction to order the results. * * @return array Array of the content languages. * * @since 3.7.0 */ - public static function getContentLanguages($checkPublished = true, $checkInstalled = true, $pivot = 'lang_code', $orderField = null, + public static function getContentLanguages($publishedStates = array(1), $checkInstalled = true, $pivot = 'lang_code', $orderField = null, $orderDirection = null) { static $contentLanguages = null; @@ -362,12 +362,22 @@ public static function getContentLanguages($checkPublished = true, $checkInstall $languages = $contentLanguages; - // Check if the language is published, if needed. - if ($checkPublished) + // B/C layer. Before __DEPLOY_VERSION__. + if ($publishedStates === true) + { + $publishedStates = array(1); + } + elseif ($publishedStates === false) + { + $publishedStates = array(); + } + + // Check the language published state, if needed. + if (count($publishedStates) > 0) { foreach ($languages as $key => $language) { - if ((int) $language->published === 0) + if (!in_array((int) $language->published, $publishedStates, true)) { unset($languages[$key]); }