-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPPNFormPlugin.inc.php
145 lines (123 loc) · 3.53 KB
/
PPNFormPlugin.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
/**
* @file plugins/generic/ppnForm/PPNFormPlugin.inc.php
*
* @brief Add PPNs to the submission metadata.
*
*/
import('lib.pkp.classes.plugins.GenericPlugin');
class PPNFormPlugin extends GenericPlugin {
/**
* @copydoc Plugin::getName()
*/
function getName() {
return 'PPNFormPlugin';
}
/**
* @copydoc Plugin::getDisplayName()
*/
function getDisplayName() {
return 'PPNFormPlugin';
}
/**
* @copydoc Plugin::getDescription()
*/
function getDescription() {
return __('plugins.generic.ppnForm.description');
}
/**
* @copydoc Plugin::register()
*/
function register($category, $path, $mainContextId = null) {
$success = parent::register($category, $path);
if ($success && $this->getEnabled()) {
// Get custom DAO.
import('plugins.generic.ppnForm.classes.PPNDAO');
$ppnDao = new PPNDAO();
DAORegistry::registerDAO('PPNDAO', $ppnDao);
// Show ppn grid in publication and submission workflow.
HookRegistry::register('Templates::Submission::SubmissionMetadataForm::AdditionalMetadata', array($this, 'metadataFieldEdit'));
HookRegistry::register('Template::Workflow::Publication', array($this, 'addToPublicationForms'));
// Load grid handler.
HookRegistry::register('LoadComponentHandler', array($this, 'setupGridHandler'));
// Load JS for grid handler.
HookRegistry::register('TemplateManager::display',array($this, 'addGridhandlerJs'));
}
return $success;
}
/**
* Permit requests to the ppn grid handler.
* @param $hookName string The name of the hook being invoked
* @param $args array The parameters to the invoked hook
*/
function setupGridHandler($hookName, $params) {
$component =& $params[0];
if ($component == 'plugins.generic.ppnForm.controllers.grid.PPNGridHandler') {
import($component);
PPNGridHandler::setPlugin($this);
return true;
}
return false;
}
/**
* Insert ppn grid in the submission metadata form
*/
function metadataFieldEdit($hookName, $params) {
$smarty =& $params[1];
$output =& $params[2];
$output .= $smarty->fetch($this->getTemplateResource('metadataForm.tpl'));
return false;
}
/**
* Insert ppn grid in the publication tab.
*/
function addToPublicationForms($hookName, $params) {
$smarty =& $params[1];
$output =& $params[2];
$submission = $smarty->get_template_vars('submission');
$smarty->assign([
'submissionId' => $submission->getId(),
]);
$output .= sprintf(
'<tab id="ppnGridInWorkflow" label="%s">%s</tab>',
__('plugins.generic.ppnForm.ppnTab'),
$smarty->fetch($this->getTemplateResource('metadataForm.tpl'))
);
return false;
}
/**
* Add custom gridhandlerJS for backend
*/
function addGridhandlerJs($hookName, $params) {
$templateMgr = $params[0];
$request = $this->getRequest();
$gridHandlerJs = $this->getJavaScriptURL($request, false) . DIRECTORY_SEPARATOR . 'PPNGridHandler.js';
$templateMgr->addJavaScript(
'PPNGridHandlerJs',
$gridHandlerJs,
array('contexts' => 'backend')
);
$templateMgr->addStylesheet(
'PPNGridHandlerStyles',
'#ppnGridInWorkflow { margin-top: 32px;}',
[
'inline' => true,
'contexts' => 'backend',
]
);
return false;
}
/**
* @copydoc Plugin::getInstallMigration()
*/
function getInstallMigration() {
$this->import('PPNSchemaMigration');
return new PPNSchemaMigration();
}
/**
* Get the JavaScript URL for this plugin.
*/
function getJavaScriptURL() {
return Application::get()->getRequest()->getBaseUrl() . DIRECTORY_SEPARATOR . $this->getPluginPath() . DIRECTORY_SEPARATOR . 'js';
}
}