ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 include_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 $lng;
151 
152  $_POST[$this->getPostVar()] =
154  if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "") {
155  $this->setAlert($lng->txt("msg_input_is_required"));
156 
157  return false;
158  }
159  return $this->checkSubItemsInput();
160  }
161 
167  public function insert(&$a_tpl)
168  {
169  global $lng;
170 
171  $template = new ilTemplate("tpl.prop_suggestedsolutionselector.html", true, true, "Modules/TestQuestionPool");
172 
173  foreach ($this->getOptions() as $option_value => $option_text) {
174  $template->setCurrentBlock("prop_intlink_select_option");
175  $template->setVariable("VAL_SELECT_OPTION", $option_value);
176  if ($option_value == $this->getValue()) {
177  $template->setVariable(
178  "CHK_SEL_OPTION",
179  'selected="selected"'
180  );
181  }
182  $template->setVariable("TXT_SELECT_OPTION", $option_text);
183  $template->parseCurrentBlock();
184  }
185  if ($this->getInternalLink()) {
186  $template->setCurrentBlock("delete_internallink");
187  $template->setVariable("TEXT_DELETE_INTERNALLINK", $lng->txt("remove_solution"));
188  $template->setVariable("POST_VAR", $this->getPostVar());
189  $template->parseCurrentBlock();
190  $template->setCurrentBlock("internal_link");
191  $template->setVariable("HREF_INT_LINK", $this->getInternalLink());
192  $template->setVariable("TEXT_INT_LINK", $this->getInternalLinkText());
193  $template->parseCurrentBlock();
194  }
195  $template->setCurrentBlock("prop_internallink_selector");
196  $template->setVariable("POST_VAR", $this->getPostVar());
197  if ($this->getDisabled()) {
198  $template->setVariable(
199  "DISABLED",
200  " disabled=\"disabled\""
201  );
202  }
203  $template->setVariable("TEXT_ADD_INTERNALLINK", ($this->getInternalLink()) ? $lng->txt("change") : $lng->txt("add"));
204  $template->setVariable("CMD_ADD_INTERNALLINK", $this->getAddCommand());
205  $template->parseCurrentBlock();
206  $a_tpl->setCurrentBlock("prop_generic");
207  $a_tpl->setVariable("PROP_GENERIC", $template->get());
208  $a_tpl->parseCurrentBlock();
209  }
210 }
$template
getPostVar()
Get Post Variable.
This class represents a selection list property in a property form.
setAlert($a_alert)
Set Alert Text.
setType($a_type)
Set Type.
special template class to simplify handling of ITX/PEAR
__construct($a_title="", $a_postvar="")
Constructor.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
setInternalLinkText($a_value)
Set internal link.text.
This class represents a property that may include a sub form.
$_POST["username"]