BUGFIX Changed CMSMain->LangSelector() to always return a DropdownField, which ensures the 'Locale' parameter is always available to be passed along with ajax queries

ENHANCEMENT Passing sitetree instance to CMSMain->LangSelector() in order to trigger canTranslate() filtering

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@88139 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-10-05 20:41:54 +00:00
parent ee340bc99e
commit ed127fabf3

View File

@ -1259,23 +1259,19 @@ JS;
* Called by the SSViewer when rendering the template. * Called by the SSViewer when rendering the template.
*/ */
function LangSelector() { function LangSelector() {
$member = Member::currentUser(); //check to see if the current user can switch langs or not $member = Member::currentUser();
if(Permission::checkMember($member, 'VIEW_LANGS')) {
$dropdown = new LanguageDropdownField( $dropdown = new LanguageDropdownField(
'LangSelector', 'LangSelector',
'Language', 'Language',
array(), array(),
'SiteTree', 'SiteTree',
'Locale-English' 'Locale-English',
singleton('SiteTree')
); );
$dropdown->setValue(Translatable::get_current_locale()); $dropdown->setValue(Translatable::get_current_locale());
return $dropdown; return $dropdown;
} }
//user doesn't have permission to switch langs so just show a string displaying current language
return i18n::get_locale_name( Translatable::get_current_locale() );
}
/** /**
* Determine if there are more than one languages in our site tree. * Determine if there are more than one languages in our site tree.
* *