-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSupporterPagePlugin.inc.php
More file actions
116 lines (98 loc) · 2.88 KB
/
SupporterPagePlugin.inc.php
File metadata and controls
116 lines (98 loc) · 2.88 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
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
/**
* @file plugins/generic/supporterPage/SupporterPagePlugin.inc.php
*
* Copyright (c) 2020 Language Science Press
* Developed by Ronald Steffen
* Distributed under the MIT license. For full terms see the file docs/License.
*
* @class SupporterPagePlugin
*
*/
import('lib.pkp.classes.plugins.GenericPlugin');
class SupporterPagePlugin extends GenericPlugin {
function register($category, $path, $mainContextId = NULL) {
if (parent::register($category, $path, $mainContextId)) {
if ($this->getEnabled($mainContextId)) {
$this->addLocaleData();
if ($this->getEnabled()) {
HookRegistry::register ('LoadHandler', array(&$this, 'handleSupporterPageRequest'));
}
}
return true;
}
return false;
}
function handleSupporterPageRequest($hookName, $args) {
$page = $args[0];
if ($page == 'supporters') {
$args[1] =$page;
define('SUPPORTERPAGE_PLUGIN_NAME', $this->getName());
define('HANDLER_CLASS', 'SupporterPageHandler');
$this->import('SupporterPageHandler');
return true;
}
return false;
}
/**
* @see Plugin::getActions()
*/
function getActions($request, $verb) {
$router = $request->getRouter();
import('lib.pkp.classes.linkAction.request.AjaxModal');
return array_merge(
$this->getEnabled()?array(
new LinkAction(
'settings',
new AjaxModal(
$router->url($request, null, null, 'manage', null, array('verb' => 'settings', 'plugin' => $this->getName(), 'category' => 'generic')),
$this->getDisplayName()
),
__('manager.plugins.settings'),
null
),
):array(),
parent::getActions($request, $verb)
);
}
/**
* @see Plugin::manage()
*/
function manage($args, $request) {
switch ($request->getUserVar('verb')) {
case 'settings':
$context = $request->getContext();
AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON, LOCALE_COMPONENT_PKP_MANAGER);
$templateMgr = TemplateManager::getManager($request);
$templateMgr->registerPlugin('function', 'plugin_url', array($this, 'smartyPluginUrl'));
$this->import('SettingsForm');
$form = new SettingsForm($this, $context->getId());
if ($request->getUserVar('save')) {
$form->readInputData();
if ($form->validate()) {
$form->execute();
return new JSONMessage(true);
}
} else {
$form->initData();
}
return new JSONMessage(true, $form->fetch($request));
}
return parent::manage($args, $request);
}
function getDisplayName() {
return __('plugins.generic.supporterPage.displayName');
}
function getDescription() {
return __('plugins.generic.supporterPage.description');
}
/**
* Get the name of the settings file to be installed on new context
* creation.
* @return string
*/
function getContextSpecificPluginSettingsFile() {
return $this->getPluginPath() . '/settings.xml';
}
}
?>