/** * Maps Zotero attachments to Omeka files, et al. * * @param Zend_Feed_Element * @param bool Flag indicating that this is a top-level attachment. */ protected function _mapAttachment(Zend_Feed_Element $element, $topLevelAttachment = false) { if (!$topLevelAttachment) { $this->_elementTexts['Zotero']['Attachment Title'][] = array('text' => $element->title(), 'html' => false); $urlXpath = '//default:tr[@class="url"]/default:td'; if ($url = $this->_contentXpath($element->content, $urlXpath, true)) { $this->_elementTexts['Zotero']['Attachment URL'][] = array('text' => $url, 'html' => false); // If a attachment that is not top-level has no URL, still assign it // a placeholder to maintain relationships between the "Attachment // Title" and "Attachment Url" elements. } else { $this->_elementTexts['Zotero']['Attachment URL'][] = array('text' => '[No URL]', 'html' => false); } } // The Zotero API will not return a file unless a private key exists, so // prevent unnecessary requests. if (!$this->_privateKey) { return; } // Get the file URLs. $method = "{$this->_libraryType}ItemFile"; $urls = $this->_client->{$method}($this->_libraryId, $element->key()); // Not all attachments have corresponding files in Amazon S3, so return // those that do not. if (!$urls['s3']) { return; } // Name the file. $uri = Zend_Uri::factory($urls['s3']); // Set the original filename as the basename of the URL path. $name = urldecode(basename($uri->getPath())); // Set the file metadata. $this->_fileMetadata['files'][] = array('source' => $urls['zotero'], 'name' => $name, 'metadata' => array('Dublin Core' => array('Title' => array(array('text' => $element->title(), 'html' => false)), 'Identifier' => array(array('text' => $url, 'html' => false))))); }