-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmmobjedit.php
129 lines (110 loc) · 3.19 KB
/
mmobjedit.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
<?php // mmobjedit.php
use mondrakeNG\mm\classes\MMClass;
require_once 'mmheader.php';
if (!isset($_GET['obj']))
die("<br /><br />Missing parameter.");
$objName = $_GET['obj'];
$cls = new MMClass;
$cls->read($objName);
$obj = new $objName;
$colDets = $obj->getColumnProperties();
if (isset($_GET['view'])) {
$primaryKey = $_GET['view'];
$obj->read(base64_decode($primaryKey));
}
$retTo = $_SERVER['HTTP_REFERER'];
echo <<<_END
<!-- The HTML section -->
<style>.signup { border: 1px solid #999999;
font: normal 12px verdana; color:#444444; }</style>
</head><body>
<form method='post' action='mmobjdbop.php'>
<table>
<td>$cls->mm_class_desc</td>
<td>
<input type='submit' value='Delete' />
<input type='hidden' name='obj' value='$objName'/>
<input type='hidden' name='mmaction' value='Del'/>
<input type='hidden' name='primaryKey' value='$primaryKey'/>
<input type='hidden' name='referer' value='$retTo'/>
</td>
</table>
</form>
<table class="signup" border="0" cellpadding="2" cellspacing="2" bgcolor="#eeeeee">
<form method='post' action='mmobjdbop.php'>
<input type='hidden' name='obj' value='$objName'/>
<input type='hidden' name='primaryKey' value='$primaryKey'/>
<input type='hidden' name='referer' value='$retTo'/>
_END;
if ($_GET['mmaction'] == 'Update')
echo"<input type='hidden' name='mmaction' value='Upd'/>";
else
echo"<input type='hidden' name='mmaction' value='Add'/>";
foreach ($colDets as $a => $b) {
$tmp = $obj->$a;
echo "<tr><td>$a</td>";
switch ($b['type']) {
case 'boolean':
echo "<td>{$b['type']}</td>";
if ($b['editable']) {
if ($obj->$a) $isChecked = 'checked'; else $isChecked = '';
echo "<td><input type='checkbox' name='$a' value='1' $isChecked/></td>";
}
else {
echo "<td>$tmp</td>";
}
break;
case 'integer':
case 'time':
case 'date':
echo "<td>{$b['type']}</td>";
if ($b['editable']) {
echo "<td><input class='signup' type='text' size='12' name='$a' value='$tmp' /></td>";
}
else {
echo "<td>$tmp</td>";
}
break;
case 'timestamp':
echo "<td>{$b['type']}</td>";
if ($b['editable']) {
echo "<td><input class='signup' type='text' size='22' name='$a' value='$tmp' /></td>";
}
else {
echo "<td>$tmp</td>";
}
break;
case 'text':
if ($b['editable']) {
if($b['length']) {
$size = ($b['length'] > 60) ? 60 : $b['length'];
echo "<td>{$b['type']}/{$b['length']}</td>";
echo "<td><input class='signup' type='text' size='$size' maxlength='{$b['length']}' name='$a' value='$tmp' /></td>";
}
else {
echo "<td>{$b['type']}</td>";
echo "<td><textarea class='signup' name='$a' cols='100' rows='15'>$tmp</textarea></td>";
}
}
else {
echo "<td>{$b['type']}</td><td>$tmp</td>";
}
break;
default:
echo "<td>{$b['type']}/{$b['length']}</td>";
if ($b['editable']) {
$size = ($b['length'] > 60) ? 60 : $b['length'];
echo "<td><input class='signup' type='text' size='$size' maxlength='{$b['length']}' name='$a' value='$tmp' /></td>";
}
else {
echo "<td>$tmp</td>";
}
}
echo"</tr>";
}
echo <<<_END
</tr><tr><td colspan="3" align="center">
<input type="submit" value='{$_GET['mmaction']}' />
</tr></form></table>
_END;
?>