getEnabled()) { $this->_registerTemplateResource(); } return $success; } /** * @see Plugin::getName() */ function getName() { return 'MedraExportPlugin'; } /** * @see Plugin::getDisplayName() */ function getDisplayName() { return __('plugins.importexport.medra.displayName'); } /** * @see Plugin::getDescription() */ function getDescription() { return __('plugins.importexport.medra.description'); } /** * @copydoc Plugin::getTemplatePath() */ function getTemplatePath($inCore = false) { return $this->getTemplateResourceName() . ':templates/'; } /** * @copydoc PubObjectsExportPlugin::getSubmissionFilter() */ function getSubmissionFilter() { return 'article=>medra-xml'; } /** * @copydoc PubObjectsExportPlugin::getIssueFilter() */ function getIssueFilter() { return 'issue=>medra-xml'; } /** * @copydoc PubObjectsExportPlugin::getRepresentationFilter() */ function getRepresentationFilter() { return 'galley=>medra-xml'; } /** * @copydoc ImportExportPlugin::getPluginSettingsPrefix() */ function getPluginSettingsPrefix() { return 'medra'; } /** * @copydoc DOIPubIdExportPlugin::getSettingsFormClassName() */ function getSettingsFormClassName() { return 'MedraSettingsForm'; } /** * @copydoc PubObjectsExportPlugin::getExportDeploymentClassName() */ function getExportDeploymentClassName() { return 'MedraExportDeployment'; } /** * @copydoc PubObjectsExportPlugin::depositXML() */ function depositXML($objects, $context, $filename) { // Use a different endpoint for testing and // production. $this->import('classes.MedraWebservice'); $endpoint = ($this->isTestMode($context) ? MEDRA_WS_ENDPOINT_DEV : MEDRA_WS_ENDPOINT); // Get credentials. $username = $this->getSetting($context->getId(), 'username'); $password = $this->getSetting($context->getId(), 'password'); // Retrieve the XML. assert(is_readable($filename)); $xml = file_get_contents($filename); assert($xml !== false && !empty($xml)); // Instantiate the mEDRA web service wrapper. $ws = new MedraWebservice($endpoint, $username, $password); // Register the XML with mEDRA. $result = $ws->upload($xml); if ($result === true) { // Mark all objects as registered. foreach($objects as $object) { $object->setData($this->getDepositStatusSettingName(), EXPORT_STATUS_REGISTERED); $this->saveRegisteredDoi($context, $object); } } else { // Handle errors. if (is_string($result)) { $result = array( array('plugins.importexport.common.register.error.mdsError', $result) ); } else { $result = false; } } return $result; } } ?>