forked from ajnyga/dates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDatesPlugin.inc.php
94 lines (78 loc) · 2.43 KB
/
DatesPlugin.inc.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
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* @file plugins/generic/dates/DatesPlugin.inc.php
*
* Copyright (c) 2014-2019 Simon Fraser University
* Copyright (c) 2003-2019 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class dates
* @ingroup plugins_generic_dates
*
* @brief dates plugin class
*/
import('lib.pkp.classes.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 iff 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()) {
// Insert Dates div
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->get_template_vars('article');
$dates = "";
$submitdate = $article->getDateSubmitted();
$publishdate = $article->getDatePublished();
$reviewdate = "";
$editDecisionDao = DAORegistry::getDAO('EditDecisionDAO');
$decisions = $editDecisionDao->getEditorDecisions($article->getId());
foreach ($decisions as $decision) {
if ($decision['stageId'] == '3' && $decision['decision'] == '1')
$reviewdate = $decision[dateDecided];
}
$dates = array();
if ($submitdate)
$dates['received'] = date('Y-m-d',strtotime($submitdate));
if ($reviewdate)
$dates['accepted'] = date('Y-m-d',strtotime($reviewdate));
if ($publishdate)
$dates['published'] = date('Y-m-d',strtotime($publishdate));
$smarty->assign('dates', $dates);
$output .= $smarty->fetch($this->getTemplateResource('dates.tpl'));
return false;
}
}
?>