-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformObject.php
More file actions
executable file
·691 lines (591 loc) · 21 KB
/
formObject.php
File metadata and controls
executable file
·691 lines (591 loc) · 21 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
<?php
/*
File: lib/formobject.php
Author: Nathan Davies
Created: 13/03/08
Purpose: Used to build forms rapidly
Ammendments: 4th December 2008 Nathan Davies Added defineTimeSelection function
Comment: Each function returns just what it says - there are no containing divs added, this is the responsibilty of the calling code, but an function here can be used
*/
class formObject
{
var $loDataObject ;
public function formObject($poDB)
{
$this->loDataObject = $poDB ;
} // end of formObject function
function buildFormInput($pnFormat, $pcContainerID, $pcLabelID, $pcLabelFor, $pcLabel, $pcInputID, $pcInput)
{
switch($pnFormat)
{
case 1: // standard input with a label
$lcReturn = '<div class="row" id="' .$pcContainerID .'" >
<span class="label" id="' .$pcLabelID . '"><label for="' . $pcLabelFor . '">' . $pcLabel . '</label></span> ' ;
$lcReturn .= '<span class="formw" id="' . $pcInputID . '">' . $pcInput . '</span></div>' ;
break ;
case 2: // a form spacer
$lcReturn = '<div class="row"></div>';
break ;
case 3: // button container
$lcReturn = '<div class="row" id="' . $pcContainerID . '" ><span class="label"></span>' ;
$lcReturn .= '<span class="formw" id="' . $pcInputID . '">' . $pcInput . '</span></div>' ;
break ;
case 4: // standard input with a warning label
$lcReturn = '<div class="row" id="' .$pcContainerID .'" >
<span class="label" id="' .$pcLabelID . '"><span class="warninglabel"><label for="' . $pcLabelFor . '">' . $pcLabel . '</label></span></span> ' ;
$lcReturn .= '<span class="formw" id="' . $pcInputID . '">' . $pcInput . '</span></div>' ;
break ;
case 5: // standard input without a label
$lcReturn = '<div class="row" id="' .$pcContainerID .'" >' ;
$lcReturn .= '<span class="formw" id="' . $pcInputID . '">' . $pcInput . '</span></div>' ;
break ;
case 6: // scrolling div to handle mutiple related items such as check boxes - alternative to the multi select via ctrl key
$lcReturn = '<div class="row" id="' .$pcContainerID .'" >
<span class="label" id="' .$pcLabelID . '"><label for="' . $pcLabelFor . '">' . $pcLabel . '</label></span> ' ;
$lcReturn .= '<span class="formw" id="' . $pcInputID . '">' ;
$lcReturn .= '<div class="multiselect" id="' . $pcLabelFor .'">' . $pcInput . '</div></span></div>' ;
break ;
}
return $lcReturn ;
} // end of buildFormInput
function defineDateSelection($plSetDefault, $pcIDSuffix, $pdDate, $plIsReadOnly, $pnTabIndex)
{
// $plSetDefault - True = default of current date or the date supplied in the third parameter, False = default of start of current year as the event system doesn't allow you to schedule past events
// $pcIDSuffix - The end of the ID, all elements retruned hve the same base they then have a different suffix, recommend '_ClarifyingName'
// $pdDate - The date that neeeds to be set
if($plSetDefault)
{
if(!empty($pdDate))
{
$lnCurrentDay = date('j', mktime(0,0,0,substr($pdDate, 5, 2), substr($pdDate, 8, 2), substr($pdDate, 0,4))) ;
$lnCurrentMonth = date('n', mktime(0,0,0,substr($pdDate, 5, 2), substr($pdDate, 8, 2), substr($pdDate, 0,4))) ;
$lnCurrentYear = date('Y', mktime(0,0,0,substr($pdDate, 5, 2), substr($pdDate, 8, 2), substr($pdDate, 0,4))) ;
}
else
{
$lnCurrentDay = date('j') ;
$lnCurrentMonth = date('n') ;
$lnCurrentYear = date('Y') ;
}
}
else
{
$lnCurrentDay = 1 ; // first day of the month
$lnCurrentMonth = date('n'); // the next month - so there are no past events
$lnCurrentYear = date('Y') ;
}
$lnYear = intVal(date('Y'));
$lcDayID = "cbo_datePickerDay" . $pcIDSuffix ;
$lcMonthID = "cbo_datePickerMonth" . $pcIDSuffix ;
$lcYearID = "cbo_datePickerYear" . $pcIDSuffix ;
$lcDayName = "cbo_datePickerDay" . $pcIDSuffix . "_name" ;
$lcMonthName = "cbo_datePickerMonth" . $pcIDSuffix . "_name" ;
$lcYearName = "cbo_datePickerYear" . $pcIDSuffix . "_name" ;
$lcDefinition = '<select class="dayPicker" id="' . $lcDayID . '" name="' . $lcDayName . '" title="Select the day" tabindex="' . $pnTabIndex . '">' ;
for($i=1; $i<=31; $i++)
{
$lcDefinition .= '<option value="' . $i .'"';
if($lnCurrentDay == $i)
{
$lcDefinition .= ' selected="selected" ' ;
}
$lcDefinition .= '>' . $i . ' </option>' ;
}
$lcDefinition .= '</select>' ;
$lnTabIndex = $pnTabIndex + 1 ;
$lcDefinition .= '<select class="monthPicker" id="' . $lcMonthID . '" name="' . $lcMonthName .'" title="Select the month" tabindex="' . $lnTabIndex . '">' ;
for($i=1; $i<=12; $i++)
{
$lcDefinition .= '<option value="' . $i .'"';
if($lnCurrentMonth == $i)
{
$lcDefinition .= ' selected="selected" ' ;
}
$lcDefinition .= '>' . date('F', mktime(0, 0, 0, $i, 1)) . '</option>' ;
}
$lcDefinition .= '</select>' ;
$lnTabIndex = $pnTabIndex + 1 ;
$lcDefinition .= '<select class="yearPicker" id="' . $lcYearID . '" name="' . $lcYearName . '" title="Select the year" tabindex="' . $lnTabIndex .'">' ;
for($i=0; $i<=10; $i++)
{
$lnYearToAdd = $lnYear + $i ;
$lcDefinition .= '<option value="' . $lnYearToAdd . '"' ;
if($lnYearToAdd == $lnCurrentYear)
{
$lcDefinition .= ' selected="selected" ' ;
}
$lcDefinition .= '">' . $lnYearToAdd. '</option>' ;
}
$lcDefinition .= '</select>' ;
return $lcDefinition ;
} // end of defineDateSelection
function defineTimeSelection($plSetDefault, $pcIDSuffix, $ptTime, $plIsReadOnly, $pnTabIndex)
{
// $plSetDefault - True = default of current time or the date supplied in the third parameter, False = default of midnight
// $pcIDSuffix - The end of the ID, all elements retruned hve the same base they then have a different suffix, recommend '_ClarifyingName'
// $ptTime - The time that neeeds to be set
if($plSetDefault)
{
if(!empty($ptTime))
{
$lnCurrentHour = date('H', mktime(intVal(substr($ptTime, 0, 2)), 0, 0, 0, 0, 0)) ;
$lnCurrentMinute = date('i', mktime(0, intVal(substr($ptTime, 3, 2)), 0, 0, 0, 0)) ;
}
else
{
$lnCurrentHour = date('H') ;
$lnCurrentMinute = date('i') ;
}
}
else
{
$lnCurrentHour = 00 ;
$lnCurrentMinute = 00 ; // default if nothing set is midnight
}
$lnYear = intVal(date('Y'));
$lcHourID = "cbo_datePickerHour" . $pcIDSuffix ;
$lcMinuteID = "cbo_datePickerMinute" . $pcIDSuffix ;
$lcHourName = "cbo_datePickerHour" . $pcIDSuffix . "_name" ;
$lcMinuteName = "cbo_datePickerMinute" . $pcIDSuffix . "_name" ;
$lcDefinition = '<select class="dayPicker" id="' . $lcHourID . '" name="' . $lcHourName . '" title="Select the hour" tabindex="' . $pnTabIndex . '">' ;
for($i=0; $i<=23; $i++)
{
$lcDefinition .= '<option value="' . $i .'"';
if(intVal($lnCurrentHour) == $i)
{
$lcDefinition .= ' selected="selected" ' ;
}
$lcDefinition .= '>' . str_pad(strVal($i), 2, '0', STR_PAD_LEFT) . ' </option>' ;
}
$lcDefinition .= '</select>' ;
$lnTabIndex = $pnTabIndex + 1 ;
$lcDefinition .= '<select class="dayPicker" id="' . $lcMinuteID . '" name="' . $lcMinuteName .'" title="Select the minutes" tabindex="' . $lnTabIndex . '">' ;
for($i=0; $i<=59; $i++)
{
$lcDefinition .= '<option value="' . $i .'"';
if(intVal($lnCurrentMinute) == $i)
{
$lcDefinition .= ' selected="selected" ' ;
}
$lcDefinition .= '>' . str_pad(strVal($i), 2, '0', STR_PAD_LEFT) . '</option>' ;
}
$lcDefinition .= '</select>' ;
return $lcDefinition ;
} // end of defineTimeSelection
function createInputSelect($pnRetreivalType, $pnReturnType, $pcSelectID, $pnSelection, $plIsReadOnly, $pcExtra, $pcClass, $pnTabIndex)
{
switch($pnRetreivalType)
{
case 1: // get rating
$lcSelectStr =
"SELECT
a.ID, a.description, a.isDefault
FROM tbl_rating a
ORDER BY a.ID ASC";
break;
case 2: // get food options
$lcSelectStr =
"SELECT
a.ID, a.description, a.isDefault
FROM tbl_food a
ORDER BY a.ID ASC" ;
break ;
case 3: // get Church names
$lcSelectStr =
"SELECT
a.ID, concat(a.name, '(' , a.town, ')') as description, 0 as isDefault
FROM tbl_church a
ORDER BY a.name ASC, a.town ASC" ;
break ;
case 4: // get a list of Forums - excluding the one a thread ia currently in
$lcSelectStr =
"SELECT
a.ID, a.title as description, 0 as isDefault
FROM tbl_forum a
WHERE a.ID NOT IN (
SELECT b.forumID FROM tbl_thread b WHERE b.ID = $pnSelection)
ORDER BY a.title ASC" ;
break ;
case 5: // get the list of available Bible translations
$lcSelectStr =
"SELECT
a.refID as ID, a.description, a.isDefault
FROM tbl_bible a
ORDER by a.description ASC" ; // note use REF ID as this is saved against user to aid delivery of this system
break ;
case 6: // get the list of sermon topics
$lcSelectStr =
"SELECT
a.ID, a.title as description , 0 as isDefault
FROM tbl_topic a
ORDER by a.title ASC";
break ;
case 7: // get the list of links for admin panel so even isLive=0 are loaded
$lcSelectStr =
"SELECT a.ID, a.title as description, 0 as IsDefault
FROM tbl_links a
ORDER BY a.title ASC" ;
break ;
case 8: // get the lost of forums for admin panel
$lcSelectStr =
"SELECT a.ID, a.title as description, 0 as isDefault
FROM tbl_forum a
ORDER BY a.title ASC" ;
break ;
case 9: // get the list of resource types
$lcSelectStr =
"SELECT a.ID, a.title as description, 0 as isDefault
FROM tbl_resourcetype a
ORDER BY a.title ASC" ;
break ;
case 10: // get the downloads for a specifc type
$lcSelectStr =
"SELECT a.ID, a.title as description, 0 as isDefault
FROM tbl_resource a
WHERE a.resourceTypeID = $pnSelection AND a.isGeneric = 1
ORDER BY a.title ASC";
$pnSelection = 0 ;
break ;
case 11: // get the list of speakers
$lcSelectStr =
"SELECT a.ID, a.name as description, 0 as isDefault
FROM tbl_speaker a
ORDER BY a.name ASC" ;
break ;
case 12: // get the headline and ID for each news item - this is for the admin area
$lcSelectStr =
"SELECT a.ID, a.title as description, 0 as isDefault
FROM tbl_news a
ORDER BY a.title ASC" ;
break ;
case 13: // get the title and ID for each event - this is for the admin area
$lcSelectStr =
"SELECT a.ID, a.title as description, 0 as isDefault
FROM tbl_event a
ORDER BY a.title ASC" ;
break ;
case 14: // list of venues
$lcSelectStr =
"SELECT a.ID, a.name as description, 0 as isDefault
FROM tbl_venue a
ORDER BY a.name ASC " ;
break ;
}
// execute the select
$laResults = $this->loDataObject->queryGetData(false, $lcSelectStr);
$lcItemID = !empty($pcSelectID)? $pcSelectID : "list" . $pnRetreivalType ;
switch($pnReturnType)
{
case 1: // write the results into a select input object
$lvReturn = "<select id=" . "'" . $lcItemID . "' " ;
if(!empty($pcExtra))
{
$lvReturn .= $pcExtra . " " ;
}
if(!empty($pcClass))
{
$lvReturn .= "class='" . $pcClass ."' " ;
}
$lvReturn.= " tabindex='" . $pnTabIndex . "'>";
foreach($laResults as $lcDataLine)
{
$lvReturn .= "<option value=" . $lcDataLine['ID'] . " ";
if($pnSelection >= 0)
{
if($lcDataLine['ID'] == $pnSelection)
{
$lvReturn .= "selected='selected'";
}
}
else
{
if($lcDataLine['isDefault'])
{
$lvReturn .= "selected='selected'";
}
}
$lvReturn .= ">" . $lcDataLine['description'] ."</option>";
}
$lvReturn .= "</select>";
break;
case 2: // return the array from the query
$lvReturn = $laResults ;
}
return $lvReturn ;
} // end of createInputSelect
function enumToInputSelect($pcTable, $pcENUMColumn, $pcListID, $pcSelection, $plIsReadOnly, $pcExtra, $pcClass, $pnTabIndex)
{
$lcGetENUM = "SHOW COLUMNS FROM $pcTable LIKE '$pcENUMColumn'";
$laENUM = $this->loDataObject->queryGetData(false, $lcGetENUM) ;
$lcEnumData = $laENUM[0]['Type'] ;
$lnStartPos = strpos($lcEnumData,"(") + 1 ;
$lnEndPos = strpos($lcEnumData, ")");
$lcEnumData = substr($lcEnumData, $lnStartPos, $lnEndPos-$lnStartPos) ;
$lcEnumData = str_replace("'", "", $lcEnumData) ;
$laEnumData = explode(",", $lcEnumData) ;
if(empty($pcListID))
{
$pcListID = "list" . $pcENUMcolumn ;
}
$lcReturn = "<select id='" . $pcListID . "' " ;
if(!empty($pcExtra))
{
$lcReturn .= $pcExtra . " " ;
}
if(!empty($pcClass))
{
$lcReturn .= "class='" . $pcClass ."' " ;
}
$lcReturn .= "tabindex='" . $pnTabIndex . "'>";
$lnCount = count($laEnumData) - 1 ;
for($lnPntr = 0; $lnPntr <= $lnCount; $lnPntr++)
{
$lnValue = $lnPntr + 1 ;
$lcReturn .= "<option value=" . $lnValue ;
if($pcSelection == $laEnumData[$lnPntr])
{
$lcReturn .= " selected='selected'" ;
}
$lcReturn .= " >" . $laEnumData[$lnPntr] ."</option>";
}
$lcReturn .= "</select>";
return $lcReturn ;
} // end of enumToInputSelect
function defineSelectFixedValues($pcElementID, $pcValueList, $pcTitle, $pcExtra, $pnSelectedItem, $plIsReadOnly, $pcClass, $pnTabIndex)
{
$laValueList = explode("||", $pcValueList) ;
$lcReturn = '<select id="' . $pcElementID .'" name="' . $pcElementID . '" title="' . $pcTitle . '" ' ;
if(!empty($pcExtra)) // extra options specified - used for code such as onchange event handlers
{
$lcReturn .= $pcExtra . ' ' ;
}
if(!empty($pcClass)) // there is a CSS class to apply to this
{
$lcReturn .= 'class="' . $pcClass . '" ' ;
}
$lcReturn .= 'tabindex="' . $pnTabIndex . '">' ;
$lnCount = count($laValueList) - 1 ;
for($lnPntr=0; $lnPntr <= $lnCount; $lnPntr++)
{
$laValueDetails = explode("^^", $laValueList[$lnPntr]) ;
$lcReturn .= '<option value="' . $laValueDetails[0] . '" ' ;
if($pnSelectedItem === $lnPntr)
{
$lcReturn .= 'selected="selected" ' ;
}
$lcReturn .= '>' . $laValueDetails[1] . '</option>' ;
}
$lcReturn .= '</select>' ;
} // end of defineSelectFixedValues
function defineInputText($pcElementID, $pcValue, $pcTitle, $pnMaxLength, $pnSize, $pcExtra, $pcClass, $plIsReadOnly, $pnTabIndex)
{
$lcReturn = '<input id="' . $pcElementID . '"
type="text"
title="' . $pcTitle . '"
value="' . $pcValue . '"
maxlength="' . $pnMaxLength . '"
size="' . $pnSize . '"
tabindex="' . $pnTabIndex .'" ' ;
if(!empty($pcExtra)) // extra options specified - used for code such as onchange event handlers or supplying a name for the control
{
$lcReturn .= $pcExtra . ' ' ;
}
if(!empty($pcClass)) // there is a CSS class to apply to this
{
$lcReturn .= 'class="' . $pcClass . '"' ;
}
if($plIsReadOnly)
{
$lcReturn .= 'readonly="readonly" ' ;
}
$lcReturn .='/>' ;
return $lcReturn ;
} // end of defineInputText
function defineInputPassword($pcElementID, $pcValue, $pcTitle, $pnMaxLength, $pnSize, $pcExtra, $pcClass, $plIsReadOnly, $pnTabIndex)
{
$lcReturn = '<input id="' . $pcElementID . '"
type="password"
title="' . $pcTitle . '"
value="' . $pcValue . '"
maxlength="' . $pnMaxLength . '"
size="' . $pnSize . '"
tabindex="' . $pnTabIndex .'" ' ;
if(!empty($pcExtra)) // extra options specified - used for code such as onchange event handlers
{
$lcReturn .= $pcExtra . ' ' ;
}
if(!empty($pcClass)) // there is a CSS class to apply to this
{
$lcReturn .= 'class="' . $pcClass . '" ' ;
}
if($plIsReadOnly)
{
$lcReturn .= 'readonly="readonly"' ;
}
$lcReturn .='/>' ;
return $lcReturn ;
} // end of defineInputText
function defineInputFile($pcElementID, $pcValue, $pcTitle, $pnMaxSize, $pnSize, $pcExtra, $pcClass, $plIsReadOnly, $pnTabIndex, $pcSizeSuffix)
{
$lcReturn = '<input type="hidden" name="MAX_FILE_SIZE' . $pcSizeSuffix . '" value="' . $pnMaxSize . '" />' ;
$lcReturn .= '<input id="' . $pcElementID . '"
type="file"
title="' . $pcTitle . '"
value="' . $pcValue . '"
size="' . $pnSize . '"
tabindex="' . $pnTabIndex . '" ' ;
if(!empty($pcExtra)) // extra options specified - used for code such as onchange event handlers
{
$lcReturn .= $pcExtra . ' ' ;
}
if(!empty($pcClass)) // there is a CSS class to apply to this
{
$lcReturn .= 'class="' . $pcClass . '" ' ;
}
if($plIsReadOnly)
{
$lcReturn .= 'readonly="readonly"' ;
}
$lcReturn .='/>' ;
return $lcReturn ;
} // end of defineInputFile
function defineInputTextArea($pcElementID, $pcValue, $pcTitle, $pnRows, $pnColumns, $pcExtra, $pcClass, $plIsReadOnly, $pnTabIndex)
{
$lcReturn = '<textarea id="' . $pcElementID . '"
title="' . $pcTitle . '"
cols="' . $pnColumns . '"
rows="' . $pnRows . '"
tabindex="' . $pnTabIndex .'" ' ;
if(!empty($pcExtra)) // extra options specified - used for code such as onchange event handlers
{
$lcReturn .= $pcExtra . ' ' ;
}
if(!empty($pcClass)) // there is a CSS class to apply to this
{
$lcReturn .= 'class="' . $pcClass . '" ' ;
}
if($plIsReadOnly)
{
$lcReturn .= 'readonly="readonly" ' ;
}
$lcReturn .= '>' ;
if(!empty($pcValue))
{
$lcReturn .= $pcValue ;
}
$lcReturn .= '</textarea>' ;
return $lcReturn ;
} // end of defineInputText
function defineInputCheckBox($pcElementID, $pcValue, $pcTitle, $pcExtra, $pcClass, $plIsChecked, $plIsReadOnly, $pnTabIndex)
{
$lcReturn = '<input type="checkbox"
title="' . $pcTitle . '"
id="' . $pcElementID . '"
value="' . $pcValue . '"
tabindex="' . $pnTabIndex . '" ' ;
if(!empty($pcExtra)) // extra options specified - used for code such as onchange event handlers
{
$lcReturn .= $pcExtra . ' ' ;
}
if(!empty($pcClass)) // there is a CSS class to apply to this
{
$lcReturn .= 'class="' . $pcClass . '"' ;
}
if($plIsChecked) // this is checked by default
{
$lcReturn .= 'checked="checked" ' ;
}
if($plIsReadOnly)
{
$lcReturn .= 'disabled="disabled" ' ;
}
$lcReturn .= '/>' ;
return $lcReturn ;
} // end of defineInputCheckBox
function defineInputRadioButton($pcElementID, $pcValueList, $pcTitle, $pcExtra, $pnCheckedItem, $plIsReadOnly, $pnTabIndex)
{
$lcReturn = '' ;
$laValueList = explode("||", $pcValueList) ;
$lnCount = count($laValueList) - 1 ;
for($lnPntr=0; $lnPntr <= $lnCount; $lnPntr++)
{
$lcReturn .= '<input type="radio"
id="' . $pcElementID . '"
value="' . $laValueList[$lnPntr] . '"
tabindex="' . $pnTabIndex + $lnPntr . '" ';
if(!empty($pcExtra)) // extra options specified - used for code such as onchange event handlers
{
$lcReturn .= $pcExtra . ' ';
}
if(!empty($pcClass)) // there is a CSS class to apply to this
{
$lcReturn .= 'class="' . $pcClass . '" ' ;
}
if($pnCheckedItem === $lnPntr) // this item is checked by default
{
$lcReturn .= 'checked="checked" ' ;
}
if($plIsReadOnly)
{
$lcReturn .= 'readonly="readonly"' ;
}
$lcReturn .= ' />' ;
}
return $lcReturn ;
} // end of defineInputRadioButton
function defineInputButton($pnType, $pcElementID, $pcValue, $pcTitle, $pcClass, $pcExtra, $plIsReadOnly, $pnTabIndex)
{
// There are cases when the form doesn't use a standard submit buton but rather it uses an image with an onclick.
// This function handles both of these cases as well as the various traditional input buttons.
switch($pnType)
{
case 1: // image with an onclick
$lcReturn = '<img id="' . $pcElementID . '" src="' . $pcValue . '" title="' . $pcTitle .'" alt="' .$pcTitle . '" onmouseover="this.style.cursor=\'pointer\';" ' ;
break ;
case 2: // input - submit
$lcReturn = '<input type="submit"
id="' . $pcElementID . '"
title="' . $pcTitle . '"
value="' . $pcValue . '" ' ;
break ;
case 3: // input - reset
$lcReturn = '<input type="reset"
id="' . $pcElementID . '"
title="' . $pcTitle . '"
value="' . $pcValue . '" ' ;
break ;
default: // input - button
$lcReturn = '<input type="button"
id="' . $pcElementID . '"
title="' . $pcTitle . '"
value="' . $pcValue . '" ' ;
break ;
}
$lcReturn .= 'tabindex="' . $pnTabIndex . '" ' ;
if(!empty($lcReturn))
{
if(!empty($pcClass))
{
$lcReturn .= 'class="' . $pcClass . '" ' ;
}
if(!empty($pcExtra))
{
$lcReturn .= $pcExtra . ' ' ;
}
if($plIsReadOnly)
{
if($pnType == 1)
{
$lcReturn .= 'style="display:none" ' ;
}
else
{
$lcReturn .= 'disabled="disabled" ' ;
}
}
$lcReturn .= ' />';
}
return $lcReturn ;
} // end of defineInputText
} // end of formobject class definition
?>