ILIAS  Release_4_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  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2007 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
34 {
35  protected $options = array();
36  protected $value;
37 
44  function __construct($a_title = "", $a_postvar = "")
45  {
46  parent::__construct($a_title, $a_postvar);
47  $this->setType("advselect");
48  }
49 
55  function addOption($a_value, $a_text, $a_html = "")
56  {
57  $this->options[$a_value] = array("value" => $a_value,
58  "txt" => $a_text, "html" => $a_html);
59  }
60 
66  function getOptions()
67  {
68  return $this->options;
69  }
70 
76  function setValue($a_value)
77  {
78  $this->value = $a_value;
79  }
80 
86  function getValue()
87  {
88  return $this->value;
89  }
90 
96  function setValueByArray($a_values)
97  {
98  $this->setValue($a_values[$this->getPostVar()]);
99  }
100 
106  function checkInput()
107  {
108  global $lng;
109 
110  $_POST[$this->getPostVar()] =
112  if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
113  {
114  $this->setAlert($lng->txt("msg_input_is_required"));
115 
116  return false;
117  }
118  return true;
119  }
120 
126  function insert(&$a_tpl)
127  {
128  include_once("./Services/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
129  $selection = new ilAdvancedSelectionListGUI();
130  $selection->setFormSelectMode($this->getPostVar(), "", false,
131  "", "", "",
132  "", "", "", "");
133  $selection->setId($this->getPostVar());
134  $selection->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
135  $selection->setSelectedValue($this->getValue());
136  $selection->setUseImages(false);
137  $selection->setOnClickMode(ilAdvancedSelectionListGUI::ON_ITEM_CLICK_FORM_SELECT);
138 
139  foreach($this->getOptions() as $option)
140  {
141  $selection->addItem($option["txt"], $option["value"], "",
142  "", $option["value"], "", $option["html"]);
143  if ($this->getValue() == $option["value"])
144  {
145  $selection->setListTitle($option["txt"]);
146  }
147  }
148 
149  $a_tpl->setCurrentBlock("prop_generic");
150  $a_tpl->setVariable("PROP_GENERIC", $selection->getHTML());
151  $a_tpl->parseCurrentBlock();
152  }
153 
154 }