Beispiel #1
0
 /**
  * Generate a SimpleXMLElement Atom object for the search
  *
  * @param array $queryParams
  * @return SimpleXMLElement
  */
 public function toAtom($queryParams)
 {
     if (!$this->loaded) {
         $this->load();
     }
     // TEMP: multi-format support
     if (!empty($queryParams['content'])) {
         $content = $queryParams['content'];
     } else {
         $content = array('none');
     }
     $content = $content[0];
     $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?>' . '<entry xmlns="' . Zotero_Atom::$nsAtom . '" xmlns:zapi="' . Zotero_Atom::$nsZoteroAPI . '"/>');
     $xml->title = $this->name ? $this->name : '[Untitled]';
     $author = $xml->addChild('author');
     // TODO: group item creator
     $author->name = Zotero_Libraries::getName($this->libraryID);
     $author->uri = Zotero_URI::getLibraryURI($this->libraryID, true);
     $xml->id = Zotero_URI::getSearchURI($this);
     $xml->published = Zotero_Date::sqlToISO8601($this->dateAdded);
     $xml->updated = Zotero_Date::sqlToISO8601($this->dateModified);
     $link = $xml->addChild("link");
     $link['rel'] = "self";
     $link['type'] = "application/atom+xml";
     $link['href'] = Zotero_API::getSearchURI($this);
     $xml->addChild('zapi:key', $this->key, Zotero_Atom::$nsZoteroAPI);
     $xml->addChild('zapi:version', $this->version, Zotero_Atom::$nsZoteroAPI);
     if ($content == 'json') {
         $xml->content['type'] = 'application/json';
         $xml->content = Zotero_Utilities::formatJSON($this->toJSON($queryParams));
     }
     return $xml;
 }