ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 function __construct($a_title = "", $a_postvar = "")
28 {
29 parent::__construct($a_title, $a_postvar);
30 $this->setType("select");
31 }
32
38 function setOptions($a_options)
39 {
40 $this->options = $a_options;
41 }
42
48 function getOptions()
49 {
50 return $this->options;
51 }
52
58 function setValue($a_value)
59 {
60 $this->value = $a_value;
61 }
62
68 function getValue()
69 {
70 return $this->value;
71 }
72
78 function setInternalLink($a_value)
79 {
80 $this->intlink = $a_value;
81 }
82
88 function getInternalLink()
89 {
90 return $this->intlink;
91 }
92
98 function setInternalLinkText($a_value)
99 {
100 $this->intlinktext = $a_value;
101 }
102
109 {
110 return $this->intlinktext;
111 }
112
118 function setAddCommand($a_add_command)
119 {
120 $this->addCommand = $a_add_command;
121 }
122
128 function getAddCommand()
129 {
130 return ($this->addCommand) ? $this->addCommand : "addInternalLink";
131 }
132
138 function setValueByArray($a_values)
139 {
140 $this->setValue($a_values[$this->getPostVar()]);
141 }
142
148 function checkInput()
149 {
150 global $lng;
151
152 $_POST[$this->getPostVar()] =
154 if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
155 {
156 $this->setAlert($lng->txt("msg_input_is_required"));
157
158 return false;
159 }
160 return $this->checkSubItemsInput();
161 }
162
168 function insert(&$a_tpl)
169 {
170 global $lng;
171
172 $template = new ilTemplate("tpl.prop_suggestedsolutionselector.html", TRUE, TRUE, "Modules/TestQuestionPool");
173
174 foreach($this->getOptions() as $option_value => $option_text)
175 {
176 $template->setCurrentBlock("prop_intlink_select_option");
177 $template->setVariable("VAL_SELECT_OPTION", $option_value);
178 if ($option_value == $this->getValue())
179 {
180 $template->setVariable("CHK_SEL_OPTION",
181 'selected="selected"');
182 }
183 $template->setVariable("TXT_SELECT_OPTION", $option_text);
184 $template->parseCurrentBlock();
185 }
186 if ($this->getInternalLink())
187 {
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 {
201 $template->setVariable("DISABLED",
202 " disabled=\"disabled\"");
203 }
204 $template->setVariable("TEXT_ADD_INTERNALLINK", ($this->getInternalLink()) ? $lng->txt("change") : $lng->txt("add"));
205 $template->setVariable("CMD_ADD_INTERNALLINK", $this->getAddCommand());
206 $template->parseCurrentBlock();
207 $a_tpl->setCurrentBlock("prop_generic");
208 $a_tpl->setVariable("PROP_GENERIC", $template->get());
209 $a_tpl->parseCurrentBlock();
210 }
211
212}
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
$_POST['username']
Definition: cron.php:12
global $lng
Definition: privfeed.php:40