mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00:00
API CHANGE Removed CMSMainMarkingFilter, replaced a while ago by CMSSiteTreeFilter_Search
This commit is contained in:
parent
5a0208d77a
commit
2c3dd5dd53
@ -1490,70 +1490,3 @@ JS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @package cms
|
||||
* @subpackage content
|
||||
*/
|
||||
class CMSMainMarkingFilter {
|
||||
|
||||
function __construct() {
|
||||
$this->ids = array();
|
||||
$this->expanded = array();
|
||||
|
||||
$where = array();
|
||||
|
||||
// Match against URLSegment, Title, MenuTitle & Content
|
||||
if (isset($_REQUEST['Term'])) {
|
||||
$term = Convert::raw2sql($_REQUEST['Term']);
|
||||
$where[] = "\"URLSegment\" LIKE '%$term%' OR \"Title\" LIKE '%$term%' OR \"MenuTitle\" LIKE '%$term%' OR \"Content\" LIKE '%$term%'";
|
||||
}
|
||||
|
||||
// Match against date
|
||||
if (isset($_REQUEST['LastEdited'])) {
|
||||
$date = $_REQUEST['LastEdited'];
|
||||
$date = ((int)substr($date,6,4)) . '-' . ((int)substr($date,3,2)) . '-' . ((int)substr($date,0,2));
|
||||
$where[] = "\"LastEdited\" > '$date'";
|
||||
}
|
||||
|
||||
// Match against exact ClassName
|
||||
if (isset($_REQUEST['ClassName']) && $_REQUEST['ClassName'] != 'All') {
|
||||
$klass = Convert::raw2sql($_REQUEST['ClassName']);
|
||||
$where[] = "\"ClassName\" = '$klass'";
|
||||
}
|
||||
|
||||
$where = empty($where) ? '' : 'WHERE (' . implode(') AND (',$where) . ')';
|
||||
|
||||
$parents = array();
|
||||
|
||||
/* Do the actual search */
|
||||
$res = DB::query('SELECT "ParentID", "ID" FROM "SiteTree" '.$where);
|
||||
if (!$res) return;
|
||||
|
||||
/* And keep a record of parents we don't need to get parents of themselves, as well as IDs to mark */
|
||||
foreach($res as $row) {
|
||||
if ($row['ParentID']) $parents[$row['ParentID']] = true;
|
||||
$this->ids[$row['ID']] = true;
|
||||
}
|
||||
|
||||
/* We need to recurse up the tree, finding ParentIDs for each ID until we run out of parents */
|
||||
while (!empty($parents)) {
|
||||
$res = DB::query('SELECT "ParentID", "ID" FROM "SiteTree" WHERE "ID" in ('.implode(',',array_keys($parents)).')');
|
||||
$parents = array();
|
||||
|
||||
foreach($res as $row) {
|
||||
if ($row['ParentID']) $parents[$row['ParentID']] = true;
|
||||
$this->ids[$row['ID']] = true;
|
||||
$this->expanded[$row['ID']] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mark($node) {
|
||||
$id = $node->ID;
|
||||
if(array_key_exists((int) $id, $this->expanded)) $node->markOpened();
|
||||
return array_key_exists((int) $id, $this->ids) ? $this->ids[$id] : false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user