-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathDatesPlugin.inc.php
More file actions
103 lines (88 loc) · 2.9 KB
/
DatesPlugin.inc.php
File metadata and controls
103 lines (88 loc) · 2.9 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
/**
* @file plugins/generic/dates/DatesPlugin.inc.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2003-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class dates
* @ingroup plugins_generic_dates
*
* @brief dates plugin class
*/
use APP\decision\Decision;
use APP\facades\Repo;
use PKP\plugins\GenericPlugin;
class DatesPlugin extends GenericPlugin {
/**
* Called as a plugin is registered to the registry
* @param $category String Name of category plugin was registered to
* @return boolean True if plugin initialized successfully; if false,
* the plugin will not be registered.
*/
function register($category, $path, $mainContextId = NULL) {
$success = parent::register($category, $path, $mainContextId);
if (!Config::getVar('general', 'installed') || defined('RUNNING_UPGRADE')) return true;
if ($success && $this->getEnabled()) {
HookRegistry::register('Templates::Article::Details', array($this, 'addDates'));
}
return $success;
}
/**
* Get the plugin display name.
* @return string
*/
function getDisplayName() {
return __('plugins.generic.dates.displayName');
}
/**
* Get the plugin description.
* @return string
*/
function getDescription() {
return __('plugins.generic.dates.description');
}
/**
* Add dates to article landing page
* @param $hookName string
* @param $params array
*/
function addDates($hookName, $params) {
$request = $this->getRequest();
$context = $request->getContext();
$smarty = $params[1];
$output =& $params[2];
$article = $smarty->getTemplateVars('article');
$dates = "";
$submitdate = $article->getDateSubmitted();
$publishdate = $article->getDatePublished();
$reviewdate = "";
$decisions = Repo::decision()->getCollector()
->filterBySubmissionIds([$article->getId()])
->getMany();
// Loop through the decisions
foreach ($decisions as $decision) {
// If we have a review stage decision and it was a submission accepted decision, get to date for the decision
// Note that since version 3.4 the decision value has changed from '1' to '2' for accepted
if ($decision->getData('stageId') == '3' && $decision->getData('decision') == '2'){
$reviewdate = $decision->getData('dateDecided');
}
}
$dates = array();
$dateFormatShort = PKPString::convertStrftimeFormat($context->getLocalizedDateFormatShort($locale));
if ($submitdate)
$dates['received'] = date($dateFormatShort,strtotime($submitdate));
if ($reviewdate)
$dates['accepted'] = date($dateFormatShort,strtotime($reviewdate));
if ($publishdate)
$dates['published'] = date($dateFormatShort,strtotime($publishdate));
// Only show dates if there was a review
if ($reviewdate){
$smarty->assign('dates', $dates);
$output .= $smarty->fetch($this->getTemplateResource('dates.tpl'));
}
return false;
}
}
?>