psf
psf
includes
html
textbox.php
1
<?php
2
3
// Part of php simple framework (psf)
4
5
// This program is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation, either version 3 of the License, or
8
// (at your option) any later version.
9
10
// This program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
14
15
// Copyright (c) Petr Bena <petr@bena.rocks> 2015 - 2018
16
17
if
(!defined(
"PSF_ENTRY_POINT"
))
18
die(
"Not a valid psf entry point"
);
19
20
require_once (dirname(__FILE__) .
"/element.php"
);
21
22
class
TextBox
extends
HtmlElement
23
{
24
public
$Enabled =
true
;
25
public
$Name;
26
public
$Value;
27
private
$Multiline =
false
;
28
public
$Rows = NULL;
29
public
$ReadOnly =
false
;
31
public
$Password
=
false
;
32
public
$Placeholder = NULL;
33
34
public
function
__construct($_name = NULL, $_value = NULL, $_parent = NULL)
35
{
36
$this->Name = $_name;
37
$this->Value = $_value;
38
parent::__construct($_parent);
39
}
40
41
public
function
SetMultiline()
42
{
43
$this->DisableIndenting();
44
$this->Multiline =
true
;
45
$this->Rows = 6;
46
}
47
48
public
function
ToHtml()
49
{
50
if
($this->Password)
51
$_e =
"<input type=\"password\""
;
52
else
if
(!$this->Multiline)
53
$_e =
"<input type=\"text\""
;
54
else
55
$_e =
'<textarea'
;
56
if
($this->Name !== NULL)
57
$_e .=
" name=\"$this->Name\""
;
58
if
($this->Rows !== NULL)
59
$_e .=
" rows=\"$this->Rows\""
;
60
if
(!$this->Multiline && $this->Value !== NULL)
61
$_e .=
" value=\""
. htmlspecialchars($this->Value) .
"\""
;
62
if
($this->Style !== NULL)
63
$_e .=
" style=\""
. $this->Style->ToCss() .
"\""
;
64
if
($this->ClassName !== NULL)
65
$_e .=
" class=\""
. $this->ClassName .
"\""
;
66
if
($this->ReadOnly ===
true
)
67
$_e .=
" readonly"
;
68
if
($this->Placeholder !== NULL)
69
$_e .=
" placeholder=\""
. $this->Placeholder .
"\""
;
70
$_e .=
">"
;
71
if
($this->Multiline)
72
{
73
if
($this->Value !== NULL)
74
{
75
$_e .= htmlspecialchars($this->Value);
76
}
77
$_e .=
'</textarea>'
;
78
}
79
return
$_e;
80
}
81
}
HtmlElement
Definition:
element.php:23
TextBox\$Password
$Password
If true, this text box will be acting as password input.
Definition:
textbox.php:31
TextBox
Definition:
textbox.php:22
Generated on Fri Aug 9 2019 14:18:54 for psf by
1.8.13