Skip to content

Commit

Permalink
MINOR Using Form->forTemplate() to include <form> tags in controller …
Browse files Browse the repository at this point in the history
…actions on AssetAdmin and CMSMain (underlying clientside logic has changed)
  • Loading branch information
chillu committed Jul 8, 2011
1 parent 75ce441 commit c4c3d21
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
2 changes: 1 addition & 1 deletion code/controller/AssetAdmin.php
Expand Up @@ -358,7 +358,7 @@ public function doAdd($data, $form) {
return $record->ID;
} else if($this->isAjax()) {
$form = $this->getEditForm($record->ID);
return $form->formHtmlContent();
return $form->forTemplate();
} else {
return $this->redirect(Controller::join_links($this->Link('show'), $record->ID));
}
Expand Down
22 changes: 11 additions & 11 deletions code/controller/CMSMain.php
Expand Up @@ -345,7 +345,7 @@ function save_siteconfig($data, $form) {

$this->response->addHeader('X-Status', _t('LeftAndMain.SAVEDUP'));

return $form->formHtmlContent();
return $form->forTemplate();
}
/**
* Get a database record to be managed by the CMS
Expand Down Expand Up @@ -578,7 +578,7 @@ public function save($data, $form) {
$form = $this->getEditForm($record->ID);
}

return $form->formHtmlContent();
return $form->forTemplate();
}


Expand Down Expand Up @@ -615,7 +615,7 @@ public function doAdd($data, $form) {
return $record->ID;
} else if(Director::is_ajax()) {
$form = $this->getEditForm($record->ID);
return $form->formHtmlContent();
return $form->forTemplate();
} else {
return $this->redirect(Controller::join_links($this->Link('show'), $record->ID));
}
Expand Down Expand Up @@ -757,7 +757,7 @@ public function revert($data, $form) {

$form = $this->getEditForm($record->ID);

return $form->formHtmlContent();
return $form->forTemplate();
}

/**
Expand Down Expand Up @@ -791,7 +791,7 @@ public function delete($data, $form) {
'Live',
"\"SiteTree_Live\".\"ID\" = $recordID"
);
return ($liveRecord) ? $form->formHtmlContent() : "";
return ($liveRecord) ? $form->forTemplate() : "";
} else {
$this->redirectBack();
}
Expand Down Expand Up @@ -988,7 +988,7 @@ function rollback($data, $form) {

$form = $this->getEditForm($record->ID);

return $form->formHtmlContent();
return $form->forTemplate();
}

function publish($data, $form) {
Expand All @@ -1013,7 +1013,7 @@ function unpublish($data, $form) {
// Reload form, data and actions might have changed
$form = $this->getEditForm($record->ID);

return $form->formHtmlContent();
return $form->forTemplate();
}

function performRollback($id, $version) {
Expand Down Expand Up @@ -1187,7 +1187,7 @@ function compareversions() {
}

if($this->isAjax()) {
return $form->formHtmlContent();
return $form->forTemplate();
} else {
$templateData = $this->customise(array(
"EditForm" => $form
Expand Down Expand Up @@ -1426,7 +1426,7 @@ function restore($data, $form) {
// Reload form, data and actions might have changed
$form = $this->getEditForm($restoredPage->ID);

return $form->formHtmlContent();
return $form->forTemplate();
}

function duplicate($request) {
Expand All @@ -1450,7 +1450,7 @@ function duplicate($request) {
// Reload form, data and actions might have changed
$form = $this->getEditForm($newPage->ID);

return $form->formHtmlContent();
return $form->forTemplate();
} else {
user_error("CMSMain::duplicate() Bad ID: '$id'", E_USER_WARNING);
}
Expand All @@ -1471,7 +1471,7 @@ function duplicatewithchildren($request) {
// Reload form, data and actions might have changed
$form = $this->getEditForm($newPage->ID);

return $form->formHtmlContent();
return $form->forTemplate();
} else {
user_error("CMSMain::duplicate() Bad ID: '$id'", E_USER_WARNING);
}
Expand Down
8 changes: 6 additions & 2 deletions code/controller/CMSPagesController.php
Expand Up @@ -13,8 +13,12 @@ function init() {
}

function show($request) {
$c = new CMSPageEditController();
return $this->redirect(Controller::join_links($c->Link('show'), $request->param('ID')));
if($request->param('ID')) {
$c = new CMSPageEditController();
return $this->redirect(Controller::join_links($c->Link('show'), $request->param('ID')));
} else {
return parent::show($request);
}
}

}
2 changes: 1 addition & 1 deletion javascript/AssetAdmin.js
Expand Up @@ -47,7 +47,7 @@
var currNode = $('.cms-tree')[0].firstSelected();
if(currNode) {
var url = $(currNode).find('a').attr('href');
$('.cms-edit-form').loadForm(url);
$('.cms-content').loadForm(url);
}
$('.cms-tree')[0].setCustomURL('admin/assets/getsubtree');
$('.cms-tree')[0].reload({onSuccess: function() {
Expand Down
9 changes: 6 additions & 3 deletions javascript/CMSMain.js
Expand Up @@ -201,8 +201,9 @@
if (e.button!=2) {
var $link = $(this);
$link.addClass('loading');
jQuery('.cms-edit-form').entwine('ss').loadForm(
jQuery('.cms-content').entwine('ss').loadForm(
$(this).attr('href'),
null,
function(e) {
$link.removeClass('loading');
}
Expand Down Expand Up @@ -263,8 +264,9 @@

var link = $(this).siblings('.versionlink').find('a').attr('href');
td.addClass('loading');
jQuery('.cms-edit-form').entwine('ss').loadForm(
jQuery('.cms-content').entwine('ss').loadForm(
link,
null,
function(e) {
td.removeClass('loading');
}
Expand Down Expand Up @@ -314,8 +316,9 @@
data.push({name:$button.attr('name'), value: $button.val()});

if(loadEditForm) {
jQuery('.cms-edit-form').entwine('ss').loadForm(
jQuery('.cms-content').entwine('ss').loadForm(
this.attr('action'),
null,
function(e) {
$button.removeClass('loading');
},
Expand Down

0 comments on commit c4c3d21

Please sign in to comment.