ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSelectInputGUI.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 
32 {
33  protected $options;
34  protected $value;
35 
42  function __construct($a_title = "", $a_postvar = "")
43  {
44  parent::__construct($a_title, $a_postvar);
45  $this->setType("select");
46  }
47 
53  function setOptions($a_options)
54  {
55  $this->options = $a_options;
56  }
57 
63  function getOptions()
64  {
65  return $this->options;
66  }
67 
73  function setValue($a_value)
74  {
75  $this->value = $a_value;
76  }
77 
83  function getValue()
84  {
85  return $this->value;
86  }
87 
93  function setValueByArray($a_values)
94  {
95  $this->setValue($a_values[$this->getPostVar()]);
96  }
97 
103  function checkInput()
104  {
105  global $lng;
106 
107  $_POST[$this->getPostVar()] =
108  ilUtil::stripSlashes($_POST[$this->getPostVar()]);
109  if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
110  {
111  $this->setAlert($lng->txt("msg_input_is_required"));
112 
113  return false;
114  }
115  return $this->checkSubItemsInput();
116  }
117 
123  function insert(&$a_tpl)
124  {
125  foreach($this->getOptions() as $option_value => $option_text)
126  {
127  $a_tpl->setCurrentBlock("prop_select_option");
128  $a_tpl->setVariable("VAL_SELECT_OPTION", $option_value);
129  if ($option_value == $this->getValue())
130  {
131  $a_tpl->setVariable("CHK_SEL_OPTION",
132  'selected="selected"');
133  }
134  $a_tpl->setVariable("TXT_SELECT_OPTION", $option_text);
135  $a_tpl->parseCurrentBlock();
136  }
137  $a_tpl->setCurrentBlock("prop_select");
138  $a_tpl->setVariable("POST_VAR", $this->getPostVar());
139  if ($this->getDisabled())
140  {
141  $a_tpl->setVariable("DISABLED",
142  " disabled=\"disabled\"");
143  }
144  $a_tpl->parseCurrentBlock();
145  }
146 
147 }