forked from kaschioudi/sword
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathSwordSettingsForm.php
82 lines (67 loc) · 2.12 KB
/
SwordSettingsForm.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
<?php
/**
* @file SwordSettingsForm.php
*
* Copyright (c) 2003-2024 Simon Fraser University
* Copyright (c) 2003-2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file LICENSE.
*
* @class SwordSettingsForm
* @brief Form for SWORD plugin settings
*/
namespace APP\plugins\generic\sword;
use PKP\form\Form;
use PKP\context\Context;
use APP\template\TemplateManager;
use APP\plugins\generic\sword\SwordPlugin;
class SwordSettingsForm extends Form {
/** @var $_context Context */
protected $_context = null;
/** @var $_plugin SwordPlugin */
protected $_plugin = null;
/**
* Constructor
* @param $plugin SwordPlugin
* @param $context Context
*/
public function __construct(SwordPlugin $plugin, Context $context) {
$this->_plugin = $plugin;
$this->_context = $context;
parent::__construct($plugin->getTemplateResource('settingsForm.tpl'));
}
/**
* Initialize plugin settings form
*
* @return void
*/
public function initData() {
$this->setData('allowAuthorSpecify', $this->_plugin->getSetting($this->_context->getId(), 'allowAuthorSpecify'));
$this->setData('showDepositButton', $this->_plugin->getSetting($this->_context->getId(), 'showDepositButton'));
}
/**
* Assign form data to user-submitted data
*
* @return void
*/
public function readInputData() {
$this->readUserVars(['allowAuthorSpecify', 'showDepositButton']);
}
/**
* @copydoc Form::fetch()
*/
function fetch($request, $template = null, $display = false) {
$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign('pluginJavaScriptURL', $this->_plugin->getJsUrl($request));
return parent::fetch($request, $template, $display);
}
/**
* Save form.
*/
public function execute(...$functionArgs) {
$allowAuthorSpecify = intval($this->getData('allowAuthorSpecify'));
$this->_plugin->updateSetting($this->_context->getId(), 'allowAuthorSpecify', $allowAuthorSpecify);
$showDepositButton = intval($this->getData('showDepositButton'));
$this->_plugin->updateSetting($this->_context->getId(), 'showDepositButton', $showDepositButton);
parent::execute(...$functionArgs);
}
}