mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT Moved i18n::get_existing_content_languages() to correct namespace in Translatable::get_existing_content_languages().
BUGFIX Using SQL DISTINCT in get_existing_content_languages() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@69891 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
6e91017d17
commit
23ed38765c
@ -853,26 +853,6 @@ class i18n extends Object {
|
||||
return self::$all_locales;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of languages with at least one element translated in (including the default language)
|
||||
*
|
||||
* @param string $className Look for languages in elements of this class
|
||||
* @return array Map of languages in the form langCode => langName
|
||||
*/
|
||||
static function get_existing_content_languages($className = 'SiteTree', $where = '') {
|
||||
if(!Translatable::is_enabled()) return false;
|
||||
|
||||
$query = new SQLQuery('Lang',$className.'_lang',$where,"",'Lang');
|
||||
$dbLangs = $query->execute()->column();
|
||||
$langlist = array_merge((array)Translatable::default_lang(), (array)$dbLangs);
|
||||
$returnMap = array();
|
||||
$allCodes = array_merge(self::$all_locales, self::$common_languages);
|
||||
foreach ($langlist as $langCode) {
|
||||
$returnMap[$langCode] = (is_array($allCodes[$langCode]) ? $allCodes[$langCode][0] : $allCodes[$langCode]);
|
||||
}
|
||||
return $returnMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches the root-directory for module-directories
|
||||
* (identified by having a _config.php on their first directory-level).
|
||||
|
@ -467,7 +467,7 @@ class Image_Uploader extends Controller {
|
||||
|
||||
// set reading lang
|
||||
if(Translatable::is_enabled() && !Director::is_ajax()) {
|
||||
Translatable::choose_site_lang(array_keys(i18n::get_existing_content_languages('SiteTree')));
|
||||
Translatable::choose_site_lang(array_keys(Translatable::get_existing_content_languages('SiteTree')));
|
||||
}
|
||||
|
||||
parent::init();
|
||||
|
@ -743,6 +743,27 @@ class Translatable extends DataObjectDecorator {
|
||||
}
|
||||
return $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of languages with at least one element translated in (including the default language)
|
||||
*
|
||||
* @param string $className Look for languages in elements of this class
|
||||
* @return array Map of languages in the form langCode => langName
|
||||
*/
|
||||
static function get_existing_content_languages($className = 'SiteTree', $where = '') {
|
||||
if(!Translatable::is_enabled()) return false;
|
||||
$baseTable = ClassInfo::baseDataClass($className);
|
||||
$query = new SQLQuery('Distinct Lang',$baseTable,$where,"",'Lang');
|
||||
$dbLangs = $query->execute()->column();
|
||||
$langlist = array_merge((array)Translatable::default_lang(), (array)$dbLangs);
|
||||
$returnMap = array();
|
||||
$allCodes = array_merge(i18n::$all_locales, i18n::$common_languages);
|
||||
foreach ($langlist as $langCode) {
|
||||
if($langCode)
|
||||
$returnMap[$langCode] = (is_array($allCodes[$langCode]) ? $allCodes[$langCode][0] : $allCodes[$langCode]);
|
||||
}
|
||||
return $returnMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ class LanguageDropdownField extends GroupedDropdownField {
|
||||
*/
|
||||
function __construct($name, $title, $dontInclude = array(), $translatingClass = 'SiteTree', $list = 'Common-English' ) {
|
||||
$usedlangs = array_diff(
|
||||
i18n::get_existing_content_languages($translatingClass),
|
||||
Translatable::get_existing_content_languages($translatingClass),
|
||||
$dontInclude
|
||||
);
|
||||
// we accept in dontInclude both language codes and names, so another diff is required
|
||||
|
Loading…
x
Reference in New Issue
Block a user