MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mmultiselection.class
Ir para a documentação deste ficheiro.
1
<?php
2
class
MMultiSelectionField
extends
MListControl
3
{
4
var
$buttons
;
5
var
$fields
;
6
var
$showcode
;
7
var
$shownav
;
8
var
$layout
;
9
var
$codevalue
;
10
var
$info
;
11
var
$colWidth
;
12
var
$numRows
;
13
var
$fieldWidth
;
14
15
function
__construct
(
$name
=
''
,
$value
=
null
,
$label
=
''
,
$fields
=
''
, $width = 200,
$buttons
=
false
,
16
$info
=
''
,
$hint
=
''
)
17
{
18
parent::__construct(
$name
,
$label
,
null
,
null
,
$hint
);
19
$this->page->AddScript(
'm_multitext2.js'
);
20
$this->fields =
$fields
;
21
$this->colWidth = $width;
22
$this->buttons =
$buttons
;
23
$this->info =
$info
;
24
$this->layout =
'horizontal'
;
25
$this->fieldWidth = $width - 20;
26
$this->showcode =
false
;
27
$this->shownav =
false
;
28
$this->numRows = 5;
29
$this->formMode = 0;
30
}
31
32
function
GetCodeValue
()
33
{
34
$value
=
$this->value
;
35
36
if
(is_array(
$value
))
37
{
38
foreach
(
$value
as $v)
39
{
40
$n = count($this->fields);
41
42
for
($j = 0; $j < $n; $j++)
43
{
44
$options
= $this->fields[$j]->options;
45
$r = array_search($v,
$options
);
46
47
if
($r !==
false
)
48
$this->codevalue[] = $r;
49
}
50
}
51
}
52
53
return
$this->codevalue
;
54
}
55
56
function
SetCodeValue
(
$value
)
57
{
58
$this->codevalue =
$value
;
59
$r = array
60
(
61
);
62
63
if
(is_array(
$value
))
64
{
65
for
($i = 0; $i < count(
$value
); $i++)
66
{
67
$a =
$value
[$i];
68
69
if
(is_array($a))
// varios valores => varios fields
70
{
71
for
($j = 0; $j < count($a); $j++)
72
{
73
$options
= $this->fields[$j][3];
74
75
if
(
$options
)
76
{
77
$r[$i] .=
'['
.
$options
[
$value
[$i][$j]] .
'] '
;
78
}
79
else
80
{
81
$r[$i] .=
'['
.
$value
[$i][$j] .
'] '
;
82
}
83
}
84
}
85
else
// valor unico => apenas um field (na posicao 0)
86
{
87
$options
= $this->fields[0][3];
88
89
if
(
$options
)
90
{
91
$r[$i] .=
'['
.
$options
[$a] .
'] '
;
92
}
93
else
94
{
95
$r[$i] .=
'['
. $a .
'] '
;
96
}
97
}
98
}
99
}
100
101
$this->value = $r;
102
}
103
104
function
GenerateInner
()
105
{
106
$numFields = count($this->fields);
107
$this->page->OnSubmit(
"_MIOLO_MultiTextField2_onSubmit('{$this->form->name}','{$this->name}')"
);
108
109
// select
110
$labelS = $this->info .
" "
;
111
$content
= array
112
(
113
);
114
115
if
(is_array($this->value))
116
{
117
foreach
($this->value as $v)
118
{
119
$multiValue =
''
;
120
121
if
(is_array($v))
122
foreach
($v as $v2)
123
$multiValue .=
"["
. $v2 .
"] "
;
124
else
125
$multiValue = $v;
126
127
$content
[] =
new
MOption
(
''
, $multiValue, $multiValue);
128
}
129
}
130
131
$field =
new
MMultiSelection
(
"{$this->name}[]"
, array(), $labelS,
$content
,
''
,
''
, $this->numRows);
132
133
$field->_AddStyle(
'width'
,
"{$this->colWidth}px"
);
134
$field->AddAttribute(
'onKeyDown'
,
"return MIOLO_MultiTextField2_onKeyDown(this,this.form,'{$this->name}',event,$numFields);"
);
135
$field->AddAttribute(
'onChange'
,
"_MIOLO_MultiTextField2_onSelect(this.form,'{$this->name}', $numFields)"
);
136
$field->SetClass(
'select'
,
false
);
137
$field->formMode = 2;
138
$select = $field;
139
140
// fields - cada field é um selection
141
$fields
= array();
142
143
$n = 1;
144
145
foreach
($this->fields as $f)
146
{
147
$f->SetName(
"{$this->name}_options{$n}"
);
148
$f->SetClass(
'combo'
);
149
$btnAdd[$n] =
new
MButton
(
"{$this->name}_add{$n}"
,
'Adicionar'
,
150
"_MIOLO_MultiSelectionField_add(this.form,'{$this->name}','$n')"
);
151
$btnAdd[$n]->SetClass(
'button'
);
152
$b =
new
MDiv
(
''
, array(
new
Div
(
''
,
' '
,
'label'
), $btnAdd[$n]));
153
$f->_AddStyle(
'width'
,
"{$this->fieldWidth}px"
);
154
$f->formMode = 2;
155
$fields
[] =
new
MHContainer
(
''
,array($f,$b));
156
$n++;
157
}
158
159
// buttons
160
$b =
$buttons
[] =
new
MButton
(
"{$this->name}_remove"
,
'Remover'
,
161
"_MIOLO_MultiTextField2_remove(this.form,'{$this->name}',$numFields)"
);
162
$b->SetClass(
'button'
);
163
164
if
($this->shownav)
165
{
166
$b =
$buttons
[] =
new
MButton
(
"{$this->name}_up"
,
'/\\'
,
167
"_MIOLO_MultiTextField2_moveUp(this.form,'{$this->name}',$numFields)"
);
168
$b->SetClass(
'button'
);
169
$b =
$buttons
[] =
new
MButton
(
"{$this->name}_down"
,
'\\/'
,
170
"_MIOLO_MultiTextField2_moveDown(this.form,'{$this->name}',$numFields)"
);
171
$b->SetClass(
'button'
);
172
}
173
$btnSel =
new
MDiv
(
''
,
$buttons
);
174
175
$commentIn = $this->painter->Comment(
'START OF Field MultiSelectionField'
);
176
$commentOut = $this->painter->Comment(
'END OF Field MultiSelectionField'
);
177
178
// layout
179
180
$cFields =
new
MVContainer
(
''
,
$fields
);
181
$cSelect =
new
MVContainer
(
''
, array($select, $btnSel));
182
$t = array($cFields,$cSelect);
183
184
$group =
new
MBaseGroup
(
''
, $this->label, $t,
'horizontal'
,
'css'
);
185
186
$div =
new
MDiv
(
''
, $group,
'm-multitext-field'
);
187
$this->inner = array
188
(
189
$commentIn,
190
$div,
191
$commentOut
192
);
193
194
return
$this->inner
;
195
}
196
}
197
?>
Div
Definição
compatibility.class:68
MBaseGroup
Definição
groupcontrols.class:4
MButton
Definição
buttoncontrols.class:4
MComponent\$name
$name
Definição
mcomponent.class:17
MControl\$inner
$inner
Definição
mcontrol.class:141
MDiv
Definição
blockcontrols.class:23
MFormControl\$value
$value
Definição
mformcontrol.class:6
MFormControl\$label
$label
Definição
mformcontrol.class:5
MFormControl\$hint
$hint
Definição
mformcontrol.class:7
MHContainer
Definição
mcontainer.class:193
MListControl
Definição
listcontrols.class:3
MListControl\$options
$options
Definição
listcontrols.class:4
MListControl\$content
$content
Definição
listcontrols.class:6
MMultiSelectionField
Definição
mmultiselection.class:3
MMultiSelectionField\$codevalue
$codevalue
Definição
mmultiselection.class:9
MMultiSelectionField\$buttons
$buttons
Definição
mmultiselection.class:4
MMultiSelectionField\$layout
$layout
Definição
mmultiselection.class:8
MMultiSelectionField\GetCodeValue
GetCodeValue()
Definição
mmultiselection.class:32
MMultiSelectionField\__construct
__construct($name='', $value=null, $label='', $fields='', $width=200, $buttons=false, $info='', $hint='')
Definição
mmultiselection.class:15
MMultiSelectionField\$numRows
$numRows
Definição
mmultiselection.class:12
MMultiSelectionField\GenerateInner
GenerateInner()
Definição
mmultiselection.class:104
MMultiSelectionField\$shownav
$shownav
Definição
mmultiselection.class:7
MMultiSelectionField\$fields
$fields
Definição
mmultiselection.class:5
MMultiSelectionField\SetCodeValue
SetCodeValue($value)
Definição
mmultiselection.class:56
MMultiSelectionField\$showcode
$showcode
Definição
mmultiselection.class:6
MMultiSelectionField\$info
$info
Definição
mmultiselection.class:10
MMultiSelectionField\$colWidth
$colWidth
Definição
mmultiselection.class:11
MMultiSelectionField\$fieldWidth
$fieldWidth
Definição
mmultiselection.class:13
MMultiSelection
Definição
listcontrols.class:221
MOption
Definição
optionscontrol.class:4
MVContainer
Definição
mcontainer.class:185
classes
ui
controls
mmultiselection.class
Gerado por
1.10.0