XOOPS  2.6.0
Password.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
12 namespace Xoops\Form;
13 
26 class Password extends Element
27 {
33  //private $size;
34 
40  //private $maxlength;
41 
48  //public $autoComplete = false;
49 
56  //private $placeholder;
57 
69  public function __construct(
70  $caption,
71  $name,
72  $size,
73  $maxlength,
74  $value = '',
75  $autoComplete = false,
76  $placeholder = ''
77  ) {
78  $this->setCaption($caption);
79  $this->setAttribute('type', 'password');
80  $this->setAttribute('name', $name);
81  $this->setAttribute('size', intval($size));
82  $this->setAttribute('maxlength', intval($maxlength));
83  $this->setValue($value);
84  $this->setAttribute('autocomplete', $autoComplete ? 'yes' : 'no');
85  if (!empty($placeholder)) {
86  $this->setAttribute('placeholder', $placeholder);
87  }
88  }
89 
95  public function getSize()
96  {
97  return (int) $this->getAttribute('size');
98  }
99 
105  public function getMaxlength()
106  {
107  return (int) $this->getAttribute('maxlength');
108  }
109 
115  public function getPlaceholder()
116  {
117  return (string) $this->setAttribute('placeholder');
118  }
119 
125  public function render()
126  {
127  if ($this->getSize() > $this->getMaxcols()) {
128  $maxcols = $this->getMaxcols();
129  } else {
130  $maxcols = $this->getSize();
131  }
132  $this->addAttribute('class', 'span' . $maxcols);
133 
135  return '<input ' . $attributes . 'value="'
136  . $this->getValue() . '" ' . $this->getExtra() .' >';
137  }
138 }
setValue($value)
Definition: Element.php:199
getValue($encode=false)
Definition: Element.php:180
setCaption($caption)
Definition: Element.php:396
setAttribute($name, $value=null)
Definition: Attributes.php:42
getExtra($encode=false)
Definition: Element.php:539
addAttribute($name, $value)
Definition: Attributes.php:117
__construct($caption, $name, $size, $maxlength, $value= '', $autoComplete=false, $placeholder= '')
Definition: Password.php:69