private function setItems($resultList) { $this->_xml->appendChild($this->_xml->createElement('Documents')); foreach ($resultList->getResults() as $result) { $document = new Opus_Document($result->getId()); $documentXml = new Util_Document($document); $domNode = $this->_xml->importNode($documentXml->getNode(), true); // add publication date in RFC_2822 format $date = $document->getServerDatePublished()->getDateTime(); $itemPubDate = $this->_xml->createElement('ItemPubDate', $date->format(DateTime::RFC2822)); $domNode->appendChild($itemPubDate); $this->_xml->documentElement->appendChild($domNode); } }
/** * Returns a list of documents from the database. * @param $resultIds ids of documents for export * @return array [docId] DocumentXml */ private function getDocumentsFromDatabase($documentIds) { $documents = array(); foreach ($documentIds as $docId) { $document = new Opus_Document($docId); $documentXml = new Util_Document($document); $documents[$docId] = $documentXml->getNode(); } return $documents; }
/** * Displays the metadata of a document. * @return void */ public function indexAction() { // call export index-action, if parameter is set if (!is_null($this->getRequest()->getParam('export'))) { $params = $this->getRequest()->getParams(); // export module ignores pagination parameters unset($params['rows']); unset($params['start']); $params['searchtype'] = 'id'; return $this->_redirectToAndExit('index', null, 'index', 'export', $params); } $this->view->title = $this->view->translate('frontdoor_title'); $request = $this->getRequest(); $docId = $request->getParam('docId', ''); $this->view->docId = $docId; $baseUrl = $request->getBaseUrl(); if ($docId == '') { $this->printDocumentError("frontdoor_doc_id_missing", 404); return; } $document = null; try { $document = new Opus_Document($docId); } catch (Opus_Model_NotFoundException $e) { $this->printDocumentError("frontdoor_doc_id_not_found", 404); return; } $documentXml = null; try { $documentXml = new Util_Document($document); } catch (Application_Exception $e) { switch ($document->getServerState()) { case self::SERVER_STATE_DELETED: $this->printDocumentError("frontdoor_doc_deleted", 410); return; case self::SERVER_STATE_UNPUBLISHED: $this->printDocumentError("frontdoor_doc_unpublished", 403); return; } $this->printDocumentError("frontdoor_doc_access_denied", 403); return; } $documentNode = $documentXml->getNode(); /* XSLT transformation. */ $docBuilder = new Frontdoor_Model_DocumentBuilder(); $xslt = $docBuilder->buildDomDocument($this->view->getScriptPath('index') . DIRECTORY_SEPARATOR . 'index'); $proc = new XSLTProcessor(); $proc->registerPHPFunctions(self::TRANSLATE_FUNCTION); $proc->registerPHPFunctions(self::TRANSLATE_DEFAULT_FUNCTION); $proc->registerPHPFunctions(self::FILE_ACCESS_FUNCTION); $proc->registerPHPFunctions(self::FORMAT_DATE_FUNCTION); $proc->registerPHPFunctions(self::EMBARGO_ACCESS_FUNCTION); $proc->registerPHPFunctions(self::SORT_ORDER_FUNCTION); $proc->registerPHPFunctions(self::CHECK_LANGUAGE_FILE_FUNCTION); $proc->registerPHPFunctions(self::GET_STYLESHEET_FUNCTION); $proc->registerPHPFunctions('urlencode'); $proc->importStyleSheet($xslt); $config = Zend_Registry::getInstance()->get('Zend_Config'); $layoutPath = 'layouts/' . (isset($config, $config->theme) ? $config->theme : ''); $numOfShortAbstractChars = isset($config, $config->frontdoor->numOfShortAbstractChars) ? $config->frontdoor->numOfShortAbstractChars : '0'; $proc->setParameter('', 'baseUrlServer', $this->view->fullUrl()); $proc->setParameter('', 'baseUrl', $baseUrl); $proc->setParameter('', 'layoutPath', $baseUrl . '/' . $layoutPath); $proc->setParameter('', 'isMailPossible', $this->isMailPossible($document)); $proc->setParameter('', 'numOfShortAbstractChars', $numOfShortAbstractChars); /* print on demand config */ $printOnDemandEnabled = false; $podConfig = $config->get('printOnDemand', false); if ($podConfig !== false) { $printOnDemandEnabled = true; $proc->setParameter('', 'printOnDemandUrl', $podConfig->get('url', '')); $proc->setParameter('', 'printOnDemandButton', $podConfig->get('button', '')); } $proc->setParameter('', 'printOnDemandEnabled', $printOnDemandEnabled); $frontdoorContent = $proc->transformToXML($documentNode); /* Setup view. */ $this->view->frontdoor = $frontdoorContent; $this->view->baseUrl = $baseUrl; $this->view->doctype('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">'); $dateModified = $document->getServerDateModified(); if (!is_null($dateModified)) { $this->view->headMeta()->appendHttpEquiv('Last-Modified', $dateModified->getDateTime()->format(DateTime::RFC1123)); } $this->addMetaTagsForDocument($document); $this->view->title = $this->getFrontdoorTitle($document); $this->incrementStatisticsCounter($docId); $actionbox = new Admin_Form_ActionBox(); $actionbox->prepareRenderingAsView(); $actionbox->populateFromModel($document); $this->view->adminform = $actionbox; }