mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #1063 from stojg/pull/published-pages-cmsfilter
NEW Adding CMS sitetree filter to see the current 'live' site
This commit is contained in:
commit
1b0add3ecf
@ -202,6 +202,47 @@ abstract class CMSSiteTreeFilter extends Object {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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()}
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function pagesIncluded() {
|
||||||
|
$pages = Versioned::get_including_deleted('SiteTree');
|
||||||
|
$pages = $this->applyDefaultFilters($pages);
|
||||||
|
$pages = $pages->filterByCallback(function($page) {
|
||||||
|
return $page->ExistsOnLive;
|
||||||
|
});
|
||||||
|
return $this->mapIDs($pages);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Works a bit different than the other filters:
|
* Works a bit different than the other filters:
|
||||||
* Shows all pages *including* those deleted from stage and live.
|
* Shows all pages *including* those deleted from stage and live.
|
||||||
|
@ -96,3 +96,18 @@ Feature: Search for a page
|
|||||||
And I press the "Apply Filter" button
|
And I press the "Apply Filter" button
|
||||||
Then I should see "Live Page" in the tree
|
Then I should see "Live Page" in the tree
|
||||||
And I should not see "About Us" in the tree
|
And I should not see "About Us" in the tree
|
||||||
|
|
||||||
|
Scenario: I can include only live pages in my search
|
||||||
|
Given a "page" "Live Page"
|
||||||
|
And the "page" "Live Page" is published
|
||||||
|
And a "page" "Draft Page"
|
||||||
|
And a "page" "Draft Page" is unpublished
|
||||||
|
And a "page" "Deleted Page"
|
||||||
|
And the "page" "Deleted Page" is unpublished
|
||||||
|
And the "page" "Deleted Page" is deleted
|
||||||
|
|
||||||
|
When I select "Published pages" from "Pages"
|
||||||
|
And I press the "Apply Filter" button
|
||||||
|
Then I should not see "Draft Page" in the tree
|
||||||
|
And I should not see "Deleted Page" in the tree
|
||||||
|
But I should see "Live Page" in the tree
|
Loading…
Reference in New Issue
Block a user