forked from withanage/ojsLeibnizOpen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOAIMetadataFormatPlugin_WGL.inc.php
147 lines (126 loc) · 3.37 KB
/
OAIMetadataFormatPlugin_WGL.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/oaiMetadataFormats/wgl/OAIMetadataFormatPlugin_WGL.inc.php
*
* Distributed under the GNU GPL v3
*
* @class OAIMetadataFormatPlugin_WGL
* @ingroup oai_format
* @see OAI
*
* @brief wgl metadata format plugin for OAI.
*/
import('lib.pkp.classes.plugins.OAIMetadataFormatPlugin');
class OAIMetadataFormatPlugin_WGL extends OAIMetadataFormatPlugin {
/**
* Get the name of this plugin. The name must be unique within
* its category.
* @return String name of plugin
*/
function getName() {
return 'OAIFormatPlugin_WGL';
}
/**
* @copydoc Plugin::getDisplayName()
*/
function getDisplayName() {
return __('plugins.OAIMetadata.wgl.displayName');
}
/**
* @copydoc Plugin::getDescription()
*/
function getDescription() {
return __('plugins.OAIMetadata.wgl.description');
}
/**
* Determine whether the plugin can be disabled.
* @return boolean
*/
function getCanDisable() {
return true;
}
/**
* Determine whether the plugin can be enabled.
* @return boolean
*/
function getCanEnable() {
return true;
}
/**
* Determine whether the plugin is enabled.
* @return boolean
*/
function getEnabled() {
$request = PKPApplication::getRequest();
if (!$request) return false;
$context = $request->getContext();
if (!$context) return false;
return $this->getSetting($context->getId(), 'enabled');
}
/**
* Set whether the plugin is enabled.
* @param $enabled boolean
*/
function setEnabled($enabled) {
$request = PKPApplication::getRequest();
$context = $request->getContext();
$this->updateSetting($context->getId(), 'enabled', $enabled, 'bool');
}
function getFormatClass() {
return 'OAIMetadataFormat_WGL';
}
static function getMetadataPrefix() {
return 'wgl';
}
static function getSchema() {
return 'http://www.leibnizopen.de/fileadmin/default/documents/oai_wgl/oai_wgl.xsd';
}
static function getNamespace() {
return 'http://www.leibnizopen.de/fileadmin/default/documents/oai_wgl/';
}
/**
* @copydoc Plugin::getActions()
*/
function getActions($request, $actionArgs) {
$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_merge($actionArgs, array('verb' => 'settings'))),
$this->getDisplayName()
),
__('manager.plugins.settings'),
null
),
):array(),
parent::getActions($request, $actionArgs)
);
}
function manage($args, $request) {
$this->import('WGLSettingsForm');
switch($request->getUserVar('verb')) {
case 'settings':
$settingsForm = new WGLSettingsForm($this);
$settingsForm->initData();
return new JSONMessage(true, $settingsForm->fetch($request));
case 'save':
$settingsForm = new WGLSettingsForm($this);
$settingsForm->readInputData();
if ($settingsForm->validate()) {
$settingsForm->execute();
$notificationManager = new NotificationManager();
$notificationManager->createTrivialNotification(
$request->getUser()->getId(),
NOTIFICATION_TYPE_SUCCESS,
array('contents' => __('plugins.OAIMetadata.wgl.settings.saved'))
);
return new JSONMessage(true);
}
return new JSONMessage(true, $settingsForm->fetch($request));
}
return parent::manage($args, $request);
}
}