1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Manage Form |
5
|
|
|
* |
6
|
|
|
* @category lib |
7
|
|
|
* @package lib\Form |
8
|
|
|
* @author Judicaël Paquet <[email protected]> |
9
|
|
|
* @copyright Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93) |
10
|
|
|
* @license https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël |
11
|
|
|
* @version Release: 1.0.0 |
12
|
|
|
* @filesource https://github.com/las93/venus2 |
13
|
|
|
* @link https://github.com/las93 |
14
|
|
|
* @since 1.0 |
15
|
|
|
*/ |
16
|
|
|
namespace Venus\lib\Form; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* This class manage the Form |
20
|
|
|
* |
21
|
|
|
* @category lib |
22
|
|
|
* @package lib\Form |
23
|
|
|
* @author Judicaël Paquet <[email protected]> |
24
|
|
|
* @copyright Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93) |
25
|
|
|
* @license https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël |
26
|
|
|
* @version Release: 1.0.0 |
27
|
|
|
* @filesource https://github.com/las93/venus2 |
28
|
|
|
* @link https://github.com/las93 |
29
|
|
|
* @since 1.0 |
30
|
|
|
*/ |
31
|
|
|
class Textarea extends Common |
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* the label of element |
35
|
|
|
* |
36
|
|
|
* @access private |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
private $_sLabel = null; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* the value of element |
43
|
|
|
* |
44
|
|
|
* @access private |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
private $_sValue = null; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* constructor that it increment (static) for all use |
51
|
|
|
* |
52
|
|
|
* @access public |
53
|
|
|
* @param string $sName name |
54
|
|
|
* @param string $sLabel label of textarea |
55
|
|
|
* @param string $sValue value of textarea |
56
|
|
|
* @return \Venus\lib\Form\Textarea |
|
|
|
|
57
|
|
|
*/ |
58
|
|
View Code Duplication |
public function __construct(string $sName, string $sLabel = null, string $sValue = null) |
|
|
|
|
59
|
|
|
{ |
60
|
|
|
$this->setName($sName); |
61
|
|
|
$this->setValue($sValue); |
62
|
|
|
|
63
|
|
|
if ($sLabel !== null) { $this->setLabel($sLabel); } |
64
|
|
|
else { $this->setLabel($sName); } |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* get the Value |
69
|
|
|
* |
70
|
|
|
* @access public |
71
|
|
|
* @return string |
72
|
|
|
*/ |
73
|
|
|
public function getValue() : string |
74
|
|
|
{ |
75
|
|
|
return $this->_sValue; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* set the Value |
80
|
|
|
* |
81
|
|
|
* @access public |
82
|
|
|
* @param string $sValue Value of input; |
83
|
|
|
* @return \Venus\lib\Form\Textarea |
84
|
|
|
*/ |
85
|
|
|
public function setValue(string $sValue) : Textarea |
86
|
|
|
{ |
87
|
|
|
$this->_sValue = $sValue; |
88
|
|
|
return $this; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* get the Label |
93
|
|
|
* |
94
|
|
|
* @access public |
95
|
|
|
* @return string |
96
|
|
|
*/ |
97
|
|
|
public function getLabel() : string |
98
|
|
|
{ |
99
|
|
|
return $this->_sLabel; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* set the Label |
104
|
|
|
* |
105
|
|
|
* @access public |
106
|
|
|
* @param string $sLabel Label of input; |
107
|
|
|
* @return \Venus\lib\Form\Textarea |
108
|
|
|
*/ |
109
|
|
|
public function setLabel(string $sLabel) : Textarea |
110
|
|
|
{ |
111
|
|
|
$this->_sLabel = $sLabel; |
112
|
|
|
return $this; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* if the button is clicked |
117
|
|
|
* |
118
|
|
|
* @access public |
119
|
|
|
* @param string $sType type of input; |
120
|
|
|
* @return bool |
121
|
|
|
*/ |
122
|
|
|
public function isClicked(string $sType) : bool |
|
|
|
|
123
|
|
|
{ |
124
|
|
|
if ($this->getType() === 'submit' || $this->getType() === 'button') { |
|
|
|
|
125
|
|
|
|
126
|
|
|
if (isset($_POST[$this->getName()])) { return true; } |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
return false; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* get the <html> |
134
|
|
|
* |
135
|
|
|
* @access public |
136
|
|
|
* @return string |
137
|
|
|
*/ |
138
|
|
|
public function fetch() : string |
139
|
|
|
{ |
140
|
|
|
$sContent = ''; |
141
|
|
|
|
142
|
|
|
if ($this->getLabel()) { |
143
|
|
|
|
144
|
|
|
$sContent .= '<label>'.$this->getLabel().'</label> '; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
$sContent .= '<textarea name="'.$this->getName().'">'; |
148
|
|
|
|
149
|
|
|
if ($this->getValue() !== null) { $sContent .= $this->getValue(); } |
150
|
|
|
|
151
|
|
|
$sContent .= '</textarea>'; |
152
|
|
|
|
153
|
|
|
return $sContent; |
154
|
|
|
} |
155
|
|
|
} |
156
|
|
|
|
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.