mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-09-30 13:19:14 +02:00
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
This commit is contained in:
parent
d71d3c2253
commit
73b5103a78
@ -315,7 +315,7 @@ JS;
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($record->canEdit()) {
|
if($record->canEdit()) {
|
||||||
$actions->push(new FormAction('save','Save draft'));
|
$actions->push(new FormAction('save','Save'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -393,15 +393,6 @@ JS;
|
|||||||
return "admin/$action";
|
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) {
|
public function deletefromlive($urlParams, $form) {
|
||||||
$id = $_REQUEST['ID'];
|
$id = $_REQUEST['ID'];
|
||||||
Versioned::reading_stage('Live');
|
Versioned::reading_stage('Live');
|
||||||
|
@ -353,7 +353,7 @@ JS;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save page handler
|
* Save and Publish page handler
|
||||||
*/
|
*/
|
||||||
public function save($urlParams, $form) {
|
public function save($urlParams, $form) {
|
||||||
$className = $this->stat('tree_class');
|
$className = $this->stat('tree_class');
|
||||||
@ -487,8 +487,14 @@ JS;
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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();
|
return FormResponse::respond();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a piece of javascript that will update the actions of the main form
|
* Return a piece of javascript that will update the actions of the main form
|
||||||
|
@ -1,13 +1,6 @@
|
|||||||
function action_publish_right() {
|
function action_publish_right() {
|
||||||
$('Form_EditForm').notify('BeforeSave');
|
var publish = true;
|
||||||
Ajax.SubmitForm('Form_EditForm', 'action_publish', {
|
$('Form_EditForm').save(false, null, 'save', publish);
|
||||||
onSuccess : function(response) {
|
|
||||||
Ajax.Evaluator(response);
|
|
||||||
},
|
|
||||||
onFailure : function(response) {
|
|
||||||
errorMessage('Error publishing content', response);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
function action_revert_right() {
|
function action_revert_right() {
|
||||||
Ajax.SubmitForm('Form_EditForm', 'action_revert', {
|
Ajax.SubmitForm('Form_EditForm', 'action_revert', {
|
||||||
|
@ -129,8 +129,10 @@ CMSForm.prototype = {
|
|||||||
/**
|
/**
|
||||||
* Save the contens of the form, by submitting it and resetting is changed checker
|
* Save the contens of the form, by submitting it and resetting is changed checker
|
||||||
* on success.
|
* 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;
|
_AJAX_LOADING = true;
|
||||||
if(typeof tinyMCE != 'undefined') tinyMCE.triggerSave();
|
if(typeof tinyMCE != 'undefined') tinyMCE.triggerSave();
|
||||||
if(!action) action = "save";
|
if(!action) action = "save";
|
||||||
@ -160,6 +162,10 @@ CMSForm.prototype = {
|
|||||||
} else {
|
} else {
|
||||||
var data = this.serializeAllFields() + '&ajax=1&action_' + action + '=1';
|
var data = this.serializeAllFields() + '&ajax=1&action_' + action + '=1';
|
||||||
}
|
}
|
||||||
|
if(publish)
|
||||||
|
{
|
||||||
|
data += '&publish=1';
|
||||||
|
}
|
||||||
|
|
||||||
statusMessage("Saving...", null, true);
|
statusMessage("Saving...", null, true);
|
||||||
new Ajax.Request(this.action, {
|
new Ajax.Request(this.action, {
|
||||||
|
Loading…
Reference in New Issue
Block a user