2011-03-24 09:18:01 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Publish items batch action.
|
|
|
|
*
|
|
|
|
* @package cms
|
|
|
|
* @subpackage batchaction
|
|
|
|
*/
|
|
|
|
class CMSBatchAction_Publish extends CMSBatchAction {
|
|
|
|
function getActionTitle() {
|
|
|
|
return _t('CMSBatchActions.PUBLISH_PAGES', 'Publish');
|
|
|
|
}
|
|
|
|
|
2011-05-03 04:17:02 +02:00
|
|
|
function run(SS_List $pages) {
|
2011-03-24 09:18:01 +01:00
|
|
|
return $this->batchaction($pages, 'doPublish',
|
|
|
|
_t('CMSBatchActions.PUBLISHED_PAGES', 'Published %d pages, %d failures')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function applicablePages($ids) {
|
|
|
|
return $this->applicablePagesHelper($ids, 'canPublish', true, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Un-publish items batch action.
|
|
|
|
*
|
|
|
|
* @package cms
|
|
|
|
* @subpackage batchaction
|
|
|
|
*/
|
|
|
|
class CMSBatchAction_Unpublish extends CMSBatchAction {
|
|
|
|
function getActionTitle() {
|
|
|
|
return _t('CMSBatchActions.UNPUBLISH_PAGES', 'Un-publish');
|
|
|
|
}
|
|
|
|
|
2011-05-03 04:17:02 +02:00
|
|
|
function run(SS_List $pages) {
|
2011-03-24 09:18:01 +01:00
|
|
|
return $this->batchaction($pages, 'doUnpublish',
|
|
|
|
_t('CMSBatchActions.UNPUBLISHED_PAGES', 'Un-published %d pages')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete items batch action.
|
|
|
|
*
|
|
|
|
* @package cms
|
|
|
|
* @subpackage batchaction
|
|
|
|
*/
|
|
|
|
class CMSBatchAction_Delete extends CMSBatchAction {
|
|
|
|
function getActionTitle() {
|
|
|
|
return _t('CMSBatchActions.DELETE_DRAFT_PAGES', 'Delete from draft site');
|
|
|
|
}
|
|
|
|
|
2011-05-03 04:17:02 +02:00
|
|
|
function run(SS_List $pages) {
|
2011-03-24 09:18:01 +01:00
|
|
|
$status = array(
|
|
|
|
'modified'=>array(),
|
|
|
|
'deleted'=>array(),
|
|
|
|
'error'=>array()
|
|
|
|
);
|
|
|
|
|
|
|
|
foreach($pages as $page) {
|
|
|
|
$id = $page->ID;
|
|
|
|
|
|
|
|
// Perform the action
|
|
|
|
if($page->canDelete()) $page->delete();
|
|
|
|
else $status['error'][$page->ID] = true;
|
|
|
|
|
|
|
|
// check to see if the record exists on the live site,
|
|
|
|
// if it doesn't remove the tree node
|
|
|
|
$liveRecord = Versioned::get_one_by_stage( 'SiteTree', 'Live', "\"SiteTree\".\"ID\"=$id");
|
|
|
|
if($liveRecord) {
|
|
|
|
$liveRecord->IsDeletedFromStage = true;
|
|
|
|
$status['modified'][$liveRecord->ID] = array(
|
|
|
|
'TreeTitle' => $liveRecord->TreeTitle,
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$status['deleted'][$id] = array();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return Convert::raw2json($status);
|
|
|
|
}
|
|
|
|
|
|
|
|
function applicablePages($ids) {
|
|
|
|
return $this->applicablePagesHelper($ids, 'canDelete', true, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unpublish (delete from live site) items batch action.
|
|
|
|
*
|
|
|
|
* @package cms
|
|
|
|
* @subpackage batchaction
|
|
|
|
*/
|
|
|
|
class CMSBatchAction_DeleteFromLive extends CMSBatchAction {
|
|
|
|
function getActionTitle() {
|
|
|
|
return _t('CMSBatchActions.DELETE_PAGES', 'Delete from published site');
|
|
|
|
}
|
2011-03-28 04:12:22 +02:00
|
|
|
|
2011-03-24 09:18:01 +01:00
|
|
|
|
2011-05-03 04:17:02 +02:00
|
|
|
function run(SS_List $pages) {
|
2011-03-24 09:18:01 +01:00
|
|
|
$status = array(
|
|
|
|
'modified'=>array(),
|
|
|
|
'deleted'=>array()
|
|
|
|
);
|
|
|
|
|
|
|
|
foreach($pages as $page) {
|
|
|
|
$id = $page->ID;
|
|
|
|
|
|
|
|
// Perform the action
|
|
|
|
if($page->canDelete()) $page->doDeleteFromLive();
|
|
|
|
|
|
|
|
// check to see if the record exists on the stage site, if it doesn't remove the tree node
|
|
|
|
$stageRecord = Versioned::get_one_by_stage( 'SiteTree', 'Stage', "\"SiteTree\".\"ID\"=$id");
|
|
|
|
if($stageRecord) {
|
|
|
|
$stageRecord->IsAddedToStage = true;
|
|
|
|
$status['modified'][$stageRecord->ID] = array(
|
|
|
|
'TreeTitle' => $stageRecord->TreeTitle,
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$status['deleted'][$id] = array();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return Convert::raw2json($status);
|
|
|
|
}
|
|
|
|
|
|
|
|
function applicablePages($ids) {
|
|
|
|
return $this->applicablePagesHelper($ids, 'canDelete', false, true);
|
|
|
|
}
|
|
|
|
}
|