|
1
|
|
|
<?php |
|
2
|
|
|
/* For licensing terms, see /license.txt */ |
|
3
|
|
|
|
|
4
|
|
|
use Chamilo\PluginBundle\Entity\ImsLti\ImsLtiTool; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Class FrmAdd. |
|
8
|
|
|
*/ |
|
9
|
|
|
class FrmAdd extends FormValidator |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @var ImsLtiTool|null |
|
13
|
|
|
*/ |
|
14
|
|
|
private $baseTool; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* FrmAdd constructor. |
|
18
|
|
|
* |
|
19
|
|
|
* @param string $name |
|
20
|
|
|
* @param array $attributes |
|
21
|
|
|
* @param ImsLtiTool|null $tool |
|
22
|
|
|
*/ |
|
23
|
|
|
public function __construct( |
|
24
|
|
|
$name, |
|
25
|
|
|
$attributes = [], |
|
26
|
|
|
ImsLtiTool $tool = null |
|
27
|
|
|
) { |
|
28
|
|
|
parent::__construct($name, 'POST', '', '', $attributes, self::LAYOUT_HORIZONTAL, true); |
|
29
|
|
|
|
|
30
|
|
|
$this->baseTool = $tool; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Build the form |
|
35
|
|
|
*/ |
|
36
|
|
|
public function build() |
|
37
|
|
|
{ |
|
38
|
|
|
$plugin = ImsLtiPlugin::create(); |
|
39
|
|
|
|
|
40
|
|
|
$this->addHeader($plugin->get_lang('ToolSettings')); |
|
41
|
|
|
$this->addText('name', get_lang('Name')); |
|
42
|
|
|
$this->addTextarea('description', get_lang('Description')); |
|
43
|
|
|
|
|
44
|
|
|
if (null === $this->baseTool) { |
|
45
|
|
|
$this->addElement('url', 'launch_url', $plugin->get_lang('LaunchUrl')); |
|
46
|
|
|
$this->addRule('launch_url', get_lang('Required'), 'required'); |
|
47
|
|
|
$this->addText('consumer_key', $plugin->get_lang('ConsumerKey')); |
|
48
|
|
|
$this->addText('shared_secret', $plugin->get_lang('SharedSecret')); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
$this->addButtonAdvancedSettings('lti_adv'); |
|
52
|
|
|
$this->addHtml('<div id="lti_adv_options" style="display:none;">'); |
|
53
|
|
|
$this->addTextarea( |
|
54
|
|
|
'custom_params', |
|
55
|
|
|
[$plugin->get_lang('CustomParams'), $plugin->get_lang('CustomParamsHelp')] |
|
56
|
|
|
); |
|
57
|
|
|
|
|
58
|
|
|
if (null === $this->baseTool || |
|
59
|
|
|
($this->baseTool && !$this->baseTool->isActiveDeepLinking()) |
|
60
|
|
|
) { |
|
61
|
|
|
$this->addCheckBox( |
|
62
|
|
|
'deep_linking', |
|
63
|
|
|
[null, $plugin->get_lang('SupportDeppLinkingHelp'), null], |
|
64
|
|
|
$plugin->get_lang('SupportDeepLinking') |
|
65
|
|
|
); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
$this->addHtml('</div>'); |
|
69
|
|
|
$this->addButtonAdvancedSettings('lti_privacy', get_lang('Privacy')); |
|
70
|
|
|
$this->addHtml('<div id="lti_privacy_options" style="display:none;">'); |
|
71
|
|
|
$this->addCheckBox('share_name', null, $plugin->get_lang('ShareLauncherName')); |
|
72
|
|
|
$this->addCheckBox('share_email', null, $plugin->get_lang('ShareLauncherEmail')); |
|
73
|
|
|
$this->addCheckBox('share_picture', null, $plugin->get_lang('ShareLauncherPicture')); |
|
74
|
|
|
$this->addHtml('</div>'); |
|
75
|
|
|
$this->addButtonCreate($plugin->get_lang('AddExternalTool')); |
|
76
|
|
|
$this->applyFilter('__ALL__', 'Security::remove_XSS'); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function setDefaultValues() |
|
80
|
|
|
{ |
|
81
|
|
|
if (null !== $this->baseTool) { |
|
82
|
|
|
$this->setDefaults( |
|
83
|
|
|
[ |
|
84
|
|
|
'name' => $this->baseTool->getName(), |
|
85
|
|
|
'description' => $this->baseTool->getDescription(), |
|
86
|
|
|
'custom_params' => $this->baseTool->getCustomParams(), |
|
87
|
|
|
'share_name' => $this->baseTool->isSharingName(), |
|
88
|
|
|
'share_email' => $this->baseTool->isSharingEmail(), |
|
89
|
|
|
'share_picture' => $this->baseTool->isSharingPicture(), |
|
90
|
|
|
] |
|
91
|
|
|
); |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|