ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCheckboxInputGUI.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 $value = "1";
34  protected $checked;
35  protected $optiontitle = "";
36  protected $additional_attributes = '';
37 
44  function __construct($a_title = "", $a_postvar = "")
45  {
46  parent::__construct($a_title, $a_postvar);
47  $this->setType("checkbox");
48  }
49 
55  function setValue($a_value)
56  {
57  $this->value = $a_value;
58  }
59 
65  function getValue()
66  {
67  return $this->value;
68  }
69 
75  function setChecked($a_checked)
76  {
77  $this->checked = $a_checked;
78  }
79 
85  function getChecked()
86  {
87  return $this->checked;
88  }
89 
95  function setOptionTitle($a_optiontitle)
96  {
97  $this->optiontitle = $a_optiontitle;
98  }
99 
105  function getOptionTitle()
106  {
107  return $this->optiontitle;
108  }
109 
115  function setValueByArray($a_values)
116  {
117  $this->setChecked($a_values[$this->getPostVar()]);
118  foreach($this->getSubItems() as $item)
119  {
120  $item->setValueByArray($a_values);
121  }
122  }
123 
129  function setAdditionalAttributes($a_attrs)
130  {
131  $this->additional_attributes = $a_attrs;
132  }
133 
139  {
141  }
142 
148  function checkInput()
149  {
150  global $lng;
151 
152  $_POST[$this->getPostVar()] =
153  ilUtil::stripSlashes($_POST[$this->getPostVar()]);
154 
155  $ok = $this->checkSubItemsInput();
156  return $ok;
157  }
158 
163  function insert(&$a_tpl)
164  {
165  $a_tpl->setCurrentBlock("prop_checkbox");
166  $a_tpl->setVariable("POST_VAR", $this->getPostVar());
167  $a_tpl->setVariable("ID", $this->getFieldId());
168  $a_tpl->setVariable("PROPERTY_VALUE", $this->getValue());
169  $a_tpl->setVariable("OPTION_TITLE", $this->getOptionTitle());
170  if(strlen($this->getAdditionalAttributes()))
171  {
172  $a_tpl->setVariable('PROP_CHECK_ATTRS',$this->getAdditionalAttributes());
173  }
174  if ($this->getChecked())
175  {
176  $a_tpl->setVariable("PROPERTY_CHECKED",
177  'checked="checked"');
178  }
179  if ($this->getDisabled())
180  {
181  $a_tpl->setVariable("DISABLED",
182  'disabled="disabled"');
183  }
184  $a_tpl->parseCurrentBlock();
185  }
186 
187 }