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

Services/Form/classes/class.ilSelectInputGUI.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 
00031 class ilSelectInputGUI extends ilSubEnabledFormPropertyGUI
00032 {
00033         protected $options;
00034         protected $value;
00035         
00042         function __construct($a_title = "", $a_postvar = "")
00043         {
00044                 parent::__construct($a_title, $a_postvar);
00045                 $this->setType("select");
00046         }
00047 
00053         function setOptions($a_options)
00054         {
00055                 $this->options = $a_options;
00056         }
00057 
00063         function getOptions()
00064         {
00065                 return $this->options;
00066         }
00067 
00073         function setValue($a_value)
00074         {
00075                 $this->value = $a_value;
00076         }
00077 
00083         function getValue()
00084         {
00085                 return $this->value;
00086         }
00087         
00093         function setValueByArray($a_values)
00094         {
00095                 $this->setValue($a_values[$this->getPostVar()]);
00096         }
00097 
00103         function checkInput()
00104         {
00105                 global $lng;
00106                 
00107                 $_POST[$this->getPostVar()] = 
00108                         ilUtil::stripSlashes($_POST[$this->getPostVar()]);
00109                 if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
00110                 {
00111                         $this->setAlert($lng->txt("msg_input_is_required"));
00112 
00113                         return false;
00114                 }
00115                 return $this->checkSubItemsInput();
00116         }
00117 
00123         function insert(&$a_tpl)
00124         {
00125                 foreach($this->getOptions() as $option_value => $option_text)
00126                 {
00127                         $a_tpl->setCurrentBlock("prop_select_option");
00128                         $a_tpl->setVariable("VAL_SELECT_OPTION", $option_value);
00129                         if ($option_value == $this->getValue())
00130                         {
00131                                 $a_tpl->setVariable("CHK_SEL_OPTION",
00132                                         'selected="selected"');
00133                         }
00134                         $a_tpl->setVariable("TXT_SELECT_OPTION", $option_text);
00135                         $a_tpl->parseCurrentBlock();
00136                 }
00137                 $a_tpl->setCurrentBlock("prop_select");
00138                 $a_tpl->setVariable("POST_VAR", $this->getPostVar());
00139                 if ($this->getDisabled())
00140                 {
00141                         $a_tpl->setVariable("DISABLED",
00142                                 " disabled=\"disabled\"");
00143                 }
00144                 $a_tpl->parseCurrentBlock();
00145         }
00146 
00147 }

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