1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-19 08:52:22 +01:00

Improve search. Fix #385 and #421

This commit is contained in:
Thomas Tanghus 2014-02-26 12:30:38 +01:00
parent 16de03fcfd
commit 2a1f308acb

View File

@ -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;
}