ILIAS  release_8 Revision v8.24
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 global $DIC;
163 $lng = $DIC['lng'];
164
165 $_POST[$this->getPostVar()] =
166 ilUtil::stripSlashes($_POST[$this->getPostVar()]);
167 if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "") {
168 $this->setAlert($lng->txt("msg_input_is_required"));
169
170 return false;
171 }
172 return $this->checkSubItemsInput();
173 }
174
175 public function insert($a_tpl): void
176 {
177 global $DIC;
178 $lng = $DIC['lng'];
179
180 $template = new ilTemplate("tpl.prop_suggestedsolutionselector.html", true, true, "Modules/TestQuestionPool");
181
182 foreach ($this->getOptions() as $option_value => $option_text) {
183 $template->setCurrentBlock("prop_intlink_select_option");
184 $template->setVariable("VAL_SELECT_OPTION", $option_value);
185 if ($option_value == $this->getValue()) {
186 $template->setVariable(
187 "CHK_SEL_OPTION",
188 'selected="selected"'
189 );
190 }
191 $template->setVariable("TXT_SELECT_OPTION", $option_text);
192 $template->parseCurrentBlock();
193 }
194 if ($this->getInternalLink()) {
195 $template->setCurrentBlock("delete_internallink");
196 $template->setVariable("TEXT_DELETE_INTERNALLINK", $lng->txt("remove_solution"));
197 $template->setVariable("POST_VAR", $this->getPostVar());
198 $template->parseCurrentBlock();
199 $template->setCurrentBlock("internal_link");
200 $template->setVariable("HREF_INT_LINK", $this->getInternalLink());
201 $template->setVariable("TEXT_INT_LINK", $this->getInternalLinkText());
202 $template->parseCurrentBlock();
203 }
204 $template->setCurrentBlock("prop_internallink_selector");
205 $template->setVariable("POST_VAR", $this->getPostVar());
206 if ($this->getDisabled()) {
207 $template->setVariable(
208 "DISABLED",
209 " disabled=\"disabled\""
210 );
211 }
212 $template->setVariable("TEXT_ADD_INTERNALLINK", ($this->getInternalLink()) ? $lng->txt("change") : $lng->txt("add"));
213 $template->setVariable("CMD_ADD_INTERNALLINK", $this->getAddCommand());
214 $template->parseCurrentBlock();
215 $a_tpl->setCurrentBlock("prop_generic");
216 $a_tpl->setVariable("PROP_GENERIC", $template->get());
217 $a_tpl->parseCurrentBlock();
218 }
219}
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc