예제 #1
0
 /**
  * Load a single item bib by itemKey
  *
  * @param string $itemKey
  * @return Zotero_Item
  */
 public function fetchItemBib($itemKey, $style)
 {
     //TODO:parse correctly and return just bib
     $aparams = array('target' => 'item', 'content' => 'bib', 'itemKey' => $itemKey);
     if ($style) {
         $aparams['style'] = $style;
     }
     $reqUrl = $this->apiRequestString($aparams);
     $response = $this->_request($reqUrl, 'GET');
     if ($response->isError()) {
         return false;
         throw new Exception("Error fetching items");
     }
     $entry = Zotero_Lib_Utils::getFirstEntryNode($response->getRawBody());
     if ($entry == null) {
         return false;
     }
     $item = new Zotero_Item($entry, $this);
     $this->items->addItem($item);
     return $item;
 }
예제 #2
0
 /**
  * Load a single collection by collectionKey
  *
  * @param string $collectionKey
  * @return Zotero_Collection
  */
 public function fetchCollection($collectionKey)
 {
     $aparams = array('target' => 'collection', 'content' => 'json', 'collectionKey' => $collectionKey);
     $reqUrl = $this->owningLibrary->apiRequestString($aparams);
     $response = $this->owningLibrary->_request($reqUrl, 'GET');
     if ($response->isError()) {
         return false;
         throw new Exception("Error fetching collection");
     }
     $entry = Zotero_Lib_Utils::getFirstEntryNode($response->getRawBody());
     if ($entry == null) {
         return false;
     }
     $collection = new Zotero_Collection($entry, $this);
     $this->addCollection($collection);
     return $collection;
 }