ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 {
16  protected $options = array();
17  protected $value;
18 
25  function __construct($a_title = "", $a_postvar = "")
26  {
27  parent::__construct($a_title, $a_postvar);
28  $this->setType("advselect");
29  }
30 
36  function addOption($a_value, $a_text, $a_html = "")
37  {
38  $this->options[$a_value] = array("value" => $a_value,
39  "txt" => $a_text, "html" => $a_html);
40  }
41 
47  function getOptions()
48  {
49  return $this->options;
50  }
51 
57  function setValue($a_value)
58  {
59  $this->value = $a_value;
60  }
61 
67  function getValue()
68  {
69  return $this->value;
70  }
71 
77  function setValueByArray($a_values)
78  {
79  $this->setValue($a_values[$this->getPostVar()]);
80  }
81 
87  function checkInput()
88  {
89  global $lng;
90 
91  $_POST[$this->getPostVar()] =
93  if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
94  {
95  $this->setAlert($lng->txt("msg_input_is_required"));
96 
97  return false;
98  }
99  return true;
100  }
101 
107  function insert(&$a_tpl)
108  {
109  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
110  $selection = new ilAdvancedSelectionListGUI();
111  $selection->setFormSelectMode($this->getPostVar(), "", false,
112  "", "", "",
113  "", "", "", "");
114  $selection->setId($this->getPostVar());
115  $selection->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
116  $selection->setSelectedValue($this->getValue());
117  $selection->setUseImages(false);
118  $selection->setOnClickMode(ilAdvancedSelectionListGUI::ON_ITEM_CLICK_FORM_SELECT);
119 
120  foreach($this->getOptions() as $option)
121  {
122  $selection->addItem($option["txt"], $option["value"], "",
123  "", $option["value"], "", $option["html"]);
124  if ($this->getValue() == $option["value"])
125  {
126  $selection->setListTitle($option["txt"]);
127  }
128  }
129 
130  $a_tpl->setCurrentBlock("prop_generic");
131  $a_tpl->setVariable("PROP_GENERIC", $selection->getHTML());
132  $a_tpl->parseCurrentBlock();
133  }
134 
135 }