-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTypesetSettingsForm.inc.php
112 lines (89 loc) · 2.25 KB
/
TypesetSettingsForm.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
<?php
/**
* @file plugins/generic/typeset/TypesetSettingsForm.inc.php
*
*/
import('lib.pkp.classes.form.Form');
//TODO
class TypesetSettingsForm extends Form {
/**
* TypesetForm constructor.
* @param $plugin
*/
/*** * @var context */
private $_context;
/** @var Settings Plugin */
private $_plugin;
private $_pluginSettings;
function __construct($plugin, $contextId) {
$this->_context = $contextId;
$this->_plugin = $plugin;
$this->_pluginSettings = [
'typesetToolAggression',
'typesetToolClean',
'typesetToolImage',
'typesetToolReference',
'typesetPythonVirtualPath',
'typesetToolOutputTEI'
];
parent::__construct($plugin->getTemplateResource('TypesetSettingsForm.tpl'));
$this->setData('pluginName', $plugin->getName());
}
private function _getPluginSettings() {
return $this->_pluginSettings;
}
function initData() {
foreach ($this->_getPluginSettings() as $pluginSetting){
$this->_setValue($pluginSetting);
}
}
/**
* @return
*/
function execute() {
$plugin = $this->_plugin;
$context = Request::getContext();
$contextId = $context ? $context->getId() : CONTEXT_ID_NONE;
foreach ($this->_getPluginSettings() as $settingName) {
$plugin->updateSetting($contextId, $settingName, $this->getData($settingName));
}
return true;
}
/**
* @param $args
* @param PKPRequest $request
* @return mixed
*/
function manage($args, $request) {
$plugin = $this->getAuthorizedContextObject(ASSOC_TYPE_PLUGIN);
return $plugin->manage($args, $request);
}
/**
* Fetchs template
* @param PKPRequest $request
* @return string
*/
function fetch($request) {
$templateMgr = TemplateManager::getManager($request);
return parent::fetch($request);
}
/**
* @param string $pluginSetting
*/
private function _setValue(string $pluginSetting) {
$plugin = $this->_plugin;
$context = Request::getContext();
$contextId = $context ? $context->getId() : CONTEXT_ID_NONE;
$setting = $plugin->getSetting($contextId, $pluginSetting);
if (isset($setting) & !empty($setting)) {
$this->setData($pluginSetting, $setting);
}
}
/**
* Assign form data to user-submitted data.
*/
function readInputData() {
parent::readInputData();
$this->readUserVars($this->_getPluginSettings());
}
}