MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mmultitextfield3.class
Ir para a documentação deste ficheiro.
1
<?php
2
8
class
MMultiTextField3
extends
MMultiTextField2
9
{
10
11
function
__construct
(
$name
=
''
,
$value
=
null
,
$label
=
''
,
$fields
=
''
, $width = 200,
$buttons
=
false
,
$layout
=
'vertical'
,
$hint
=
''
)
12
{
13
parent::__construct(
$name
,
$value
,
$label
,
$fields
, $width,
$buttons
,
$layout
,
$hint
);
14
$this->page->AddScript(
'm_multitext3.js'
);
15
}
16
17
function
GetCodeValue
()
18
{
19
$r = array
20
(
21
);
22
23
$value
=
$this->value
;
24
25
if
(is_array(
$value
))
26
{
27
for
($i = 0; $i < count(
$value
); $i++)
28
{
29
$s = substr(
$value
[$i], 1, strlen(trim(
$value
[$i])) - 2);
30
$a = explode(
'] ['
, $s);
31
32
if
(is_array($a))
33
{
34
for
($j = 0; $j < count($a); $j++)
35
{
36
if
($this->fields[$j] instanceof
MSelection
)
37
{
38
$r[$i][$j] = array_search($a[$j], $this->fields[$j]->options);
39
}
40
else
41
{
42
$r[$i][$j] = $a[$j];
43
}
44
}
45
}
46
}
47
}
48
49
$this->codevalue = $r;
50
return
$this->codevalue
;
51
}
52
53
function
SetCodeValue
(
$value
)
54
{
55
$this->codevalue =
$value
;
56
$r = array
57
(
58
);
59
60
if
(is_array(
$value
))
61
{
62
foreach
(
$value
as $i=>$v)
63
{
64
$a =
$value
[$i];
65
66
if
(is_array($a))
// varios valores => varios fields
67
{
68
for
($j = 0; $j < count($a); $j++)
69
{
70
if
($this->fields[$j] instanceof
MSelection
)
71
{
72
$r[$i] .=
'['
. $this->fields[$j]->GetOption(
$value
[$i][$j]) .
'] '
;
73
}
74
else
75
{
76
$r[$i] .=
'['
.
$value
[$i][$j] .
'] '
;
77
}
78
}
79
}
80
else
// valor unico => apenas um field (na posicao 0)
81
{
82
if
($this->fields[$i] instanceof
MSelection
)
83
{
84
$r[$i] .=
'['
. $this->fields[$i]->GetOption(
$value
[$i]) .
'] '
;
85
}
86
else
87
{
88
$r[$i] .=
'['
.
$value
[$i] .
'] '
;
89
}
90
}
91
}
92
}
93
94
$this->value = $r;
95
}
96
97
function
GenerateInner
()
98
{
99
$numFields = count($this->fields);
100
101
$this->page->OnSubmit(
"_MIOLO_MultiTextField3_onSubmit('{$this->form->name}','{$this->name}')"
);
102
103
// fields
104
$fields
=
''
;
105
$n = 1;
106
$ref =
''
;
107
108
foreach
($this->fields as $f)
109
{
110
$ref .= ($ref ?
','
:
''
) . $f->GetName();
111
$f->form =
$this->form
;
112
$f->SetLabel(htmlspecialchars($f->label));
113
$f->formMode = 2;
114
if
($f->size ==
''
) $f->_AddStyle(
'width'
,
"{$this->colWidth}px"
);
115
$fields
[] = $f;
116
$n++;
117
}
118
119
// select
120
$labelS = $this->info .
" "
;
121
$content = array
122
(
123
);
124
125
if
(is_array($this->value))
126
{
127
foreach
($this->value as $v)
128
{
129
$multiValue =
''
;
130
131
if
(is_array($v))
132
foreach
($v as $v2)
133
$multiValue .=
"["
. $v2 .
"] "
;
134
else
135
$multiValue = $v;
136
137
$content[] =
new
MOption
(
''
, $multiValue, $multiValue);
138
}
139
}
140
141
$field =
new
MMultiSelection
(
"{$this->name}[]"
, array(),$labelS,$content,
''
,
''
, $this->numRows);
142
$field->_AddStyle(
'width'
,
"{$this->colWidth}px"
);
143
$field->AddAttribute(
'onKeyDown'
,
"return MIOLO_MultiTextField3_onKeyDown(this,this.form,'{$this->name}',event,$numFields);"
);
144
$field->AddAttribute(
'onChange'
,
"_MIOLO_MultiTextField3_onSelect(this.form,'{$this->name}', '{$ref}')"
);
145
$field->SetClass(
'select'
,
false
);
146
$field->formMode = 2;
147
$select = $field;
148
149
// buttons
150
151
$disposition = ($this->layout ==
'horizontal'
) ?
'vertical'
:
'horizontal'
;
152
$button[] =
new
MButton
(
"{$this->name}_add"
,
'Adicionar'
,
153
"_MIOLO_MultiTextField3_add(this.form, '{$this->name}','{$ref}')"
);
154
$button[] =
new
MButton
(
"{$this->name}_modify"
,
'Modificar'
,
155
"_MIOLO_MultiTextField3_modify(this.form,'{$this->name}','{$ref}')"
);
156
$button[] =
new
MButton
(
"{$this->name}_remove"
,
'Remover'
,
157
"_MIOLO_MultiTextField3_remove(this.form,'{$this->name}','{$ref}')"
);
158
159
if
($this->shownav)
160
{
161
$button[] =
new
MButton
(
"{$this->name}_up"
,
'/\\'
,
162
"_MIOLO_MultiTextField3_moveUp(this.form,'{$this->name}','{$ref}')"
);
163
$button[] =
new
MButton
(
"{$this->name}_down"
,
'\\/'
,
164
"_MIOLO_MultiTextField3_moveDown(this.form,'{$this->name}','{$ref}')"
);
165
}
166
167
foreach
($button as $b)
168
$b->SetClass(
'button'
);
169
170
$buttons
=
new
MContainer
(
''
, $button, $disposition);
171
172
$commentIn = $this->painter->Comment(
'START OF Field MultiTextField3'
);
173
$commentOut = $this->painter->Comment(
'END OF Field MultiTextField3'
);
174
175
// layout
176
177
$t = array();
178
$cFields =
new
MContainer
(
''
,
$fields
,
'vertical'
);
179
$cFields->AddBoxStyle(
'width'
,
"{$this->fieldWidth}px"
);
180
if
($this->layout ==
'vertical'
)
181
{
182
$t[] = $select;
183
$t[] = $cFields;
184
$t[] =
$buttons
;
185
$group =
new
BaseGroup
(
''
, $this->label, $t,
'vertical'
,
'css'
);
186
}
187
elseif ($this->layout ==
'vertical2'
)
188
{
189
$t[] = $cFields;
190
$t[] =
$buttons
;
191
$t[] = $select;
192
$group =
new
BaseGroup
(
''
, $this->label, $t,
'vertical'
,
'css'
);
193
}
194
elseif ($this->layout ==
'horizontal'
)
195
{
196
$t[] =
new
MDiv
(
''
, $cFields,
'fieldPosH'
);
197
$t[] =
new
MDiv
(
''
, array(
new
Div
(
''
,
' '
,
'label'
),
$buttons
),
'buttonPosH'
);
198
$t[] =
new
MDiv
(
''
, $select,
'selectPosH'
);
199
$group =
new
BaseGroup
(
''
, $this->label, $t,
'horizontal'
,
'css'
);
200
}
201
202
$div =
new
MDiv
(
''
, $group,
'm-multitext-field'
);
203
$this->inner = array
204
(
205
$commentIn,
206
$div,
207
$commentOut
208
);
209
210
return
$this->inner
;
211
}
212
}
213
?>
BaseGroup
Definição
compatibility.class:122
Div
Definição
compatibility.class:68
MButton
Definição
buttoncontrols.class:4
MComponent\$name
$name
Definição
mcomponent.class:17
MContainer
Definição
mcontainer.class:4
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\$form
$form
Definição
mformcontrol.class:13
MFormControl\$hint
$hint
Definição
mformcontrol.class:7
MMultiSelection
Definição
listcontrols.class:221
MMultiTextField2
Definição
mmultitextfield2.class:9
MMultiTextField2\$codevalue
$codevalue
Definição
mmultitextfield2.class:15
MMultiTextField2\$buttons
$buttons
Definição
mmultitextfield2.class:10
MMultiTextField2\$layout
$layout
Definição
mmultitextfield2.class:14
MMultiTextField2\$fields
$fields
Definição
mmultitextfield2.class:11
MMultiTextField3
Definição
mmultitextfield3.class:9
MMultiTextField3\GetCodeValue
GetCodeValue()
Definição
mmultitextfield3.class:17
MMultiTextField3\__construct
__construct($name='', $value=null, $label='', $fields='', $width=200, $buttons=false, $layout='vertical', $hint='')
Definição
mmultitextfield3.class:11
MMultiTextField3\GenerateInner
GenerateInner()
Definição
mmultitextfield3.class:97
MMultiTextField3\SetCodeValue
SetCodeValue($value)
Definição
mmultitextfield3.class:53
MOption
Definição
optionscontrol.class:4
MSelection
Definição
listcontrols.class:63
classes
ui
controls
mmultitextfield3.class
Gerado por
1.10.0