ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilRadioMatrixInputGUI.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("radiomatrix");
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()] =
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 true;
116  }
117 
123  function insert(&$a_tpl)
124  {
125  $tpl = new ilTemplate("tpl.prop_radiomatrix.html", true, true, "Services/Form");
126 
127 
128  foreach($this->getOptions() as $option_value => $option_html)
129  {
130  $tpl->touchBlock("row_start");
131  $tpl->touchBlock("item");
132 
133  $tpl->setCurrentBlock("option_start");
134  $tpl->setVariable("VAL_RADIO_OPTION", $option_value);
135  $tpl->setVariable("POST_VAR", $this->getPostVar());
136  $tpl->setVariable("OP_ID", $this->getPostVar() . "[" . $option_value . "]");
137  if ($option_value == $this->getValue())
138  {
139  $tpl->setVariable("CHK_RADIO_OPTION",
140  'checked="checked"');
141  }
142  if ($this->getDisabled())
143  {
144  $tpl->setVariable("DISABLED",
145  " disabled=\"disabled\"");
146  }
147  $tpl->setVariable("TXT_RADIO_OPTION", $option_html);
148  $tpl->parseCurrentBlock();
149  $tpl->touchBlock("item");
150 
151  $tpl->touchBlock("row_end");
152  $tpl->touchBlock("item");
153  }
154  $a_tpl->setCurrentBlock("prop_generic");
155  $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
156  $a_tpl->parseCurrentBlock();
157  }
158 
159 }