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

Services/Form/classes/class.ilTextInputGUI.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 ilTextInputGUI extends ilSubEnabledFormPropertyGUI
00032 {
00033         protected $value;
00034         protected $maxlength = 200;
00035         protected $size = 40;
00036         
00043         function __construct($a_title = "", $a_postvar = "")
00044         {
00045                 parent::__construct($a_title, $a_postvar);
00046                 $this->setInputType("text");
00047         }
00048 
00054         function setValue($a_value)
00055         {
00056                 $this->value = $a_value;
00057         }
00058 
00064         function getValue()
00065         {
00066                 return $this->value;
00067         }
00068 
00074         function setMaxLength($a_maxlength)
00075         {
00076                 $this->maxlength = $a_maxlength;
00077         }
00078 
00084         function getMaxLength()
00085         {
00086                 return $this->maxlength;
00087         }
00088 
00094         function setSize($a_size)
00095         {
00096                 $this->size = $a_size;
00097         }
00098 
00104         function setValueByArray($a_values)
00105         {
00106                 $this->setValue($a_values[$this->getPostVar()]);
00107         }
00108 
00114         function getSize()
00115         {
00116                 return $this->size;
00117         }
00118         
00126         public function setInputType($a_type)
00127         {
00128                 $this->input_type = $a_type;
00129         }
00130         
00136         public function getInputType()
00137         {
00138                 return $this->input_type;
00139         }
00140         
00141 
00147         function checkInput()
00148         {
00149                 global $lng;
00150                 
00151                 $_POST[$this->getPostVar()] = 
00152                         ilUtil::stripSlashes($_POST[$this->getPostVar()]);
00153                 if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
00154                 {
00155                         $this->setAlert($lng->txt("msg_input_is_required"));
00156 
00157                         return false;
00158                 }
00159                 
00160                 return $this->checkSubItemsInput();
00161         }
00162 
00168         function insert(&$a_tpl)
00169         {
00170                 $a_tpl->setCurrentBlock("prop_text");
00171                 
00172                 switch($this->getInputType())
00173                 {
00174                         case 'password':
00175                                 $a_tpl->setVariable('PROP_INPUT_TYPE','password');
00176                                 break;                  
00177                         case 'text':
00178                         default:
00179                                 $a_tpl->setVariable('PROP_INPUT_TYPE','text');
00180                 }
00181                 $a_tpl->setVariable("POST_VAR", $this->getPostVar());
00182                 $a_tpl->setVariable("ID", $this->getFieldId());
00183                 $a_tpl->setVariable("PROPERTY_VALUE",
00184                         ilUtil::prepareFormOutput($this->getValue()));
00185                 $a_tpl->setVariable("SIZE", $this->getSize());
00186                 $a_tpl->setVariable("MAXLENGTH", $this->getMaxLength());
00187                 if ($this->getDisabled())
00188                 {
00189                         $a_tpl->setVariable("DISABLED",
00190                                 " disabled=\"disabled\"");
00191                 }
00192                 $a_tpl->parseCurrentBlock();
00193         }
00194 }

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