MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
minputgrid.class
Ir para a documentação deste ficheiro.
1
<?php
2
6
class
MInputGridColumn
extends
MFormControl
7
{
8
public
$colWidth
;
9
13
public
function
__construct
(
$name
,
$label
=
''
,
$colWidth
= 0,
$value
= array() )
14
{
15
parent::__construct(
$name
,
$value
,
$label
);
16
17
$this->colWidth =
$colWidth
;
18
}
19
}
20
21
25
class
MInputGrid
extends
MFormControl
26
{
27
public
$cols
;
// array of column definitions
28
protected
$numRows
;
// the number of rows
29
public
$numCols
;
// the number of cols
30
public
$aValue
;
// array com os valores dos campos
34
public
function
__construct
(
$name
,
$label
=
''
, $rows = 0 )
35
{
36
$this->numRows = $rows;
37
$this->numCols = 0;
38
39
parent::__construct(
$name
, array(),
$label
);
40
}
41
45
public
function
getRowCount
()
46
{
47
return
$this->numRows
;
48
}
49
53
public
function
setRowCount
( $rows )
54
{
55
$this->numRows = $rows;
56
}
57
61
public
function
addColumn
(
$label
,
$name
, $colWidth = 0,
$value
=
''
)
62
{
63
for
( $i = 0; $i <
$this->numRows
; $i++ )
64
{
65
$this->
setFieldValue
( $i + 1, $this->numCols + 1,
$value
);
66
}
67
68
$this->cols[$this->numCols++] =
new
MInputGridColumn
(
$label
,
$name
, $colWidth,
$value
);
69
}
70
74
public
function
generateInner
()
75
{
76
$t = array();
77
78
$t[0][0] =
''
;
79
80
for
( $i = 0; $i <
$this->numRows
; $i++ )
81
{
82
$t[$i + 1][0] = $this->painter->span(
new
Span
(
''
, ($i + 1) .
": "
,
MControl::CLASS_CAPTION
) );
83
}
84
85
foreach
( $this->cols as $col => $column )
86
{
87
$t[0][$col + 1] = $this->painter->span(
new
Span
(
''
, $column->label,
MControl::CLASS_CAPTION
) );
88
89
for
( $i = 0; $i <
$this->numRows
; $i++ )
90
{
91
if
( is_object( $column->value ) )
92
{
93
$text = clone($column->value);
94
}
95
else
96
{
97
$text =
new
TextField
(
"{$this->name}[$i][$col]"
, $this->aValue[$i][$col],
''
, $column->colWidth );
98
}
99
$text->setAttribute(
'rowNumber'
,
"$i"
);
100
$t[$i + 1][$col + 1] = $text->generate();
101
}
102
}
103
104
$table =
new
MTable
( $t, array(), array(), array() );
105
106
$this->inner = $table->getRender(
'table'
);
107
}
108
112
public
function
setValue
(
$value
)
113
{
114
if
( is_array(
$value
) && ( count($this->cols) > 0 ) )
115
{
116
foreach
( $this->cols as $col => $column )
117
{
118
for
( $i = 0; $i <
$this->numRows
; $i++ )
119
{
120
if
(
$value
[$i][$col] != NULL )
121
{
122
$this->
setFieldValue
( $i + 1, $col + 1,
$value
[$i][$col] );
123
}
124
}
125
}
126
}
127
}
128
132
public
function
getValue
()
133
{
134
return
$this->aValue
;
135
}
136
140
public
function
getFieldValue
( $row, $col, $default =
''
)
141
{
142
$value
= $this->aValue[$row - 1][$col - 1];
143
144
return
isset(
$value
) ?
$value
: $default;
145
}
146
150
public
function
setFieldValue
( $row, $col,
$value
)
151
{
152
$this->aValue[$row - 1][$col - 1] =
$value
;
153
}
154
158
public
function
getRow
( $row )
159
{
160
return
$this->aValue[$row - 1];
161
}
162
163
}
164
165
?>
MComponent\$name
$name
Definição
mcomponent.class:17
MControl\CLASS_CAPTION
const CLASS_CAPTION
Definição
mcontrol.class:46
MFormControl
Definição
mformcontrol.class:4
MFormControl\$value
$value
Definição
mformcontrol.class:6
MFormControl\$label
$label
Definição
mformcontrol.class:5
MInputGridColumn
Definição
minputgrid.class:7
MInputGridColumn\__construct
__construct( $name, $label='', $colWidth=0, $value=array())
Definição
minputgrid.class:13
MInputGridColumn\$colWidth
$colWidth
Definição
minputgrid.class:8
MInputGrid
Definição
minputgrid.class:26
MInputGrid\$aValue
$aValue
Definição
minputgrid.class:30
MInputGrid\generateInner
generateInner()
Definição
minputgrid.class:74
MInputGrid\$numRows
$numRows
Definição
minputgrid.class:28
MInputGrid\getRow
getRow( $row)
Definição
minputgrid.class:158
MInputGrid\__construct
__construct( $name, $label='', $rows=0)
Definição
minputgrid.class:34
MInputGrid\setRowCount
setRowCount( $rows)
Definição
minputgrid.class:53
MInputGrid\$numCols
$numCols
Definição
minputgrid.class:29
MInputGrid\$cols
$cols
Definição
minputgrid.class:27
MInputGrid\getValue
getValue()
Definição
minputgrid.class:132
MInputGrid\addColumn
addColumn( $label, $name, $colWidth=0, $value='')
Definição
minputgrid.class:61
MInputGrid\setValue
setValue( $value)
Definição
minputgrid.class:112
MInputGrid\getRowCount
getRowCount()
Definição
minputgrid.class:45
MInputGrid\getFieldValue
getFieldValue( $row, $col, $default='')
Definição
minputgrid.class:140
MInputGrid\setFieldValue
setFieldValue( $row, $col, $value)
Definição
minputgrid.class:150
MTable
Definição
tablecontrols.class:10
Span
Definição
compatibility.class:67
TextField
Definição
compatibility.class:132
classes
ui
controls
minputgrid.class
Gerado por
1.10.0