XOOPS RMCommon Utilities  2.1.8.91RC
 All Classes Namespaces Files Functions Variables
text.class.php
Go to the documentation of this file.
1 <?php
2 // $Id: text.class.php 1016 2012-08-26 23:28:48Z i.bitcero $
3 // --------------------------------------------------------------
4 // Red México Common Utilities
5 // A framework for Red México Modules
6 // Author: Eduardo Cortés <i.bitcero@gmail.com>
7 // Email: i.bitcero@gmail.com
8 // License: GPL 2.0
9 // --------------------------------------------------------------
10 
15 {
16  var $_size = 30;
17  var $_max;
18  var $_value = '';
19  var $_password = false;
20  var $_enabled = true;
21 
31  function __construct($caption, $name, $size=50, $max=255, $value='',$password=false, $enabled=true){
32  $this->setName($name);
33  $this->setCaption($caption);
34  $this->_size = $size;
35  $this->_max = $max;
36  $this->_value = $value;
37  $this->_password = $password;
38  $this->_enabled = $enabled;
39  }
44  public function setSize($size){
45  $this->_size = $size;
46  }
51  public function getSize(){
52  return $this->_size;
53  }
58  public function setMax($max){
59  $this->_max = $max;
60  }
65  public function getMax(){
66  return $this->_max;
67  }
72  public function setValue($value){
73  $this->_value = $value;
74  }
79  public function getValue(){
80  return $this->_value;
81  }
86  public function setPassword($value=false){
87  $this->_password = $value;
88  }
93  public function getPassword(){
94  return $this->_password;
95  }
100  public function render(){
101  if(!is_numeric($this->_size))
102  $this->_size = 50;
103 
104  $ret = '<input type="'.($this->_password ? 'password' :'text').'" size="'.$this->_size.'" name="'.$this->getName().'" id="'.$this->id().'"'.($this->getMax()>0 ? ' maxlength="'.$this->getMax().'"' : '').' value="'.(isset($_REQUEST[$this->getName()]) ? $_REQUEST[$this->getName()] : $this->getValue()).'" ';
105  if ($this->getClass() != ''){
106  $ret .= 'class="'.$this->getClass().'" '.$this->getExtra();
107  } else {
108  $ret .= $this->getExtra();
109  }
110 
111  $ret .= ($this->_enabled ? '' : ' disabled="disabled"').' />';
112  return $ret;
113  }
114 }
115 
121 {
122  var $_type;
128  public function __construct($caption, $type=0, $class='', $desc=''){
129  $this->setName('');
130  $this->setDescription($desc);
131  $this->setCaption($caption);
132  $this->_type = $type;
133  $this->setClass($class);
134  }
140  public function setType($type){
141  $this->_type = $type;
142  }
147  public function getType($type){
148  return $this->_type;
149  }
154  function render(){
155  if($this->_type>0){
156  $rtn = "<h4 class='form_subtitle ".$this->getClass()."'>".$this->getCaption()."</h4>";
157  } else {
158  $rtn = "<span class='".$this->getClass()."'>".$this->getCaption()."</span>";
159  }
160  return $rtn;
161  }
162 }
163 
168 {
169  private $_rows = 4;
170  private $_cols = 45;
171  private $_value = '';
172  private $width = '';
173  private $height = '';
174 
184  public function __construct($caption, $name, $rows=4, $cols=45, $value='', $width='', $height=''){
185  $this->_rows = $rows;
186  $this->_cols = $cols;
187  $this->_value = $value;
188  $this->setCaption($caption);
189  $this->setName($name);
190  $this->width = $width;
191  $this->height = $height;
192  }
197  public function setRows($rows){
198  $this->_rows = $rows;
199  }
204  public function getRows(){
205  return $this->_rows;
206  }
211  public function setCols($cols){
212  $this->_cols = $cols;
213  }
218  public function getCols(){
219  return $this->_cols;
220  }
225  function setValue($value){
226  $this->_value = $value;
227  }
232  function getValue(){
233  return $this->_value;
234  }
239  function render(){
240  $ret = "<textarea name='".$this->getName()."' id='".$this->id()."' cols='".$this->_cols."' rows='".$this->_rows."' ";
241  if ($this->getClass()!=''){
242  $ret .= "class='".$this->getClass()."' ";
243  }
244  if ($this->width!='' || $this->height!=''){
245  $ret .= "style='".($this->width!='' ? "width: $this->width; " : '').($this->height!='' ? "height: $this->height; " : '')."'";
246  }
247  $ret .= $this->getExtra().">".(isset($_REQUEST[$this->getName()]) ? $_REQUEST[$this->getName()] : $this->_value)."</textarea>";
248  return $ret;
249  }
250 }
251 
256 {
261  public function __construct($caption, $cell, $id=''){
262  $this->setCaption($caption);
263  $this->setExtra($cell);
264  $this->setName($id);
265  }
270  function render(){
271  return $this->getExtra();
272  }
273 }