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:
parent
f9da29208e
commit
525ebecc89
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user