/**
  * Displays the metadata of a document.
  * @return void
  */
 public function indexAction()
 {
     $request = $this->getRequest();
     $docId = $request->getParam('docId', '');
     if ($request->has('searchtype') && $request->has('rows') && $request->has('start')) {
         $listRows = $request->getParam('rows');
         $start = $request->getParam('start');
         $this->view->listRows = $listRows;
         $request->setParam('rows', '1');
         // make sure only 1 entry is diplayed
         $query = Application_Search_Navigation::getQueryUrl($request, $this->getLogger());
         $searcher = new Opus_SolrSearch_Searcher();
         $resultList = $searcher->search($query);
         $queryResult = $resultList->getResults();
         if (is_array($queryResult) && !empty($queryResult) && $queryResult[0] instanceof Opus_Search_Result_Match) {
             $resultDocId = $queryResult[0]->getId();
             if (!empty($docId)) {
                 if ($resultDocId != $docId) {
                     $this->view->messages = array('notice' => $this->view->translate('frontdoor_pagination_list_changed'));
                 }
             } else {
                 $docId = $resultDocId;
             }
             $this->view->paginate = true;
             $numHits = $resultList->getNumberOfHits();
             if ($request->getParam('searchtype') == 'latest') {
                 $this->view->numOfHits = $numHits < $listRows ? $numHits : $listRows;
             } else {
                 $this->view->numOfHits = $numHits;
             }
             $this->view->searchPosition = $start;
             $this->view->firstEntry = 0;
             $this->view->lastEntry = $this->view->numOfHits - 1;
             $this->view->previousEntry = $this->view->searchPosition - 1 < 0 ? 0 : $this->view->searchPosition - 1;
             $this->view->nextEntry = $this->view->searchPosition + 1 < $this->view->numOfHits - 1 ? $this->view->searchPosition + 1 : $this->view->numOfHits - 1;
         }
     }
     if ($docId == '') {
         $this->printDocumentError("frontdoor_doc_id_missing", 404);
         return;
     }
     // 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');
     $this->view->docId = $docId;
     $baseUrl = $request->getBaseUrl();
     $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 Application_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 = $this->getConfig();
     $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);
     $proc->setParameter('', 'urnResolverUrl', $config->urn->resolverUrl);
     /* 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;
 }
示例#2
0
 /**
  * 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;
 }