2016-08-16 03:22:58 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\CMS\Controllers;
|
|
|
|
|
|
|
|
use SilverStripe\CMS\Model\SiteTree;
|
|
|
|
use SilverStripe\ORM\SS_List;
|
2017-03-21 05:26:46 +01:00
|
|
|
use SilverStripe\Versioned\Versioned;
|
2016-08-16 03:22:58 +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
|
|
|
|
*/
|
|
|
|
class CMSSiteTreeFilter_PublishedPages extends CMSSiteTreeFilter
|
|
|
|
{
|
|
|
|
|
2017-01-25 21:59:25 +01:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public static function title()
|
|
|
|
{
|
2018-02-20 22:32:13 +01:00
|
|
|
return _t(__CLASS__ . '.Title', "Published pages");
|
2017-01-25 21:59:25 +01:00
|
|
|
}
|
2016-08-16 03:22:58 +02:00
|
|
|
|
2017-01-25 21:59:25 +01:00
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $childrenMethod = "AllHistoricalChildren";
|
2016-08-16 03:22:58 +02:00
|
|
|
|
2017-01-25 21:59:25 +01:00
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $numChildrenMethod = 'numHistoricalChildren';
|
2016-08-16 03:22:58 +02:00
|
|
|
|
2017-01-25 21:59:25 +01:00
|
|
|
/**
|
|
|
|
* Filters out all pages who's status who's status that doesn't exist on live
|
|
|
|
*
|
|
|
|
* @see {@link SiteTree::getStatusFlags()}
|
|
|
|
* @return SS_List
|
|
|
|
*/
|
|
|
|
public function getFilteredPages()
|
|
|
|
{
|
2020-04-15 03:31:02 +02:00
|
|
|
$pages = Versioned::get_including_deleted(SiteTree::class)
|
2019-01-17 21:27:55 +01:00
|
|
|
->innerJoin(
|
|
|
|
'SiteTree_Live',
|
|
|
|
'"SiteTree_Versions"."RecordID" = "SiteTree_Live"."ID"'
|
|
|
|
);
|
2020-04-15 03:31:02 +02:00
|
|
|
|
|
|
|
$pages = $this->applyDefaultFilters($pages);
|
|
|
|
|
|
|
|
return $pages;
|
2017-01-25 21:59:25 +01:00
|
|
|
}
|
2016-08-16 03:22:58 +02:00
|
|
|
}
|