ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSuggestedSolutionSelectorGUI.php
Go to the documentation of this file.
1<?php
2
27{
28 protected $options;
29 protected $value;
30 protected $addCommand;
31 protected $intlink;
32 protected $intlinktext;
33
40 public function __construct($a_title = "", $a_postvar = "")
41 {
42 parent::__construct($a_title, $a_postvar);
43 $this->setType("select");
44 }
45
51 public function setOptions($a_options): void
52 {
53 $this->options = $a_options;
54 }
55
61 public function getOptions(): array
62 {
63 return $this->options;
64 }
65
71 public function setValue($a_value): void
72 {
73 $this->value = $a_value;
74 }
75
81 public function getValue(): string
82 {
83 return $this->value;
84 }
85
91 public function setInternalLink($a_value): void
92 {
93 $this->intlink = $a_value;
94 }
95
101 public function getInternalLink(): string
102 {
103 return $this->intlink;
104 }
105
111 public function setInternalLinkText($a_value): void
112 {
113 $this->intlinktext = $a_value;
114 }
115
121 public function getInternalLinkText(): string
122 {
123 return $this->intlinktext;
124 }
125
131 public function setAddCommand($a_add_command): void
132 {
133 $this->addCommand = $a_add_command;
134 }
135
141 public function getAddCommand(): string
142 {
143 return ($this->addCommand) ? $this->addCommand : "addInternalLink";
144 }
145
151 public function setValueByArray($a_values): void
152 {
153 $this->setValue($a_values[$this->getPostVar()]);
154 }
155
160 public function checkInput(): bool
161 {
162 if ($this->getRequired() && $this->str($this->getPostVar()) === '') {
163 $this->setAlert($this->lng->txt('msg_input_is_required'));
164 return false;
165 }
166
167 return $this->checkSubItemsInput();
168 }
169
170 public function insert($a_tpl): void
171 {
172 $template = new ilTemplate("tpl.prop_suggestedsolutionselector.html", true, true, "components/ILIAS/TestQuestionPool");
173
174 foreach ($this->getOptions() as $option_value => $option_text) {
175 $template->setCurrentBlock("prop_intlink_select_option");
176 $template->setVariable("VAL_SELECT_OPTION", $option_value);
177 if ($option_value == $this->getValue()) {
178 $template->setVariable(
179 "CHK_SEL_OPTION",
180 'selected="selected"'
181 );
182 }
183 $template->setVariable("TXT_SELECT_OPTION", $option_text);
184 $template->parseCurrentBlock();
185 }
186 if ($this->getInternalLink()) {
187 $template->setCurrentBlock("delete_internallink");
188 $template->setVariable("TEXT_DELETE_INTERNALLINK", $this->lng->txt("remove_solution"));
189 $template->setVariable("POST_VAR", $this->getPostVar());
190 $template->parseCurrentBlock();
191 $template->setCurrentBlock("internal_link");
192 $template->setVariable("HREF_INT_LINK", $this->getInternalLink());
193 $template->setVariable("TEXT_INT_LINK", $this->getInternalLinkText());
194 $template->parseCurrentBlock();
195 }
196 $template->setCurrentBlock("prop_internallink_selector");
197 $template->setVariable("POST_VAR", $this->getPostVar());
198 if ($this->getDisabled()) {
199 $template->setVariable(
200 "DISABLED",
201 " disabled=\"disabled\""
202 );
203 }
204 $template->setVariable(
205 "TEXT_ADD_INTERNALLINK",
206 ($this->getInternalLink()) ? $this->lng->txt("change") : $this->lng->txt("add")
207 );
208 $template->setVariable("CMD_ADD_INTERNALLINK", $this->getAddCommand());
209 $template->parseCurrentBlock();
210 $a_tpl->setCurrentBlock("prop_generic");
211 $a_tpl->setVariable("PROP_GENERIC", $template->get());
212 $a_tpl->parseCurrentBlock();
213 }
214}
This class represents a property that may include a sub form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct($a_title="", $a_postvar="")
Constructor.
setInternalLinkText($a_value)
Set internal link.text.
special template class to simplify handling of ITX/PEAR
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc