ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilAdvSelectInputGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
15 {
19  protected $lng;
20 
21  protected $options = array();
22  protected $value;
23 
30  public function __construct($a_title = "", $a_postvar = "")
31  {
32  global $DIC;
33 
34  $this->lng = $DIC->language();
35  parent::__construct($a_title, $a_postvar);
36  $this->setType("advselect");
37  }
38 
44  public function addOption($a_value, $a_text, $a_html = "")
45  {
46  $this->options[$a_value] = array("value" => $a_value,
47  "txt" => $a_text, "html" => $a_html);
48  }
49 
55  public function getOptions()
56  {
57  return $this->options;
58  }
59 
65  public function setValue($a_value)
66  {
67  $this->value = $a_value;
68  }
69 
75  public function getValue()
76  {
77  return $this->value;
78  }
79 
85  public function setValueByArray($a_values)
86  {
87  $this->setValue($a_values[$this->getPostVar()]);
88  }
89 
95  public function checkInput()
96  {
97  $lng = $this->lng;
98 
99  $_POST[$this->getPostVar()] =
101  if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "") {
102  $this->setAlert($lng->txt("msg_input_is_required"));
103 
104  return false;
105  }
106  return true;
107  }
108 
114  public function insert($a_tpl)
115  {
116  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
117  $selection = new ilAdvancedSelectionListGUI();
118  $selection->setFormSelectMode(
119  $this->getPostVar(),
120  "",
121  false,
122  "",
123  "",
124  "",
125  "",
126  "",
127  "",
128  ""
129  );
130  $selection->setId($this->getPostVar());
131  $selection->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
132  $selection->setSelectedValue($this->getValue());
133  $selection->setUseImages(false);
134  $selection->setOnClickMode(ilAdvancedSelectionListGUI::ON_ITEM_CLICK_FORM_SELECT);
135 
136  foreach ($this->getOptions() as $option) {
137  $selection->addItem(
138  $option["txt"],
139  $option["value"],
140  "",
141  "",
142  $option["value"],
143  "",
144  $option["html"]
145  );
146  if ($this->getValue() == $option["value"]) {
147  $selection->setListTitle($option["txt"]);
148  }
149  }
150 
151  $a_tpl->setCurrentBlock("prop_generic");
152  $a_tpl->setVariable("PROP_GENERIC", $selection->getHTML());
153  $a_tpl->parseCurrentBlock();
154  }
155 }
global $DIC
Definition: saml.php:7
getPostVar()
Get Post Variable.
setValue($a_value)
Set Value.
insert($a_tpl)
Insert property html.
setValueByArray($a_values)
Set value by array.
__construct($a_title="", $a_postvar="")
Constructor.
setAlert($a_alert)
Set Alert Text.
setType($a_type)
Set Type.
checkInput()
Check input, strip slashes etc.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
User interface class for advanced drop-down selection lists.
This class represents a property in a property form.
This class represents an advanced selection list property in a property form.
$_POST["username"]
addOption($a_value, $a_text, $a_html="")
Add an Options.