-
Notifications
You must be signed in to change notification settings - Fork 0
/
AutoView.php
80 lines (69 loc) · 2.27 KB
/
AutoView.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
<?php
class AutoView extends Form
{
private $viewName;
private $object;
public function __construct($object = false)
{
if ($object) {
$this->object = new $object();
}
$this->viewName = get_class($this->object);
}
public function json()
{
echo json_encode(classVars($this->viewName));
}
public function table()
{
$objectProperties = classVars($this->viewName);
echo '<table>';
echo '<tbody>';
echo '<tr>';
foreach ($objectProperties as $key => $property) {
echo '<td>'.$this->object->{'get'.ucfirst($property)}().'</td>';
}
echo '</tr>';
echo '</tbody>';
echo '</table>';
}
public function form($aFormProperties = array())
{
echo '<h1>'.ucfirst($this->viewName).'</h1>';
echo '<form action="/'.$this->viewName.'" method="POST">';
echo '<h3>Register</h3>
<table border="1" style="border-collapse: collapse;">';
/*
<tr>
<td>Name:</td>
<td><input type="text" name="name" value="" maxlength="80" autofocus="autofocus" title="Name" required="required"></td>
</tr>
<tr>
<td>Quantity:</td>
<td><input type="number" name="quantity" value="0" title="Quantity" required="required"></td>
</tr>
<tr>
<td>Release Date:</td>
<td><input type="date" name="releaseDate" value="<?php echo date("Y-m-d");?>" title="Release Date" required="required"></td>
</tr>
<tr>
<td>Active:</td>
<td>
Yes: <input type="radio" name="active" value="1" title="Active" checked="checked">
No: <input type="radio" name="active" value="0" title="Active">
</td>
</tr>
*/
echo '</table>
<p>
<input type="submit">
</p>
</form>
<hr>';
}
public function create()
{
$this->form();
$this->table();
}
}