- $filtered = array();
- foreach ($this->links as $l) {
- if ($smallHash == smallHash($l['linkdate'])) {
- // Yes, this is ugly and slow
- $filtered[$l['linkdate']] = $l;
- return $filtered;
- }
+ // Filter link database according to parameters.
+ $searchtags = !empty($filterRequest['searchtags']) ? escape($filterRequest['searchtags']) : '';
+ $searchterm = !empty($filterRequest['searchterm']) ? escape($filterRequest['searchterm']) : '';
+
+ // Search tags + fullsearch.
+ if (! empty($searchtags) && ! empty($searchterm)) {
+ $type = LinkFilter::$FILTER_TAG | LinkFilter::$FILTER_TEXT;
+ $request = array($searchtags, $searchterm);
+ }
+ // Search by tags.
+ elseif (! empty($searchtags)) {
+ $type = LinkFilter::$FILTER_TAG;
+ $request = $searchtags;
+ }
+ // Fulltext search.
+ elseif (! empty($searchterm)) {
+ $type = LinkFilter::$FILTER_TEXT;
+ $request = $searchterm;