mirror of
https://github.com/silverstripe/silverstripe-translatable
synced 2024-10-22 11:05:59 +02:00
Set current locale on POST requests (fixes #156)
This commit is contained in:
parent
a0a6ec2f91
commit
da30096d65
@ -16,9 +16,6 @@ class TranslatableCMSMainExtension extends Extension {
|
||||
// as an intermediary rather than the endpoint controller
|
||||
if(!$this->owner->stat('tree_class')) return;
|
||||
|
||||
// Leave form submissions alone
|
||||
if($req->httpMethod() != 'GET') return;
|
||||
|
||||
// Locale" attribute is either explicitly added by LeftAndMain Javascript logic,
|
||||
// or implied on a translated record (see {@link Translatable->updateCMSFields()}).
|
||||
// $Lang serves as a "context" which can be inspected by Translatable - hence it
|
||||
@ -48,14 +45,14 @@ class TranslatableCMSMainExtension extends Extension {
|
||||
}
|
||||
Translatable::set_current_locale($this->owner->Locale);
|
||||
|
||||
// if a locale is set, it needs to match to the current record
|
||||
if($req->requestVar("Locale")) {
|
||||
$requestLocale = $req->requestVar("Locale");
|
||||
}
|
||||
|
||||
// If a locale is set, it needs to match to the current record
|
||||
$requestLocale = $req->requestVar("Locale");
|
||||
$page = $this->owner->currentPage();
|
||||
if(
|
||||
$requestLocale && $page && $page->hasExtension('Translatable')
|
||||
$req->httpMethod() == 'GET' // leave form submissions alone
|
||||
&& $requestLocale
|
||||
&& $page
|
||||
&& $page->hasExtension('Translatable')
|
||||
&& $page->Locale != $requestLocale
|
||||
&& $req->latestParam('Action') != 'EditorToolbar'
|
||||
) {
|
||||
|
Loading…
Reference in New Issue
Block a user