2009-08-04 05:09:26 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2009-10-22 00:26:52 +02:00
|
|
|
* Base class for filtering the subtree for certain node statuses.
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2009-10-22 00:26:52 +02:00
|
|
|
* The simplest way of building a CMSSiteTreeFilter is to create a pagesToBeShown() method that
|
|
|
|
* returns an Iterator of maps, each entry containing the 'ID' and 'ParentID' of the pages to be
|
2014-03-27 20:29:30 +01:00
|
|
|
* included in the tree. The result of a DB::query() can then be returned directly.
|
2009-10-22 00:26:52 +02:00
|
|
|
*
|
|
|
|
* If you wish to make a more complex tree, you can overload includeInTree($page) to return true/
|
2014-03-27 20:29:30 +01:00
|
|
|
* false depending on whether the given page should be included. Note that you will need to include
|
2009-10-22 00:26:52 +02:00
|
|
|
* parent helper pages yourself.
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2009-08-04 05:09:26 +02:00
|
|
|
* @package cms
|
|
|
|
* @subpackage content
|
|
|
|
*/
|
2015-04-30 07:14:45 +02:00
|
|
|
abstract class CMSSiteTreeFilter extends Object implements LeftAndMain_SearchFilter {
|
2009-10-22 00:26:52 +02:00
|
|
|
|
2009-11-22 09:23:12 +01:00
|
|
|
/**
|
|
|
|
* @var Array Search parameters, mostly properties on {@link SiteTree}.
|
|
|
|
* Caution: Unescaped data.
|
|
|
|
*/
|
|
|
|
protected $params = array();
|
|
|
|
|
|
|
|
/**
|
2015-04-30 07:14:45 +02:00
|
|
|
* List of filtered items and all their parents
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2015-04-30 07:14:45 +02:00
|
|
|
* @var array
|
2009-11-22 09:23:12 +01:00
|
|
|
*/
|
|
|
|
protected $_cache_ids = null;
|
2015-04-30 07:14:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Subset of $_cache_ids which include only items that appear directly in search results.
|
|
|
|
* When highlighting these, item IDs in this subset should be visually distinguished from
|
|
|
|
* others in the complete set.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $_cache_highlight_ids = null;
|
2009-08-04 05:09:26 +02:00
|
|
|
|
2009-11-22 09:23:12 +01:00
|
|
|
/**
|
|
|
|
* @var Array
|
|
|
|
*/
|
|
|
|
protected $_cache_expanded = array();
|
|
|
|
|
|
|
|
/**
|
2016-01-06 00:42:07 +01:00
|
|
|
* @var string
|
2009-11-22 09:23:12 +01:00
|
|
|
*/
|
|
|
|
protected $childrenMethod = null;
|
2014-07-20 01:46:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $numChildrenMethod = 'numChildren';
|
|
|
|
|
2012-10-30 05:56:14 +01:00
|
|
|
/**
|
|
|
|
* Returns a sorted array of all implementators of CMSSiteTreeFilter, suitable for use in a dropdown.
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2012-10-30 05:56:14 +01:00
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public static function get_all_filters() {
|
|
|
|
// get all filter instances
|
|
|
|
$filters = ClassInfo::subclassesFor('CMSSiteTreeFilter');
|
2014-03-27 20:29:30 +01:00
|
|
|
|
2012-10-30 05:56:14 +01:00
|
|
|
// remove abstract CMSSiteTreeFilter class
|
|
|
|
array_shift($filters);
|
2014-03-27 20:29:30 +01:00
|
|
|
|
2012-10-30 05:56:14 +01:00
|
|
|
// add filters to map
|
|
|
|
$filterMap = array();
|
|
|
|
foreach($filters as $filter) {
|
2014-03-27 20:29:30 +01:00
|
|
|
$filterMap[$filter] = $filter::title();
|
2012-10-30 05:56:14 +01:00
|
|
|
}
|
2014-03-27 20:29:30 +01:00
|
|
|
|
|
|
|
// Ensure that 'all pages' filter is on top position and everything else is sorted alphabetically
|
|
|
|
uasort($filterMap, function($a, $b) {
|
|
|
|
return ($a === CMSSiteTreeFilter_Search::title())
|
|
|
|
? -1
|
|
|
|
: strcasecmp($a, $b);
|
|
|
|
});
|
2012-10-30 05:56:14 +01:00
|
|
|
|
|
|
|
return $filterMap;
|
|
|
|
}
|
2009-11-22 09:23:12 +01:00
|
|
|
|
2012-09-19 12:07:46 +02:00
|
|
|
public function __construct($params = null) {
|
2009-11-22 09:23:12 +01:00
|
|
|
if($params) $this->params = $params;
|
|
|
|
|
|
|
|
parent::__construct();
|
2009-08-04 05:09:26 +02:00
|
|
|
}
|
2009-11-22 09:23:12 +01:00
|
|
|
|
2012-09-19 12:07:46 +02:00
|
|
|
public function getChildrenMethod() {
|
2009-11-22 09:23:12 +01:00
|
|
|
return $this->childrenMethod;
|
2009-10-22 00:26:52 +02:00
|
|
|
}
|
2014-07-20 01:46:15 +02:00
|
|
|
|
|
|
|
public function getNumChildrenMethod() {
|
|
|
|
return $this->numChildrenMethod;
|
|
|
|
}
|
|
|
|
|
2015-04-30 07:14:45 +02:00
|
|
|
public function getPageClasses($page) {
|
|
|
|
if($this->_cache_ids === NULL) {
|
|
|
|
$this->populateIDs();
|
|
|
|
}
|
|
|
|
|
|
|
|
// If directly selected via filter, apply highlighting
|
|
|
|
if(!empty($this->_cache_highlight_ids[$page->ID])) {
|
|
|
|
return 'filtered-item';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-22 00:26:52 +02:00
|
|
|
/**
|
2014-08-06 05:00:48 +02:00
|
|
|
* Gets the list of filtered pages
|
|
|
|
*
|
|
|
|
* @see {@link SiteTree::getStatusFlags()}
|
|
|
|
* @return SS_List
|
|
|
|
*/
|
|
|
|
abstract public function getFilteredPages();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array Map of Page IDs to their respective ParentID values.
|
2009-11-22 09:23:12 +01:00
|
|
|
*/
|
2014-08-06 05:00:48 +02:00
|
|
|
public function pagesIncluded() {
|
|
|
|
return $this->mapIDs($this->getFilteredPages());
|
|
|
|
}
|
2009-11-22 09:23:12 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Populate the IDs of the pages returned by pagesIncluded(), also including
|
2009-10-22 00:26:52 +02:00
|
|
|
* the necessary parent helper pages.
|
|
|
|
*/
|
|
|
|
protected function populateIDs() {
|
2009-11-22 09:23:12 +01:00
|
|
|
$parents = array();
|
|
|
|
$this->_cache_ids = array();
|
2015-04-30 07:14:45 +02:00
|
|
|
$this->_cache_highlight_ids = array();
|
2009-11-22 09:23:12 +01:00
|
|
|
|
|
|
|
if($pages = $this->pagesIncluded()) {
|
2009-10-22 00:26:52 +02:00
|
|
|
|
2016-01-06 00:42:07 +01:00
|
|
|
// And keep a record of parents we don't need to get
|
2009-11-22 09:23:12 +01:00
|
|
|
// parents of themselves, as well as IDs to mark
|
|
|
|
foreach($pages as $pageArr) {
|
|
|
|
$parents[$pageArr['ParentID']] = true;
|
|
|
|
$this->_cache_ids[$pageArr['ID']] = true;
|
2015-04-30 07:14:45 +02:00
|
|
|
$this->_cache_highlight_ids[$pageArr['ID']] = true;
|
2009-10-22 00:26:52 +02:00
|
|
|
}
|
2012-09-04 04:51:14 +02:00
|
|
|
|
|
|
|
while(!empty($parents)) {
|
2014-07-20 01:46:15 +02:00
|
|
|
$q = Versioned::get_including_deleted('SiteTree', '"RecordID" in ('.implode(',',array_keys($parents)).')');
|
|
|
|
$list = $q->map('ID', 'ParentID');
|
2012-09-04 04:51:14 +02:00
|
|
|
$parents = array();
|
2014-07-20 01:46:15 +02:00
|
|
|
foreach($list as $id => $parentID) {
|
|
|
|
if ($parentID) $parents[$parentID] = true;
|
|
|
|
$this->_cache_ids[$id] = true;
|
|
|
|
$this->_cache_expanded[$id] = true;
|
2009-10-22 00:26:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-22 09:23:12 +01:00
|
|
|
public function isPageIncluded($page) {
|
2015-04-30 07:14:45 +02:00
|
|
|
if($this->_cache_ids === NULL) {
|
|
|
|
$this->populateIDs();
|
|
|
|
}
|
2009-11-22 09:23:12 +01:00
|
|
|
|
2015-04-30 07:14:45 +02:00
|
|
|
return !empty($this->_cache_ids[$page->ID]);
|
2009-10-22 00:26:52 +02:00
|
|
|
}
|
2014-03-27 20:29:30 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Applies the default filters to a specified DataList of pages
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2014-03-27 20:29:30 +01:00
|
|
|
* @param DataList $query Unfiltered query
|
|
|
|
* @return DataList Filtered query
|
|
|
|
*/
|
|
|
|
protected function applyDefaultFilters($query) {
|
|
|
|
$sng = singleton('SiteTree');
|
|
|
|
foreach($this->params as $name => $val) {
|
|
|
|
if(empty($val)) continue;
|
|
|
|
|
|
|
|
switch($name) {
|
|
|
|
case 'Term':
|
|
|
|
$query = $query->filterAny(array(
|
|
|
|
'URLSegment:PartialMatch' => $val,
|
|
|
|
'Title:PartialMatch' => $val,
|
|
|
|
'MenuTitle:PartialMatch' => $val,
|
|
|
|
'Content:PartialMatch' => $val
|
|
|
|
));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'LastEditedFrom':
|
|
|
|
$fromDate = new DateField(null, null, $val);
|
2014-07-24 04:34:06 +02:00
|
|
|
$query = $query->filter("LastEdited:GreaterThanOrEqual", $fromDate->dataValue().' 00:00:00');
|
2014-03-27 20:29:30 +01:00
|
|
|
break;
|
2009-10-22 00:26:52 +02:00
|
|
|
|
2014-03-27 20:29:30 +01:00
|
|
|
case 'LastEditedTo':
|
|
|
|
$toDate = new DateField(null, null, $val);
|
2014-07-24 04:34:06 +02:00
|
|
|
$query = $query->filter("LastEdited:LessThanOrEqual", $toDate->dataValue().' 23:59:59');
|
2014-03-27 20:29:30 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'ClassName':
|
|
|
|
if($val != 'All') {
|
|
|
|
$query = $query->filter('ClassName', $val);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if($sng->hasDatabaseField($name)) {
|
|
|
|
$filter = $sng->dbObject($name)->defaultSearchFilter();
|
|
|
|
$filter->setValue($val);
|
|
|
|
$query = $query->alterDataQuery(array($filter, 'apply'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $query;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps a list of pages to an array of associative arrays with ID and ParentID keys
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2014-03-27 20:29:30 +01:00
|
|
|
* @param DataList $pages
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
protected function mapIDs($pages) {
|
|
|
|
$ids = array();
|
|
|
|
if($pages) foreach($pages as $page) {
|
|
|
|
$ids[] = array('ID' => $page->ID, 'ParentID' => $page->ParentID);
|
|
|
|
}
|
|
|
|
return $ids;
|
|
|
|
}
|
2009-08-04 05:09:26 +02:00
|
|
|
}
|
|
|
|
|
2014-07-28 08:57:09 +02:00
|
|
|
/**
|
|
|
|
* This filter will display the SiteTree as a site visitor might see the site, i.e only the
|
|
|
|
* pages that is currently published.
|
|
|
|
*
|
|
|
|
* Note that this does not check canView permissions that might hide pages from certain visitors
|
2015-08-24 06:14:33 +02:00
|
|
|
*
|
|
|
|
* @package cms
|
|
|
|
* @subpackage content
|
2014-07-28 08:57:09 +02:00
|
|
|
*/
|
2015-08-24 06:14:33 +02:00
|
|
|
class CMSSiteTreeFilter_PublishedPages extends CMSSiteTreeFilter {
|
2014-07-28 08:57:09 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
static public function title() {
|
|
|
|
return _t('CMSSIteTreeFilter_PublishedPages.Title', "Published pages");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $childrenMethod = "AllHistoricalChildren";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $numChildrenMethod = 'numHistoricalChildren';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Filters out all pages who's status who's status that doesn't exist on live
|
|
|
|
*
|
|
|
|
* @see {@link SiteTree::getStatusFlags()}
|
2014-08-06 05:00:48 +02:00
|
|
|
* @return SS_List
|
2014-07-28 08:57:09 +02:00
|
|
|
*/
|
2014-08-06 05:00:48 +02:00
|
|
|
public function getFilteredPages() {
|
2014-07-28 08:57:09 +02:00
|
|
|
$pages = Versioned::get_including_deleted('SiteTree');
|
|
|
|
$pages = $this->applyDefaultFilters($pages);
|
|
|
|
$pages = $pages->filterByCallback(function($page) {
|
2015-06-05 01:09:23 +02:00
|
|
|
return $page->getExistsOnLive();
|
2014-07-28 08:57:09 +02:00
|
|
|
});
|
2014-08-06 05:00:48 +02:00
|
|
|
return $pages;
|
2014-07-28 08:57:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-22 09:23:12 +01:00
|
|
|
/**
|
|
|
|
* Works a bit different than the other filters:
|
|
|
|
* Shows all pages *including* those deleted from stage and live.
|
|
|
|
* It does not filter out pages still existing in the different stages.
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2009-11-22 09:23:12 +01:00
|
|
|
* @package cms
|
|
|
|
* @subpackage content
|
|
|
|
*/
|
2009-08-04 05:09:26 +02:00
|
|
|
class CMSSiteTreeFilter_DeletedPages extends CMSSiteTreeFilter {
|
2014-07-20 01:46:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
2009-11-22 09:23:12 +01:00
|
|
|
protected $childrenMethod = "AllHistoricalChildren";
|
2014-07-20 01:46:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $numChildrenMethod = 'numHistoricalChildren';
|
2009-11-22 09:23:12 +01:00
|
|
|
|
2012-09-19 12:07:46 +02:00
|
|
|
static public function title() {
|
2015-05-15 01:51:23 +02:00
|
|
|
return _t('CMSSiteTreeFilter_DeletedPages.Title', "All pages, including archived");
|
2009-08-04 05:09:26 +02:00
|
|
|
}
|
|
|
|
|
2014-08-06 05:00:48 +02:00
|
|
|
public function getFilteredPages() {
|
2009-11-22 09:23:12 +01:00
|
|
|
$pages = Versioned::get_including_deleted('SiteTree');
|
2014-03-27 20:29:30 +01:00
|
|
|
$pages = $this->applyDefaultFilters($pages);
|
2014-08-06 05:00:48 +02:00
|
|
|
return $pages;
|
2009-08-04 05:09:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-22 09:23:12 +01:00
|
|
|
/**
|
|
|
|
* Gets all pages which have changed on stage.
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2009-11-22 09:23:12 +01:00
|
|
|
* @package cms
|
|
|
|
* @subpackage content
|
|
|
|
*/
|
2009-08-04 05:09:26 +02:00
|
|
|
class CMSSiteTreeFilter_ChangedPages extends CMSSiteTreeFilter {
|
2009-11-22 09:23:12 +01:00
|
|
|
|
2012-09-19 12:07:46 +02:00
|
|
|
static public function title() {
|
2015-05-15 01:51:23 +02:00
|
|
|
return _t('CMSSiteTreeFilter_ChangedPages.Title', "Modified pages");
|
2009-08-04 05:09:26 +02:00
|
|
|
}
|
|
|
|
|
2014-08-06 05:00:48 +02:00
|
|
|
public function getFilteredPages() {
|
2014-03-27 20:29:30 +01:00
|
|
|
$pages = Versioned::get_by_stage('SiteTree', 'Stage');
|
|
|
|
$pages = $this->applyDefaultFilters($pages)
|
|
|
|
->leftJoin('SiteTree_Live', '"SiteTree_Live"."ID" = "SiteTree"."ID"')
|
2014-08-07 05:49:09 +02:00
|
|
|
->where('"SiteTree"."Version" <> "SiteTree_Live"."Version"');
|
2014-08-06 05:00:48 +02:00
|
|
|
return $pages;
|
2014-03-27 20:29:30 +01:00
|
|
|
}
|
|
|
|
}
|
2009-11-22 09:23:12 +01:00
|
|
|
|
2014-03-27 20:29:30 +01:00
|
|
|
/**
|
|
|
|
* Filters pages which have a status "Removed from Draft".
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2014-03-27 20:29:30 +01:00
|
|
|
* @package cms
|
|
|
|
* @subpackage content
|
|
|
|
*/
|
|
|
|
class CMSSiteTreeFilter_StatusRemovedFromDraftPages extends CMSSiteTreeFilter {
|
|
|
|
|
|
|
|
static public function title() {
|
|
|
|
return _t('CMSSiteTreeFilter_StatusRemovedFromDraftPages.Title', 'Live but removed from draft');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Filters out all pages who's status is set to "Removed from draft".
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2014-08-06 05:00:48 +02:00
|
|
|
* @return SS_List
|
2014-03-27 20:29:30 +01:00
|
|
|
*/
|
2014-08-06 05:00:48 +02:00
|
|
|
public function getFilteredPages() {
|
2014-03-27 20:29:30 +01:00
|
|
|
$pages = Versioned::get_including_deleted('SiteTree');
|
|
|
|
$pages = $this->applyDefaultFilters($pages);
|
|
|
|
$pages = $pages->filterByCallback(function($page) {
|
|
|
|
// If page is removed from stage but not live
|
2015-06-05 01:09:23 +02:00
|
|
|
return $page->getIsDeletedFromStage() && $page->getExistsOnLive();
|
2014-03-27 20:29:30 +01:00
|
|
|
});
|
2014-08-06 05:00:48 +02:00
|
|
|
return $pages;
|
2014-03-27 20:29:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Filters pages which have a status "Draft".
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2014-03-27 20:29:30 +01:00
|
|
|
* @package cms
|
|
|
|
* @subpackage content
|
|
|
|
*/
|
|
|
|
class CMSSiteTreeFilter_StatusDraftPages extends CMSSiteTreeFilter {
|
|
|
|
|
|
|
|
static public function title() {
|
2015-05-15 01:51:23 +02:00
|
|
|
return _t('CMSSiteTreeFilter_StatusDraftPages.Title', 'Draft pages');
|
2014-03-27 20:29:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Filters out all pages who's status is set to "Draft".
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2014-03-27 20:29:30 +01:00
|
|
|
* @see {@link SiteTree::getStatusFlags()}
|
2014-08-06 05:00:48 +02:00
|
|
|
* @return SS_List
|
2014-03-27 20:29:30 +01:00
|
|
|
*/
|
2014-08-06 05:00:48 +02:00
|
|
|
public function getFilteredPages() {
|
2014-03-27 20:29:30 +01:00
|
|
|
$pages = Versioned::get_by_stage('SiteTree', 'Stage');
|
|
|
|
$pages = $this->applyDefaultFilters($pages);
|
|
|
|
$pages = $pages->filterByCallback(function($page) {
|
|
|
|
// If page exists on stage but not on live
|
2015-06-05 01:09:23 +02:00
|
|
|
return (!$page->getIsDeletedFromStage() && $page->getIsAddedToStage());
|
2014-03-27 20:29:30 +01:00
|
|
|
});
|
2014-08-06 05:00:48 +02:00
|
|
|
return $pages;
|
2014-03-27 20:29:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Filters pages which have a status "Deleted".
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2014-03-27 20:29:30 +01:00
|
|
|
* @package cms
|
|
|
|
* @subpackage content
|
|
|
|
*/
|
|
|
|
class CMSSiteTreeFilter_StatusDeletedPages extends CMSSiteTreeFilter {
|
2014-07-20 01:46:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $childrenMethod = "AllHistoricalChildren";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $numChildrenMethod = 'numHistoricalChildren';
|
2014-03-27 20:29:30 +01:00
|
|
|
|
|
|
|
static public function title() {
|
2015-05-15 01:51:23 +02:00
|
|
|
return _t('CMSSiteTreeFilter_StatusDeletedPages.Title', 'Archived pages');
|
2014-03-27 20:29:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Filters out all pages who's status is set to "Deleted".
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2014-03-27 20:29:30 +01:00
|
|
|
* @see {@link SiteTree::getStatusFlags()}
|
2014-08-06 05:00:48 +02:00
|
|
|
* @return SS_List
|
2014-03-27 20:29:30 +01:00
|
|
|
*/
|
2014-08-06 05:00:48 +02:00
|
|
|
public function getFilteredPages() {
|
2014-03-27 20:29:30 +01:00
|
|
|
$pages = Versioned::get_including_deleted('SiteTree');
|
|
|
|
$pages = $this->applyDefaultFilters($pages);
|
2014-07-20 01:46:15 +02:00
|
|
|
|
2014-03-27 20:29:30 +01:00
|
|
|
$pages = $pages->filterByCallback(function($page) {
|
|
|
|
// Doesn't exist on either stage or live
|
2015-06-05 01:09:23 +02:00
|
|
|
return $page->getIsDeletedFromStage() && !$page->getExistsOnLive();
|
2014-03-27 20:29:30 +01:00
|
|
|
});
|
2014-08-06 05:00:48 +02:00
|
|
|
return $pages;
|
2009-10-22 00:26:52 +02:00
|
|
|
}
|
2009-08-04 05:09:26 +02:00
|
|
|
}
|
|
|
|
|
2009-11-22 09:23:12 +01:00
|
|
|
/**
|
|
|
|
* @package cms
|
|
|
|
* @subpackage content
|
|
|
|
*/
|
2009-08-04 05:09:26 +02:00
|
|
|
class CMSSiteTreeFilter_Search extends CMSSiteTreeFilter {
|
2009-11-22 09:23:12 +01:00
|
|
|
|
2012-09-19 12:07:46 +02:00
|
|
|
static public function title() {
|
2009-11-22 09:45:59 +01:00
|
|
|
return _t('CMSSiteTreeFilter_Search.Title', "All pages");
|
2009-08-04 05:09:26 +02:00
|
|
|
}
|
|
|
|
|
2009-10-22 00:26:52 +02:00
|
|
|
/**
|
|
|
|
* Retun an array of maps containing the keys, 'ID' and 'ParentID' for each page to be displayed
|
|
|
|
* in the search.
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2014-08-06 05:00:48 +02:00
|
|
|
* @return SS_List
|
2009-10-22 00:26:52 +02:00
|
|
|
*/
|
2014-08-06 05:00:48 +02:00
|
|
|
public function getFilteredPages() {
|
2014-03-27 20:29:30 +01:00
|
|
|
// Filter default records
|
|
|
|
$pages = Versioned::get_by_stage('SiteTree', 'Stage');
|
|
|
|
$pages = $this->applyDefaultFilters($pages);
|
2014-08-06 05:00:48 +02:00
|
|
|
return $pages;
|
2009-08-04 05:09:26 +02:00
|
|
|
}
|
2012-04-12 09:23:20 +02:00
|
|
|
}
|