mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
MINOR Merged r69410 from trunk
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@69839 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
1e4083c290
commit
3351aef184
@ -370,11 +370,7 @@ JS;
|
|||||||
Versioned::reading_stage('Live');
|
Versioned::reading_stage('Live');
|
||||||
singleton($treeClass)->flushCache();
|
singleton($treeClass)->flushCache();
|
||||||
$record = DataObject::get_one( $treeClass, "`$treeClass`.ID = $id");
|
$record = DataObject::get_one( $treeClass, "`$treeClass`.ID = $id");
|
||||||
if($record) {
|
if($record) Versioned::reading_stage(null);
|
||||||
$record->DeletedFromStage = true;
|
|
||||||
} else {
|
|
||||||
Versioned::reading_stage(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $record;
|
return $record;
|
||||||
|
|
||||||
@ -387,7 +383,7 @@ JS;
|
|||||||
$record = $this->getRecord($id);
|
$record = $this->getRecord($id);
|
||||||
|
|
||||||
if($record) {
|
if($record) {
|
||||||
if($record->DeletedFromStage) $record->Status = _t('CMSMain.REMOVEDFD',"Removed from the draft site");
|
if($record->IsDeletedFromStage) $record->Status = _t('CMSMain.REMOVEDFD',"Removed from the draft site");
|
||||||
|
|
||||||
$fields = $record->getCMSFields($this);
|
$fields = $record->getCMSFields($this);
|
||||||
if ($fields == null) {
|
if ($fields == null) {
|
||||||
@ -407,7 +403,7 @@ JS;
|
|||||||
if($liveRecord) $liveURLField->setValue($liveRecord->AbsoluteLink());
|
if($liveRecord) $liveURLField->setValue($liveRecord->AbsoluteLink());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$record->DeletedFromStage) {
|
if(!$record->IsDeletedFromStage) {
|
||||||
$stageURLField->setValue($record->AbsoluteLink());
|
$stageURLField->setValue($record->AbsoluteLink());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,7 +426,7 @@ JS;
|
|||||||
$form->loadDataFrom($record);
|
$form->loadDataFrom($record);
|
||||||
$form->disableDefaultAction();
|
$form->disableDefaultAction();
|
||||||
|
|
||||||
if(!$record->canEdit() || $record->DeletedFromStage) {
|
if(!$record->canEdit() || $record->IsDeletedFromStage) {
|
||||||
$readonlyFields = $form->Fields()->makeReadonly();
|
$readonlyFields = $form->Fields()->makeReadonly();
|
||||||
$form->setFields($readonlyFields);
|
$form->setFields($readonlyFields);
|
||||||
}
|
}
|
||||||
@ -464,7 +460,6 @@ JS;
|
|||||||
$p = $this->getNewItem("new-$className-$parent".$suffix, false);
|
$p = $this->getNewItem("new-$className-$parent".$suffix, false);
|
||||||
$p->write();
|
$p->write();
|
||||||
|
|
||||||
$p->CheckedPublicationDifferences = $p->AddedToStage = true;
|
|
||||||
return $this->returnItemToUser($p);
|
return $this->returnItemToUser($p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -520,6 +515,11 @@ JS;
|
|||||||
return $newItem;
|
return $newItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the page from live. This means a page in draft mode might still exist.
|
||||||
|
*
|
||||||
|
* @see delete()
|
||||||
|
*/
|
||||||
public function deletefromlive($urlParams, $form) {
|
public function deletefromlive($urlParams, $form) {
|
||||||
$id = $_REQUEST['ID'];
|
$id = $_REQUEST['ID'];
|
||||||
Versioned::reading_stage('Live');
|
Versioned::reading_stage('Live');
|
||||||
@ -577,9 +577,8 @@ JS;
|
|||||||
* @uses SiteTree->doRevertToLive()
|
* @uses SiteTree->doRevertToLive()
|
||||||
*/
|
*/
|
||||||
public function revert($urlParams, $form) {
|
public function revert($urlParams, $form) {
|
||||||
$id = $_REQUEST['ID'];
|
$id = (int)$_REQUEST['ID'];
|
||||||
$record = DataObject::get_by_id("SiteTree", $id);
|
$record = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree_Live\".\"ID\" = {$id}");
|
||||||
|
|
||||||
// a user can restore a page without publication rights, as it just adds a new draft state
|
// a user can restore a page without publication rights, as it just adds a new draft state
|
||||||
// (this action should just be available when page has been "deleted from draft")
|
// (this action should just be available when page has been "deleted from draft")
|
||||||
if($record && !$record->canEdit()) return Security::permissionFailure($this);
|
if($record && !$record->canEdit()) return Security::permissionFailure($this);
|
||||||
@ -595,19 +594,32 @@ JS;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the current page
|
* Delete the current page from draft stage.
|
||||||
|
* @see deletefromlive()
|
||||||
*/
|
*/
|
||||||
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");
|
||||||
if($record && !$record->canDelete()) return Security::permissionFailure();
|
if($record && !$record->canDelete()) return Security::permissionFailure();
|
||||||
|
|
||||||
|
// save ID and delete record
|
||||||
$recordID = $record->ID;
|
$recordID = $record->ID;
|
||||||
$record->delete();
|
$record->delete();
|
||||||
$record->ID = $recordID;
|
|
||||||
|
|
||||||
if(Director::is_ajax()) {
|
if(Director::is_ajax()) {
|
||||||
return $this->tellBrowserAboutPublicationChange($record, sprintf(_t('CMSMain.REMOVEDPAGEFROMDRAFT',"Removed '%s' from the draft site"),$record->Title));
|
// need a valid ID value even if the record doesn't have one in the database
|
||||||
|
// (its still present in the live tables)
|
||||||
|
$liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree_Live\".\"ID\" = $recordID");
|
||||||
|
// if the page has never been published to live, we need to act the same way as in deletefromlive()
|
||||||
|
if($liveRecord) {
|
||||||
|
// the form is readonly now, so we need to refresh the representation
|
||||||
|
FormResponse::get_page($recordID);
|
||||||
|
return $this->tellBrowserAboutPublicationChange($liveRecord, sprintf(_t('CMSMain.REMOVEDPAGEFROMDRAFT',"Removed '%s' from the draft site"),$record->Title));
|
||||||
|
} else {
|
||||||
|
FormResponse::add($this->deleteTreeNodeJS($record));
|
||||||
|
FormResponse::status_message(sprintf(_t('CMSMain.REMOVEDPAGEFROMDRAFT',"Removed '%s' from the draft site"),$record->Title), 'good');
|
||||||
|
return FormResponse::respond();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Director::redirectBack();
|
Director::redirectBack();
|
||||||
}
|
}
|
||||||
@ -683,7 +695,7 @@ JS;
|
|||||||
function tellBrowserAboutPublicationChange($page, $statusMessage) {
|
function tellBrowserAboutPublicationChange($page, $statusMessage) {
|
||||||
$JS_title = Convert::raw2js($page->TreeTitle());
|
$JS_title = Convert::raw2js($page->TreeTitle());
|
||||||
|
|
||||||
$JS_stageURL = $page->DeletedFromStage ? '' : Convert::raw2js($page->AbsoluteLink());
|
$JS_stageURL = $page->IsDeletedFromStage ? '' : Convert::raw2js($page->AbsoluteLink());
|
||||||
$liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "`SiteTree`.ID = $page->ID");
|
$liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "`SiteTree`.ID = $page->ID");
|
||||||
$JS_liveURL = $liveRecord ? Convert::raw2js($liveRecord->AbsoluteLink()) : '';
|
$JS_liveURL = $liveRecord ? Convert::raw2js($liveRecord->AbsoluteLink()) : '';
|
||||||
|
|
||||||
@ -1010,10 +1022,8 @@ JS;
|
|||||||
$record->destroy();
|
$record->destroy();
|
||||||
|
|
||||||
// DataObject::delete_by_id($this->stat('tree_class'), $id);
|
// DataObject::delete_by_id($this->stat('tree_class'), $id);
|
||||||
$record->CheckedPublicationDifferences = $record->DeletedFromStage = true;
|
|
||||||
|
|
||||||
// check to see if the record exists on the live site, if it doesn't remove the tree node
|
// check to see if the record exists on the live site, if it doesn't remove the tree node
|
||||||
// $_REQUEST['showqueries'] = 1 ;
|
|
||||||
$liveRecord = Versioned::get_one_by_stage( $this->stat('tree_class'), 'Live', "`{$this->stat('tree_class')}`.`ID`={$id}");
|
$liveRecord = Versioned::get_one_by_stage( $this->stat('tree_class'), 'Live', "`{$this->stat('tree_class')}`.`ID`={$id}");
|
||||||
|
|
||||||
if($liveRecord) {
|
if($liveRecord) {
|
||||||
@ -1328,7 +1338,6 @@ JS
|
|||||||
$newrecord = clone $record;
|
$newrecord = clone $record;
|
||||||
$newrecord->ID = $temporalID;
|
$newrecord->ID = $temporalID;
|
||||||
|
|
||||||
$newrecord->CheckedPublicationDifferences = $newrecord->AddedToStage = true;
|
|
||||||
return $this->returnItemToUser($newrecord);
|
return $this->returnItemToUser($newrecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user