forked from pkp/crossrefReferenceLinking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCrossrefReferenceLinkingInfoSender.php
81 lines (73 loc) · 2.47 KB
/
CrossrefReferenceLinkingInfoSender.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/**
* @file CrossrefReferenceLinkingInfoSender.php
*
* Copyright (c) 2013-2023 Simon Fraser University
* Copyright (c) 2003-2023 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file LICENSE.
*
* @class CrossrefReferenceLinkingInfoSender
* @brief Scheduled task to check for found Crossref references DOIs.
*/
namespace APP\plugins\generic\crossrefReferenceLinking;
use APP\core\Application;
use APP\journal\Journal;
use PKP\plugins\PluginRegistry;
use PKP\scheduledTask\ScheduledTask;
class CrossrefReferenceLinkingInfoSender extends ScheduledTask
{
protected CrossrefReferenceLinkingPlugin $plugin;
/**
* Constructor.
* @param $args array task arguments
*/
public function __construct($args)
{
parent::__construct($args);
$this->plugin = PluginRegistry::getPlugin('generic', 'crossrefreferencelinkingplugin');
$this->plugin->addLocaleData();
}
/**
* @copydoc ScheduledTask::getName()
*/
public function getName(): string
{
return __('plugins.generic.crossrefReferenceLinking.senderTask.name');
}
/**
* @copydoc ScheduledTask::executeActions()
*/
public function executeActions(): bool
{
if (!$this->plugin) {
return false;
}
foreach ($this->getJournals() as $journal) {
// Get published articles to check
$submissionsToCheck = $this->plugin->getSubmissionsToCheck($journal);
foreach ($submissionsToCheck as $submissionToCheck) { /** @var Article $submissionToCheck */
$this->plugin->considerFoundCrossrefReferencesDOIs($submissionToCheck->getCurrentPublication());
}
}
return true;
}
/**
* Get all journals that meet the requirements to have
* their articles or issues DOIs sent to Crossref.
*
* @return Journal[]
*/
protected function getJournals(): array
{
$contextDao = Application::getContextDAO(); /** @var JournalDAO $contextDao */
$contextFactory = $contextDao->getAll(true); /** @var DAOResultFactory $contextFactory */
$journals = [];
foreach ($contextFactory->toIterator() as $journal) { /** @var Journal $journal */
if ($this->plugin->citationsEnabled($journal->getId()) &&
$this->plugin->hasCrossrefCredentials($journal->getId())) {
$journals[] = $journal;
}
}
return $journals;
}
}