ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilSuggestedSolutionSelectorGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once "./Services/Form/classes/class.ilSubEnabledFormPropertyGUI.php";
5
14{
15 protected $options;
16 protected $value;
17 protected $addCommand;
18 protected $intlink;
19 protected $intlinktext;
20
27 public function __construct($a_title = "", $a_postvar = "")
28 {
29 parent::__construct($a_title, $a_postvar);
30 $this->setType("select");
31 }
32
38 public function setOptions($a_options)
39 {
40 $this->options = $a_options;
41 }
42
48 public function getOptions()
49 {
50 return $this->options;
51 }
52
58 public function setValue($a_value)
59 {
60 $this->value = $a_value;
61 }
62
68 public function getValue()
69 {
70 return $this->value;
71 }
72
78 public function setInternalLink($a_value)
79 {
80 $this->intlink = $a_value;
81 }
82
88 public function getInternalLink()
89 {
90 return $this->intlink;
91 }
92
98 public function setInternalLinkText($a_value)
99 {
100 $this->intlinktext = $a_value;
101 }
102
108 public function getInternalLinkText()
109 {
110 return $this->intlinktext;
111 }
112
118 public function setAddCommand($a_add_command)
119 {
120 $this->addCommand = $a_add_command;
121 }
122
128 public function getAddCommand()
129 {
130 return ($this->addCommand) ? $this->addCommand : "addInternalLink";
131 }
132
138 public function setValueByArray($a_values)
139 {
140 $this->setValue($a_values[$this->getPostVar()]);
141 }
142
148 public function checkInput()
149 {
150 global $DIC;
151 $lng = $DIC['lng'];
152
153 $_POST[$this->getPostVar()] =
155 if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "") {
156 $this->setAlert($lng->txt("msg_input_is_required"));
157
158 return false;
159 }
160 return $this->checkSubItemsInput();
161 }
162
168 public function insert(&$a_tpl)
169 {
170 global $DIC;
171 $lng = $DIC['lng'];
172
173 $template = new ilTemplate("tpl.prop_suggestedsolutionselector.html", true, true, "Modules/TestQuestionPool");
174
175 foreach ($this->getOptions() as $option_value => $option_text) {
176 $template->setCurrentBlock("prop_intlink_select_option");
177 $template->setVariable("VAL_SELECT_OPTION", $option_value);
178 if ($option_value == $this->getValue()) {
179 $template->setVariable(
180 "CHK_SEL_OPTION",
181 'selected="selected"'
182 );
183 }
184 $template->setVariable("TXT_SELECT_OPTION", $option_text);
185 $template->parseCurrentBlock();
186 }
187 if ($this->getInternalLink()) {
188 $template->setCurrentBlock("delete_internallink");
189 $template->setVariable("TEXT_DELETE_INTERNALLINK", $lng->txt("remove_solution"));
190 $template->setVariable("POST_VAR", $this->getPostVar());
191 $template->parseCurrentBlock();
192 $template->setCurrentBlock("internal_link");
193 $template->setVariable("HREF_INT_LINK", $this->getInternalLink());
194 $template->setVariable("TEXT_INT_LINK", $this->getInternalLinkText());
195 $template->parseCurrentBlock();
196 }
197 $template->setCurrentBlock("prop_internallink_selector");
198 $template->setVariable("POST_VAR", $this->getPostVar());
199 if ($this->getDisabled()) {
200 $template->setVariable(
201 "DISABLED",
202 " disabled=\"disabled\""
203 );
204 }
205 $template->setVariable("TEXT_ADD_INTERNALLINK", ($this->getInternalLink()) ? $lng->txt("change") : $lng->txt("add"));
206 $template->setVariable("CMD_ADD_INTERNALLINK", $this->getAddCommand());
207 $template->parseCurrentBlock();
208 $a_tpl->setCurrentBlock("prop_generic");
209 $a_tpl->setVariable("PROP_GENERIC", $template->get());
210 $a_tpl->parseCurrentBlock();
211 }
212}
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
setType($a_type)
Set Type.
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
This class represents a property that may include a sub form.
This class represents a selection list property in a property form.
__construct($a_title="", $a_postvar="")
Constructor.
setInternalLinkText($a_value)
Set internal link.text.
special template class to simplify handling of ITX/PEAR
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46