Skip to content

Commit

Permalink
Set current locale on POST requests (fixes #156)
Browse files Browse the repository at this point in the history
  • Loading branch information
chillu committed Jun 1, 2015
1 parent a0a6ec2 commit da30096
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions code/controller/TranslatableCMSMainExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ function init() {
// 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
Expand Down Expand Up @@ -48,14 +45,14 @@ function init() {
}
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'
) {
Expand Down

0 comments on commit da30096

Please sign in to comment.