Source of the test_input_builder.php sample.
001 <?php
002
003 /**
004 * Test Input Builder class
005 * 14.02.2004 Thomas Wiedmann https://twiedmann.de
006 * License GPL
007 */
008
009 /**
010 * Create a new InputBuilder Object
011 */
012 include("InputBuilder.class.php");
013 $ib = new InputBuilder();
014
015 /**
016 * Build code for every <INPUT
017 *
018 * @param $p_nInput number Fieldnumber
019 * @param $p_sValue string Value for Input
020 */
021
022 function build ($p_nInput,$p_sValue="") {
023 global $ib, $sMode;
024 $ib->init();
025 $nInput = (INT) $p_nInput;
026 $sValue = $p_sValue;
027 switch($nInput) {
028 case 1:
029 /**
030 * Standard Input
031 */
032 $ib->Init();
033 $ib->Set_sType('TEXT');
034 $ib->Set_sClass('Edit');
035 $ib->Set_sName('Firstname');
036 $ib->Set_sID('Firstname');
037 $ib->Set_sValue($sValue);
038 $ib->Set_nSize(20);
039 $ib->Set_nMaxLength(30);
040 $ib->Set_nTabIndex($nInput);
041 break;
042 case 2:
043 /**
044 * Standard Input
045 */
046 $ib->Init();
047 $ib->Set_sType('TEXT');
048 $ib->Set_sClass('Edit');
049 $ib->Set_sName('Lastname');
050 $ib->Set_sID('Lastname');
051 $ib->Set_sValue($sValue);
052 $ib->Set_nSize(20);
053 $ib->Set_nMaxLength(30);
054 $ib->Set_nTabIndex($nInput);
055 break;
056 case 3:
057 /**
058 * Standard Input - READONLY
059 */
060 $ib->Init();
061 $ib->Set_sType('TEXT');
062 $ib->Set_sClass('NoEdit');
063 $ib->Set_sProperties('READONLY="READONLY"');
064 $ib->Set_sName('SecNo');
065 $ib->Set_sID('SecNo');
066 $ib->Set_sValue($sValue);
067 $ib->Set_nSize(35);
068 $ib->Set_nTabIndex($nInput);
069 break;
070 case 4:
071 /**
072 * SELECT Input
073 */
074 $ib->Init();
075 $ib->Set_sType('SELECT');
076 $ib->Set_sClass('Edit');
077 $ib->Set_sName('Country');
078 $ib->Set_sID('Country');
079 $ib->Set_sValue($sValue);
080 $ib->Set_AddsOption('Germany');
081 $ib->Set_AddsOption('Old Europe');
082 $ib->Set_AddsOption('World');
083 $ib->Set_AddsOption('Universe');
084 $ib->Set_AddsOption('don\'t know');
085 $ib->Set_nSize(1);
086 $ib->Set_nTabIndex($nInput);
087 break;
088 case 5:
089 /**
090 * Standard Input with LABLE
091 */
092 $ib->Init();
093 $ib->Set_sType('TEXT');
094 $ib->Set_sClass('Edit');
095 $ib->Set_sName('Phonenumber');
096 $ib->Set_sID('Phonenumber');
097 $ib->Set_sValue($sValue);
098 $ib->Set_nSize(20);
099 $ib->Set_nMaxLength(20);
100 $ib->Set_nTabIndex($nInput);
101 $ib->Set_nLableType(2);
102 $ib->Set_sFieldname('Phone number');
103 break;
104 case 6:
105 /**
106 * Standard Input with LABLE
107 */
108 $ib->Init();
109 $ib->Set_sType('TEXT');
110 $ib->Set_sClass('Edit');
111 $ib->Set_sName('Email');
112 $ib->Set_sID('Email');
113 $ib->Set_sValue($sValue);
114 $ib->Set_nSize(30);
115 $ib->Set_nMaxLength(30);
116 $ib->Set_nTabIndex($nInput);
117 $ib->Set_nLableType(2);
118 $ib->Set_sFieldname('E-Mail');
119 break;
120
121 case 98:
122 /**
123 * Submit Button
124 */
125 $ib->Init();
126 $ib->Set_sType('SUBMIT');
127 $ib->Set_sName('Button[1]');
128 $ib->Set_sID('Button[1]');
129 $ib->Set_sValue($sValue);
130 $ib->Set_nTabIndex($nInput);
131 $ib->Set_sAccessKey('S') ;
132 if ($sMode == 'SEND')
133 $ib->Set_sProperties('DISABLED="DISABLED"') ;
134 break;
135 case 99:
136 /**
137 * Reset Button
138 */
139 $ib->Init();
140 $ib->Set_sType('SUBMIT');
141 $ib->Set_sName('Button[2]');
142 $ib->Set_sID('Button[2]');
143 $ib->Set_sValue($sValue);
144 $ib->Set_nTabIndex($nInput);
145 $ib->Set_sAccessKey('R') ;
146 break;
147 }
148 /**
149 * return complete <INPUT HTML Statement
150 */
151 return $ib->Get_sInput();
152 }
153
154 /**
155 * check $_POST
156 */
157 $aButton = array();
158 if (isset($_POST['Button'])) {
159 $aButton = $_POST['Button'];
160 }
161
162 $sFirstname = "";
163 if (isset($_POST['Firstname'])) {
164 $sFirstname = htmlentities($_POST['Firstname']);
165 }
166
167 $sLastname = "";
168 if (isset($_POST['Lastname'])) {
169 $sLastname = htmlentities($_POST['Lastname']);
170 }
171
172 $sSecNo = md5(time());
173
174 $sCountry = "";
175 if (isset($_POST['Country'])) {
176 $sCountry = htmlentities($_POST['Country']);
177 }
178
179 $sPhonenumber = "";
180 if (isset($_POST['Phonenumber'])) {
181 $sPhonenumber = htmlentities($_POST['Phonenumber']);
182 }
183
184 $sEmail = "";
185 if (isset($_POST['Email'])) {
186 $sEmail = htmlentities($_POST['Email']);
187 }
188
189 /**
190 * check submit button
191 */
192 $sMode = "NEW";
193 if (isset($aButton[1])) {
194 $sMode = "SEND";
195 }
196 if (isset($aButton[2])) {
197 $sMode = "RESET";
198 }
199
200 /**
201 * after submit
202 */
203 switch ($sMode) {
204 case 'RESET' :
205 $sFirstname = "";
206 $sLastname = "";
207 $sCountry = "";
208 $sPhonenumber = "";
209 $sEmail = "";
210 break;
211 case 'SEND' :
212 break;
213 }
214
215 /**
216 * Start HTML Template
217 */
218
219 ?>
220
221 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/transitional.dtd">
222 <HTML>
223 <HEAD>
224 <meta name="author" content="TW">
225 <meta name="generator" content="SciTE Version 1.53 by Neil Hodgson">
226 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
227
228
229 <TITLE>Test Input Builder class</TITLE>
230 <STYLE>
231 BODY
232 { background-color:#FFFFFF; }
233 FORM
234 { padding:20px; border:4px solid #CCCCCC; background-color:#EEEEEE; }
235 LEGEND
236 { font-size: 11px; font-family: verdana,arial,helvetica; color: #0000A0; }
237 AUSWAHL
238 { background-color:#DDFFFF; border:1px solid #CCCCCC; }
239 INPUT.Edit
240 { color:#000000; background-color:#FFFFFF; }
241 INPUT.NoEdit
242 { color:#000000; background-color:#EEEEEE; }
243 INPUT.Info
244 { font-size:10px; color:#408080; background-color:#EEEEFF; width:100px; border:1px solid #408080; }
245 BUTTON.Enabled
246 { background-color:#EEEEEE; color:#000000; width:100px; border:2px solid #000000; }
247 BUTTON.Disabled
248 { background-color:#EEEEEE; color:#000000; width:100px; border:2px solid #000000; }
249 FIELDSET
250 { margin: 5px 5px 5px 5px; }
251 DIV
252 { margin: 5px 5px 5px 5px; }
253 TABLE
254 { margin: 5px 5px 5px 5px; }
255 LABLE
256 { margin: 5px 5px 5px 5px; }
257 </STYLE>
258 </HEAD>
259 <BODY>
260 <FORM method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" accept-charset="ISO-8859-1, ISO-8859-2">
261 <h1>Test Input Builder class</h1>
262 <FIELDSET>
263 <LEGEND>Address (with TABLE)</LEGEND>
264 <TABLE>
265 <TR>
266 <TD>
267 Firstname
268 </TD>
269 <TD>
270 <?php echo build(1,$sFirstname); ?>
271 </TD>
272 </TR>
273 <TR>
274 <TD>
275 Lastname
276 </TD>
277 <TD>
278 <?php echo build(2,$sLastname); ?>
279 </TD>
280 </TR>
281 <TR>
282 <TD>
283 Security number
284 </TD>
285 <TD>
286 <?php echo build(3,$sSecNo); ?>
287 </TD>
288 </TR>
289 <TR>
290 <TD>
291 Country
292 </TD>
293 <TD>
294 <?php echo build(4,$sCountry); ?>
295 </TD>
296 </TR>
297 </TABLE>
298 </FIELDSET>
299 <FIELDSET>
300 <LEGEND>Address (with LABLE)</LEGEND>
301 <DIV>
302 <?php echo build(5,$sPhonenumber); ?>
303 </DIV>
304 <DIV>
305 <?php echo build(6,$sEmail); ?>
306 </DIV>
307 </FIELDSET>
308 <FIELDSET>
309 <LEGEND>Function</LEGEND>
310 <DIV>
311 <?php echo build(98,"[S]end"); ?>
312 <?php echo build(99,"[R]eset"); ?>
313 </DIV>
314 </FIELDSET>
315 <br>
316 Hinweis: <br>
317 Nach jedem SUBMIT wird eine neue Securitynumber erzeugt um zu erkennen,
318 dass das Formuar neu aufgebaut worden ist. Die Daten werden nicht
319 geprüft, ausgewertet oder gespeichert.
320 </FORM>
321 </BODY>
322 </HTML>
323