-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphpfn7.php
More file actions
3971 lines (3556 loc) · 111 KB
/
phpfn7.php
File metadata and controls
3971 lines (3556 loc) · 111 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
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* PHPMaker Common classes and functions
* (C) 2002-2010 e.World Technology Limited. All rights reserved.
*/
/**
* Export document class
*/
class cExportDocument {
var $Table;
var $Text;
var $Line = "";
var $Style = "h"; // "v"(Vertical) or "h"(Horizontal)
var $Horizontal = TRUE; // Horizontal
// Constructor
function cExportDocument(&$tbl, $style) {
$this->Table = $tbl;
if (strtolower($style) == "v")
$this->Style = "v";
$this->Horizontal = ($this->Table->Export <> "xml" && ($this->Style <> "v" || $this->Table->Export == "csv"));
}
// Header
function ExportHeader() {
switch ($this->Table->Export) {
case "html":
case "email":
if (EW_EXPORT_CSS_STYLES)
$this->Text .= "<style>" . ew_ReadFile(EW_PROJECT_STYLESHEET_FILENAME) . "</style>\r\n";
$this->Text .= "<table class=\"ewExportTable\">";
break;
case "word":
case "excel":
$this->Text .= "<table>";
break;
case "csv":
$this->Text .= "";
}
}
// Field Caption
function ExportCaption(&$fld) {
$this->ExportValueEx($fld, $fld->ExportCaption(), FALSE);
}
// Field value
function ExportValue(&$fld) {
$this->ExportValueEx($fld, $fld->ExportValue($this->Table->Export, $this->Table->ExportOriginalValue), TRUE);
}
// Field aggregate
function ExportAggregate(&$fld, $type) {
if ($this->Horizontal) {
global $Language;
$val = "";
if (in_array($type, array("TOTAL", "COUNT", "AVERAGE")))
$val = $Language->Phrase($type) . ": " . $fld->ExportValue($this->Table->Export, $this->Table->ExportOriginalValue);
$this->ExportValueEx($fld, $val, FALSE);
}
}
// Export a value (caption, field value, or aggregate)
function ExportValueEx(&$fld, $val, $usestyle) {
switch ($this->Table->Export) {
case "html":
case "email":
case "word":
case "excel":
$this->Text .= "<td" . (($usestyle && EW_EXPORT_CSS_STYLES) ? $fld->CellStyles() : "") . ">";
if ($this->Table->Export == "excel" && $fld->FldDataType == EW_DATATYPE_STRING && is_numeric($val)) {
$this->Text .= "=\"" . strval($val) . "\"";
} else {
$this->Text .= strval($val);
}
$this->Text .= "</td>";
break;
case "csv":
if ($this->Line <> "")
$this->Line .= ",";
$this->Line .= "\"" . str_replace("\"", "\"\"", strval($val)) . "\"";
}
}
// Begin a row
function BeginExportRow($usestyle = FALSE) {
if ($this->Horizontal) {
switch ($this->Table->Export) {
case "html":
case "email":
case "word":
case "excel":
$this->Text .= "<tr" . (($usestyle && EW_EXPORT_CSS_STYLES) ? $this->Table->RowStyles() : "") . ">";
break;
case "csv":
$this->Line = "";
}
}
}
// End a row
function EndExportRow() {
if ($this->Horizontal) {
switch ($this->Table->Export) {
case "html":
case "email":
case "word":
case "excel":
$this->Text .= "</tr>";
break;
case "csv":
$this->Line .= "\r\n";
$this->Text .= $this->Line;
}
}
}
// Export a field
function ExportField(&$fld) {
if ($this->Horizontal) {
$this->ExportValue($fld);
} else { // Vertical, export as a row
$td = "<td" . ((EW_EXPORT_CSS_STYLES) ? $fld->CellStyles() : "") . ">";
$this->Text .= "<tr><td>" . $fld->ExportCaption() . "</td>" . $td .
$fld->ExportValue($this->Table->Export, $this->Table->ExportOriginalValue) .
"</td></tr>";
}
}
// Footer
function ExportFooter() {
switch ($this->Table->Export) {
case "html":
case "email":
case "word":
case "excel":
$this->Text .= "</table>";
}
}
}
/**
* QueryString class
*/
class cQueryString {
var $values = array();
var $Count;
function cQueryString() {
$ar = explode("&", ew_ServerVar("QUERY_STRING"));
foreach ($ar as $p) {
$arp = explode("=", $p);
if (count($arp) == 2) $this->values[urldecode($arp[0])] = $arp[1];
}
$this->Count = count($this->values);
}
function getValue($name) {
return (array_key_exists($name, $this->values)) ? $this->values[$name] : "";
}
function getUrlDecodedValue($name) {
return urldecode($this->getValue($name));
}
function getRawUrlDecodedValue($name) {
return rawurldecode($this->getValue($name));
}
function getConvertedValue($name) {
return ew_ConvertFromUtf8($this->getRawUrlDecodedValue($name));
}
}
/**
* Email class
*/
class cEmail {
// Class properties
var $Sender = ""; // Sender
var $Recipient = ""; // Recipient
var $Cc = ""; // Cc
var $Bcc = ""; // Bcc
var $Subject = ""; // Subject
var $Format = ""; // Format
var $Content = ""; // Content
var $Charset = ""; // Charset
var $SendErrDescription; // Send error description
// Method to load email from template
function Load($fn) {
$fn = ew_ScriptFolder() . EW_PATH_DELIMITER . $fn;
$sWrk = ew_ReadFile($fn); // Load text file content
if ($sWrk <> "") {
// Locate Header & Mail Content
if (EW_IS_WINDOWS) {
$i = strpos($sWrk, "\r\n\r\n");
} else {
$i = strpos($sWrk, "\n\n");
if ($i === FALSE) $i = strpos($sWrk, "\r\n\r\n");
}
if ($i > 0) {
$sHeader = substr($sWrk, 0, $i);
$this->Content = trim(substr($sWrk, $i, strlen($sWrk)));
if (EW_IS_WINDOWS) {
$arrHeader = explode("\r\n", $sHeader);
} else {
$arrHeader = explode("\n", $sHeader);
}
for ($j = 0; $j < count($arrHeader); $j++) {
$i = strpos($arrHeader[$j], ":");
if ($i > 0) {
$sName = trim(substr($arrHeader[$j], 0, $i));
$sValue = trim(substr($arrHeader[$j], $i+1, strlen($arrHeader[$j])));
switch (strtolower($sName))
{
case "subject":
$this->Subject = $sValue;
break;
case "from":
$this->Sender = $sValue;
break;
case "to":
$this->Recipient = $sValue;
break;
case "cc":
$this->Cc = $sValue;
break;
case "bcc":
$this->Bcc = $sValue;
break;
case "format":
$this->Format = $sValue;
break;
}
}
}
}
}
}
// Method to replace sender
function ReplaceSender($ASender) {
$this->Sender = str_replace('<!--$From-->', $ASender, $this->Sender);
}
// Method to replace recipient
function ReplaceRecipient($ARecipient) {
$this->Recipient = str_replace('<!--$To-->', $ARecipient, $this->Recipient);
}
// Method to add Cc email
function AddCc($ACc) {
if ($ACc <> "") {
if ($this->Cc <> "") $this->Cc .= ";";
$this->Cc .= $ACc;
}
}
// Method to add Bcc email
function AddBcc($ABcc) {
if ($ABcc <> "") {
if ($this->Bcc <> "") $this->Bcc .= ";";
$this->Bcc .= $ABcc;
}
}
// Method to replace subject
function ReplaceSubject($ASubject) {
$this->Subject = str_replace('<!--$Subject-->', $ASubject, $this->Subject);
}
// Method to replace content
function ReplaceContent($Find, $ReplaceWith) {
$this->Content = str_replace($Find, $ReplaceWith, $this->Content);
}
// Method to send email
function Send() {
global $gsEmailErrDesc;
$result = ew_SendEmail($this->Sender, $this->Recipient, $this->Cc, $this->Bcc,
$this->Subject, $this->Content, $this->Format, $this->Charset);
$this->SendErrDescription = $gsEmailErrDesc;
return $result;
}
}
/**
* Pager item class
*/
class cPagerItem {
var $Start;
var $Text;
var $Enabled;
}
/**
* Numeric pager class
*/
class cNumericPager {
var $Items = array();
var $Count, $FromIndex, $ToIndex, $RecordCount, $PageSize, $Range;
var $FirstButton, $PrevButton, $NextButton, $LastButton;
var $ButtonCount = 0;
var $Visible = TRUE;
function cNumericPager($StartRec, $DisplayRecs, $TotalRecs, $RecRange)
{
$this->FirstButton = new cPagerItem;
$this->PrevButton = new cPagerItem;
$this->NextButton = new cPagerItem;
$this->LastButton = new cPagerItem;
$this->FromIndex = intval($StartRec);
$this->PageSize = intval($DisplayRecs);
$this->RecordCount = intval($TotalRecs);
$this->Range = intval($RecRange);
if ($this->PageSize == 0) return;
if ($this->FromIndex > $this->RecordCount)
$this->FromIndex = $this->RecordCount;
$this->ToIndex = $this->FromIndex + $this->PageSize - 1;
if ($this->ToIndex > $this->RecordCount)
$this->ToIndex = $this->RecordCount;
// setup
$this->SetupNumericPager();
// update button count
if ($this->FirstButton->Enabled) $this->ButtonCount++;
if ($this->PrevButton->Enabled) $this->ButtonCount++;
if ($this->NextButton->Enabled) $this->ButtonCount++;
if ($this->LastButton->Enabled) $this->ButtonCount++;
$this->ButtonCount += count($this->Items);
}
// Add pager item
function AddPagerItem($StartIndex, $Text, $Enabled)
{
$Item = new cPagerItem;
$Item->Start = $StartIndex;
$Item->Text = $Text;
$Item->Enabled = $Enabled;
$this->Items[] = $Item;
}
// Setup pager items
function SetupNumericPager()
{
if ($this->RecordCount > $this->PageSize) {
$Eof = ($this->RecordCount < ($this->FromIndex + $this->PageSize));
$HasPrev = ($this->FromIndex > 1);
// First Button
$TempIndex = 1;
$this->FirstButton->Start = $TempIndex;
$this->FirstButton->Enabled = ($this->FromIndex > $TempIndex);
// Prev Button
$TempIndex = $this->FromIndex - $this->PageSize;
if ($TempIndex < 1) $TempIndex = 1;
$this->PrevButton->Start = $TempIndex;
$this->PrevButton->Enabled = $HasPrev;
// Page links
if ($HasPrev || !$Eof) {
$x = 1;
$y = 1;
$dx1 = intval(($this->FromIndex-1)/($this->PageSize*$this->Range))*$this->PageSize*$this->Range + 1;
$dy1 = intval(($this->FromIndex-1)/($this->PageSize*$this->Range))*$this->Range + 1;
if (($dx1+$this->PageSize*$this->Range-1) > $this->RecordCount) {
$dx2 = intval($this->RecordCount/$this->PageSize)*$this->PageSize + 1;
$dy2 = intval($this->RecordCount/$this->PageSize) + 1;
} else {
$dx2 = $dx1 + $this->PageSize*$this->Range - 1;
$dy2 = $dy1 + $this->Range - 1;
}
while ($x <= $this->RecordCount) {
if ($x >= $dx1 && $x <= $dx2) {
$this->AddPagerItem($x, $y, $this->FromIndex<>$x);
$x += $this->PageSize;
$y++;
} elseif ($x >= ($dx1-$this->PageSize*$this->Range) && $x <= ($dx2+$this->PageSize*$this->Range)) {
if ($x+$this->Range*$this->PageSize < $this->RecordCount) {
$this->AddPagerItem($x, $y . "-" . ($y+$this->Range-1), TRUE);
} else {
$ny = intval(($this->RecordCount-1)/$this->PageSize) + 1;
if ($ny == $y) {
$this->AddPagerItem($x, $y, TRUE);
} else {
$this->AddPagerItem($x, $y . "-" . $ny, TRUE);
}
}
$x += $this->Range*$this->PageSize;
$y += $this->Range;
} else {
$x += $this->Range*$this->PageSize;
$y += $this->Range;
}
}
}
// Next Button
$TempIndex = $this->FromIndex + $this->PageSize;
$this->NextButton->Start = $TempIndex;
$this->NextButton->Enabled = !$Eof;
// Last Button
$TempIndex = intval(($this->RecordCount-1)/$this->PageSize)*$this->PageSize + 1;
$this->LastButton->Start = $TempIndex;
$this->LastButton->Enabled = ($this->FromIndex < $TempIndex);
}
}
}
/**
* PrevNext pager class
*/
class cPrevNextPager {
var $FirstButton, $PrevButton, $NextButton, $LastButton;
var $CurrentPage, $PageCount, $FromIndex, $ToIndex, $RecordCount;
var $Visible = TRUE;
function cPrevNextPager($StartRec, $DisplayRecs, $TotalRecs)
{
$this->FirstButton = new cPagerItem;
$this->PrevButton = new cPagerItem;
$this->NextButton = new cPagerItem;
$this->LastButton = new cPagerItem;
$this->FromIndex = intval($StartRec);
$this->PageSize = intval($DisplayRecs);
$this->RecordCount = intval($TotalRecs);
if ($this->PageSize == 0) return;
$this->CurrentPage = intval(($this->FromIndex-1)/$this->PageSize) + 1;
$this->PageCount = intval(($this->RecordCount-1)/$this->PageSize) + 1;
if ($this->FromIndex > $this->RecordCount)
$this->FromIndex = $this->RecordCount;
$this->ToIndex = $this->FromIndex + $this->PageSize - 1;
if ($this->ToIndex > $this->RecordCount)
$this->ToIndex = $this->RecordCount;
// First Button
$TempIndex = 1;
$this->FirstButton->Start = $TempIndex;
$this->FirstButton->Enabled = ($TempIndex <> $this->FromIndex);
// Prev Button
$TempIndex = $this->FromIndex - $this->PageSize;
if ($TempIndex < 1) $TempIndex = 1;
$this->PrevButton->Start = $TempIndex;
$this->PrevButton->Enabled = ($TempIndex <> $this->FromIndex);
// Next Button
$TempIndex = $this->FromIndex + $this->PageSize;
if ($TempIndex > $this->RecordCount)
$TempIndex = $this->FromIndex;
$this->NextButton->Start = $TempIndex;
$this->NextButton->Enabled = ($TempIndex <> $this->FromIndex);
// Last Button
$TempIndex = intval(($this->RecordCount-1)/$this->PageSize)*$this->PageSize + 1;
$this->LastButton->Start = $TempIndex;
$this->LastButton->Enabled = ($TempIndex <> $this->FromIndex);
}
}
/**
* Field class
*/
class cField {
var $TblName; // Table name
var $TblVar; // Table variable name
var $FldName; // Field name
var $FldVar; // Field variable name
var $FldExpression; // Field expression (used in SQL)
var $FldIsVirtual; // Virtual field
var $FldVirtualExpression; // Virtual field expression (used in ListSQL)
var $FldDefaultErrMsg; // Default error message
var $VirtualValue; // Virtual field value
var $TooltipValue; // Field tooltip value
var $TooltipWidth = 0; // Field tooltip width
var $FldType; // Field type
var $FldDataType; // PHPMaker Field type
var $AdvancedSearch; // AdvancedSearch Object
var $Upload; // Upload Object
var $FldDateTimeFormat; // Date time format
var $CssStyle; // CSS style
var $CssClass; // CSS class
var $ImageAlt; // Image alt
var $ImageWidth = 0; // Image width
var $ImageHeight = 0; // Image height
var $ImageResize = FALSE; // Image resize
var $ViewCustomAttributes; // View custom attributes
var $EditCustomAttributes; // Edit custom attributes
var $Count; // Count
var $Total; // Total
var $TrueValue = '1';
var $FalseValue = '0';
var $Visible = TRUE; // Visible
var $Disabled; // Disabled
var $TruncateMemoRemoveHtml; // Remove HTML from memo field
var $CustomMsg = ""; // Custom message
var $CellCssClass = ""; // Cell CSS class
var $CellCssStyle = ""; // Cell CSS style
var $CellCustomAttributes = ""; // Cell custom attributes
var $MultiUpdate; // Multi update
var $OldValue; // Old Value
var $ConfirmValue; // Confirm value
var $CurrentValue; // Current value
var $ViewValue; // View value
var $EditValue; // Edit value
var $EditValue2; // Edit value 2 (search)
var $HrefValue; // Href value
var $HrefValue2; // Href value 2 (confirm page upload control)
var $FormValue; // Form value
var $QueryStringValue; // QueryString value
var $DbValue; // Database value
var $Sortable = TRUE; // Sortable
var $UploadPath = EW_UPLOAD_DEST_PATH; // Upload path
var $CellAttrs = array(); // Cell custom attributes
var $EditAttrs = array(); // Edit custom attributes
var $ViewAttrs = array(); // View custom attributes
// Constructor
function cField($tblvar, $tblname, $fldvar, $fldname, $fldexp, $fldtype, $flddtfmt, $upload, $fldvirtualexp, $fldvirtual) {
$this->TblVar = $tblvar;
$this->TblName = $tblname;
$this->FldVar = $fldvar;
$this->FldName = $fldname;
$this->FldExpression = $fldexp;
$this->FldType = $fldtype;
$this->FldDataType = ew_FieldDataType($fldtype);
$this->FldDateTimeFormat = $flddtfmt;
$this->AdvancedSearch = new cAdvancedSearch();
if ($upload)
$this->Upload = new cUpload($this->TblVar, $this->FldVar);
$this->FldVirtualExpression = $fldvirtualexp;
$this->FldIsVirtual = $fldvirtual;
}
// Field caption
function FldCaption() {
global $Language;
return $Language->FieldPhrase($this->TblVar, substr($this->FldVar, 2), "FldCaption");
}
// Field title
function FldTitle() {
global $Language;
return $Language->FieldPhrase($this->TblVar, substr($this->FldVar, 2), "FldTitle");
}
// Field image alt
function FldAlt() {
global $Language;
return $Language->FieldPhrase($this->TblVar, substr($this->FldVar, 2), "FldAlt");
}
// Field error message
function FldErrMsg() {
global $Language;
$err = $Language->FieldPhrase($this->TblVar, substr($this->FldVar, 2), "FldErrMsg");
if ($err == "") $err = $this->FldDefaultErrMsg . " - " . $this->FldCaption();
return $err;
}
// View Attributes
function ViewAttributes() {
$sAtt = "";
$sStyle = trim($this->CssStyle);
if (@$this->ViewAttrs["style"] <> "")
$sStyle .= " " . $this->ViewAttrs["style"];
$sClass = trim($this->CssClass);
if (@$this->ViewAttrs["class"] <> "")
$sClass .= " " . $this->ViewAttrs["class"];
if (trim($sStyle) <> "")
$sAtt .= " style=\"" . trim($sStyle) . "\"";
if (trim($sClass) <> "")
$sAtt .= " class=\"" . trim($sClass) . "\"";
if (trim($this->ImageAlt) <> "")
$this->ViewAttrs["alt"] = trim($this->ImageAlt);
if (intval($this->ImageWidth) > 0 && (!$this->ImageResize || ($this->ImageResize && intval($this->ImageHeight) <= 0)))
$this->ViewAttrs["width"] = intval($this->ImageWidth);
if (intval($this->ImageHeight) > 0 && (!$this->ImageResize || ($this->ImageResize && intval($this->ImageWidth) <= 0)))
$this->ViewAttrs["height"] = intval($this->ImageHeight);
foreach ($this->ViewAttrs as $k => $v) {
if ($k <> "style" && $k <> "class" && trim($v) <> "")
$sAtt .= " " . $k . "=\"" . trim($v) . "\"";
}
if (trim($this->ViewCustomAttributes) <> "")
$sAtt .= " " . trim($this->ViewCustomAttributes);
return $sAtt;
}
// Edit attributes
function EditAttributes() {
$sAtt = "";
$sStyle = trim($this->CssStyle);
if (@$this->EditAttrs["style"] <> "")
$sStyle .= " " . $this->EditAttrs["style"];
$sClass = trim($this->CssClass);
if (@$this->EditAttrs["class"] <> "")
$sClass .= " " . $this->EditAttrs["class"];
if (trim($sStyle) <> "")
$sAtt .= " style=\"" . trim($sStyle) . "\"";
if ($sClass <> "")
$sAtt .= " class=\"" . trim($sClass) . "\"";
if ($this->Disabled)
$this->EditAttrs["disabled"] = "disabled";
foreach ($this->EditAttrs as $k => $v) {
if ($k <> "style" && $k <> "class" && trim($v) <> "")
$sAtt .= " " . $k . "=\"" . trim($v) . "\"";
}
if (trim($this->EditCustomAttributes) <> "")
$sAtt .= " " . trim($this->EditCustomAttributes);
return $sAtt;
}
// Cell styles
function CellStyles() {
$sAtt = "";
$sStyle = trim($this->CellCssStyle);
if (@$this->CellAttrs["style"] <> "")
$sStyle .= " " . $this->CellAttrs["style"];
$sClass = trim($this->CellCssClass);
if (@$this->CellAttrs["class"] <> "")
$sClass .= " " . $this->CellAttrs["class"];
if (trim($sStyle) <> "")
$sAtt .= " style=\"" . trim($sStyle) . "\"";
if (trim($sClass) <> "")
$sAtt .= " class=\"" . trim($sClass) . "\"";
return $sAtt;
}
// Cell attributes
function CellAttributes() {
$sAtt = $this->CellStyles();
foreach ($this->CellAttrs as $k => $v) {
if ($k <> "style" && $k <> "class" && trim($v) <> "")
$sAtt .= " " . $k . "=\"" . trim($v) . "\"";
}
if (trim($this->CellCustomAttributes) <> "")
$sAtt .= " " . trim($this->CellCustomAttributes);
return $sAtt;
}
// Sort
function getSort() {
return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TblVar . "_" . EW_TABLE_SORT . "_" . $this->FldVar];
}
function setSort($v) {
if (@$_SESSION[EW_PROJECT_NAME . "_" . $this->TblVar . "_" . EW_TABLE_SORT . "_" . $this->FldVar] <> $v) {
$_SESSION[EW_PROJECT_NAME . "_" . $this->TblVar . "_" . EW_TABLE_SORT . "_" . $this->FldVar] = $v;
}
}
function ReverseSort() {
return ($this->getSort() == "ASC") ? "DESC" : "ASC";
}
// List view value
function ListViewValue() {
if ($this->FldDataType == EW_DATATYPE_XML) {
return $this->ViewValue . " ";
} else {
$value = trim(strval($this->ViewValue));
if ($value <> "") {
$value2 = trim(preg_replace('/<[^img][^>]*>/i', '', strval($value)));
return ($value2 <> "") ? $this->ViewValue : " ";
} else {
return " ";
}
}
}
// Export caption
function ExportCaption() {
return (EW_EXPORT_FIELD_CAPTION) ? $this->FldCaption() : $this->FldName;
}
// Export value
function ExportValue($Export, $Original) {
$ExportValue = ($Original) ? $this->CurrentValue : $this->ViewValue;
if ($Export == "xml" && is_null($ExportValue))
$ExportValue = "<Null>";
return $ExportValue;
}
// Form value
function setFormValue($v) {
$this->FormValue = ew_StripSlashes($v);
if (is_array($this->FormValue))
$this->FormValue = implode(",", $this->FormValue);
$this->CurrentValue = $this->FormValue;
}
// Old value (from $_POST)
function setOldValue($v) {
$this->OldValue = ew_StripSlashes($v);
if (is_array($this->OldValue)) {
$this->OldValue = implode(",", $this->OldValue);
} else {
$this->OldValue = $v;
}
}
// QueryString value
function setQueryStringValue($v) {
$this->QueryStringValue = ew_StripSlashes($v);
$this->CurrentValue = $this->QueryStringValue;
}
// Database value
function setDbValue($v) {
$this->DbValue = $v;
$this->CurrentValue = $this->DbValue;
}
// Set database value with error default
function SetDbValueDef(&$rs, $value, $default, $skip = FALSE) {
if (($skip && strval($value) == "") || !$this->Visible || $this->Disabled)
return;
switch ($this->FldType) {
case 2:
case 3:
case 16:
case 17:
case 18: // Integer
$value = trim($value);
$DbValue = (is_numeric($value)) ? intval($value) : $default;
break;
case 19:
case 20:
case 21: // Big integer
$value = trim($value);
$DbValue = (is_numeric($value)) ? $value : $default;
break;
case 5:
case 6:
case 14:
case 131: // Double
case 139:
case 4: // Single
$value = trim($value);
$value = ew_StrToFloat($value);
$DbValue = (is_numeric($value)) ? $value : $default;
break;
case 7:
case 133:
case 134:
case 135: // Date
case 141: // XML
case 145: // Time
case 146: // DateTiemOffset
case 201:
case 203:
case 129:
case 130:
case 200:
case 202: // String
$value = trim($value);
$DbValue = ($value == "") ? $default : $value;
break;
case 128:
case 204:
case 205: // Binary
$DbValue = (is_null($value)) ? $default : $value;
break;
case 72: // GUID
$value = trim($value);
$DbValue = ($value <> "" && ew_CheckGUID($value)) ? $value : $default;
break;
case 11: // Boolean
$DbValue = (is_bool($value) || is_numeric($value)) ? $value : $default;
break;
default:
$DbValue = $value;
}
$this->setDbValue($DbValue);
$rs[$this->FldName] = $this->DbValue;
}
// Session value
function getSessionValue() {
return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TblVar . "_" . $this->FldVar . "_SessionValue"];
}
function setSessionValue($v) {
$_SESSION[EW_PROJECT_NAME . "_" . $this->TblVar . "_" . $this->FldVar . "_SessionValue"] = $v;
}
}
/**
* List option collection class
*/
class cListOptions {
var $Items = array();
var $CustomItem = "";
// Add and return a new option (return-by-reference is for PHP 5 only)
function &Add($Name) {
$item = new cListOption($Name);
$this->Items[$Name] = $item;
return $item;
}
// Load default settings
function LoadDefault() {
$this->CustomItem = "";
foreach ($this->Items as $key => $item)
$this->Items[$key]->Body = "";
}
// Hide all options
function HideAllOptions() {
foreach ($this->Items as $key => $item)
$this->Items[$key]->Visible = FALSE;
}
// Show all options
function ShowAllOptions() {
foreach ($this->Items as $key => $item)
$this->Items[$key]->Visible = TRUE;
}
// Get item by name (return-by-reference is for PHP 5 only)
// predefined names: view/edit/copy/delete/detail_<DetailTable>/userpermission/checkbox
function &GetItem($Name) {
$item = array_key_exists($Name, $this->Items) ? $this->Items[$Name] : NULL;
return $item;
}
// Move item to position
function MoveItem($Name, $Pos) {
$cnt = count($this->Items);
if ($Pos < 0 || $Pos >= $cnt)
return;
$item = $this->GetItem($Name);
if ($item) {
$item = ew_Clone($item);
unset($this->Items[$Name]);
$this->Items = array_merge(array_slice($this->Items, 0, $Pos),
array($Name => $item), array_slice($this->Items, $Pos));
}
}
// Render list options
function Render($Part, $Pos) {
$ShowTd = ($Pos <> "bottom");
if ($this->CustomItem <> "") {
$cnt = 0;
foreach ($this->Items as $key => $item) {
$item = $this->Items[$key];
if ($item->Visible && $this->ShowPos($item->OnLeft, $Pos))
$cnt++;
if ($item->Name == $this->CustomItem)
$opt = $item;
}
if (is_object($opt) && $cnt > 0) {
if ($this->ShowPos($opt->OnLeft, $Pos)) {
echo $opt->Render($Part, $ShowTd, $cnt);
} else {
echo $opt->Render("", $ShowTd, $cnt);
}
}
} else {
foreach ($this->Items as $key => $item) {
$item = $this->Items[$key];
if ($item->Visible && $this->ShowPos($item->OnLeft, $Pos))
echo $item->Render($Part, $ShowTd);
}
}
}
function ShowPos($OnLeft, $Pos) {
return ($OnLeft && $Pos == "left") || (!$OnLeft && $Pos == "right") || ($Pos == "bottom");
}
}
/**
* List option class
*/
class cListOption {
var $Name;
var $OnLeft;
var $CssStyle;
var $Visible = TRUE;
var $Header;
var $Body;
var $Footer;
function cListOption($Name) {
$this->Name = $Name;
}
function Render($Part, $ShowTd, $ColSpan = 1) {
if ($Part == "header") {
$value = $this->Header;
} elseif ($Part == "body") {
$value = $this->Body;
} elseif ($Part == "footer") {
$value = $this->Footer;
} else {
$value = $Part;
}
$td = "";
if ($ShowTd) {
$td = "<td";
if ($this->CssStyle <> "")
$td .= " style=\"" . $this->CssStyle . "\"";
if ($ColSpan > 1)
$td .= " colspan=\"" . $ColSpan . "\"";
$td .= ">";
}
if (strval($value) <> "") {
$res = "<span class=\"phpmaker\">" . $value . "</span>";
if ($td <> "") {
$res = $td . $res . "</td>";
} else {
$res .= " ";
}
} else {
if ($td <> "") {
$res = $td . "<span class=\"phpmaker\"> </span></td>";
} else {
$res = "";
}
}
return $res;
}
}
?>
<?php
/**
* Advanced Search class
*/
class cAdvancedSearch {
var $SearchValue; // Search value
var $SearchOperator; // Search operator
var $SearchCondition; // Search condition
var $SearchValue2; // Search value 2
var $SearchOperator2; // Search operator 2
}
?>
<?php
/**
* Upload class
*/
class cUpload {
var $Index = 0; // Index for multiple form elements
var $TblVar; // Table variable
var $FldVar; // Field variable
var $Message; // Error message
var $DbValue; // Value from database
var $Value = NULL; // Upload value
var $Action; // Upload action
var $FileName; // Upload file name
var $FileSize; // Upload file size
var $ContentType; // File content type
var $ImageWidth; // Image width
var $ImageHeight; // Image height
var $Error; // Upload error
// Constructor
function cUpload($TblVar, $FldVar, $Binary = FALSE) {
$this->TblVar = $TblVar;
$this->FldVar = $FldVar;
}
function getSessionID() {
return EW_PROJECT_NAME . "_" . $this->TblVar . "_" . $this->FldVar . "_" . $this->Index;
}
// Save value to Session
function SaveDbToSession() {
$sSessionID = $this->getSessionID();
$_SESSION[$sSessionID . "_DbValue"] = $this->DbValue;
}
// Restore value from Session
function RestoreDbFromSession() {
$sSessionID = $this->getSessionID();
$this->DbValue = @$_SESSION[$sSessionID . "_DbValue"];
}