From 2a1f308acbec4e6b00eda373cb47be084609edba Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Wed, 26 Feb 2014 12:30:38 +0100 Subject: [PATCH] Improve search. Fix #385 and #421 --- lib/searchprovider.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/searchprovider.php b/lib/searchprovider.php index 5f9fae1d..bf390d0a 100644 --- a/lib/searchprovider.php +++ b/lib/searchprovider.php @@ -23,13 +23,19 @@ class SearchProvider extends \OC_Search_Provider{ foreach($results as $result) { $link = \OCP\Util::linkToRoute('contacts_index').'#' . $result['id']; $props = array(); + $display = (isset($result['FN']) && $result['FN']) ? $result['FN'] : null; foreach(array('EMAIL', 'NICKNAME', 'ORG') as $searchvar) { - if(isset($result[$searchvar]) && count($result[$searchvar]) > 0 && strlen($result[$searchvar][0]) > 3) { - $props = array_merge($props, $result[$searchvar]); + if(isset($result[$searchvar]) && $result[$searchvar]) { + if(is_array($result[$searchvar])) { + $result[$searchvar] = array_filter($result[$searchvar]); + } + $prop = is_array($result[$searchvar]) ? implode(',', $result[$searchvar]) : $result[$searchvar]; + $props[] = $prop; + $display = $display ?: $result[$searchvar]; } } $props = array_map($unescape, $props); - $searchresults[]=new \OC_Search_Result($result['FN'], implode(', ', $props), $link, (string)$l->t('Contact'));//$name,$text,$link,$type + $searchresults[]=new \OC_Search_Result($display, implode(', ', $props), $link, (string)$l->t('Contact'), null);//$name,$text,$link,$type } return $searchresults; }