mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
MINOR added language dropdown to subsite (from r84567)
This commit is contained in:
parent
4be67533d4
commit
f9a95055cb
@ -21,9 +21,10 @@ class Subsite extends DataObject implements PermissionProvider {
|
||||
'RedirectURL' => 'Varchar(255)',
|
||||
'DefaultSite' => 'Boolean',
|
||||
'Theme' => 'Varchar',
|
||||
'Language' => 'Varchar(6)',
|
||||
|
||||
// Used to hide unfinished/private subsites from public view.
|
||||
// If unset, will default to
|
||||
// If unset, will default to true
|
||||
'IsPublic' => 'Boolean'
|
||||
);
|
||||
|
||||
@ -143,6 +144,8 @@ class Subsite extends DataObject implements PermissionProvider {
|
||||
array("Domain" => "TextField", "IsPrimary" => "CheckboxField"),
|
||||
"SubsiteID", $this->ID);
|
||||
|
||||
$languageSelector = new DropdownField('Language', 'Language', i18n::get_common_languages());
|
||||
|
||||
$fields = new FieldSet(
|
||||
new TabSet('Root',
|
||||
new Tab('Configuration',
|
||||
@ -151,6 +154,7 @@ class Subsite extends DataObject implements PermissionProvider {
|
||||
|
||||
new HeaderField("Domains for this subsite"),
|
||||
$domainTable,
|
||||
$languageSelector,
|
||||
// new TextField('RedirectURL', 'Redirect to URL', $this->RedirectURL),
|
||||
new CheckboxField('DefaultSite', 'Default site', $this->DefaultSite),
|
||||
new CheckboxField('IsPublic', 'Enable public access', $this->IsPublic),
|
||||
@ -251,6 +255,13 @@ JS;
|
||||
|
||||
Session::set('SubsiteID', (int)$subsiteID);
|
||||
|
||||
// Set locale
|
||||
if (is_object($subsite) && $subsite->Language != '') {
|
||||
if (isset(i18n::$likely_subtags[$subsite->Language])) {
|
||||
i18n::set_locale(i18n::$likely_subtags[$subsite->Language]);
|
||||
}
|
||||
}
|
||||
|
||||
// Only bother flushing caches if we've actually changed
|
||||
if($subsiteID != self::currentSubsiteID()) {
|
||||
Permission::flush_permission_cache();
|
||||
|
Loading…
Reference in New Issue
Block a user