aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorpafcu <pafcu@iki.fi>2015-01-08 18:25:38 +0200
committerpafcu <pafcu@iki.fi>2015-01-08 18:25:38 +0200
commit80c77b7f92af72dd6518ef768c0cc0c31e82bb26 (patch)
treeb7a133bb500fe497ebefff0762ab6472f2fb698c /mod
parenta2e43ae1723b10806e1df77a673331104cf39d1a (diff)
parent32c6eab01c820c0ab44aa1b8860bf3173061e4e2 (diff)
downloadvolse-hubzilla-80c77b7f92af72dd6518ef768c0cc0c31e82bb26.tar.gz
volse-hubzilla-80c77b7f92af72dd6518ef768c0cc0c31e82bb26.tar.bz2
volse-hubzilla-80c77b7f92af72dd6518ef768c0cc0c31e82bb26.zip
Merge pull request #833 from pafcu/oneautocompleter
Fixes for the new autocompletion
Diffstat (limited to 'mod')
-rw-r--r--mod/acl.php3
-rw-r--r--mod/search_ac.php48
2 files changed, 28 insertions, 23 deletions
diff --git a/mod/acl.php b/mod/acl.php
index f575db55b..d406942c3 100644
--- a/mod/acl.php
+++ b/mod/acl.php
@@ -293,9 +293,10 @@ function navbar_complete(&$a) {
$url = $directory['url'] . '/dirsearch';
}
+ $count = (x($_REQUEST,'count')?$_REQUEST['count']:100);
if($url) {
$query = $url . '?f=' ;
- $query .= '&name=' . urlencode($search) . '&limit=50' . (($address) ? '&address=' . urlencode($search) : '');
+ $query .= '&name=' . urlencode($search) . "&limit=$count" . (($address) ? '&address=' . urlencode($search) : '');
$x = z_fetch_url($query);
if($x['success']) {
diff --git a/mod/search_ac.php b/mod/search_ac.php
index 36da21376..b4f5c9600 100644
--- a/mod/search_ac.php
+++ b/mod/search_ac.php
@@ -1,8 +1,9 @@
<?php
+// Autocomplete for saved searches. Should probably be put in the same place as the other autocompletes
function search_ac_init(&$a){
if(!local_user())
- return "";
+ killme();
$start = (x($_REQUEST,'start')?$_REQUEST['start']:0);
@@ -13,17 +14,6 @@ function search_ac_init(&$a){
$search = $_REQUEST['query'];
}
-
- $sql_extra = '';
-
- $x = array();
- $x['query'] = $search;
- $x['photos'] = array();
- $x['links'] = array();
- $x['suggestions'] = array();
- $x['data'] = array();
-
-
// Priority to people searches
if ($search) {
@@ -32,18 +22,23 @@ function search_ac_init(&$a){
}
- $r = q("SELECT `abook_id`, `xchan_name`, `xchan_photo_s`, `xchan_url` FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d
+ $r = q("SELECT `abook_id`, `xchan_name`, `xchan_photo_s`, `xchan_url`, `xchan_addr` FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d
$people_sql_extra
ORDER BY `xchan_name` ASC ",
intval(local_user())
);
+ $results = array();
if($r) {
foreach($r as $g) {
- $x['photos'][] = $g['xchan_photo_s'];
- $x['links'][] = $g['xchan_url'];
- $x['suggestions'][] = '@' . $g['xchan_name'];
- $x['data'][] = 'cid=' . intval($g['abook_id']);
+ $results[] = array(
+ "photo" => $g['xchan_photo_s'],
+ "name" => '@'.$g['xchan_name'],
+ "id" => $g['abook_id'],
+ "link" => $g['xchan_url'],
+ "label" => '',
+ "nick" => '',
+ );
}
}
@@ -53,15 +48,24 @@ function search_ac_init(&$a){
if(count($r)) {
foreach($r as $g) {
- $x['photos'][] = $a->get_baseurl() . '/images/hashtag.png';
- $x['links'][] = $g['url'];
- $x['suggestions'][] = '#' . $g['term'];
- $x['data'][] = intval($g['tid']);
+ $results[] = array(
+ "photo" => $a->get_baseurl() . '/images/hashtag.png',
+ "name" => '#'.$g['term'],
+ "id" => $g['tid'],
+ "link" => $g['url'],
+ "label" => '',
+ "nick" => '',
+ );
}
}
header("content-type: application/json");
- echo json_encode($x);
+ $o = array(
+ 'start' => $start,
+ 'count' => $count,
+ 'items' => $results,
+ );
+ echo json_encode($o);
logger('search_ac: ' . print_r($x,true));