This repository was archived by the owner on Feb 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhtml.class.php
More file actions
1574 lines (1543 loc) · 48.3 KB
/
Copy pathhtml.class.php
File metadata and controls
1574 lines (1543 loc) · 48.3 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
/**
* Class for creating a web page using only PHP.
* It supports connections to MySQL, Oracle and SQL Server.
* Allowing automate the creation of a complete website in a few lines of code.
*
* @todo Add HTML5 support
* @package PHP2HTML
* @version 1.0 BETA
* @author MANUEL GONZALEZ RIVERA <phptohtml@gmail.com>
* @copyright Copyright (R) 2012, MANUEL GONZALEZ RIVERA <phptohtml@gmail.com>
* @license http://opensource.org/licenses/MIT MIT
*/
ini_set( 'display_errors', 1 );
error_reporting(0);
set_exception_handler('captureException');
register_shutdown_function('captureShutdown');
require_once 'html.def.php';
require_once 'html.attributes.php';
require_once 'html.attributes.ext.php';
require_once 'html.actions.php';
/**
* Class for creating a web page using only PHP.
* It supports connections to MySQL, Oracle and SQL Server.
* Allowing automate the creation of a complete website in a few lines of code.
*
*
* @todo Code optimization
* @package PHP2HTML
* @version 1.0
* @author MANUEL GONZALEZ RIVERA <phptohtml@gmail.com>
* @copyright Copyright (R) 2012, MANUEL GONZALEZ RIVERA <phptohtml@gmail.com>
* @license http://opensource.org/licenses/MIT MIT
*/
class PHP2HTML{
/**
* Determines whether the class is in development mode.
* This allows you to show or hide the errors.
*
* @var Boolean
*/
private $DevelopMode;
/**
* Connection Type
*
* @var string Connection Type
*/
private $connType;
/**
* DocType
*
* @var string DocType
*/
private $docType;
/**
* Array for Meta tags
*
* @var array Meta tags
*/
private $meta_array = array();
/**
* Array with the CSS Files added
*
* @var array CSS Files
*/
private $css_array = array();
/**
* Array with the JS Files added
*
* @var array JS Files
*/
private $js_array = array();
/**
* Css Styles added
*
* @var string CSS styles
*/
private $css_style = array();
/**
* Header section (Js, CSS, Styles, Meta tags)
*
* @var string Header section
*/
private $head_scr = '';
/**
* Body section
*
* @var string Body section
*/
private $body_doc = '';
/**
* The css class for body tag
*
* @var string CSS body
*/
private $body_class='';
/**
*
* This is the active connection object
*
* @var object $Cnn Connection object
*/
public $Cnn;
/**
* Time when the class starts
* @var time
*/
private $start;
/**
* The time that the class is started.
*/
function Start(){
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$this->start = $time;
}
/**
* Time when the class ends
*/
function Ends(){
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $this->start), 4);
echo BK.'<!--Page generated in '.$total_time.' seconds.-->';
}
/**
* Initialize the class and set default meta data, css and js defined in html.var.php
*
* @param boolean $mode
*/
function __construct($mode=DEVELOP){
set_error_handler(array( $this, 'handleBasicError' ));
$this->Start();
$this->DevelopMode = $mode;
$this->docType(DOC_TYPE);
$this->Set_Meta();
$this->setConnType();
}
/**
* Ends the connection associated to class
*/
function __destruct() {
$this->letConnection();
$this->Ends();
}
/**
* Set the database connection used in the class.
* The class can use different connections types
* for example switching from Oracle to MySql and then
* to a Sql Server connection and retrieve data
* from diferent sources for different parts of the page.
* This use is restricted to only one connection at time
*
* Example:
* <code>
* $p = new PHP2HTML();
*
* //Set the parameters at execution time
* $p->setConnection("MyServer", "MyUser", "MyPass", "MyDB");
*
* //Use the default parameters stored in html.var.php
* $p->setConnection();
* </code>
*
* This variables could be set by default in the <strong>html.var.php</strong>
* and changed at execution time.
*
* @todo Add PostegreSQL support
* @param String $dbHost Database Host
* @param String $db_User Database User
* @param String $db_Pass User database Password
* @param String $db_Database Database name
* @param Boolean $db_persist Connection persistant
*
*/
function setConnection($dbHost = DB_HOST, $db_User = DB_USER, $db_Pass = DB_PASS, $db_Database = DB_DATABASE, $db_persist = DB_PERSIST){
if($this->connType=='none'){
$this->letConnection();
$this->Cnn = null;
}elseif($this->connType=='mssql'){
$this->Cnn = null;
require_once 'mssql.class.php';
$this->Cnn = new mssqlConn($this, $dbHost, $db_Database, $db_User, $db_Pass, $db_persist);
}elseif($this->connType=='mysql'){
$this->Cnn = null;
require_once 'mysql.class.php';
$this->Cnn = new mysqlConn($this, $dbHost, $db_Database, $db_User, $db_Pass, $db_persist);
}elseif($this->connType=='mysqli'){
$this->Cnn = null;
require_once 'mysqli.class.php';
$this->Cnn = new mysqliConn($this, $dbHost, $db_Database, $db_User, $db_Pass, $db_persist);
}elseif($this->connType=='oracle'){
$this->Cnn = null;
require_once 'oracle.class.php';
$this->Cnn = new oracleConn($this, $dbHost, $db_Database, $db_User, $db_Pass, $db_persist);
}else{
$this->Cnn = null;
}
}
/**
* Close the active connection
*
* @return null
*/
private function letConnection(){
if($this->Cnn!=null){
$this->Cnn->Close();
}
}
/**
* Sets the connection type that will be used to populate the
* contents of the page (none,mssql,oracle, mysql, mysqli).
* Is limited to one connection at time
* Example:
*
* <code>
* $p->setConnType('mysqli');
* </code>
*
* @param string $connType mysql|mysqli|oracle|mssql
*/
function setConnType($connType=CON_TYPE){
$this->connType=$connType;
}
/**
* Returns the connection object
*
* Example:
* <code>
* $myconn = $p->getConn();
* </code>
*
* @return object Returns the connection object
*/
function getConn(){
return $this->Cnn;
}
/**
* Gets the connection type that will be used to populate the contents of the page
* (none, mssql, mysql, oracle and mysqli)
*
* Example:
* <code>
* $p->setConnType("oracle");
* $connType = $p->getConn();
* echo $connType;
* //Prints Oracle
* </code>
*
* @return String Returns the active connection Type
*/
function getConnType(){
return $this->connType;
}
/**
* Sets the new DocType HTML document (Transitional, Estrict, ETC)
* Example:
*
* <code>
* $newDocType='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN..."';
* $p->docType($newDocType);
* </code>
*
* @param string $newDocType
*/
function doctype($newDocType){
$this->docType = $newDocType;
}
/**
* Sets the Body Class
*
* Example:
*
* <code>
* $p->BodyClass("myBodyClass");
* </code>
*
* @param string $class
*/
function BodyClass($class){
$this->body_class.=" ".$class;
}
/**
* Add the meta data defined by user in execution time
* or defined in html.var.php
*
* Example:
*
* <code>
* $p->Set_Meta("New Title for the page");
* </code>
*
* @param string $meta_title
* @param string $meta_content
* @param string $meta_charset
* @param string $meta_description
* @param string $meta_keywords
* @param string $meta_author
* @param string $meta_robots
*
* This variables could be set by default in the <strong>html.var.php</strong>
* and changed at execution time.
*/
function Set_Meta($meta_title = META_TITLE, $meta_content = META_CONTENT, $meta_charset = META_CHARSET, $meta_description = META_DESC, $meta_keywords = META_KEYWORD, $meta_author = META_AUTHOR, $meta_robots = META_ROBOTS){
$this->meta_array['m_lang'] = HTML_LANG;
$this->meta_array['m_contnt'] = $meta_content;
$this->meta_array['m_charst'] = $meta_charset;
$this->meta_array['m_ptitle'] = $meta_title;
$this->meta_array['m_descri'] = $meta_description;
$this->meta_array['m_keywor'] = $meta_keywords;
$this->meta_array['m_author'] = $meta_author;
$this->meta_array['m_robots'] = $meta_robots;
}
/**
* Add a user defined meta data definition
*
* @param String $meta Meta Name
* @param String $description Meta Description
*/
function Add_MetaData($meta, $description){
$this->meta_array[$meta] = $description;
}
/**
* Add a style to the header
*
* Example:
*
* <code>
* $myStyle= 'input{text-align:center;}';
* $p->Style($myStyle);
* </code>
*
* @param String $style
*/
function Add_Style($style){
array_push($this->css_style,$style);
}
/**
* Return to the user an array with the meta data definitions
*
* Example:
*
* <code>
* $myMeta= $p->Return_Meta();
* print_r($myMeta);
* </code>
*
* @return Array Returns array containing the meta tags
*/
function Return_Meta(){
return $this->meta_array;
}
/**
* Add a CSS file to the headers.
* If the file does not exists adds a comment
*
* Example:
*
* <code>
* $p->CSS('css/styles.css');
* </code>
*
* @param string Add the css link to the header
*/
function CSS($cssfile=""){
if(checkCurl()){
if(!strstr($cssfile,"http")){
if(file_exists($cssfile)){
$cssfile = '<link type="text/css" rel="stylesheet" href="'.$cssfile.'"/>';
array_push($this->css_array, $cssfile);
}else{
$this->Comment("The local file $cssfile does not exists");
}
}else{
if($this->remoteFileExists($cssfile)){
$cssfile = '<link type="text/css" rel="stylesheet" href="'.$cssfile.'"/>';
array_push($this->css_array, $cssfile);
}else{
$this->Comment("The external file $cssfile does not exists");
}
}
}else{
if(!strstr($cssfile,"http")){
$cssfile = '<link type="text/css" rel="stylesheet" href="'.$cssfile.'"/>';
array_push($this->css_array, $cssfile);
}else{
$this->Comment("The file $cssfile is external an CURL is deactivated");
$cssfile = '<link type="text/css" rel="stylesheet" href="'.$cssfile.'"/>';
array_push($this->css_array, $cssfile);
}
}
}
/**
* Return to the user the CSS files added
*
* Example:
*
* <code>
* $myCSSFiles= $p->Return_CSS();
* print_r($myCSSFiles);
* </code>
*
* @return Array Returns array containing the css files added
*/
function Return_CSS(){
return $this->css_array;
}
/**
* Add a JS file to the page header
* If the file does not exists adds a comment
*
* Example:
*
* <code>
* $p->JS('http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js');
* </code>
*
* @param string $jsfile
*/
function JS($jsfile){
if(checkCurl()){
if(!strstr($jsfile,"http")){
if(file_exists($jsfile)){
$jsfile = '<script type="text/javascript" src="'.$jsfile.'"></script>';
array_push($this->js_array, $jsfile);
}else{
$this->Comment("The local file $jsfile does not exists");
}
}else{
if($this->remoteFileExists($jsfile)){
$jsfile = '<script type="text/javascript" src="'.$jsfile.'"></script>';
array_push($this->js_array, $jsfile);
}else{
$this->Comment("The external file $jsfile does not exists");
}
}
}else{
if(!strstr($jsfile,"http")){
$jsfile = '<script type="text/javascript" src="'.$jsfile.'"></script>';
array_push($this->js_array, $jsfile);
}else{
$this->Comment("The file $jsfile is external an CURL is deactivated");
$jsfile = '<script type="text/javascript" src="'.$jsfile.'"></script>';
array_push($this->js_array, $jsfile);
}
}
}
/**
* Returns the array whitch contains the js libraries imported
*
* Example:
*
* <code>
* $myJSFiles= $p->Return_JS();
* print_r($myJSFiles);
* </code>
*
* @return array Returns array containig the JS files added
*/
function Return_JS(){
return $this->js_array;
}
/**
* Create de Page with the user defined contents
*
* @todo Validate and complete or remove this function
* @deprecated since version 0.1 alpha
* @param String $Template
*/
function CreateFromTemplate($Template){
$result = file_get_contents($Template);
$result = str_replace('{d_type}',DOC_TYPE, $result);
$meta_tag = $this->Return_Meta();
foreach ($meta_tag as $key=>$value) {
$result = str_replace('{'.$key.'}', $value, $result);
}
foreach($this->Return_CSS() as $value){
$result = str_replace('</head>',$value.BK."</head>".BK, $result);
}
foreach($this->Return_JS() as $value){
$result = str_replace('</head>',$value.BK."</head>".BK, $result);
}
$result = ($this->head_scr=='' ? $result : str_replace('</head>','<script type="text/javascript">'.$this->head_scr.BK."</script>".BK."</head>".BK, $result));
$result = ($this->body_doc=='' ? $result : str_replace('</body>',$this->body_doc.BK."</body>".BK, $result));
print $result;
}
/**
* Append an HTML Comment to the body
*
* Example:
*
* <code>
* $p->Comment('This is a HTML Comment');
* </code>
*
* @param String $comment
*/
function Comment($comment){
$this->body_doc = $this->body_doc .BK.'<!--'.$comment.'-->';
}
/**
* Append an HTML tag/string to the body
* Example:
*
* <code>
* $p->Body('Add something to the body');
* $p->Body('<span>Add something more to the body</span>');
* </code>
*
* @param string $htmlTags
*/
function Body($htmlTags){
$this->body_doc = $this->body_doc . $htmlTags;
}
/**
* Append a file content to the body
*
* Example:
*
* <code>
* $p->File('contents/myFile.txt');
* $p->File('../libs/myLib.js');
* </code>
*
* @param string $file
*/
function File($file){
$result = htmlspecialchars(utf8_decode(file_get_contents($file)));
if($result){
$this->body_doc = $this->body_doc .BK. $result;
}else{
$this->Comment("Error reading the file: $file");
}
}
/**
* Append a html file content to the body
*
* Example:
*
* <code>
* $p->HTML('contents/myPage.htm');
* $p->HTML('../libs/other.html');
* </code>
*
* @param string $file
*/
function HTML($file){
$result = utf8_decode(file_get_contents($file));
if($result){
$this->body_doc = $this->body_doc .BK. $result;
}else{
$this->Comment("Error reading the file: $file");
}
}
/**
* Append a php file
*
* Example:
*
* <code>
* $p->AddPHP('myfunctions.php');
* </code>
*
* @param String $file
*/
function AddPHP($file){
ob_start();
include($file);
$returned = ob_get_contents();
ob_end_clean();
$this->body_doc = $this->body_doc .BK. $returned;
}
/**
* Append a Javascript Code
*
* Example:
*
* <code>
* $myCode = '$("#target").click(function() {
* alert("Handler for .click() called.");
* });';
* $p->AddJS($myCode);
* </code>
*
* @param String Add a javascript code to the header
*/
function AddJS($code){
$this->head_scr = $this->head_scr.BK.$code.BK;
}
/**
* Add a html break line
*
* @param int $c The number of html breaks
*/
function HTMLbr($c=1){
for($i=0;$i<$c;$i++){
$this->body_doc = $this->body_doc.BK.br_;
}
}
/**
* Append a Form tag to the body
*
* Example:
*
* <code>
* $frmObj = $p->Text("", "", "txtName", "txtName");
* $frmObj.= $p->Pswd("", "", "txtPass", "txtPass");
* $frmObj.= $p->Btn(ST, "Go...");
* $p->Body($p->Form("myForm","POST","response.php", $frmObj));
* </code>
*
* @param String $name Form Name
* @param String $method Method Form POST/GET
* @param string $action Default Action
* @param String $objects Objects
* @param String $properties
* @return String
*/
function Form($name = "", $method = "", $action = "", $objects = "", $properties=""){
$form = $this->iT(form_, name($name). method($method). action($action). $properties);
$form.= BK. $objects;
$form.=_form;
return $form;
}
/**
* Returns the Password input
*
* Example:
*
* <code>
* $frmObj = $p->Text("", "25", "", "txtName", "txtName");
* $frmObj.= $p->Pswd("", "20", "", "txtPass", "txtPass");
* $frmObj.= $p->Btn(ST, "Go...");
* $p->Body($p->Form("myForm","POST","response.php", $frmObj));
* </code>
*
* @param String $value
* @param String $size
* @param String $class
* @param String $id
* @param String $name
* @param String $properties
* @return String
*/
function Pswd($value="", $size="", $class="", $id="", $name="", $properties=""){
$Pswd = '<input type="password"';
$Pswd.= size($size);
$Pswd.= cClass($class);
$Pswd.= id($id);
$Pswd.= name($name);
$Pswd.= ($properties==""? "":' '.$properties);
$Pswd.= value($value);
$Pswd.='>';
return $Pswd.BK;
}
/**
* Returns the Input text field
*
* Example:
*
* <code>
* $frmObj = $p->Text("", "25", "", "txtName", "txtName");
* $frmObj.= $p->Pswd("", "20", "", "txtPass", "txtPass");
* $frmObj.= $p->Btn(ST, "Go...");
* $p->Body($p->Form("myForm","POST","response.php", $frmObj));
* </code>
*
* @param String $value
* @param String $size
* @param String $class
* @param String $id
* @param String $name
* @param String $properties
* @return String
*/
function Text($value="", $size="", $class="",$id="", $name="", $properties=""){
$Text = '<input type="text"';
$Text.= size($size);
$Text.= cClass($class);
$Text.= id($id);
$Text.= name($name);
$Text.= ($properties==""? "":' '.$properties);
$Text.= value($value);
$Text.= '>';
return $Text.BK;
}
/**
* Returns a table
*
* @param String $data
* @param String $class
* @param String $id
* @param String $name
* @param String $properties
* @return String
*/
function tableField($data="", $class="",$id="", $name="", $properties=""){
$table = '<table ';
$table.= cClass($class);
$table.= id($id);
$table.= name($name);
$table.= ($properties==""? "":' '.$properties);
$table.= '>';
$table.= $data;
$table.= _table;
return $table;
}
/**
* Returns the table header
*
* @todo Complete the function
*
* @param String $class
* @param String $id
* @param String $name
* @param String $properties
* @return String
*/
function tableHead($class="",$id="", $name="", $properties=""){
return $tHead;
}
/**
* Returns the table body
*
* @todo Complete the function
*
* @param String $class
* @param String $id
* @param String $name
* @param String $properties
* @return String
*/
function tableBody($class="",$id="", $name="", $properties=""){
return $tBody;
}
/**
* Returns the table footer
*
* @todo Complete the function
*
* @param String $class
* @param String $id
* @param String $name
* @param String $properties
* @return String
*/
function tableFoot($class="",$id="", $name="", $properties=""){
return $tFoot;
}
/**
* Convert a query to table
*
*
* @param String $caption
* @param String $class
* @param String $id
* @param String $name
* @param String $properties
* @return String
*/
function query2Table($caption="",$class="",$id="", $name="", $properties=""){
if($this->connType=='none'){
$this->Comment("There is no valid resource to create the table.");
return null;
}else{
$cols = $this->Cnn->numColumns();
$rows = $this->Cnn->numRows();
$table_cols = "";
$table_rows = "";
$table = $this->iT(table_,
cClass($class).
id($id).
name($name).
' '. $properties);
$table.= ($caption== "" ? "": capt_ . $caption . _capt);
$n = 0;
while($this->Cnn->Fetch(false)){
if($n==0){
if($this->connType=='mssql'){
$table_cols = tr_;
for($i=0;$i<$cols;$i++){
$finfo = mssql_fetch_field($this->Cnn->rs,$i);
$table_cols.=th_.$finfo->name._th;
}
$table_cols.= _tr;
}elseif($this->connType=='mysql'){
$table_cols = tr_;
for($i=0;$i<$cols;$i++){
$finfo = mysql_fetch_field($this->Cnn->rs,$i);
$table_cols.=th_.$finfo->name._th;
}
$table_cols.= _tr;
}elseif($this->connType=='mysqli'){
$table_cols = tr_;
while ($finfo = mysqli_fetch_field($this->Cnn->rs)) {
$table_cols.=th_.$finfo->name._th;
}
$table_cols.= _tr;
}elseif($this->connType=='oracle'){
$table_cols = tr_;
for($i=0;$i<$cols;$i++){
$finfo = oci_field_name($this->Cnn->rs,$i);
$table_cols.=th_.$finfo->name._th;
}
$table_cols.= _tr;
}
}
$table_rows.= tr_;
for($colx=0; $colx<$cols; $colx++){
$table_rows.= td_ . $this->Cnn->row[$colx] ._td;
}
$table_rows.= _tr;
$n++;
}
$table.=$table_cols.$table_rows._table;
return $table;
}
}
/**
* Converts an array to table
*
* @todo Complete the function
*
* @param array $data
* @param array $ColsName
* @param string $class
* @param string $id
* @param string $name
* @param string $properties
* @return string
*/
function arrayToTableData($data=array(), $ColsName=array(), $class="",$id="", $name="", $properties=""){
return $table;
}
/**
* Converts a database recordset in array
*
* @param object $result
* @return array
*/
function db_result_array_values($result) {
$type=$this->getConnType();
if($type=='mysql'){
for ($array = array(); $row = mysql_fetch_row($result); isset($row[0]) ? $array[$row[0]] = $row[1] : $array[] = $row[1]);
}elseif($type=='mysqli'){
for ($array = array(); $row = mysqli_fetch_row($result); isset($row[0]) ? $array[$row[0]] = $row[1] : $array[] = $row[1]);
}elseif($type=='mssql'){
for ($array = array(); $row = mssql_fetch_row($result); isset($row[0]) ? $array[$row[0]] = $row[1] : $array[] = $row[1]);
}elseif($type=='oracle'){
for ($array = array(); $row = oci_fetch_row($result); isset($row[0]) ? $array[$row[0]] = $row[1] : $array[] = $row[1]);
}
return $array;
}
/**
* Returns a Combo witch is populated from an array
*
* Example:
* <code>
* $data = array();
*
* for($i=1;$i<=10;$i++){
* array_push($data, "Option ".$i);
* }
*
* $p->Body($p->Combo($data));
* </code>
*
* @param array $data
* @param bool $recordset
* @param string $selected
* @param string $class
* @param string $id
* @param string $name
* @param string $properties
* @return string
*/
function Combo($data = array(), $recordset = false, $selected="", $class="",$id="", $name="", $properties=""){
$combo = $this->iT(select_,
cClass($class).
id($id).
name($name).
($properties==""? "":' '.$properties)
).BK;
if($recordset==true){
$data = $this->db_result_array_values($data);
}
if($selected == ""){
$combo.= $this->iT(opt_, id("-1").selected_).SELECT_DEFAULT._opt;
foreach($data as $key=>$value){
$combo.= $this->iT(opt_, id($key)).$value._opt;
}
}else{
$combo.= $this->iT(opt_, id("-1")).SELECT_DEFAULT._opt;
foreach($data as $key=>$value){
if($selected == $key){
$combo.= $this->iT(opt_, id($key).selected_).$value._opt;
}else{
$combo.= $this->iT(opt_, id($key)).$value._opt;
}
}
}
$combo.=_select;
return $combo;
}
/**
* Returns a Check element
*
* Example:
*
* <code>
* $lb = $p->lblFor("Checkbox","chjs");
* $cj = $p->Check("ON", "chjs", "chjs", true, false);
* $p->Body($lb.$cj);
* </code>
*
* @param string $value
* @param boolean $checked
* @param boolean $disabled
* @param string $class
* @param string $id
* @param string $name
* @param string $properties
* @return string
*/
function Check($value ="", $checked=false, $disabled=false, $class="", $id="", $name="", $properties=""){
$check = '<input type="checkbox"';
$check.= cClass($class);
$check.= id($id);
$check.= name($name);
$check.= ($properties==""? "":' '.$properties);
$check.= ' value="'.$value.'">';
$check = ($checked ==false ? $check : str_replace('>',checked_.'>', $check));
$check = ($disabled==false ? $check : str_replace('>',disabled_.'>', $check));
return $check.BK;
}
/**
* Returns a ratio element
*
* Example:
*
* <code>
* $lb = $p->lblFor("Ratio button","rtbt");
* $rt = $p->Ratio("ON", "rtbt", "rtbt", true, false);
* $p->Body($lb.$rt);
* </code>
*
* @param string $value
* @param boolean $checked
* @param boolean $disabled
* @param string $class
* @param string $id
* @param string $name
* @param string $properties
* @return string
*/
function Ratio($value ="", $checked=false, $disabled=false, $class="", $id="", $name="", $properties=""){
$radio = '<input type="radio"';
$radio.= value($value);
$radio.= cClass($class);
$radio.= id($id);
$radio.= name($name);
$radio.= ($properties==""? "":' '.$properties);
$radio.= '>';
$radio = ($checked ==false ? $radio : str_replace('>',checked_.'>', $radio));
$radio = ($disabled==false ? $radio : str_replace('>',disabled_.'>', $radio));
return $radio;
}
/**
* Returns a Textarea Element
*
* Example:
*
* <code>
* $p->Body($p->Area());
* </code>
*
* @param string $value
* @param int $rows
* @param int $cols
* @param string $class
* @param string $id
* @param string $name
* @param string $properties
* @return string
*/
function Area($value ="", $rows=AREA_ROWS, $cols=AREA_COLS, $class="", $id="", $name="", $properties=""){