16 import(
'lib.pkp.classes.scheduledTask.ScheduledTask');
30 $this->_plugin = $plugin;
32 if (is_a($plugin,
'CrossRefExportPlugin')) {
33 $plugin->addLocaleData();
36 parent::__construct($args);
43 return __(
'plugins.importexport.crossref.senderTask.name');
50 if (!$this->_plugin)
return false;
55 foreach ($journals as $journal) {
59 $doiPubIdPlugin = $pubIdPlugins[
'doipubidplugin'];
61 if ($doiPubIdPlugin->getSetting($journal->getId(),
'enablePublicationDoi')) {
63 $unregisteredArticles = $plugin->getUnregisteredArticles($journal);
65 if (count($unregisteredArticles)) {
66 $this->
_registerObjects($unregisteredArticles,
'article=>crossref-xml', $journal,
'articles');
81 $journalFactory = $contextDao->getAll(
true);
84 while($journal = $journalFactory->next()) {
85 $journalId = $journal->getId();
86 if (!$plugin->getSetting($journalId,
'username') || !$plugin->getSetting($journalId,
'password') || !$plugin->getSetting($journalId,
'automaticRegistration'))
continue;
90 if (isset($pubIdPlugins[
'doipubidplugin'])) {
91 $doiPubIdPlugin = $pubIdPlugins[
'doipubidplugin'];
92 if (!$doiPubIdPlugin->getSetting($journalId,
'enabled'))
continue;
93 $doiPrefix = $doiPubIdPlugin->getSetting($journalId,
'doiPrefix');
97 $journals[] = $journal;
99 $this->
addExecutionLogEntry(__(
'plugins.importexport.common.senderTask.warning.noDOIprefix', array(
'path' => $journal->getPath())), SCHEDULED_TASK_MESSAGE_TYPE_WARNING);
113 function _registerObjects($objects, $filter, $journal, $objectsFileNamePart) {
115 import(
'lib.pkp.classes.file.FileManager');
122 foreach ($objects as $object) {
124 $exportXml = $plugin->exportXML(array($object), $filter, $journal);
127 $objectsFileNamePartId = $objectsFileNamePart .
'-' . $object->getId();
128 $exportFileName = $plugin->getExportFileName($plugin->getExportPath(), $objectsFileNamePartId, $journal,
'.xml');
129 $fileManager->writeFile($exportFileName, $exportXml);
131 $result = $plugin->depositXML($object, $journal, $exportFileName);
132 if ($result !==
true) {
136 $fileManager->deleteByPath($exportFileName);
145 if (is_array($result)) {
146 foreach($result as $error) {
147 assert(is_array($error) && count($error) >= 1);
149 __($error[0], array(
'param' => (isset($error[1]) ? $error[1] :
null))),
150 SCHEDULED_TASK_MESSAGE_TYPE_WARNING