-
Notifications
You must be signed in to change notification settings - Fork 0
/
AccountForm.php
executable file
·124 lines (120 loc) · 4.22 KB
/
AccountForm.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
<?php
require_once 'Component.php';
class AccountForm extends Component {
function __construct($children = [], $attribs = []) {
parent::__construct($children, $attribs);
foreach (
['action', 'inline', 'email', 'pw', 'fname', 'scr', 'dob',
'gender', 'vis', 'loc', 'stat'] as $attr)
{
if (!isset($attribs[$attr])) {
$this->attr[$attr] = "";
}
}
if (!isset($attribs['omit'])) {
$this->attr['omit'] = [];
}
}
function renderHTML() {
$formClass = $this->attr['inline'] ? "" : "form-box";
$cm = $this->attr['gender'] == "Male" ? "checked" : "";
$cf = $this->attr['gender'] == "Female" ? "checked" : "";
$c0 = $this->attr['vis'] == 0 ? "checked" : "";
$c1 = $this->attr['vis'] == 1 ? "checked" : "";
$c2 = $this->attr['vis'] == 2 ? "checked" : "";
echo <<<EOT
<form class="{$formClass}" method="post" action="{$this->attr['action']}">
EOT;
if (!isset($this->attr['omit']['email'])) {
echo <<<EOT
<div>
<label class="formLabel" for="email">Email Address</label>
<input type="email" name="email" value="{$this->attr['email']}"
required="required"/>
</div>
EOT;
}
if (!isset($this->attr['omit']['pw'])) {
echo <<<EOT
<div>
<label class="formLabel" for="pw">Password</label>
<input type="password" name="pw" value="{$this->attr['pw']}"
required="required"/>
</div>
EOT;
}
if (!isset($this->attr['omit']['fname'])) {
echo <<<EOT
<div>
<label class="formLabel" for="fname">Full name</label>
<input type="text" name="fname" value="{$this->attr['fname']}"
required="required"/>
</div>
EOT;
}
if (!isset($this->attr['omit']['scr'])) {
echo <<<EOT
<div>
<label class="formLabel" for="scr">Screen name</label>
<input type="text" name="scr" value="{$this->attr['scr']}"
required="required"/>
</div>
EOT;
}
if (!isset($this->attr['omit']['dob'])) {
echo <<<EOT
<div>
<label class="formLabel" for="dob">Date of Birth</label>
<input type="date" name="dob" value="{$this->attr['dob']}"
required="required"/>
</div>
EOT;
}
if (!isset($this->attr['omit']['gender'])) {
echo <<<EOT
<div>
<label class="formLabel" for="gender">Gender</label>
<label class="formLabel" for="gender">Male</label>
<input type="radio" name="gender" value="Male"/ {$cm}>
<label class="formLabel" for="gender">Female</label>
<input type="radio" name="gender" value="Female" {$cf}/>
</div>
EOT;
}
if (!isset($this->attr['omit']['vis'])) {
echo <<<EOT
<div>
<label class="formlabel" for="vis">Visibility</label>
<label class="formlabel" for="vis">Everyone</label>
<input type="radio" name="vis" value="0" {$c0}/>
<label class="formlabel" for="vis">Friends-only</label>
<input type="radio" name="vis" value="1" {$c1}/>
<label class="formlabel" for="vis">Private</label>
<input type="radio" name="vis" value="2" {$c2}/>
</div>
EOT;
}
if (!isset($this->attr['omit']['loc'])) {
echo <<<EOT
<div>
<label class="formlabel" for="loc">Your current location</label>
<input type="text" name="loc" value="{$this->attr['loc']}"/>
</div>
EOT;
}
if (!isset($this->attr['omit']['stat'])) {
echo <<<EOT
<div>
<label class="formlabel" for="stat">Your current status</label>
<textarea class="status" name="stat">{$this->attr['stat']}</textarea>
</div>
EOT;
}
if (!isset($this->attr['nosubmit'])) {
echo <<<EOT
<input value="{$this->attr['verb']}" type="submit"/>
EOT;
}
echo '</form>';
}
}