• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/Form/classes/class.ilRadioGroupInputGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2007 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 include_once("./Services/Form/classes/class.ilRadioOption.php");
00025 
00033 class ilRadioGroupInputGUI extends ilFormPropertyGUI
00034 {
00035         protected $options = array();
00036         protected $value;
00037         
00044         function __construct($a_title = "", $a_postvar = "")
00045         {
00046                 parent::__construct($a_title, $a_postvar);
00047                 $this->setType("radio");
00048         }
00049 
00055         function addOption($a_option)
00056         {
00057                 $this->options[] = $a_option;
00058         }
00059 
00065         function getOptions()
00066         {
00067                 return $this->options;
00068         }
00069 
00075         function setValue($a_value)
00076         {
00077                 $this->value = $a_value;
00078         }
00079 
00085         function getValue()
00086         {
00087                 return $this->value;
00088         }
00089         
00095         function setValueByArray($a_values)
00096         {
00097                 $this->setValue($a_values[$this->getPostVar()]);
00098         }
00099 
00105         function checkInput()
00106         {
00107                 global $lng;
00108                 
00109                 $_POST[$this->getPostVar()] = 
00110                         ilUtil::stripSlashes($_POST[$this->getPostVar()]);
00111                 if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
00112                 {
00113                         $this->setAlert($lng->txt("msg_input_is_required"));
00114 
00115                         return false;
00116                 }
00117                 
00118                 $ok = true;
00119                 foreach($this->getOptions() as $option)
00120                 {
00121                         foreach($option->getSubItems() as $item)
00122                         {
00123                                 $item_ok = $item->checkInput();
00124                                 if (!$item_ok && ($_POST[$this->getPostVar()] == $option->getValue()))
00125                                 {
00126                                         $ok = false;
00127                                 }
00128                         }
00129                 }
00130                 return $ok;
00131 
00132         }
00133 
00139         function insert(&$a_tpl)
00140         {
00141                 foreach($this->getOptions() as $option)
00142                 {
00143                         // information text for option
00144                         if ($option->getInfo() != "")
00145                         {
00146                                 $a_tpl->setCurrentBlock("radio_option_desc");
00147                                 $a_tpl->setVariable("RADIO_OPTION_DESC", $option->getInfo());
00148                                 $a_tpl->parseCurrentBlock();
00149                         }
00150                         
00151                         $a_tpl->setCurrentBlock("prop_radio_option");
00152                         $a_tpl->setVariable("POST_VAR", $this->getPostVar());
00153                         $a_tpl->setVariable("VAL_RADIO_OPTION", $option->getValue());
00154                         $a_tpl->setVariable("OP_ID", $this->getFieldId()."_".$option->getValue());
00155                         if($this->getDisabled())
00156                         {
00157                                 $a_tpl->setVariable('DISABLED','disabled="disabled" ');
00158                         }
00159                         if ($option->getValue() == $this->getValue())
00160                         {
00161                                 $a_tpl->setVariable("CHK_RADIO_OPTION",
00162                                         'checked="checked"');
00163                         }
00164                         $a_tpl->setVariable("TXT_RADIO_OPTION", $option->getTitle());
00165                         
00166                         if (count($option->getSubItems()) > 0)
00167                         {
00168                                 $pf = new ilPropertyFormGUI();
00169                                 $pf->setMode("subform");
00170                                 $pf->setItems($option->getSubItems());
00171                                 $a_tpl->setVariable("SUB_FORM", $pf->getContent());
00172                         }
00173                         
00174                         $a_tpl->parseCurrentBlock();
00175                 }
00176                 $a_tpl->setCurrentBlock("prop_radio");
00177                 $a_tpl->parseCurrentBlock();
00178 
00179         }
00180 
00181 }

Generated on Fri Dec 13 2013 17:56:57 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1