Skip to content

Commit f88f4b6

Browse files
committed
initial commit for crossrefReferenceLinking
0 parents  commit f88f4b6

12 files changed

+1384
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
3+
/**
4+
* @file plugins/generic/crossrefReferenceLinking/CrossrefReferenceLinkingInfoSender.php
5+
*
6+
* Copyright (c) 2013-2019 Simon Fraser University
7+
* Copyright (c) 2003-2019 John Willinsky
8+
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
9+
*
10+
* @class CrossrefReferenceLinkingInfoSender
11+
* @ingroup plugins_generic_crossrefReferenceLinking
12+
*
13+
* @brief Scheduled task to check for found Crossref references DOIs.
14+
*/
15+
16+
import('lib.pkp.classes.scheduledTask.ScheduledTask');
17+
18+
19+
class CrossrefReferenceLinkingInfoSender extends ScheduledTask {
20+
/** @var $_plugin CrossrefReferenceLinkingPlugin */
21+
var $_plugin;
22+
23+
/**
24+
* Constructor.
25+
* @param $args array task arguments
26+
*/
27+
function __construct($args) {
28+
PluginRegistry::loadCategory('generic');
29+
$plugin = PluginRegistry::getPlugin('generic', 'crossrefreferencelinkingplugin'); /* @var $plugin CrossrefReferenceLinkingPlugin */
30+
31+
$this->_plugin = $plugin;
32+
33+
if (is_a($plugin, 'CrossrefReferenceLinkingPlugin')) {
34+
$plugin->addLocaleData();
35+
}
36+
37+
parent::__construct($args);
38+
}
39+
40+
/**
41+
* @copydoc ScheduledTask::getName()
42+
*/
43+
function getName() {
44+
return __('plugins.generic.crossrefReferenceLinking.senderTask.name');
45+
}
46+
47+
/**
48+
* @copydoc ScheduledTask::executeActions()
49+
*/
50+
function executeActions() {
51+
if (!$this->_plugin) return false;
52+
53+
$plugin = $this->_plugin;
54+
$journals = $this->_getJournals();
55+
56+
foreach ($journals as $journal) {
57+
// Call the plugin register function, in order to be able to save the new article and citation settings in the DB
58+
$plugin->register('generic', $plugin->getPluginPath(), $journal->getId());
59+
// Get published articles to check
60+
$articlesToCheck = $plugin->getArticlesToCheck($journal);
61+
while ($article = $articlesToCheck->next()) {
62+
$plugin->getCrossrefReferencesDOIs($article);
63+
}
64+
}
65+
return true;
66+
}
67+
68+
/**
69+
* Get all journals that meet the requirements to have
70+
* their articles or issues DOIs sent to Crossref.
71+
* @return array
72+
*/
73+
function _getJournals() {
74+
PluginRegistry::loadCategory('importexport');
75+
$crossrefExportPlugin = PluginRegistry::getPlugin('importexport', 'CrossRefExportPlugin');
76+
77+
$contextDao = Application::getContextDAO(); /* @var $contextDao JournalDAO */
78+
$journalFactory = $contextDao->getAll(true);
79+
$journals = array();
80+
while($journal = $journalFactory->next()) {
81+
$journalId = $journal->getId();
82+
if (!$journal->getSetting('citationsEnabledSubmission') || !$crossrefExportPlugin->getSetting($journalId, 'username') || !$crossrefExportPlugin->getSetting($journalId, 'password') || !$crossrefExportPlugin->getSetting($journalId, 'automaticRegistration')) continue;
83+
$journals[] = $journal;
84+
}
85+
return $journals;
86+
}
87+
}
88+
?>

0 commit comments

Comments
 (0)