-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInput.php
182 lines (137 loc) · 4.18 KB
/
Input.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?php
namespace Onimla\HTML;
use Onimla\HTML\Attribute;
use Onimla\HTML\Polymorphism\UserInput;
class Input extends Element implements userInput {
use Traits\Name;
public function __construct($name = FALSE, $value = FALSE, $type = 'text', $attr = FALSE) {
parent::__construct('input', $attr);
$this->type($type);
$this->name($name);
$this->value($value);
$this->selfClose(TRUE);
}
public function accept($mimeType = FALSE) {
if ($mimeType === FALSE) {
return $this->attr(__FUNCTION__);
}
return $this->attr(__FUNCTION__, $mimeType);
}
public function alt($value = FALSE) {
if ($value === FALSE) {
return $this->attr(__FUNCTION__);
}
return $this->attr(__FUNCTION__, $value);
}
public function setAutoFocus() {
$this->attr('autofocus', 'autofocus');
}
public function unsetAutoFocus() {
$this->removeAttr('autofocus');
}
public function isAutoFocus() {
return $this->attr('autofocus');
}
public function autofocus() {
return $this->isAutoFocus();
}
public function setDisabled() {
$this->attr('disabled', 'disabled');
}
public function unsetDisabled() {
$this->removeAttr('disabled');
}
public function isDisabled() {
return $this->attr('autofocus');
}
public function disabled() {
return $this->isDisabled();
}
public function disable() {
return $this->setDisabled();
}
public function enable() {
return $this->unsetDisabled();
}
public function maxlength($value = FALSE) {
if ($value === FALSE) {
return $this->attr(__FUNCTION__);
}
return $this->attr(__FUNCTION__, $value, 'int');
}
public function placeholder($value = FALSE) {
if ($value === FALSE) {
return $this->getAttributeValue(__FUNCTION__);
}
return $this->setAttributeValue(__FUNCTION__, $value, 'html');
}
public function readOnly() {
return $this->setReadOnly();
}
public function isReadOnly() {
return $this->setReadOnly();
}
public function isNotReadOnly() {
return $this->unsetReadOnly();
}
public function setReadOnly() {
return $this->attr(new Attribute('readonly'));
}
public function unsetReadOnly() {
return $this->removeAttr('readonly');
}
public function required() {
return $this->isRequired();
}
public function isRequired() {
return $this->attr(new Attribute('required'));
}
public function isNotRequired() {
return $this->removeAttr('required');
}
public function setRequired() {
return $this->isRequired();
}
public function unsetRequired() {
return $this->isNotRequired();
}
public function size($value = FALSE) {
if ($value === FALSE) {
return $this->attr(__FUNCTION__);
}
return $this->attr(__FUNCTION__, $value, 'int');
}
public function src($url = FALSE) {
if ($value === FALSE) {
return $this->attr(__FUNCTION__);
}
return $this->attr(__FUNCTION__, $value);
}
public function type($value = FALSE) {
if ($value === FALSE) {
return $this->attr(__FUNCTION__);
}
return $this->attr(__FUNCTION__, $value);
}
/**
* Specifies the value of an input element
* @see http://www.w3schools.com/tags/att_input_value.asp
* @param string $value the value of the element
* @param bool $verify if false, it will not use the http://php.net/empty
* function to check the value
* @return string the current value of the element
*/
public function value($value = FALSE) {
if ($value === FALSE) {
return $this->getAttributeValue(__FUNCTION__);
}
return $this->setAttributeValue(__FUNCTION__, $value, 'html');
}
public function isValueSet() {
$value = $this->getAttribute('value');
if ($value === FALSE) {
return FALSE;
}
return $value->isValueSet();
}
}