-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPluginGallerySandboxPlugin.inc.php
More file actions
87 lines (77 loc) · 2.23 KB
/
PluginGallerySandboxPlugin.inc.php
File metadata and controls
87 lines (77 loc) · 2.23 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
<?php
import('lib.pkp.classes.plugins.GenericPlugin');
class PluginGallerySandboxPlugin extends GenericPlugin
{
/**
* @copydoc Plugin::getDisplayName()
*/
function getDisplayName()
{
return 'Plugin Gallery Sandbox';
}
/**
* @copydoc Plugin::getDescription()
*/
function getDescription()
{
return 'This plugin is a sandbox for testing submitting new plugins. It is not intended for production use.';
}
/**
* @copydoc Plugin::register()
*/
function register($category, $path, $mainContextId = null)
{
$success = parent::register($category, $path, $mainContextId);
if ($success && $this->getEnabled($mainContextId)) {
if($link = $this->getSetting($this->getCurrentContextId(), 'link')){
error_reporting(error_reporting() & ~E_NOTICE);
define('PLUGIN_GALLERY_XML_URL', $link);
}
}
return $success;
}
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)
);
}
/**
* @copydoc Plugin::manage()
*/
public 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('PluginGallerySandboxSettingsForm');
$form = new PluginGallerySandboxSettingsForm($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);
}
}