Skip to content

Commit

Permalink
Merge pull request #76 from mediabeastnz/master
Browse files Browse the repository at this point in the history
Added extension hook for file search
  • Loading branch information
Aaron Carlino committed Feb 10, 2017
2 parents bd22a9d + 2fd4564 commit 9bd9732
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions code/KickAssets.php
Expand Up @@ -402,11 +402,14 @@ public function handleSearch(SS_HTTPRequest $r) {
if($r->getVar('search') === null) return;

$results = array ();
$searchTerm = $r->getVar('search');
$list = File::get()->filterAny(array(
'Title:PartialMatch' => $r->getVar('search'),
'Filename:PartialMatch' => $r->getVar('search')
'Title:PartialMatch' => $searchTerm,
'Filename:PartialMatch' => $searchTerm
))->limit(100);

$this->extend('beforeHandleSearch', $list, $searchTerm);

foreach($list as $item) {
if(!$item->canView()) continue;
$results[] = $item instanceof Folder ? $this->createFolderJSON($item) : $this->createFileJSON($item);
Expand Down

0 comments on commit 9bd9732

Please sign in to comment.