Пример #1
0
 function storeDoc($type = "")
 {
     $app_root = "{APP_ROOT}";
     if (!$type || 'json' == $type) {
         $doc = new Dase_DBO_ItemJson($this->db);
         $doc->unique_id = $this->getUnique();
         if ($doc->findOne()) {
             $doc->updated = date(DATE_ATOM);
             $doc->doc = $this->buildJson($app_root);
             $doc->update();
         } else {
             $doc->updated = date(DATE_ATOM);
             $doc->doc = $this->buildJson($app_root);
             $doc->insert();
         }
     }
     if (!$type || 'atom' == $type) {
         $entry = new Dase_Atom_Entry_Item();
         $entry = $this->injectAtomEntryData($entry, $app_root);
         $doc = new Dase_DBO_ItemAtom($this->db);
         $doc->unique_id = $this->getUnique();
         if ($doc->findOne()) {
             $doc->updated = date(DATE_ATOM);
             //passing in entry root prevent xml declaration
             $doc->doc = $entry->asXml($entry->root);
             $doc->update();
         } else {
             $doc->updated = date(DATE_ATOM);
             $doc->doc = $entry->asXml($entry->root);
             $doc->insert();
         }
     }
 }
Пример #2
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);
     }
 }
Пример #3
0
 public function getDumpJson($r)
 {
     $item_json = new Dase_DBO_ItemJson($this->db);
     $item_json->addWhere('unique_id', $this->collection->ascii_id . '/%', 'like');
     $docs = array();
     foreach ($item_json->find() as $ij) {
         $ij = clone $ij;
         $doc = str_replace('{APP_ROOT}', $r->app_root, $ij->doc);
         $docs[] = $doc;
     }
     $coll_url = $this->collection->getUrl($r->app_root);
     $updated = $this->collection->updated;
     $name = $this->collection->collection_name;
     $json = "{\"id\":\"{$coll_url}\",\"collection_name\":\"{$name}\",\"updated\":\"{$updated}\",\"items\":[";
     $json .= join(',', $docs) . ']}';
     $r->renderResponse($json);
 }