mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-01-18 07:52:21 +01:00
Contacts: Search improvements.
This commit is contained in:
parent
f9da29208e
commit
525ebecc89
@ -4,13 +4,21 @@ namespace OCA\Contacts;
|
||||
|
||||
class SearchProvider extends \OC_Search_Provider{
|
||||
function search($query) {
|
||||
$searchresults = array( );
|
||||
$results = \OCP\Contacts::search($query, array('N', 'FN', 'EMAIL', 'NICKNAME', 'ORG'));
|
||||
$l = new \OC_l10n('contacts');
|
||||
foreach($results as $result) {
|
||||
$vcard = VCard::find($result['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) {
|
||||
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 $results;
|
||||
return $searchresults;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user