Translation of SiteConfig

Fixed editing of translated configs, and added a link for the 'add
translation' not working for siteconfigs
This commit is contained in:
Ruud Arentsen 2012-07-26 15:06:42 +02:00 committed by Ingo Schommer
parent 2fb20aa7e5
commit 5b38cc31b8
4 changed files with 11 additions and 12 deletions

View File

@ -1,4 +1,4 @@
<?php
Object::add_extension('SiteTree', 'Translatable');
Object::add_extension('SiteConfig', 'Translatable');
Object::add_extension('CMSMain', 'TranslatableCMSMainExtension');
Object::add_extension('LeftAndMain', 'TranslatableCMSMainExtension');

View File

@ -52,7 +52,7 @@ class TranslatableCMSMainExtension extends Extension {
// see http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker
$langName = i18n::get_locale_name($this->owner->Locale);
HtmlEditorConfig::get('cms')->setOption('spellchecker_languages', "+{$langName}={$this->owner->Locale}");
Requirements::javascript('translatable/javascript/CMSMain.Translatable.js');
Requirements::css('translatable/css/CMSMain.Translatable.css');
}
@ -76,10 +76,10 @@ class TranslatableCMSMainExtension extends Extension {
// Protect against CSRF on destructive action
if(!SecurityToken::inst()->checkRequest($request)) return $this->owner->httpError(400);
$langCode = Convert::raw2sql($request->postVar('NewTransLang'));
$record = $this->owner->getRecord($request->postVar('ID'));
if(!$record) return $this->httpError(404);
if(!$record) return $this->owner->httpError(404);
$this->owner->Locale = $langCode;
Translatable::set_current_locale($langCode);
@ -91,11 +91,10 @@ class TranslatableCMSMainExtension extends Extension {
// @todo Allow in-memory creation of translations that don't persist in the database before the user requests it
$translatedRecord = $record->createTranslation($langCode);
$url = sprintf(
"%s/%d/?locale=%s",
singleton('CMSPageEditController')->Link('show'),
$url = Controller::join_links(
$this->owner->Link('show'),
$translatedRecord->ID,
$langCode
'?locale=' . $langCode
);
return $this->owner->redirect($url);

View File

@ -238,9 +238,9 @@ class Translatable extends DataExtension implements PermissionProvider {
return self::$current_locale;
}
if((isset($_GET['locale']) && !$langsAvailable) || (isset($_GET['locale']) && in_array($_GET['locale'], $langsAvailable))) {
// get from GET parameter
self::set_current_locale($_GET['locale']);
if((isset($_REQUEST['locale']) && !$langsAvailable) || (isset($_REQUEST['locale']) && in_array($_REQUEST['locale'], $langsAvailable))) {
// get from request parameter
self::set_current_locale($_REQUEST['locale']);
} else {
self::set_current_locale(self::default_locale());
}

View File

@ -52,7 +52,7 @@
* Requires:
* jquery.metadata
*/
$('.CMSMain :input[name=action_createtranslation]').entwine({
$('.LeftAndMain :input[name=action_createtranslation]').entwine({
onclick: function(e) {
this.parents('form').trigger('submit', [this]);