Permalink
Browse files

BUGFIX Fixed createtranslation action (broken after moving to extension)

  • Loading branch information...
chillu committed Mar 22, 2011
1 parent e40b5f9 commit 181bb07f4c2193c151ca9c4133568b53b5515847
Showing with 18 additions and 30 deletions.
  1. +4 −9 code/controller/TranslatableCMSMainExtension.php
  2. +14 −21 javascript/CMSMain.Translatable.js
@@ -4,16 +4,11 @@
*/
class TranslatableCMSMainExtension extends Extension {
function extraStatics() {
return array(
'allowed_actions' => array(
'createtranslation',
)
);
}
static $allowed_actions = array(
'createtranslation',
);
function init() {
// 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
@@ -76,7 +71,7 @@ function createtranslation($request) {
$translatedRecord->ID,
$langCode
);
return Director::redirect($url);
}
@@ -48,29 +48,22 @@
* Requires:
* jquery.metadata
*/
$('.CMSMain .createTranslation').entwine({
$('.CMSMain :input[name=action_createtranslation]').entwine({
/**
* Constructor: onmatch
*/
onmatch: function() {
var self = this;
this.find(':input[name=action_createtranslation]').bind('click', function(e) {
var form = self.parents('form');
// redirect to new URL
// TODO This should really be a POST request
document.location.href = $('base').attr('href') +
jQuery(self).metadata().url +
'?ID=' + form.find(':input[name=ID]').val() +
'&newlang=' + self.find(':input[name=NewTransLang]').val() +
'&locale=' + form.find(':input[name=Locale]').val();
onclick: function() {
var form = this.parents('form'), locale = form.find(':input[name=NewTransLang]').val();
var params = {
'ID': form.find(':input[name=ID]').val(),
'newlang': locale,
'locale': locale,
'SecurityID': form.find(':input[name=SecurityID]').val()
};
// redirect to new URL
// TODO This should really be a POST request
// TODO Fix hardcode URL
document.location.href = $('base').attr('href') + 'admin/createtranslation?' + $.param(params);
return false;
});
this._super();
return false;
}
});
});

0 comments on commit 181bb07

Please sign in to comment.