/** * @see {Opus_Model_Plugin_Interface::preStore} * Check wether to update documents on postStore. * If there is no information about a Model * the postStore hook is not triggered. * */ public function preStore(Opus_Model_AbstractDb $model) { $modelClass = get_class($model); $config = new Zend_Config_Ini(dirname(__FILE__) . '/updatedocument_filter.ini'); if (isset($config->{$modelClass})) { $this->postStoreUpdateDocuments = false; $filter = new Opus_Model_Filter(); $filter->setModel($model); $filter->setBlacklist($config->{$modelClass}->toArray()); $whitelist = $filter->describe(); foreach ($whitelist as $fieldName) { if ($model->hasField($fieldName) && $model->getField($fieldName)->isModified()) { $this->postStoreUpdateDocuments = true; break; } } } }
/** * transform XML output to desired output format * * @param Opus_Document $document Document that should be transformed * @param string $template XSLT stylesheet that should be applied * * @return string document in the given output format as plain text */ public function getPlainOutput($document, $template) { // Set up filter and get XML-Representation of filtered document. $filter = new Opus_Model_Filter(); $filter->setModel($document); $xml = $filter->toXml(); // Set up XSLT-Stylesheet $xslt = new DomDocument(); $xslt->load($this->getScriptPath() . DIRECTORY_SEPARATOR . $template); // find Enrichment that should be included in bibtex-output as note // TODO document this feature $enrichmentNote = null; $config = $this->getConfig(); if (isset($config->citationExport->bibtex->enrichment) && !empty($config->citationExport->bibtex->enrichment)) { $enrichmentNote = $config->citationExport->bibtex->enrichment; } // Set up XSLT-Processor try { $proc = new XSLTProcessor(); $proc->setParameter('', 'enrichment_note', $enrichmentNote); $proc->setParameter('', 'url_prefix', $this->_baseUrl); $proc->setParameter('', 'urnResolverUrl', $config->urn->resolverUrl); $proc->registerPHPFunctions(); $proc->importStyleSheet($xslt); return $proc->transformToXML($xml); } catch (Exception $e) { throw new Application_Exception($e->getMessage(), null, $e); } }