MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mcontainer.class
Ir para a documentação deste ficheiro.
1<?php
2
4{
6 public $separator;
7 public $spaceHeight; // espaçamento em pixels entre os campos no disposition=vertical
8 public $spaceWidth = '&nbsp;&nbsp;'; //espaçamento em pixels entre os campos no disposition=horizontal
9 public $formMode;
10
11 /* se label deve ser exibido junto com os campos
12 * Esse atributo foi modificado para private para forçar a
13 * utilizaçào do método setShowLabel. Esta modificação foi
14 * necessária para os casos em que o programador necessite
15 * que os labels dos conteúdos fossem exibidos
16 */
17 public $showLabel;
18
19 /* esta propriedade controla a exibição ou não do label dos
20 * conteúdos de um container. É necessário utilizar o método
21 * setShowChildLabel para modificar esta propriedade.
22 */
23 public $showChildLabel = true; //se o label dos conteiner conteúdos deste serão exibidos
24
29
30 public function __construct($name=NULL, $controls=NULL, $disposition='none', $formMode=self::FORM_MODE_SHOW_ABOVE)
31 {
32 parent::__construct($name);
33 $this->formMode = $formMode;
34 $controls = (($controls != '') && is_array($controls)) ? $controls : array();
35 $this->showLabel = false;
36 $this->spaceHeight = '5px';
37 $this->SetControls($controls);
38 $this->SetDisposition($disposition);
39 }
40
41 public function setClass($cssClass, $add = true)
42 {
43 $this->SetBoxClass($cssClass, $add);
44 }
45
46 public function setSpaceHeight($value)
47 {
48 $this->spaceHeight = $value;
49 }
50
51 public function setSpaceWidth($value)
52 {
53 $this->spaceWidth = $value;
54 }
55
57 {
58 $this->disposition = ($disposition == 'none') ? 'horizontal' : $disposition;
59
60 switch ( $this->disposition )
61 {
62 case 'vertical':
63 $div = new MSpacer($this->spaceHeight);
64 break;
65
66 case 'horizontal':
67 $div = new MDiv('m-divisor', $this->spaceWidth);
68 break;
69
70 default:
71 $div = NULL;
72 break;
73 }
74
75 $this->separator = $div;
76 }
77
78 public function isShowLabel()
79 {
80 return $this->showLabel;
81 }
82
83 public function isShowChildLabel()
84 {
86 }
87
88 public function setShowChildLabel($visible=true, $recursive=true)
89 {
90 $this->showChildLabel = $visible;
91
92 $controls = $this->GetControls();
93 $this->setControls($controls, $recursive);
94 }
95
96 public function setShowLabel($visible=true, $recursive=true)
97 {
98 $this->showLabel = $visible;
99
100 if ( $recursive )
101 {
102 $this->setShowChildLabel($visible, $recursive);
103 }
104 }
105
106 public function setControls($controls, $recursive=false)
107 {
108 $this->clearControls();
109
110 foreach ( $controls as $c )
111 {
112 if ( $recursive && ($c instanceof MContainer) )
113 {
114 $c->setShowChildLabel($this->showChildLabel, true);
115 }
116 if ( is_object($c) )
117 {
118 $c->showLabel = $this->showChildLabel;
119 $this->addControl($c);
120 }
121 }
122 }
123
124 public function GenerateInner()
125 {
126 $float = false;
127 $t = array();
128
129 $controls = $this->GetControls();
130
131 foreach ( $controls as $control )
132 {
133 $c = clone $control;
134 if ( $c instanceof MFormControl )
135 {
136 $c->SetAutoPostBack($this->autoPostBack || $c->autoPostBack);
137 }
138
139 if ( $c->label != '' && $c->label != '&nbsp;' && $c->forceShowLabel )
140 {
141 $c->label .= ':';
142 }
143
144 if ( $c->showLabel || $c->forceShowLabel )
145 {
146 $c->formMode = $this->formMode;
147 }
148
149 if ( $this->disposition == 'horizontal' )
150 {
151 $c->float = $this->separator->float = 'left';
152 $float = true;
153 }
154 else
155 {
156 if ( $this->formMode == self::FORM_MODE_SHOW_SIDE )
157 {
158 $hidden = NULL;
159 $form = new MForm();
160 $c = $form->generateLayoutField($c, $hidden);
161 }
162 else
163 {
164 $c = new MDiv('', $c);
165 }
166 }
167
168 $htmlPainter = new HtmlPainter();
169 $t[] = $htmlPainter->GenerateToString($c);
170 $t[] = $this->separator;
171 }
172
173 if ( $float )
174 {
175 $t[] = new Spacer();
176 }
177
178 $this->inner = $t;
179 $this->getBox()->setAttributes($this->getAttributes());
180 $this->getBox()->setClass('m-new-container');
181 }
182}
183
185{
186 public function __construct($name=NULL, $controls=NULL)
187 {
188 parent::__construct($name, $controls, 'vertical', self::FORM_MODE_SHOW_ABOVE);
189 }
190}
191
193{
194 public function __construct($name=NULL, $controls=NULL, $formMode=self::FORM_MODE_SHOW_ABOVE, $showRequiredLabel=false)
195 {
196 parent::__construct($name, $controls, 'horizontal', $formMode);
197
198 $this->showRequiredLabel = $showRequiredLabel;
199 if ( $formMode == self::FORM_MODE_SHOW_SIDE )
200 {
201 $this->label = $this->getFirstControlLabel($controls);
202 }
203 }
204
211 private function getFirstControlLabel($controls)
212 {
213 $label = '';
214
215 foreach ( $controls as $control )
216 {
217 if ( !($control instanceof MControl) ||
218 ($control instanceof MHiddenField) ||
219 ($control->getBox()->style->get('display') == 'none') ||
220 (!strlen($control->label)) )
221 {
222 continue;
223 }
224
225 $label = $control->label;
226 break;
227 }
228
229 return $label;
230 }
231}
232
237{
238 public function __construct($name=NULL, $controls=NULL)
239 {
240 parent::__construct($name, $controls, 'vertical', self::FORM_MODE_SHOW_SIDE);
241 }
242}
243
245{
246 public function __construct( $id = '', //Id do text-field a ser criado
247 $label = '', //Label do text-field
248 $value = '', //Valor do text-field
249 $required = false, //Campo é requerido (passar o validador também)
250 $validator = null, //Validator do text-field
251 $sizeTxt = '', //Tamanho do text-field (padrao 38 px)
252 $sizeLbl = '', //Tamanho do label (padrao 140 px)
253 $hint = '', //Hint do text-field
254 $readOnly = false, //Read-only do text-field
255 $jsHint = '', //JSHint
256 $disposition = 'horizontal') //Disposicao do container que irá retornar
257 {
258
259 //Cria label e seta atributos para ficar alinhado corretamente
260 $module = MIOLO::getCurrentModule();
261 $lbl = new MLabel(_M($label, $module));
262
263 $required ? $classe = 'm-caption m-caption-required' : $classe = 'm-caption';
264
265 $lbl->setClass($classe);
266 $lbl->setWidth(MUtil::NVL($sizeLbl, '140'));
267
268 //Cria text-field
269 $txtField = new MTextField($id, $value, NULL, MUtil::NVL($sizeTxt, '30'), $hint, $validator, $readOnly);
270 $txtField->setJsHint(_M($jsHint));
271
272 //Parent no construct do container
273 parent::__construct('hct' . $id, array($lbl, $txtField), $disposition);
274 }
275}
276
278{
279 public function __construct( $id = '', //Id do text-field a ser criado
280 $label = '', //Label do text-field
281 $value = '', //Valor do text-field
282 $options = array(), //Disposicao do container que irá retornar
283 $requiredLabel = false, //Campo é requerido (somente para o label)
284 $sizeSel = '', //Tamanho do text-field (padrao 38 px)
285 $sizeLbl = '', //Tamanho do label (padrao 140 px)
286 $hint = '', //Hint do text-field
287 $readOnly = false, //Read-only do text-field
288 $jsHint = '', //JSHint
289 $disposition = 'horizontal') //Disposicao do container que irá retornar
290 {
291
292 //Cria label e seta atributos para ficar alinhado corretamente
293 $module = MIOLO::getCurrentModule();
294 $lbl = new MLabel(_M($label, $module));
295
296 $requiredLabel ? $classe = 'm-caption m-caption-required' : $classe = 'm-caption';
297
298 $lbl->setClass($classe);
299 $lbl->setWidth(MUtil::NVL($sizeLbl, '140'));
300
301 //Cria MSelection
302 $selection = new MSelection($id, $value, NULL, $options, false, $hint, $sizeSel);
303 $selection->setReadOnly($readOnly);
304 $selection->setJsHint(_M($jsHint));
305
306 //Parent no construct do container
307 parent::__construct('hct' . $id, array($lbl, $selection), $disposition);
308 }
309}
310?>
setShowLabel($visible=true, $recursive=true)
setControls($controls, $recursive=false)
setSpaceWidth($value)
setClass($cssClass, $add=true)
setShowChildLabel($visible=true, $recursive=true)
setSpaceHeight($value)
setDisposition($disposition)
__construct($name=NULL, $controls=NULL, $disposition='none', $formMode=self::FORM_MODE_SHOW_ABOVE)
addControl($control)
Definição mcontrol.class:652
clearControls()
Definição mcontrol.class:714
getAttributes( $mergeDuplicates=false)
Definição mcontrol.class:509
__construct($name=NULL, $controls=NULL)
Definição mform.class:9
__construct($name=NULL, $controls=NULL, $formMode=self::FORM_MODE_SHOW_ABOVE, $showRequiredLabel=false)
static getCurrentModule()
Definição miolo.class:1066
static NVL($value1, $value2)
Definição mutil.class:38
__construct($name=NULL, $controls=NULL)
__construct( $id='', $label='', $value='', $options=array(), $requiredLabel=false, $sizeSel='', $sizeLbl='', $hint='', $readOnly=false, $jsHint='', $disposition='horizontal')
__construct( $id='', $label='', $value='', $required=false, $validator=null, $sizeTxt='', $sizeLbl='', $hint='', $readOnly=false, $jsHint='', $disposition='horizontal')