-
Notifications
You must be signed in to change notification settings - Fork 0
/
OrgUriPlugin.inc.php
123 lines (102 loc) · 3.48 KB
/
OrgUriPlugin.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
<?php
use PKP\components\forms\FieldText;
use PKP\components\forms\FieldSelect;
/**
* @file OrgUriPlugin.inc.php
*
* Copyright (c) 2021 National Library of Sweden
* Distributed under the GNU GPL v3. For full terms see LICENSE in the plugin repository root.
*
* @class OrgUriPlugin
* @ingroup generic_orgUri
* @brief Organisation URI plugin.
*/
class OrgUriPlugin extends GenericPlugin {
function register($category, $path, $mainContextId = null) {
$success = parent::register($category, $path);
if ($success && $this->getEnabled()) {
HookRegistry::register('Schema::get::context', array($this, 'addToSchema'));
HookRegistry::register('Form::config::before', array($this, 'addToForm'));
}
return $success;
}
public function addToSchema($hookName, $args) {
$schema = $args[0];
$schema->properties->organisationUri = (object) [
'type' => 'string',
'apiSummary' => true,
'multilingual' => false,
'validation' => ['nullable']
];
$schema->properties->journalLibrisUri = (object) [
'type' => 'string',
'apiSummary' => true,
'multilingual' => false,
'validation' => ['nullable']
];
$schema->properties->deliveryType = (object) [
'type' => 'string',
'apiSummary' => true,
'multilingual' => false,
'validation' => ['nullable']
];
return false;
}
public function addtoForm($hookName, $form) {
if (!defined('FORM_MASTHEAD') || $form->id !== FORM_MASTHEAD) {
return;
}
$context = Application::get()->getRequest()->getContext();
if (!$context) {
return;
}
$form->addField(new FieldText('organisationUri', [
'label' => __('plugins.generic.orgUri.organisationUri'),
'groupId' => 'publishing',
'value' => $context->getData('organisationUri'),
]));
$form->addField(new FieldText('journalLibrisUri', [
'label' => __('plugins.generic.orgUri.journalLibrisUri'),
'groupId' => 'publishing',
'value' => $context->getData('journalLibrisUri'),
]));
$deliveryOptions = [
[
'value' => 'AGREEMENT',
'label' => __('plugins.generic.orgUri.deliveryType.agreement')
],
[
'value' => 'DEPOSIT',
'label' => __('plugins.generic.orgUri.deliveryType.deposit')
]
];
$form->addField(new FieldSelect('deliveryType', [
'label' => __('plugins.generic.orgUri.deliveryType'),
'groupId' => 'publishing',
'options' => $deliveryOptions,
'default' => 'AGREEMENT',
'value' => $context->getData('deliveryType'),
]));
return false;
}
function getName() {
return 'OrganisationUri';
}
function getDisplayName() {
return __('plugins.generic.orgUri.displayName');
}
function getDescription() {
return __('plugins.generic.orgUri.description');
}
function isSitePlugin() {
return true;
}
// Can only be activated at site level.
function getCanEnable() {
return !((bool) Application::get()->getRequest()->getContext());
}
// Can only be deactivated at site level.
function getCanDisable() {
return !((bool) Application::get()->getRequest()->getContext());
}
}