MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
lookupcontrols.class
Ir para a documentação deste ficheiro.
1<?php
2
4{
5 var $action;
7 var $module;
8 var $item;
9 var $info;
10 var $autocomplete=false;
12 var $event;
16 var $showButton=true;
17 private $windowType = 'popup';
18 private $windowWidth = '';
19 private $windowHeight = '';
20 private $windowTop = '';
21 private $windowLeft = '';
22
23
24 function __construct($name='',$value='',$label='',$hint='',
25 $related='',$module='',$item='', $event='filler', $filter='')
26 {
27 parent::__construct($name,$value,$label,0,$hint);
29 $page->AddScript('m_lookup.js');
30
31 if(is_array($related))
32 {
33 ksort($related);
34 }
35 else
36 {
37 $related = array(str_replace(' ','',$related));
38 }
39 $this->related = implode(',',$related);
40
41 $this->module = $module;
42 $this->item = $item;
43 $this->function = MIOLO::_REQUEST('function');
44 $this->event = $event ? $event : 'filler';
45 $this->filter = $filter;
46 $module = $this->manager->GetConf("mad.module");
47
49 $form = ($this->form == NULL) ? $page->name : $this->form->name;
50
51 $this->lookup_name = "lookup_{$form}_{$this->name}";
52 $this->lookup_name = str_replace('.', '_', $this->lookup_name);
53
54 $this->baseModule = ($module) ? $module : "admin";
55 }
56
57 function GetModuleItem()
58 {
59 return $this->module . '.' . $this->item;
60 }
61
63 {
64 $this->module = $module;
65 $this->item = $item;
66 }
67
68 function setWindowSize( $width, $height )
69 {
70 $this->windowWidth = $width;
71 $this->windowHeight = $height;
72 }
73
74 function setWindowType( $windowType='iframe', $width='', $height='', $top='', $left='')
75 {
76 $this->windowType = $windowType;
77 $this->windowTop = $top;
78 $this->windowLeft = $left;
79 $this->setWindowSize( $width, $height);
80 }
81
82 /*
83 Method to set if the look button should be displayed
84 */
85 function setShowButton( $show=true )
86 {
87 $this->showButton = $show;
88 }
89
90 function GenerateInner()
91 {
92 $this->label = $this->label ? '&nbsp;' : '';
93
94 $base = $this->baseModule;
95
96 $filter = is_array($this->filter) ? $this->filter : array($this->filter);
98
99 $attr = $this->GetAttributes();
100
101 if ($this->showButton )
102 {
103 $content[] = new MSpan('','&nbsp;');
104 $button = new MButtonFind("javascript:MIOLO_Lookup($this->lookup_name,'$base', event);");
105 $content[] = $button->Generate();
106 }
107
108 $html = $this->painter->GenerateToString($content);
109 $html .= "<script language=\"JavaScript\">\n";
110 $html .= " var $this->lookup_name = new LookupContext();\n";
111 $html .= " $lookup_name.name = '{$lookup_name}';\n";
112 $html .= " $lookup_name.module = '{$this->module}';\n";
113 $html .= " $lookup_name.item = '{$this->item}';\n";
114 $html .= " $lookup_name.related = '{$this->related}';\n";
115 $html .= " $lookup_name.filter = '" . implode(',',$filter) . "';\n";
116 $html .= " $lookup_name.idxFilter = '" . implode(',',array_keys($filter)) . "';\n";
117 $html .= " $lookup_name.form = document.{$this->form->name};\n";
118 $html .= " $lookup_name.field = '{$this->name}';\n";
119 $html .= " $lookup_name.function = '{$this->function}';\n";
120 $html .= " $lookup_name.event = '{$this->event}';\n";
121 $html .= " $lookup_name.wType = '{$this->windowType}';\n";
122 $html .= " $lookup_name.wWidth = '{$this->windowWidth}';\n";
123 $html .= " $lookup_name.wHeight = '{$this->windowHeight}';\n";
124 $html .= " $lookup_name.wTop = '{$this->windowTop}';\n";
125 $html .= " $lookup_name.wLeft = '{$this->windowLeft}';\n";
126 $html .= " $lookup_name.autoPost = '{$this->autoPostBack}';\n";
127 $html .= " document.lookup = $lookup_name;\n";
128 $html .= "</script>\n";
129 $this->inner = $this->GenerateLabel() . $html;
130 }
131}
132
133
134//vgartner
136{
140 var $item;
141 var $info;
142 var $autocomplete=false;
148 var $showButton=true;
149 private $windowType = 'popup';
150 private $windowWidth = '';
151 private $windowHeight = '';
152 private $windowTop = '';
153 private $windowLeft = '';
154
155
156 function __construct($name='',$value='',$label='',$hint='',
157 $related='',$module='',$item='', $event='filler', $filter='')
158 {
159 parent::__construct($name,$value,$label,0,$hint);
161 $page->AddScript('m_lookup_ajax.js');
162
163 if(is_array($related))
164 {
165 ksort($related);
166 }
167 else
168 {
169 $related = array(str_replace(' ','',$related));
170 }
171 $this->related = implode(',',$related);
172
173 $this->module = $module;
174 $this->item = $item;
175 $this->function = MIOLO::_REQUEST('function');
176 $this->event = $event ? $event : 'filler';
177 $this->filter = $filter;
178 $module = $this->manager->GetConf("mad.module");
179
181 $form = ($this->form == NULL) ? $page->name : $this->form->name;
182
183 $this->lookup_name = "lookup_{$form}_{$this->name}";
184 $this->lookup_name = str_replace('.', '_', $this->lookup_name);
185
186
187 $this->baseModule = ($module) ? $module : "admin";
188 }
189
190 function GetModuleItem()
191 {
192 return $this->module . '.' . $this->item;
193 }
194
196 {
197 $this->module = $module;
198 $this->item = $item;
199 }
200
201 function setWindowSize( $width, $height )
202 {
203 $this->windowWidth = $width;
204 $this->windowHeight = $height;
205 }
206
207 function setWindowType( $windowType='iframe', $width='', $height='', $top='', $left='')
208 {
209 $this->windowType = $windowType;
210 $this->windowTop = $top;
211 $this->windowLeft = $left;
212 $this->setWindowSize( $width, $height);
213 }
214
215 /*
216 Method to set if the look button should be displayed
217 */
218 function setShowButton( $show=true )
219 {
220 $this->showButton = $show;
221 }
222
223 function GenerateInner()
224 {
225 $this->label = $this->label ? '&nbsp;' : '';
226
227 $base = $this->baseModule;
228
229 $filter = is_array($this->filter) ? $this->filter : array($this->filter);
231
232 $attr = $this->GetAttributes();
233
234 if ($this->showButton )
235 {
237 if ( strpos(MIOLO::getInstance()->getTheme()->id, "sbootstrap") === false )
238 {
239 $content[] = new MSpan('','&nbsp;');
240 }
241 $button = new MButtonFind("javascript:MIOLO_Lookup($this->lookup_name,'$base', event);");
242 $button->addAttribute('data-toggle', 'modal');
243 $button->addAttribute('data-target', '#lookupModal_' . $this->name);
244 $button->addAttribute('data-bs-toggle', 'modal');
245 $button->addAttribute('data-bs-target', '#lookupModal_' . $this->name);
246 $content[] = $button->Generate();
247 }
248
249 $html = $this->painter->GenerateToString($content);
250 $html .= "<script language=\"JavaScript\">\n";
251 $html .= " var $this->lookup_name = new LookupContext();\n";
252 $html .= " $lookup_name.name = '{$lookup_name}';\n";
253 $html .= " $lookup_name.module = '{$this->module}';\n";
254 $html .= " $lookup_name.item = '{$this->item}';\n";
255 $html .= " $lookup_name.related = '{$this->related}';\n";
256 $html .= " $lookup_name.filter = '" . implode(',',$filter) . "';\n";
257 $html .= " $lookup_name.idxFilter = '" . implode(',',array_keys($filter)) . "';\n";
258 $html .= " $lookup_name.form = document.forms[0];\n";
259 $html .= " $lookup_name.field = '{$this->name}';\n";
260 $html .= " $lookup_name.function = '{$this->function}';\n";
261 $html .= " $lookup_name.event = '{$this->event}';\n";
262 $html .= " $lookup_name.wType = '{$this->windowType}';\n";
263 $html .= " $lookup_name.wWidth = '{$this->windowWidth}';\n";
264 $html .= " $lookup_name.wHeight = '{$this->windowHeight}';\n";
265 $html .= " $lookup_name.wTop = '{$this->windowTop}';\n";
266 $html .= " $lookup_name.wLeft = '{$this->windowLeft}';\n";
267 $html .= " $lookup_name.autoPost = '{$this->autoPostBack}';\n";
268 $html .= " document.lookup = $lookup_name;\n";
269 $html .= "</script>\n";
270
271 if ( strpos(MIOLO::getInstance()->getTheme()->id, "sbootstrap") !== false )
272 {
273 $html .=
274 '<div class="modal fade" id="lookupModal_'.$this->name.'" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
275 <div class="modal-dialog modal-lg">
276 <div class="modal-content">
277 <div class="modal-header">
278 <h4 class="modal-title" id="lookupTitle_'.$this->name.'">Modal title</h4>
279 <button id="lookupCloseButton_'.$this->name.'" type="button" class="close btn-close" data-dismiss="modal" data-bs-dismiss="modal" aria-label="Fechar" title="Fechar"><span aria-hidden="true">&times;</span></button>
280 </div>
281 <div class="modal-body">
282 <iframe class="m-lookup-iframe" id="lookupIframe_'.$this->name.'" frameborder="0"></iframe>
283 </div>
284 </div>
285 </div>
286 </div>';
287 }
288
289 $this->inner = $this->GenerateLabel() . $html;
290 }
291}
292
294{}
295
297{
299
300 function __construct($name='',$value='',$label='',
301 $size=10,$hint='',$validator=null,$related='',
302 $module='',$item='', $event='filler', $filter='', $autocomplete=true)
303 {
304 parent::__construct($name,$value,$label,$hint,$related, $module, $item, $event, $filter); //$validator);
305 $this->size = $size;
306 $this->filter = $filter ? $filter : $this->name;
307 $this->autocomplete = $autocomplete ? true : false;
308 $this->validator = is_string($validator) ?
309 Validator::MASKValidator($validator) : $validator;
310 }
311
313 {
314 $autocomplete = new MAutoComplete($this->module,$this->item,$this->value,$this->related);
315 $info = $autocomplete->getResult();
316 return $info;
317 }
318
319 function GenerateInner()
320 {
321 $field = new MTextField($this->name,$this->value,$this->label,$this->size,$this->hint, $this->validator);
322 $field->attrs = $this->attrs;
323 if ( $this->autocomplete )
324 {
325 $field->setAttribute('onChange',"MIOLO_AutoComplete({$this->lookup_name},'$this->baseModule')");
326 }
327 $field->validator = $this->validator;
328 $field->form = $this->form;
329
330 if($this->value && $this->autocomplete)
331 {
333
334 $info = $this->getAutoCompleteData();
335
336 $info_ = '';
337 foreach($info as $i )
338 {
339 $info_ .= "'$i',";
340 }
341 $info_ = substr($info_, 0, -1);
342
343 if(MUtil::getBooleanValue($MIOLO->getConf('options.debug')) && $MIOLO->getConf('logs.handler') == 'screen')
344 {
345 $msg = _M('[autocomplete]: Field @1 not found!', $this->baseModule) . '<br/>';
346 }
347 $this->page->addJSCode("MIOLO_AutoCompleteDeliver(document, {$this->lookup_name}.form, '$msg', '$this->related', new Array($info_) );");
348 }
349
350 $field->SetClass('m-text-field');
351 $field->showLabel = $this->showLabel;
352 $field->formMode = $this->formMode;
353 $field->AddBoxStyle('float','left');
354 if ( $this->readonly )
355 {
356 $field->SetClass('m-readonly');
357 $field->AddAttribute('readonly');
358 }
359 $html = $field->Generate();
360 parent::GenerateInner();
361 $htmlInner = $this->GetInner();
362 $this->inner = $html . ( $this->readonly ? '' : $htmlInner) ;
363 }
364
365}
366
368{
369 function __construct($name='',$value='',$label='',
370 $size=10,$hint='',$validator=null,$related='',
371 $module='',$item='', $event='', $filter='', $autocomplete=false)
372 {
373 parent::__construct($name,$value,$label,$hint,$validator);
374 $this->size = $size;
375 $this->filter = $this->name;
376 $this->validator = is_string($validator) ?
377 Validator::MASKValidator($validator) : $validator;
378 }
379
380 function GenerateInner()
381 {
382 parent::GenerateInner();
383 $htmlInner = $this->GetInner();
384 $field = new MTextField($this->name,$this->value,$this->label,$this->size,$this->hint, $this->validator);
385 $field->attrs = $this->attrs;
386 $field->SetClass('m-text-field');
387 $field->showLabel = $this->showLabel;
388 $field->formMode = $this->formMode;
389// $field->AddBoxStyle('float','left');
390 $field->SetClass('m-readonly');
391 $field->AddAttribute('readonly');
392 $html = $field->Generate();
393 $this->inner = ( $this->readonly ? '' : $htmlInner) . $html;
394 }
395
396}
397
399{
401 public $customAttribute = array();
402 function __construct($name='',$value='',$label='',
403 $size=10,$hint='',$validator=null,$related='',
404 $module='',$item='', $event='filler', $filter='', $autocomplete=true)
405 {
406 parent::__construct($name,$value,$label,$hint,$related, $module, $item, $event, $filter); //$validator);
407 $this->size = $size;
408 $this->filter = $filter ? $filter : $this->name;
409 $this->autocomplete = $autocomplete ? true : false;
410 $this->validator = is_string($validator) ?
411 Validator::MASKValidator($validator) : $validator;
412 }
413
415 {
416 $autocomplete = new MAutoComplete($this->module,$this->item,$this->value,$this->related);
417 $info = $autocomplete->getResult();
418 return $info;
419 }
420
421 public function GenerateInner()
422 {
423 $field = new MTextField($this->name, $this->value, $this->label, $this->size, '', $this->validator);
424 $field->attrs = $this->attrs;
425 if ( $this->autocomplete )
426 {
427 if (count($this->customAttribute) > 0)
428 {
429 $i = 0;
430 foreach ($this->customAttribute as $key => $value)
431 {
432 $field->setAttribute('onChange', "MIOLO_AutoComplete_Ajax({$this->lookup_name},'$this->baseModule');" . $value);
433
434 if($i > 0)
435 {
436 $field->setAttribute($key, $value);
437 }
438
439 $i++;
440 }
441 }
442 else
443 {
444 $field->setAttribute('onChange', "MIOLO_AutoComplete_Ajax({$this->lookup_name},'$this->baseModule')");
445 }
446
447 }
448 elseif (count($this->customAttribute) > 0)
449 {
450 foreach ($this->customAttribute as $key => $value)
451 {
452 $field->setAttribute($key, $value);
453 }
454 }
455
456 $field->validator = $this->validator;
457 $field->form = $this->form;
458
459 if ( $this->value && $this->autocomplete )
460 {
462
463 $info = $this->getAutoCompleteData();
464
465 $info_ = '';
466
467 if ( $info && is_array($info) )
468 {
469 foreach ( $info as $value )
470 {
471 $value = trim(addslashes($value));
472 $info_ .= "'$value',";
473 }
474 }
475 $info_ = substr($info_, 0, -1);
476
477 if ( MUtil::getBooleanValue($MIOLO->getConf('options.debug')) && $MIOLO->getConf('logs.handler') == 'screen' )
478 {
479 $msg = _M('[autocomplete]: Field @1 not found!', $this->baseModule) . '<br/>';
480 }
481
482 // Check if it's an AJAX request
483 if ( $this->page->request('cpaint_function') != "" )
484 {
485 $this->page->addAJAXJsCode("setTimeout(\"MIOLO_AutoCompleteDeliver_Ajax(document, {$this->lookup_name}.form, '$msg', '$this->related', new Array($info_) );\", 0);");
486 }
487 else
488 {
489 $this->page->addJSCode("MIOLO_AutoCompleteDeliver_Ajax(document, {$this->lookup_name}.form, '$msg', '$this->related', new Array($info_) );");
490 }
491 }
492
493 $field->SetClass('m-text-field');
494 $field->showLabel = $this->showLabel;
495 $field->formMode = $this->formMode;
496 $field->AddBoxStyle('float', 'left');
497 if ( $this->readonly )
498 {
499 $field->SetClass('m-readonly');
500 $field->AddAttribute('readonly');
501 }
502 $html = $field->Generate();
503 parent::GenerateInner();
504 $htmlInner = $this->GetInner();
505 $this->inner = $html . $htmlInner;
506 }
507
509 {
510 if(is_array($customAttribute))
511 {
512 $this->customAttribute = $customAttribute;
513 }
514 }
515}
516
519
521{
524
525 function __construct($name='',$value='',$label='',
526 $size=10,$hint='',$validator=null,$related='',
527 $module='',$item='', $event='', $filter='', $autocomplete=false)
528 {
530 $this->page->AddScript('x/x_core.js');
531 $this->page->AddScript('m_lookup_ajax.js');
532 $this->page->AddScript('m_popup.js');
533 }
534
535 function GenerateInner()
536 {
538 $this->showLabel = ($this->formMode == 2);
539 $span = new Span('',$this->label,MControl::CLASS_CAPTION);
540 $label = $this->painter->span($span) . $this->painter->BR;
541 $form = ($this->form == NULL) ? $page->name : $this->form->name;
542 $lookup_name = "lookup_{$form}_{$this->name}";
543 $base = $this->baseModule;
544
545 $filter = is_array($this->filter) ? $this->filter : array($this->filter);
546 $attr = $this->GetAttributes();
547 $content[] = new MSpan('','&nbsp;');
549 $w = ($this->lwidth != '') ? $this->lwidth : 400;
550 $h = ($this->lheight != '') ? $this->lheight : 250;
551 $params = array(
552 "name" => $lookup_name,
553 "lmodule" => $this->module,
554 "event" => $this->event,
555 "related" => $this->related,
556 "lheight" => $this->lheight,
557 "lwidth" => $this->lwidth
558 );
559 foreach($filter as $k=>$f)
560 {
561 $params["filter$k"] = $f;
562 }
563
564 $url = $this->manager->GetActionURL($this->baseModule, 'activelookup', $item, $params);
565 $button = new MButtonFind("javascript:MIOLO_ActiveLookup('$lookup_name',200,200,$w,$h, '{$url}','','{$this->name}',1);");
566 $content[] = $button->Generate();
567 if ( $this->readonly )
568 {
569 $ro = new MSpan($this->name,$this->value,'m-readonly');
570 $this->inner = (($this->showLabel && ($this->label != '')) ? $label : '') . $this->painter->span($ro);
571 return;
572 }
573 $field = new MTextField($this->name,$this->value,$this->label,$this->size,$this->hint, $this->validator);
574 $field->attrs = $this->attrs;
575 $field->SetClass('m-text-field');
576 $html = $field->GetRender('inputtext') . $this->painter->GenerateToString($content);
577 $this->inner = $html;
578 }
579}
580
581?>
__construct($name='', $value='', $label='', $size=10, $hint='', $validator=null, $related='', $module='', $item='', $event='', $filter='', $autocomplete=false)
const CLASS_CAPTION
Definição mcontrol.class:46
static _REQUEST( $vars, $from='ALL')
Definição miolo.class:1109
static getInstance()
Definição miolo.class:134
SetModuleItem($module, $item)
__construct($name='', $value='', $label='', $hint='', $related='', $module='', $item='', $event='filler', $filter='')
setWindowSize( $width, $height)
setShowButton( $show=true)
setWindowType( $windowType='iframe', $width='', $height='', $top='', $left='')
SetModuleItem($module, $item)
__construct($name='', $value='', $label='', $hint='', $related='', $module='', $item='', $event='filler', $filter='')
setWindowSize( $width, $height)
setShowButton( $show=true)
setWindowType( $windowType='iframe', $width='', $height='', $top='', $left='')
__construct($name='', $value='', $label='', $size=10, $hint='', $validator=null, $related='', $module='', $item='', $event='', $filter='', $autocomplete=false)
__construct($name='', $value='', $label='', $size=10, $hint='', $validator=null, $related='', $module='', $item='', $event='filler', $filter='', $autocomplete=true)
setCustomAttribute($customAttribute)
__construct($name='', $value='', $label='', $size=10, $hint='', $validator=null, $related='', $module='', $item='', $event='filler', $filter='', $autocomplete=true)
static getBooleanValue($value)
Definição mutil.class:100
$url
Definição base.php:2