mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
#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:
parent
7eb2078d28
commit
b4fc0105e4
@ -1343,16 +1343,13 @@ JS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$filterCache = array();
|
||||||
|
|
||||||
// TODO: Find way to put this in a class
|
// TODO: Find way to put this in a class
|
||||||
function cmsMainMarkingFilterFunction($node) {
|
function cmsMainMarkingFilterFunction($node) {
|
||||||
// Expand all nodes
|
// Expand all nodes
|
||||||
// $node->markingFinished();
|
// $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;
|
$failed_filter = false;
|
||||||
// First check for the generic search term in the URLSegment, Title, MenuTitle, & Content
|
// First check for the generic search term in the URLSegment, Title, MenuTitle, & Content
|
||||||
if (!empty($_REQUEST['SiteTreeSearchTerm'])) {
|
if (!empty($_REQUEST['SiteTreeSearchTerm'])) {
|
||||||
@ -1387,11 +1384,29 @@ function cmsMainMarkingFilterFunction($node) {
|
|||||||
}
|
}
|
||||||
// Each filter must match or it fails
|
// Each filter must match or it fails
|
||||||
if (true == $failed_filter) {
|
if (true == $failed_filter) {
|
||||||
return false;
|
// Don't ever hide nodes with children, because otherwise if one of their children matches the search, it wouldn't be shown.
|
||||||
} else {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$filterCache[$node->ID] = false;
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
if($node->AllChildrenIncludingDeleted()->count() > 0) {
|
||||||
|
$node->markOpened();
|
||||||
|
}
|
||||||
|
|
||||||
|
$filterCache[$node->ID] = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue
Block a user