MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mcssform.class
Ir para a documentação deste ficheiro.
1<?php
2class MCSSForm extends MForm
3{
7
8 function __construct($title = '', $action = '', $close = 'backContext', $icon = '')
9 {
10 parent::__construct($title, $action, $close, $icon);
11 $this->altColor = array
12 (
13 '#FFFFFF',
14 '#EEEEEE'
15 );
16
17 $this->alternate = false;
18 }
19
20 function SetAlternateColors($color0, $color1)
21 {
22 $this->altColor = array
23 (
24 $color0,
25 $color1
26 );
27 }
28
29 function SetAlternate($alternate = false, $color1 = null)
30 {
31 $this->alternate = $alternate;
32 }
33
34 function SetField($row, $col, $width, $field = NULL, $style = array())
35 {
36 $this->structure[$row][$col]['width'] = $width;
37 $this->structure[$row][$col]['field'] = $field;
38 $this->structure[$row][$col]['style'] = $style;
39 $this->AddField($field);
40 }
41
42 function GenerateLayoutFields(&$hidden)
43 {
44 if (!is_array($this->fields))
45 return;
46
47 $t = array
48 (
49 );
50
51 ksort($this->structure, SORT_NUMERIC);
52 $rowNumber = 0;
53
54 foreach ($this->structure as $row)
55 {
56 $rowContent = array
57 (
58 );
59
60 $lastCol = count($row) - 1;
61 $colNumber = $nWidth = 0;
62
63 foreach ($row as $col)
64 {
65 $f = $col['field'];
66
67 if (count($col['style']))
68 foreach ($col['style'] as $s => $v)
69 $f->AddStyle($s, $v);
70
71// if ($f->label != '')
72// $f = new MFieldLabel('', $f->label . ':&nbsp;' . $f->Generate());
73
74 $c = $rowContent[] = new Div('', $f);
75 $width = (($colNumber == $lastCol) && ($colNumber != 0)) ? 98 - $nWidth : $col['width'];
76 $nWidth += $width;
77 $c->AddStyle('width', "{$width}%");
78 $c->AddStyle('float', 'left');
79 $c->AddStyle('padding', '1px');
80 $colNumber++;
81 }
82
83 $rowContent[] = new Spacer();
84 $d = $t[$rowNumber] = new Div('', $rowContent);
85 $d->AddStyle('clear', 'both');
86 $d->AddStyle('width', '98%');
87 $d->AddStyle('padding', '2px 1px 1px 1px');
88
89 if ($this->alternate)
90 {
91 $d->AddStyle('backgroundColor', $this->altColor[$rowNumber % 2]);
92 }
93
94 $rowNumber++;
95 }
96
97 foreach ($this->fields as $f)
98 {
99 if ((($f->className == 'textfield') && ($f->size == 0)) || ($f->className == 'hiddenfield'))
100 {
101 $hidden[] = $f;
102 continue;
103 }
104
105 if (($f->readonly || $f->maintainstate))
106 {
107 $hidden[] = $f;
108 }
109 }
110
111 return $t;
112 }
113
114 function Generate()
115 {
116 if (!isset($this->buttons))
117 {
118 if ($this->defaultButton)
119 {
120 $this->buttons[] = new FormButton(FORM_SUBMIT_BTN_NAME, 'Enviar', 'SUBMIT');
121 }
122 }
123
124 $body = new MDiv('',$this->GenerateBody(),'m-form-body panel-body card-body');
125 if (!is_null($this->bgColor)) $body->AddStyle('backgroundColor',$this->bgColor);
126 $this->box->SetControls(array($body, $footer));
127 $id = $this->GetUniqueId();
128 $this->box->SetBoxClass("m-form-outer");
129 $form = new MDiv("frm$id", $this->box,"m-form-box");
130 if (!is_null($this->align)) $form->AddBoxStyle('text-align',$this->align);
131 return $form->Generate();
132
133 }
134}
135?>
SetAlternate($alternate=false, $color1=null)
Definição mcssform.class:29
GenerateLayoutFields(&$hidden)
Definição mcssform.class:42
SetAlternateColors($color0, $color1)
Definição mcssform.class:20
__construct($title='', $action='', $close='backContext', $icon='')
Definição mcssform.class:8
SetField($row, $col, $width, $field=NULL, $style=array())
Definição mcssform.class:34
Definição mform.class:9
$width
Definição mform.class:63
$action
Definição mform.class:18
$footer
Definição mform.class:58
AddField($field, $hint=false)
Definição mform.class:932
$title
Definição mform.class:13
GenerateBody()
Definição mform.class:1897
const FORM_SUBMIT_BTN_NAME
Definição mform.class:2