Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Actually merge in Save & Publish, don't just pretend to

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.1.0@42286 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
commit 73b5103a788ee9fbd11f85097834894615e3b287 1 parent d71d3c2
@ajoneil ajoneil authored sminnee committed
View
11 code/CMSMain.php
@@ -315,7 +315,7 @@ public function getEditForm($id) {
}
if($record->canEdit()) {
- $actions->push(new FormAction('save','Save draft'));
+ $actions->push(new FormAction('save','Save'));
}
}
}
@@ -393,15 +393,6 @@ public function Link($action = null) {
return "admin/$action";
}
- public function publish($urlParams, $form) {
- $id = $_REQUEST['ID'];
- $record = DataObject::get_by_id("SiteTree", $id);
- $form->saveInto($record);
- $this->performPublish($record);
-
- return $this->tellBrowserAboutPublicationChange($record, "Published '$record->Title' successfully");
- }
-
public function deletefromlive($urlParams, $form) {
$id = $_REQUEST['ID'];
Versioned::reading_stage('Live');
View
10 code/LeftAndMain.php
@@ -353,7 +353,7 @@ public function returnItemToUser($p) {
/**
- * Save page handler
+ * Save and Publish page handler
*/
public function save($urlParams, $form) {
$className = $this->stat('tree_class');
@@ -487,7 +487,13 @@ public function save($urlParams, $form) {
}
- return FormResponse::respond();
+ // If the 'Save & Publish' button was clicked, also publish the page
+ if(isset($urlParams['publish']) && $urlParams['publish'] == 1) {
+ $this->performPublish($record);
+ return $this->tellBrowserAboutPublicationChange($record, "Published '$record->Title' successfully");
+ } else {
+ return FormResponse::respond();
+ }
}
/**
View
11 javascript/CMSMain_right.js
@@ -1,13 +1,6 @@
function action_publish_right() {
- $('Form_EditForm').notify('BeforeSave');
- Ajax.SubmitForm('Form_EditForm', 'action_publish', {
- onSuccess : function(response) {
- Ajax.Evaluator(response);
- },
- onFailure : function(response) {
- errorMessage('Error publishing content', response);
- }
- });
+ var publish = true;
+ $('Form_EditForm').save(false, null, 'save', publish);
}
function action_revert_right() {
Ajax.SubmitForm('Form_EditForm', 'action_revert', {
View
8 javascript/LeftAndMain_right.js
@@ -129,8 +129,10 @@ CMSForm.prototype = {
/**
* Save the contens of the form, by submitting it and resetting is changed checker
* on success.
+ *
+ * @param publish boolean (optional) whether to publish in addition to saving
*/
- save: function(ifChanged, callAfter, action) {
+ save: function(ifChanged, callAfter, action, publish) {
_AJAX_LOADING = true;
if(typeof tinyMCE != 'undefined') tinyMCE.triggerSave();
if(!action) action = "save";
@@ -160,6 +162,10 @@ CMSForm.prototype = {
} else {
var data = this.serializeAllFields() + '&ajax=1&action_' + action + '=1';
}
+ if(publish)
+ {
+ data += '&publish=1';
+ }
statusMessage("Saving...", null, true);
new Ajax.Request(this.action, {
Please sign in to comment.
Something went wrong with that request. Please try again.