#1801 - search provides all results back, not a filtered search (merged from branches/2.2.0, r44867)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@44925 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Andrew O'Neil 2007-11-15 22:46:52 +00:00
parent 7eb2078d28
commit b4fc0105e4

View File

@ -1343,16 +1343,13 @@ JS
}
}
$filterCache = array();
// TODO: Find way to put this in a class
function cmsMainMarkingFilterFunction($node) {
// Expand all nodes
// $node->markingFinished();
// Don't ever hide nodes with children, because otherwise if one of their children matches the search, it wouldn't be shown.
if($node->AllChildrenIncludingDeleted()->count() > 0) {
// Open all nodes with children so it is easy to see any children that match the search.
$node->markOpened();
return true;
} else {
$failed_filter = false;
// First check for the generic search term in the URLSegment, Title, MenuTitle, & Content
if (!empty($_REQUEST['SiteTreeSearchTerm'])) {
@ -1387,11 +1384,29 @@ function cmsMainMarkingFilterFunction($node) {
}
// Each filter must match or it fails
if (true == $failed_filter) {
return false;
} else {
// Don't ever hide nodes with children, because otherwise if one of their children matches the search, it wouldn't be shown.
if($node->AllChildrenIncludingDeleted()->count() > 0) {
// Open all nodes with children so it is easy to see any children that match the search.
foreach($node->AllChildrenIncludingDeleted() as $childNode) {
if(cmsMainMarkingFilterFunction($childNode)) {
$node->markOpened();
$filterCache[$node->ID] = true;
return true;
}
}
}
$filterCache[$node->ID] = false;
return false;
} else {
if($node->AllChildrenIncludingDeleted()->count() > 0) {
$node->markOpened();
}
$filterCache[$node->ID] = true;
return true;
}
}
?>