MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
tablecontrols.class
Ir para a documentação deste ficheiro.
1
<?php
2
3
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4
# Table
5
# Class for html tables
6
# - Rows, Cols and Content are 0-based
7
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8
9
class
MTable
extends
MControl
10
{
11
var
$table
;
12
var
$rowAttr
;
13
var
$cellAttr
;
14
15
function
__construct
(
$table
, $tableAttr,
$rowAttr
,
$cellAttr
)
16
{
17
parent::__construct();
18
$this->table =
$table
;
19
$this->SetAttributes($tableAttr);
20
$this->rowAttr =
$rowAttr
;
21
$this->cellAttr =
$cellAttr
;
22
}
23
}
24
25
class
MSimpleTable
extends
MTable
26
{
27
var
$cell
;
28
var
$attributes
;
29
30
function
__construct
(
$name
=
''
,
$attrs
=
''
, $row=1,
$cell
=1)
31
{
32
mcontrol::__construct(
$name
);
33
34
if
(
$attrs
==
''
)
35
{
36
$attrs
=
"cellspacing=0 cellpadding=0 border=0 width=100%"
;
37
}
38
else
39
{
40
$attrs
= str_replace(
"\""
,
''
,
$attrs
);
41
}
42
43
$this->
setAttributes
(
$attrs
);
44
$this->
setClass
( $this->attrs->items[
'class'
] );
45
46
for
($i=0; $i < $row; $i++)
47
{
48
$this->
attributes
[
'row'
][$i] =
''
;
49
50
for
($j=0; $j <
$cell
; $j++)
51
{
52
$this->
attributes
[
'cell'
][$i][$j] =
''
;
53
}
54
}
55
}
56
57
function
setRowAttribute
($i,
$name
, $attr)
58
{
59
$this->
attributes
[
'row'
][$i] .=
" $name=\"$attr\" "
;
60
}
61
62
function
setCellAttribute
($i, $j,
$name
, $attr)
63
{
64
$this->
attributes
[
'cell'
][$i][$j] .=
" $name=\"$attr\" "
;
65
}
66
67
function
setRowClass
($i,$class)
68
{
69
$this->
attributes
[
'row'
][$i] .=
" class=\"$class\" "
;
70
}
71
72
function
setCellClass
($i,$j,$class)
73
{
74
$this->
attributes
[
'cell'
][$i][$j] .=
" class=\"$class\" "
;
75
}
76
77
function
setCell
($i,$j,$content,
$attrs
=
''
)
78
{
79
$this->cell[$i][$j] = $content;
80
$this->
attributes
[
'cell'
][$i][$j] .=
$attrs
;
81
}
82
83
function
generate
()
84
{
85
$n = count($this->cell);
86
87
for
($i=0; $i<$n; $i++)
88
{
89
$k = count($this->cell[$i]);
90
91
for
($j=0; $j<$k; $j++)
92
{
93
$table
[$i][$j] = $this->painter->generateToString($this->cell[$i][$j]);
94
}
95
}
96
//$t = new MTable($table, $this->Attributes(),$this->attributes['row'],$this->attributes['cell']);
97
$this->table =
$table
;
98
//$this->SetAttributes( $tableAttr );
99
$this->rowAttr = $this->
attributes
[
'row'
];
//$rowAttr;
100
$this->cellAttr = $this->
attributes
[
'cell'
];
//$cellAttr;
101
102
return
$this->
getRender
(
'table'
);
103
}
104
105
}
106
107
class
MTableRaw
extends
MSimpleTable
108
{
109
var
$title
;
110
var
$array
;
111
var
$colTitle
;
112
var
$zebra
=
false
;
113
var
$table
;
114
var
$setBorder
=
false
;
115
var
$fixedColumnHeader
=
false
;
116
117
function
__construct
(
$title
=
''
,
$array
,
$colTitle
=
null
)
118
{
119
parent::__construct(
''
);
120
$this->title =
$title
;
121
$this->array = &
$array
;
122
$this->colTitle =
$colTitle
;
123
124
// JS's referente ao cabeçalho fixo conforme rolagem
125
$MIOLO
=
MIOLO::getInstance
();
126
$this->page->addScript(
"../themes/{$MIOLO->getTheme()->getName()}/scripts/fixed_table_header.js"
);
127
}
128
129
function
SetAlternate
(
$zebra
=
false
)
130
{
131
$this->zebra =
$zebra
;
132
}
133
134
function
Generate
()
135
{
136
$title
=
$this->title
;
137
$array
=
$this->array
;
138
$colTitle
=
$this->colTitle
;
139
140
$tbodyId =
'tbody'
.
$this->id
;
141
$bodyId =
'body'
.
$this->id
;
142
143
$t =
new
SimpleTable
($tbodyId);
144
145
if
( $this->fixedColumnHeader )
146
{
147
$this->page->onLoad(
148
"if (typeof $('#{$tbodyId}').stickyTableHeaders == 'function' ) $('#{$tbodyId}').stickyTableHeaders();"
.
149
"$('#{$bodyId}').on('scroll', function(){\$('#{$tbodyId}').stickyTableHeaders();});"
150
);
151
152
if
( !$this->title )
153
{
154
$t->attributes[
'row'
][0] =
"class=\"m-grid-row-heading\""
;
155
}
156
else
157
{
158
$t->attributes[
'row'
][1] =
"class=\"m-grid-row-heading\""
;
159
}
160
}
161
162
$t->SetClass(
"m-tableraw"
);
163
$t->SetAttributes(
'cellspacing=1 cellpadding=3 class="table"'
);
164
if
( $this->setBorder )
165
{
166
$t->SetAttributes(
'border=1'
);
167
}
168
$k = 0;
169
if
(
$title
)
170
{
171
$ncols = count(
$colTitle
);
172
$t->SetCell($k++,0,
$title
,
" class=\"m-tableraw-title\" colspan=$ncols "
);
173
}
174
if
(is_array(
$colTitle
))
175
{
176
$n = count(
$colTitle
);
177
for
($i=0;$i<$n;$i++)
178
$t->SetCell($k,$i,
$colTitle
[$i],
" class=\"m-tableraw-column-title\" "
);
179
$k++;
180
}
181
if
(is_array(
$array
))
182
{
183
$nrows = count(
$array
);
184
for
($i=0; $i<$nrows; $i++)
185
{
186
$rowClass =
"m-tableraw-row"
. ($this->zebra ?
'-'
.($i%2) :
''
);
187
$t->SetRowClass($k, $rowClass);
188
if
(is_array(
$array
[$i]))
189
{
190
$ncols = count(
$array
[$i]);
191
for
($j=0; $j<$ncols; $j++)
192
{
193
$attr = $this->
attributes
[
'cell'
][$i][$j];
194
if
($attr ==
''
) $attr =
"width=0 align=\"left\" valign=\"top\""
;
195
$t->SetCell($k,$j,
$array
[$i][$j],$attr);
196
197
}
198
}
199
else
200
{
201
$attr = $this->
attributes
[
'cell'
][$i][0];
202
if
($attr ==
''
) $attr =
"width=0 align=\"left\" valign=\"top\""
;
203
$t->SetCell($k,0,
$array
[$i], $attr);
204
}
205
$k++;
206
}
207
}
208
209
if
( strpos(
MIOLO::getInstance
()->getTheme()->
id
,
"sbootstrap"
) !==
false
)
210
{
211
$divTable =
new
MDiv
(
'divTable'
. $this->
id
, $t,
'm-grid-body'
);
212
$divTable->addBoxStyle(
'overflow'
,
'auto'
);
213
214
//barra de rolagem flutuante
215
$this->page->onload(
"$('.m-grid-body').floatingScroll();"
);
216
$this->page->onload(
"$('.fl-scrolls').css('margin-bottom', '2.6%');"
);
217
218
return
$divTable->generate();
219
}
220
221
return
$t->Generate();
222
}
223
224
}
225
226
class
MTableXml
extends
MTableRaw
227
{
228
function
__construct
(
$title
=
''
, $file,
$colTitle
=
null
)
229
{
230
$xmlTree =
new
XMLTree
($file);
231
$array
= $xmlTree->getXMLTreeAsArray();
232
parent::__construct(
$title
,
$array
,
$colTitle
);
233
}
234
}
235
236
class
TableCell
extends
MControl
237
{
238
var
$content
;
239
var
$attributes
;
240
var
$separator
;
241
var
$contentCount
;
242
243
function
__construct
()
244
{
245
parent::__construct();
246
$this->
attributes
= array();
247
$this->content = array();
248
$this->contentCount = 0;
249
$this->cssclass =
'ThemeTableCell'
;
250
$this->separator =
'<br/>'
;
251
}
252
253
function
SetAttributes
($attr)
254
{
255
foreach
($attr as $a=>$v) $this->
attributes
[$a] = $v;
256
}
257
258
function
SetAttribute
($attr,$value)
259
{
260
$this->
attributes
[$attr] = $value;
261
}
262
263
function
SetContent
(
$content
)
264
{
265
$this->content = array(
$content
);
266
$this->contentCount = 1;
267
}
268
269
function
GetContent
($pos=0)
270
{
271
if
($pos < $this->contentCount) {
272
return
$this->content[$pos];
273
}
274
return
null
;
275
}
276
277
function
ClearContent
()
278
{
279
$this->content = array();
280
$this->contentCount = 0;
281
}
282
283
function
AddContent
(
$content
)
284
{
285
$this->content[] =
$content
;
286
$this->contentCount++;
287
}
288
}
289
290
class
TableRow
extends
MControl
291
{
292
var
$cell
;
// array of Cell object
293
var
$attributes
;
294
var
$cellCount
;
295
296
function
__construct
()
297
{
298
parent::__construct();
299
$this->cell = array();
300
$this->
attributes
= array (
301
'align'
=>
''
,
302
'valign'
=>
''
303
);
304
$this->cssclass =
'ThemeTableRow'
;
305
$this->cellCount = 0;
306
}
307
308
function
SetAttributes
($attr)
309
{
310
foreach
($attr as $a=>$v) $this->
attributes
[$a] = $v;
311
}
312
313
function
SetAttribute
($attr,$value)
314
{
315
$this->
attributes
[$attr] = $value;
316
}
317
318
function
AddCell
()
319
{
320
$this->cell[$c = $this->cellCount++] =
new
TableCell
();
321
return
$c;
322
}
323
324
function
RemoveCell
(
$cell
)
325
{
326
if
(($this->cellCount > 0) && ($this->cellCount >
$cell
))
327
{
328
array_splice($this->cell,
$cell
, 1);
329
$this->cellCount--;
330
}
331
}
332
333
function
GetCell
(
$cell
)
334
{
335
if
($this->ncells >
$cell
)
336
{
337
return
$this->cell[
$cell
];
338
}
339
return
null
;
340
}
341
}
342
343
?>
MComponent\$name
$name
Definição
mcomponent.class:17
MControl
Definição
mcontrol.class:35
MControl\setAttributes
setAttributes($attr)
Definição
mcontrol.class:462
MControl\attributes
attributes( $mergeDuplicates=false)
Definição
mcontrol.class:486
MControl\setClass
setClass( $cssClass, $add=true)
Definição
mcontrol.class:398
MControl\getRender
getRender( $method)
Definição
mcontrol.class:833
MControl\$id
$id
Definição
mcontrol.class:69
MControl\$attrs
$attrs
Definição
mcontrol.class:100
MDiv
Definição
blockcontrols.class:23
MIOLO\getInstance
static getInstance()
Definição
miolo.class:134
MSimpleTable
Definição
tablecontrols.class:26
MSimpleTable\setCell
setCell($i, $j, $content, $attrs='')
Definição
tablecontrols.class:77
MSimpleTable\setRowClass
setRowClass($i, $class)
Definição
tablecontrols.class:67
MSimpleTable\$cell
$cell
Definição
tablecontrols.class:27
MSimpleTable\setCellAttribute
setCellAttribute($i, $j, $name, $attr)
Definição
tablecontrols.class:62
MSimpleTable\generate
generate()
Definição
tablecontrols.class:83
MSimpleTable\setRowAttribute
setRowAttribute($i, $name, $attr)
Definição
tablecontrols.class:57
MSimpleTable\$attributes
$attributes
Definição
tablecontrols.class:28
MSimpleTable\__construct
__construct($name='', $attrs='', $row=1, $cell=1)
Definição
tablecontrols.class:30
MSimpleTable\setCellClass
setCellClass($i, $j, $class)
Definição
tablecontrols.class:72
MTableRaw
Definição
tablecontrols.class:108
MTableRaw\$colTitle
$colTitle
Definição
tablecontrols.class:111
MTableRaw\Generate
Generate()
Definição
tablecontrols.class:134
MTableRaw\$fixedColumnHeader
$fixedColumnHeader
Definição
tablecontrols.class:115
MTableRaw\$setBorder
$setBorder
Definição
tablecontrols.class:114
MTableRaw\$array
$array
Definição
tablecontrols.class:110
MTableRaw\SetAlternate
SetAlternate($zebra=false)
Definição
tablecontrols.class:129
MTableRaw\$title
$title
Definição
tablecontrols.class:109
MTableRaw\__construct
__construct($title='', $array, $colTitle=null)
Definição
tablecontrols.class:117
MTableRaw\$table
$table
Definição
tablecontrols.class:113
MTableRaw\$zebra
$zebra
Definição
tablecontrols.class:112
MTableXml
Definição
tablecontrols.class:227
MTableXml\__construct
__construct($title='', $file, $colTitle=null)
Definição
tablecontrols.class:228
MTable
Definição
tablecontrols.class:10
MTable\__construct
__construct($table, $tableAttr, $rowAttr, $cellAttr)
Definição
tablecontrols.class:15
MTable\$cellAttr
$cellAttr
Definição
tablecontrols.class:13
MTable\$rowAttr
$rowAttr
Definição
tablecontrols.class:12
MTable\$table
$table
Definição
tablecontrols.class:11
SimpleTable
Definição
compatibility.class:178
TableCell
Definição
tablecontrols.class:237
TableCell\__construct
__construct()
Definição
tablecontrols.class:243
TableCell\$contentCount
$contentCount
Definição
tablecontrols.class:241
TableCell\SetAttribute
SetAttribute($attr, $value)
Definição
tablecontrols.class:258
TableCell\SetContent
SetContent($content)
Definição
tablecontrols.class:263
TableCell\$content
$content
Definição
tablecontrols.class:238
TableCell\SetAttributes
SetAttributes($attr)
Definição
tablecontrols.class:253
TableCell\ClearContent
ClearContent()
Definição
tablecontrols.class:277
TableCell\AddContent
AddContent($content)
Definição
tablecontrols.class:283
TableCell\$separator
$separator
Definição
tablecontrols.class:240
TableCell\$attributes
$attributes
Definição
tablecontrols.class:239
TableCell\GetContent
GetContent($pos=0)
Definição
tablecontrols.class:269
TableRow
Definição
tablecontrols.class:291
TableRow\__construct
__construct()
Definição
tablecontrols.class:296
TableRow\SetAttribute
SetAttribute($attr, $value)
Definição
tablecontrols.class:313
TableRow\$cell
$cell
Definição
tablecontrols.class:292
TableRow\AddCell
AddCell()
Definição
tablecontrols.class:318
TableRow\$cellCount
$cellCount
Definição
tablecontrols.class:294
TableRow\SetAttributes
SetAttributes($attr)
Definição
tablecontrols.class:308
TableRow\GetCell
GetCell($cell)
Definição
tablecontrols.class:333
TableRow\$attributes
$attributes
Definição
tablecontrols.class:293
TableRow\RemoveCell
RemoveCell($cell)
Definição
tablecontrols.class:324
XMLTree
Definição
compatibility.class:51
$MIOLO
$MIOLO
Definição
mdatetimefield.class:25
classes
ui
controls
tablecontrols.class
Gerado por
1.10.0