Exemple #1
0
 public function getSearchJson($r)
 {
     //move OUT of controller
     $r->checkCache();
     $search = new Dase_Solr($this->db, $this->config);
     $search->prepareSearch($r, $this->start, $this->max, $this->num, $this->sort, $this->uid);
     $ids = $search->getResultsAsIds();
     $json = "{\"app_root\":\"{$r->app_root}\",\"start\":\"{$this->start}\",\"total\":\"{$search->total}\",\"max\":\"{$this->max}\",\"items\":[";
     $items = array();
     foreach ($ids as $id) {
         $docs = new Dase_DBO_ItemJson($this->db);
         $docs->unique_id = $id;
         if ($docs->findOne()) {
             $items[] = $docs->doc;
         }
     }
     $json .= join(',', $items) . ']}';
     $result = str_replace('{APP_ROOT}', $r->app_root, $json);
     if ($r->get('callback')) {
         $r->renderResponse($r->get('callback') . '(' . $result . ');');
     } else {
         $r->renderResponse($result);
     }
 }