mirror of
https://github.com/silverstripe/silverstripe-translatable
synced 2024-10-22 11:05:59 +02:00
Consistently use uppercase "Locale" GET param
Causes inconsistent behaviour between form field name ("Locale") and view state in GET parameters ("Locale" and "locale"). Related to #156.
This commit is contained in:
parent
6731a681e9
commit
a0a6ec2f91
@ -26,8 +26,6 @@ class TranslatableCMSMainExtension extends Extension {
|
||||
$id = $req->param('ID');
|
||||
if($req->requestVar("Locale")) {
|
||||
$this->owner->Locale = $req->requestVar("Locale");
|
||||
} elseif($req->requestVar("locale")) {
|
||||
$this->owner->Locale = $req->requestVar("locale");
|
||||
} else if($id && is_numeric($id)) {
|
||||
$record = DataObject::get_by_id($this->owner->stat('tree_class'), $id);
|
||||
if($record && $record->Locale) $this->owner->Locale = $record->Locale;
|
||||
@ -53,8 +51,6 @@ class TranslatableCMSMainExtension extends Extension {
|
||||
// if a locale is set, it needs to match to the current record
|
||||
if($req->requestVar("Locale")) {
|
||||
$requestLocale = $req->requestVar("Locale");
|
||||
} else {
|
||||
$requestLocale = $req->requestVar("locale");
|
||||
}
|
||||
|
||||
$page = $this->owner->currentPage();
|
||||
@ -75,7 +71,7 @@ class TranslatableCMSMainExtension extends Extension {
|
||||
// If the record is not translated, redirect to pages overview
|
||||
return $this->owner->redirect(Controller::join_links(
|
||||
singleton('CMSPagesController')->Link(),
|
||||
'?locale=' . $requestLocale
|
||||
'?Locale=' . $requestLocale
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -140,12 +136,12 @@ class TranslatableCMSMainExtension extends Extension {
|
||||
|
||||
function updateLink(&$link) {
|
||||
$locale = $this->owner->Locale ? $this->owner->Locale : Translatable::get_current_locale();
|
||||
if($locale) $link = Controller::join_links($link, '?locale=' . $locale);
|
||||
if($locale) $link = Controller::join_links($link, '?Locale=' . $locale);
|
||||
}
|
||||
|
||||
function updateLinkWithSearch(&$link) {
|
||||
$locale = $this->owner->Locale ? $this->owner->Locale : Translatable::get_current_locale();
|
||||
if($locale) $link = Controller::join_links($link, '?locale=' . $locale);
|
||||
if($locale) $link = Controller::join_links($link, '?Locale=' . $locale);
|
||||
}
|
||||
|
||||
function updateExtraTreeTools(&$html) {
|
||||
@ -155,7 +151,7 @@ class TranslatableCMSMainExtension extends Extension {
|
||||
|
||||
function updateLinkPageAdd(&$link) {
|
||||
$locale = $this->owner->Locale ? $this->owner->Locale : Translatable::get_current_locale();
|
||||
if($locale) $link = Controller::join_links($link, '?locale=' . $locale);
|
||||
if($locale) $link = Controller::join_links($link, '?Locale=' . $locale);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1119,7 +1119,7 @@ class Translatable extends DataExtension implements PermissionProvider {
|
||||
'<li><a href="%s">%s</a></li>',
|
||||
Controller::join_links(
|
||||
$existingTranslation->CMSEditLink(),
|
||||
'?locale=' . $existingTranslation->Locale
|
||||
'?Locale=' . $existingTranslation->Locale
|
||||
),
|
||||
i18n::get_locale_name($existingTranslation->Locale)
|
||||
);
|
||||
|
@ -37,10 +37,10 @@
|
||||
},
|
||||
onchange: function(e) {
|
||||
// Get new locale code
|
||||
locale = {locale: $(e.target).val()};
|
||||
var locale = {Locale: $(e.target).val()};
|
||||
|
||||
// Check existing url
|
||||
search = /locale=[^&]*/;
|
||||
search = /Locale=[^&]*/;
|
||||
url = document.location.href;
|
||||
if(url.match(search)) {
|
||||
// Replace locale code
|
||||
|
@ -31,7 +31,7 @@
|
||||
onchange: function(e) {
|
||||
// reload tree with selected locale
|
||||
var treeDropdown = $(this).parents('form').find('#internal .treedropdown');
|
||||
treeDropdown.data('urlTree', $.path.addSearchParams(treeDropdown.data('urlTree').replace(/locale=[^&]*/, ''), 'locale='+$(this).val()));
|
||||
treeDropdown.data('urlTree', $.path.addSearchParams(treeDropdown.data('urlTree').replace(/Locale=[^&]*/, ''), 'Locale='+$(this).val()));
|
||||
treeDropdown.loadTree();
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user