Skip to content

Commit

Permalink
Add page in return.
Browse files Browse the repository at this point in the history
This makes generating pagination links much easier.
  • Loading branch information
markstory committed Mar 1, 2012
1 parent 2443f0e commit 87f06fb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Model/Search.php
Expand Up @@ -17,11 +17,16 @@ public function find($lang, $query = array()) {
$Http = new HttpSocket();
$results = $Http->get($url, array(), array('body' => json_encode($query)));
$contents = json_decode($results->body(), true);
return array_map(function ($el) {
$data = array_map(function ($el) {
return array(
'url' => $el['fields']['url'],
'contents' => $el['highlight']['contents'],
);
}, $contents['hits']['hits']);
return array(
'page' => isset($query['from']) ? $query['from'] : 1,
'total' => $contents['hits']['total'],
'data' => $data
);
}
}

0 comments on commit 87f06fb

Please sign in to comment.