mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
Added delete from stage button to CMS
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@50845 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
cc11e36249
commit
dcedf0193a
@ -394,6 +394,11 @@ JS;
|
|||||||
$actions->push(new FormAction('deletefromlive',_t('CMSMain.DELETEFP','Delete from the published site')));
|
$actions->push(new FormAction('deletefromlive',_t('CMSMain.DELETEFP','Delete from the published site')));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if($record->canEdit()) {
|
||||||
|
$actions->push($deleteAction = new FormAction('delete',_t('CMSMain.DELETE','Delete from the draft site')));
|
||||||
|
$deleteAction->addExtraClass('delete');
|
||||||
|
}
|
||||||
|
|
||||||
if($record->hasMethod('getCMSActions')) {
|
if($record->hasMethod('getCMSActions')) {
|
||||||
$extraActions = $record->getCMSActions();
|
$extraActions = $record->getCMSActions();
|
||||||
if($extraActions) foreach($extraActions as $action) $actions->push($action);
|
if($extraActions) foreach($extraActions as $action) $actions->push($action);
|
||||||
@ -566,11 +571,21 @@ JS;
|
|||||||
return FormResponse::respond();
|
return FormResponse::respond();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the current page
|
||||||
|
*/
|
||||||
public function delete($urlParams, $form) {
|
public function delete($urlParams, $form) {
|
||||||
$id = $_REQUEST['ID'];
|
$id = $_REQUEST['ID'];
|
||||||
$record = DataObject::get_one("SiteTree", "SiteTree.ID = $id");
|
$record = DataObject::get_one("SiteTree", "SiteTree.ID = $id");
|
||||||
|
$recordID = $record->ID;
|
||||||
$record->delete();
|
$record->delete();
|
||||||
Director::redirectBack();
|
$record->ID = $recordID;
|
||||||
|
|
||||||
|
if(Director::is_ajax()) {
|
||||||
|
return $this->tellBrowserAboutPublicationChange($record, sprintf(_t('CMSMain.REMOVEDPAGEFROMDRAFT',"Removed '%s' from the draft site"),$record->Title));
|
||||||
|
} else {
|
||||||
|
Director::redirectBack();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------//
|
//------------------------------------------------------------------------------------------//
|
||||||
@ -772,7 +787,6 @@ HTML;
|
|||||||
return $this->tellBrowserAboutPublicationChange($page, sprintf(_t('CMSMain.REMOVEDPAGE',"Removed '%s' from the published site"),$page->Title));
|
return $this->tellBrowserAboutPublicationChange($page, sprintf(_t('CMSMain.REMOVEDPAGE',"Removed '%s' from the published site"),$page->Title));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a few pieces of information about a change to a page
|
* Return a few pieces of information about a change to a page
|
||||||
* - Send the new status message
|
* - Send the new status message
|
||||||
@ -788,7 +802,15 @@ HTML;
|
|||||||
$JS_liveURL = Convert::raw2js(DB::query("SELECT URLSegment FROM SiteTree_Live WHERE ID = $page->ID")->value());
|
$JS_liveURL = Convert::raw2js(DB::query("SELECT URLSegment FROM SiteTree_Live WHERE ID = $page->ID")->value());
|
||||||
FormResponse::add($this->getActionUpdateJS($page));
|
FormResponse::add($this->getActionUpdateJS($page));
|
||||||
FormResponse::update_status($page->Status);
|
FormResponse::update_status($page->Status);
|
||||||
FormResponse::add("\$('sitetree').setNodeTitle($page->ID, '$JS_title')");
|
|
||||||
|
if($JS_stageURL || $JS_liveURL) {
|
||||||
|
FormResponse::add("\$('sitetree').setNodeTitle($page->ID, '$JS_title')");
|
||||||
|
} else {
|
||||||
|
FormResponse::add("var node = $('sitetree').getTreeNodeByIdx('$page->ID');");
|
||||||
|
FormResponse::add("if(node.parentTreeNode) node.parentTreeNode.removeTreeNode(node);");
|
||||||
|
FormResponse::add("$('Form_EditForm').reloadIfSetTo($page->ID);");
|
||||||
|
}
|
||||||
|
|
||||||
FormResponse::status_message($statusMessage, 'good');
|
FormResponse::status_message($statusMessage, 'good');
|
||||||
FormResponse::add("$('Form_EditForm').elements.StageURLSegment.value = '$JS_stageURL'");
|
FormResponse::add("$('Form_EditForm').elements.StageURLSegment.value = '$JS_stageURL'");
|
||||||
FormResponse::add("$('Form_EditForm').elements.LiveURLSegment.value = '$JS_liveURL'");
|
FormResponse::add("$('Form_EditForm').elements.LiveURLSegment.value = '$JS_liveURL'");
|
||||||
|
Loading…
Reference in New Issue
Block a user