From: Ravindra Nath Kakarla Date: Sun, 11 Sep 2011 12:23:09 +0000 (+0530) Subject: Livesearch handler returns proper JSON string now X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=b4f38ff041fcfe5c1a685f55fd8a801648b0f6b5;p=lorea%2Felgg.git Livesearch handler returns proper JSON string now --- diff --git a/engine/lib/input.php b/engine/lib/input.php index 56ec214dc..8ba3ac180 100644 --- a/engine/lib/input.php +++ b/engine/lib/input.php @@ -294,15 +294,15 @@ function input_livesearch_page_handler($page) { if ($entities = get_data($query)) { foreach ($entities as $entity) { - $json = json_encode(array( + $result = array( 'type' => 'user', 'name' => $entity->name, 'desc' => $entity->username, 'icon' => '', 'guid' => $entity->guid - )); - $results[$entity->name . rand(1, 100)] = $json; + ); + $results[$entity->name . rand(1, 100)] = $result; } } break; @@ -321,16 +321,16 @@ function input_livesearch_page_handler($page) { "; if ($entities = get_data($query)) { foreach ($entities as $entity) { - $json = json_encode(array( + $result = array( 'type' => 'group', 'name' => $entity->name, 'desc' => strip_tags($entity->description), 'icon' => '', 'guid' => $entity->guid - )); + ); - $results[$entity->name . rand(1, 100)] = $json; + $results[$entity->name . rand(1, 100)] = $result; } } break; @@ -353,15 +353,15 @@ function input_livesearch_page_handler($page) { if ($entities = get_data($query)) { foreach ($entities as $entity) { - $json = json_encode(array( + $result = array( 'type' => 'user', 'name' => $entity->name, 'desc' => $entity->username, 'icon' => '', 'guid' => $entity->guid - )); - $results[$entity->name . rand(1, 100)] = $json; + ); + $results[$entity->name . rand(1, 100)] = $result; } } break; @@ -376,7 +376,7 @@ function input_livesearch_page_handler($page) { } ksort($results); - echo implode($results, "\n"); + echo json_encode(array_values($results)); exit; }