-
Notifications
You must be signed in to change notification settings - Fork 0
/
DIVBasedTable.php
155 lines (121 loc) · 3.89 KB
/
DIVBasedTable.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
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
<?php
/**
* DIVBasedTable Class File
*
* @author Muhammad Arfeen
* @license Freeware
*/
/**
* DIV based table generator provides a programatic way to generate
* table via DIV tags of HTML.
*
* @author Muhammad Arfeen
* @version 1.0
* @package DIVBasedTable
*/
class DIVBasedTable {
public $TableBackGroundColor;
public $TableBorderColor;
public $TableBorder;
public $TableWidth;
public $TableWidthCol;
public $TableWidthColNo;
public $HeaderCellStyle;
public $BodyRowCellStyle;
public $TableRowStyle;
private $FinalTable;
/**
* Start a DIV table
* @param string $TableAlign alignment for the table.
*/
public function StartTable($TableAlign = "center") {
$this->FinalTable .= "<DIV class='base-layer' align=\"$TableAlign\"> ";
}
/**
* Start a DIV table header row
* @param string $HeaderRowID a unique header id
* @param string $Style to provide custom inline CSS style
*/
public function StartHeader($HeaderRowID = "id", $Style = "") {
$this->FinalTable .= "<div class='MyTableRowClass' ID='" . $HeaderRowID . "' style='" . $Style . "'> ";
}
/**
* Add a header cell
* @param string $HeaderText to provide text for the header cell
* @param string $Style to provide custom inline CSS style
* @param string $TableAlign alignment for the cell.
*/
public function AddHeaderCell($HeaderText = "AddColumn", $Style = "", $TableAlign = "center") {
$this->FinalTable .= "<div class='MyMainTableRowClass' style='" . $Style . "' align=\"$TableAlign\"><h5 class='MyTableHeaderClass'>";
$this->FinalTable .= $HeaderText . "</h5></DIV>";
}
/**
* End a header row
*/
public function StopHeader() {
$this->FinalTable .= "</DIV>";
}
/**
* Add a table row
* @param string $BodyRowID a unique id for the row
* @param string $Style to provide custom inline CSS style
*/
public function StartTableRow($BodyRowID = "id", $Style = "") {
$this->FinalTable .= "<div class='MyTableRowClass' id='" . $BodyRowID . "' style='" . $Style . "'>";
}
/**
* Add a table row
* @param string $CellText text for the cell
* @param string $Style to provide custom inline CSS style
* @param string $TableAlign alignment for the cell.
*/
public function AddBodyCell($CellText = "BodyCell", $Style = "", $TableAlign = "center") {
$this->FinalTable .= "<div class='MyMainTableRowClass' style='" . $Style . "' align=\"$TableAlign\"><P class='MyTableCellTextClass'>";
$this->FinalTable .= $CellText . "</P></DIV>";
}
/**
* End a body row
*/
public function StopTableRow() {
$this->FinalTable .= "</DIV>";
}
/**
* End table
*/
public function CloseTable() {
$this->FinalTable .= "</DIV>";
}
/**
* Get final rendered table
* @return string
*/
public function GetFinalTable() {
return $this->FinalTable;
}
/**
* Generate CSS for the table
*/
public function GetCSS() {
$this->TableWidthCol = sprintf("%d", $this->TableWidth / $this->TableWidthColNo) . "%";
$this->FinalTable .= "<style>
DIV.base-layer {
border: solid #f8f8f8 1px;
" . $this->TableStyle . "; padding: 0; text-align: center; width: auto;
}
DIV.MyTableRowClass {
width: " . $this->TableWidth . ";
}
DIV.MyMainTableRowClass {
float: left; margin: 0; padding: 0; width: " . $this->TableWidthCol . "; " . $this->TableRowStyle . "
}
H5.MyTableHeaderClass {
" . $this->HeaderCellStyle . "
}
P.MyTableCellTextClass {
" . $this->BodyRowCellStyle . "
}
</style>
";
}
}
?>