diff --git a/code/CMSMain.php b/code/CMSMain.php index fd545dce..1336f742 100644 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -9,6 +9,11 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionProvider { static $tree_class = "SiteTree"; static $subitem_class = "Member"; + /** + * SiteTree Columns that can be filtered using the the Site Tree Search button + */ + static $site_tree_filter_options = array('ClassName' => 'Page Type', 'Status' => 'Status', + 'MetaDescription' => 'Description', 'MetaKeywords' => 'Keywords'); public function init() { parent::init(); @@ -103,6 +108,59 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr return $this->getSiteTreeFor("SiteTree"); } + /** + * Returns the SiteTree columns that can be filtered using the the Site Tree Search button as a DataObjectSet + */ + public function SiteTreeFilterOptions() { + $filter_options = new DataObjectSet(); + foreach(self::$site_tree_filter_options as $key => $value) { + $record = array( + 'Column' => $key, + 'Title' => $value, + ); + $filter_options->push(new ArrayData($record)); + } + return $filter_options; + } + public function SiteTreeFilterDateField() { + $dateField = new CalendarDateField('SiteTreeFilterDate'); + return $dateField->Field(); + } + + /** + * Returns a filtered Site Tree + */ + public function filterSiteTree() { + $className = 'SiteTree'; + $rootID = null; + $obj = $rootID ? $this->getRecord($rootID) : singleton($className); + $obj->setMarkingFilterFunction('CMSMainMarkingFilterFunction'); + $obj->markPartialTree(); + + if($p = $this->currentPage()) $obj->markToExpose($p); + + // getChildrenAsUL is a flexible and complex way of traversing the tree + $siteTree = $obj->getChildrenAsUL("", ' + "