/** * Returns document type. * @return string */ public function getDocType() { try { return htmlspecialchars($this->document->getType()); } catch (Exception $e) { return 'undefined'; } }
/** * Regression test for OPUSVIER-2379 */ public function testGetRecordOaiDcDoc91DocType() { $doc = new Opus_Document(91); $this->assertEquals("report", $doc->getType(), "testdata changed"); $this->dispatch('/oai?verb=GetRecord&metadataPrefix=oai_dc&identifier=oai::91'); $this->assertResponseCode(200); $response = $this->getResponse(); $badStrings = array("Exception", "Error", "Stacktrace", "badVerb"); $this->checkForCustomBadStringsInHtml($response->getBody(), $badStrings); $xpath = $this->prepareXpathFromResultString($response->getBody()); // Regression test for OPUSVIER-2379 (show doc-type:report) $elements = $xpath->query('//oai_dc:dc/dc:type[text()="doc-type:report"]'); $this->assertEquals(1, $elements->length, "Unexpected count for doc-type:report"); }
echo "parameter --enrichment not specified; function will now exit" . PHP_EOL; exit; } else { $enrichmentField = $options['enrichment']; } $getType = 'getTitle' . ucfirst(strtolower($options['type'])); $addType = 'addTitle' . ucfirst(strtolower($options['type'])); if ($dryrun) { _log("TEST RUN: NO DATA WILL BE MODIFIED"); } $docFinder = new Opus_DocumentFinder(); $docIds = $docFinder->setEnrichmentKeyExists($enrichmentField)->ids(); _log(count($docIds) . " documents found"); foreach ($docIds as $docId) { $doc = new Opus_Document($docId); if ($doc->getType() == $doctype || $doctype == '') { $enrichments = $doc->getEnrichment(); foreach ($enrichments as $enrichment) { $enrichmentArray = $enrichment->toArray(); if ($enrichmentArray['KeyName'] == $enrichmentField) { $titles = $doc->{$getType}(); if (count($titles) > 0) { _log('Title ' . ucfirst(strtolower($options['type'])) . ' already exists for Document #' . $docId . '. Skipping.. '); } else { $title = $doc->{$addType}(); $title->setValue($enrichmentArray['Value']); if (!$dryrun) { $doc->store(); } _log('Document #' . $docId . ' updated'); }
/** * Befuellt das Formular anhand der Metadaten eines Dokuments. * @param Opus_Document $document */ public function populateFromModel($document) { $datesHelper = $this->getDatesHelper(); $this->getElement(self::ELEMENT_LANGUAGE)->setValue($document->getLanguage()); $this->getElement(self::ELEMENT_TYPE)->setValue($document->getType()); $date = $datesHelper->getDateString($document->getCompletedDate()); $this->getElement(self::ELEMENT_COMPLETED_DATE)->setValue($date); $this->getElement(self::ELEMENT_COMPLETED_YEAR)->setValue($document->getCompletedYear()); $date = $datesHelper->getDateString($document->getPublishedDate()); $this->getElement(self::ELEMENT_PUBLISHED_DATE)->setValue($date); $this->getElement(self::ELEMENT_PUBLISHED_YEAR)->setValue($document->getPublishedYear()); $date = $datesHelper->getDateString($document->getEmbargoDate()); $this->getElement(self::ELEMENT_EMBARGO_DATE)->setValue($date); }
/** * * @param Opus_Document $document * @throws CitationExport_Module_Exception in case of an invalid parameter value * * @return string */ public function getTemplateForDocument($document, $outputFormat) { if (is_null($outputFormat)) { throw new CitationExport_Model_Exception('invalid_format'); } $stylesheetsAvailable = $this->getAvailableStylesheets(); // check for document type specific stylesheet $pos = array_search($outputFormat . '_' . $document->getType(), $stylesheetsAvailable); if ($pos !== FALSE) { return $stylesheetsAvailable[$pos] . '.xslt'; } // check for generic stylesheet for format $pos = array_search($outputFormat, $stylesheetsAvailable); if ($pos !== FALSE) { return $stylesheetsAvailable[$pos] . '.xslt'; } // no applicable stylesheet found throw new CitationExport_Model_Exception('invalid_format'); }
/** * * @param Opus_Document $document * @throws CitationExport_Module_Exception in case of an invalid parameter value * * @return string */ private function getTemplateForDocument($document) { $outputFormat = $this->getRequest()->getParam('output'); if (is_null($outputFormat)) { throw new CitationExport_Model_Exception('invalid_format'); } $stylesheetsAvailable = array(); $dir = new DirectoryIterator($this->view->getScriptPath('index')); foreach ($dir as $file) { if ($file->isFile() && $file->getFilename() != '.' && $file->getFilename() != '..' && $file->isReadable()) { array_push($stylesheetsAvailable, $file->getBasename('.xslt')); } } $pos = array_search($outputFormat . '_' . $document->getType(), $stylesheetsAvailable); if ($pos !== FALSE) { return $stylesheetsAvailable[$pos] . '.xslt'; } $pos = array_search($outputFormat, $stylesheetsAvailable); if ($pos !== FALSE) { return $stylesheetsAvailable[$pos] . '.xslt'; } throw new CitationExport_Model_Exception('invalid_format'); }