Skip to content
Snippets Groups Projects
Unverified Commit b3cfe85a authored by Michael Große's avatar Michael Große
Browse files

fix(search): also filter pagename results by time

parent d22b78c8
No related branches found
No related tags found
No related merge requests found
...@@ -31,11 +31,21 @@ class Search extends Ui ...@@ -31,11 +31,21 @@ class Search extends Ui
*/ */
public function execute() public function execute()
{ {
$this->pageLookupResults = ft_pageLookup($this->query, true, useHeading('navigation')); $this->pageLookupResults = $this->filterResultsByTime(
$this->fullTextResults = ft_pageSearch($this->query, $highlight); ft_pageLookup($this->query, true, useHeading('navigation'))
);
$this->fullTextResults = $this->filterResultsByTime(
ft_pageSearch($this->query, $highlight)
);
$this->highlight = $highlight; $this->highlight = $highlight;
}
// fixme: find better place for this /**
* @param array $results search results in the form pageid => value
*
* @return array
*/
protected function filterResultsByTime(array $results) {
global $INPUT; global $INPUT;
if ($INPUT->has('after') || $INPUT->has('before')) { if ($INPUT->has('after') || $INPUT->has('before')) {
$after = $INPUT->str('after'); $after = $INPUT->str('after');
...@@ -45,17 +55,19 @@ class Search extends Ui ...@@ -45,17 +55,19 @@ class Search extends Ui
$before = is_int($before) ? $before : strtotime($before); $before = is_int($before) ? $before : strtotime($before);
// todo: should we filter $this->pageLookupResults as well? // todo: should we filter $this->pageLookupResults as well?
foreach ($this->fullTextResults as $id => $cnt) { foreach ($results as $id => $value) {
$mTime = filemtime(wikiFN($id)); $mTime = filemtime(wikiFN($id));
if ($after && $after > $mTime) { if ($after && $after > $mTime) {
unset($this->fullTextResults[$id]); unset($results[$id]);
continue; continue;
} }
if ($before && $before < $mTime) { if ($before && $before < $mTime) {
unset($this->fullTextResults[$id]); unset($results[$id]);
} }
} }
} }
return $results;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment