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

Contacts: Search improvements.

This commit is contained in:
Thomas Tanghus 2013-01-30 00:47:17 +01:00
parent f9da29208e
commit 525ebecc89

View File

@ -4,13 +4,21 @@ namespace OCA\Contacts;
class SearchProvider extends \OC_Search_Provider{ class SearchProvider extends \OC_Search_Provider{
function search($query) { function search($query) {
$searchresults = array( );
$results = \OCP\Contacts::search($query, array('N', 'FN', 'EMAIL', 'NICKNAME', 'ORG')); $results = \OCP\Contacts::search($query, array('N', 'FN', 'EMAIL', 'NICKNAME', 'ORG'));
$l = new \OC_l10n('contacts'); $l = new \OC_l10n('contacts');
foreach($results as $result) { foreach($results as $result) {
$vcard = VCard::find($result['id']); $vcard = VCard::find($result['id']);
$link = \OCP\Util::linkTo('contacts', 'index.php').'#' . $vcard['id']; $link = \OCP\Util::linkTo('contacts', 'index.php').'#' . $vcard['id'];
$results[]=new \OC_Search_Result($vcard['fullname'], '', $link, (string)$l->t('Contact'));//$name,$text,$link,$type $props = array();
} foreach(array('EMAIL', 'NICKNAME', 'ORG') as $searchvar) {
return $results; if(count($result[$searchvar]) > 0 && strlen($result[$searchvar][0]) > 3) {
$props = array_merge($props, $result[$searchvar]);
}
}
$searchresults[]=new \OC_Search_Result($vcard['fullname'], implode(', ', $props), $link, (string)$l->t('Contact'));//$name,$text,$link,$type
}
return $searchresults;
} }
} }