Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BUGFIX Fixed createtranslation action (broken after moving to extension)

  • Loading branch information...
commit 181bb07f4c2193c151ca9c4133568b53b5515847 1 parent e40b5f9
@chillu chillu authored
View
13 code/controller/TranslatableCMSMainExtension.php
@@ -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);
}
View
35 javascript/CMSMain.Translatable.js
@@ -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;
}
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.