-
Notifications
You must be signed in to change notification settings - Fork 2
/
ThemeIssuesPlugin.inc.php
125 lines (107 loc) · 3.46 KB
/
ThemeIssuesPlugin.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
/**
* @file plugins/generic/themeIssues/ThemeIssuesPlugin.inc.php
*
* Copyright (c) 2014-2020 Simon Fraser University
* Copyright (c) 2003-2020 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class ThemeIssuesPlugin
* @ingroup plugins_generic_themeIssues
*
* @brief ThemeIssues plugin class
*/
import('lib.pkp.classes.plugins.GenericPlugin');
class ThemeIssuesPlugin 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);
if ($success && $this->getEnabled()) {
HookRegistry::register('LoadHandler', array($this, 'loadPageHandler'));
// Handle issue form
HookRegistry::register('Templates::Editor::Issues::IssueData::AdditionalMetadata', array($this, 'addIssueFormFields'));
HookRegistry::register('issuedao::getAdditionalFieldNames', array($this, 'addIssueDAOFieldNames'));
HookRegistry::register('issueform::readuservars', array($this, 'readIssueFormFields'));
HookRegistry::register('issueform::initdata', array($this, 'initDataIssueFormFields'));
HookRegistry::register('issueform::execute', array($this, 'executeIssueFormFields'));
}
return $success;
}
/**
* @copydoc Plugin::getDisplayName()
*/
function getDisplayName() {
return __('plugins.generic.themeIssues.displayName');
}
/**
* @copydoc Plugin::getDescription()
*/
function getDescription() {
return __('plugins.generic.themeIssues.description');
}
/**
* Load the handler to deal with browse by section page requests
*/
public function loadPageHandler($hookName, $args) {
$page = $args[0];
if ($this->getEnabled() && $page === 'themeissues') {
$this->import('pages/ThemeIssuesHandler');
define('HANDLER_CLASS', 'ThemeIssuesHandler');
return true;
}
return false;
}
/**
* Add fields to the issue editing form
*/
public function addIssueFormFields($hookName, $args) {
$smarty =& $args[1];
$output =& $args[2];
$output .= $smarty->fetch($this->getTemplateResource('themeIssuesEdit.tpl'));
return false;
}
/**
* Read user input from additional fields in the issue editing form
*/
public function readIssueFormFields($hookName, $args) {
$issueForm =& $args[0];
$request = $this->getRequest();
$issueForm->setData('isThemeIssue', $request->getUserVar('isThemeIssue'));
}
/**
* Save additional fields in the issue editing form
*/
public function executeIssueFormFields($hookName, $args) {
$issueForm = $args[0];
$issue = $args[1];
// The issueform::execute hook fires twice, once at the start of the
// method when no issue exists. Only update the object during the
// second request
if (!$issue) {
return;
}
$issue->setData('isThemeIssue', $issueForm->getData('isThemeIssue'));
$issueDao = DAORegistry::getDAO('IssueDAO');
$issueDao->updateObject($issue);
}
/**
* Initialize data when form is first loaded
*/
public function initDataIssueFormFields($hookName, $args) {
$issueForm = $args[0];
$issueForm->setData('isThemeIssue', $issueForm->issue->getData('isThemeIssue'));
}
/**
* Add section settings to IssueDAO
*/
public function addIssueDAOFieldNames($hookName, $args) {
$fields =& $args[1];
$fields[] = 'isThemeIssue';
}
}
?>