2011-03-24 09:18:01 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Publish items batch action.
|
|
|
|
*
|
|
|
|
* @package cms
|
|
|
|
* @subpackage batchaction
|
|
|
|
*/
|
|
|
|
class CMSBatchAction_Publish extends CMSBatchAction {
|
2012-09-19 12:07:46 +02:00
|
|
|
public function getActionTitle() {
|
2011-03-24 09:18:01 +01:00
|
|
|
return _t('CMSBatchActions.PUBLISH_PAGES', 'Publish');
|
|
|
|
}
|
|
|
|
|
2012-09-19 12:07:46 +02:00
|
|
|
public 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')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-09-19 12:07:46 +02:00
|
|
|
public function applicablePages($ids) {
|
2011-03-24 09:18:01 +01:00
|
|
|
return $this->applicablePagesHelper($ids, 'canPublish', true, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-05-15 01:51:23 +02:00
|
|
|
* Unpublish items batch action.
|
2011-03-24 09:18:01 +01:00
|
|
|
*
|
|
|
|
* @package cms
|
|
|
|
* @subpackage batchaction
|
|
|
|
*/
|
|
|
|
class CMSBatchAction_Unpublish extends CMSBatchAction {
|
2012-09-19 12:07:46 +02:00
|
|
|
public function getActionTitle() {
|
2015-05-15 01:51:23 +02:00
|
|
|
return _t('CMSBatchActions.UNPUBLISH_PAGES', 'Unpublish');
|
2011-03-24 09:18:01 +01:00
|
|
|
}
|
|
|
|
|
2012-09-19 12:07:46 +02:00
|
|
|
public function run(SS_List $pages) {
|
2011-03-24 09:18:01 +01:00
|
|
|
return $this->batchaction($pages, 'doUnpublish',
|
2015-05-15 01:51:23 +02:00
|
|
|
_t('CMSBatchActions.UNPUBLISHED_PAGES', 'Unpublished %d pages')
|
2011-03-24 09:18:01 +01:00
|
|
|
);
|
|
|
|
}
|
2015-05-15 01:51:23 +02:00
|
|
|
|
|
|
|
public function applicablePages($ids) {
|
|
|
|
return $this->applicablePagesHelper($ids, 'canDeleteFromLive', false, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Archives a page, removing it from both live and stage
|
|
|
|
*
|
|
|
|
* @package cms
|
|
|
|
* @subpackage batchaction
|
|
|
|
*/
|
|
|
|
class CMSBatchAction_Archive extends CMSBatchAction {
|
|
|
|
|
|
|
|
public function getActionTitle() {
|
|
|
|
return _t('CMSBatchActions.ARCHIVE', 'Archive');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function run(SS_List $pages) {
|
|
|
|
return $this->batchaction($pages, 'doArchive',
|
|
|
|
_t('CMSBatchActions.ARCHIVED_PAGES', 'Archived %d pages')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function applicablePages($ids) {
|
|
|
|
return $this->applicablePagesHelper($ids, 'canArchive', true, true);
|
|
|
|
}
|
|
|
|
|
2011-03-24 09:18:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete items batch action.
|
|
|
|
*
|
|
|
|
* @package cms
|
|
|
|
* @subpackage batchaction
|
2015-05-15 01:51:23 +02:00
|
|
|
* @deprecated since version 4.0
|
2011-03-24 09:18:01 +01:00
|
|
|
*/
|
|
|
|
class CMSBatchAction_Delete extends CMSBatchAction {
|
2012-09-19 12:07:46 +02:00
|
|
|
public function getActionTitle() {
|
2011-03-24 09:18:01 +01:00
|
|
|
return _t('CMSBatchActions.DELETE_DRAFT_PAGES', 'Delete from draft site');
|
|
|
|
}
|
|
|
|
|
2012-09-19 12:07:46 +02:00
|
|
|
public function run(SS_List $pages) {
|
2015-05-15 01:51:23 +02:00
|
|
|
Deprecation::notice('4.0', 'Delete is deprecated. Use Archive instead');
|
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
|
2013-06-21 00:45:33 +02:00
|
|
|
$liveRecord = Versioned::get_one_by_stage( 'SiteTree', 'Live', array(
|
|
|
|
'"SiteTree"."ID"' => $id
|
|
|
|
));
|
2011-03-24 09:18:01 +01:00
|
|
|
if($liveRecord) {
|
|
|
|
$liveRecord->IsDeletedFromStage = true;
|
|
|
|
$status['modified'][$liveRecord->ID] = array(
|
|
|
|
'TreeTitle' => $liveRecord->TreeTitle,
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$status['deleted'][$id] = array();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-22 04:09:52 +02:00
|
|
|
return $this->response(_t('CMSBatchActions.DELETED_DRAFT_PAGES', 'Deleted %d pages from draft site, %d failures'), $status);
|
2011-03-24 09:18:01 +01:00
|
|
|
}
|
|
|
|
|
2012-09-19 12:07:46 +02:00
|
|
|
public function applicablePages($ids) {
|
2011-03-24 09:18:01 +01:00
|
|
|
return $this->applicablePagesHelper($ids, 'canDelete', true, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unpublish (delete from live site) items batch action.
|
|
|
|
*
|
|
|
|
* @package cms
|
|
|
|
* @subpackage batchaction
|
2015-05-15 01:51:23 +02:00
|
|
|
* @deprecated since version 4.0
|
2011-03-24 09:18:01 +01:00
|
|
|
*/
|
|
|
|
class CMSBatchAction_DeleteFromLive extends CMSBatchAction {
|
2012-09-19 12:07:46 +02:00
|
|
|
public function getActionTitle() {
|
2011-03-24 09:18:01 +01:00
|
|
|
return _t('CMSBatchActions.DELETE_PAGES', 'Delete from published site');
|
|
|
|
}
|
2011-03-28 04:12:22 +02:00
|
|
|
|
2012-09-19 12:07:46 +02:00
|
|
|
public function run(SS_List $pages) {
|
2015-05-15 01:51:23 +02:00
|
|
|
Deprecation::notice('4.0', 'Delete From Live is deprecated. Use Unpublish instead');
|
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
|
2013-06-21 00:45:33 +02:00
|
|
|
$stageRecord = Versioned::get_one_by_stage( 'SiteTree', 'Stage', array(
|
|
|
|
'"SiteTree"."ID"' => $id
|
|
|
|
));
|
2011-03-24 09:18:01 +01:00
|
|
|
if($stageRecord) {
|
|
|
|
$stageRecord->IsAddedToStage = true;
|
|
|
|
$status['modified'][$stageRecord->ID] = array(
|
|
|
|
'TreeTitle' => $stageRecord->TreeTitle,
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$status['deleted'][$id] = array();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-22 04:09:52 +02:00
|
|
|
return $this->response(_t('CMSBatchActions.DELETED_PAGES', 'Deleted %d pages from published site, %d failures'), $status);
|
2011-03-24 09:18:01 +01:00
|
|
|
}
|
|
|
|
|
2012-09-19 12:07:46 +02:00
|
|
|
public function applicablePages($ids) {
|
2011-03-24 09:18:01 +01:00
|
|
|
return $this->applicablePagesHelper($ids, 'canDelete', false, true);
|
|
|
|
}
|
2012-04-12 09:23:20 +02:00
|
|
|
}
|