MINOR Searching both Title and Filename in AssetAdmin (fixes #7013, see pull request #71)

This commit is contained in:
Ingo Schommer 2012-04-11 16:18:38 +02:00
parent 57d7655f80
commit 363dc9a4a9

View File

@ -86,9 +86,21 @@ JS
public function getList() {
$folder = $this->currentPage();
$context = $this->getSearchContext();
// Overwrite name filter to search both Name and Title attributes
$context->removeFilterByName('Name');
$params = $this->request->requestVar('q');
$list = $context->getResults($params);
// Re-add previously removed "Name" filter as combined filter
// TODO Replace with composite SearchFilter once that API exists
if(isset($params['Name'])) {
$list->where(sprintf(
'"Name" LIKE \'%%%s%%\' OR "Title" LIKE \'%%%s%%\'',
Convert::raw2sql($params['Name']),
Convert::raw2sql($params['Name'])
));
}
// Always show folders at the top
$list->sort('(CASE WHEN "File"."ClassName" = \'Folder\' THEN 0 ELSE 1 END), "Name"');