1 | <? |
---|
2 | /** |
---|
3 | * FormularioHtml |
---|
4 | * |
---|
5 | * Implementação de Formulários Padrões do Sistema. |
---|
6 | * |
---|
7 | * @author Jair Pereira <pereira.jair@gmail.com> |
---|
8 | */ |
---|
9 | |
---|
10 | include 'FormularioInput.class.php'; |
---|
11 | |
---|
12 | class FormularioHtml extends FormularioInput { |
---|
13 | protected $htmlForm; |
---|
14 | protected $label; |
---|
15 | protected $widthlabel; |
---|
16 | protected $widthinput; |
---|
17 | |
---|
18 | function desenhaHtmlForm($options,$showTableDivision = true, $showTableRow = true){ |
---|
19 | switch($this->tipo){ |
---|
20 | case 'periodo' : $this->formInput($options); break; |
---|
21 | case 'data' : $this->formInput($options); break; |
---|
22 | case 'moeda' : $this->formInput($options); break; |
---|
23 | case 'cpf' : $this->formInput($options); break; |
---|
24 | case 'cnpj' : $this->formInput($options); break; |
---|
25 | case 'input' : $this->formInput($options); break; |
---|
26 | case 'select' : $this->formSelect($options); break; |
---|
27 | case 'checkbox' : $this->formCheckBox($options); break; |
---|
28 | case 'radio' : $this->formRadio($options); break; |
---|
29 | case 'textarea' : $this->formTextArea($options); break; |
---|
30 | case 'button' : $this->formButton($options); break; |
---|
31 | case 'hidden' : $this->formHidden(false,false); break; |
---|
32 | case 'subtitulo' : $this->formSubTitulo(); break; |
---|
33 | case 'div' : $this->formDiv(); break; |
---|
34 | case 'file' : $this->formArquivo($options); break; |
---|
35 | default: $this->formInput($options); |
---|
36 | } |
---|
37 | |
---|
38 | return $this->htmlForm; |
---|
39 | } |
---|
40 | function makeDisplayHTML($options,$tipo = "input") { |
---|
41 | $opentr = $options["open_tr"]; |
---|
42 | $opentd = $options["open_td"]; |
---|
43 | $makedivision = $options["makedivision"]; |
---|
44 | $makedivision_colspan = $options["makedivision_colspan"]; |
---|
45 | $open_td_colspan = $options["open_td_colspan"]; |
---|
46 | $closetd = $options["close_td"]; |
---|
47 | $closetr = $options["close_tr"]; |
---|
48 | |
---|
49 | if ($opentr) echo "\n\t<tr>"; |
---|
50 | if ($makedivision) { |
---|
51 | if ($makedivision_colspan) $addcolspan = " colspan=" . $makedivision_colspan; |
---|
52 | if ($this->widthlabel) { $addwidthlabel = " width='" . $this->widthlabel . "'"; } |
---|
53 | echo "\n\t\t<td" . $addwidthlabel . $addcolspan ." nowrap>"; |
---|
54 | } |
---|
55 | echo "<label id='id_lbl_" . $this->name . "' for='" . $this->obrigatorio . "id_" . $this->name . "'>". $this->label . "</label>"; |
---|
56 | if ($makedivision) echo "</td>"; |
---|
57 | if ($opentd) { |
---|
58 | if ($open_td_colspan) $addcolspan2 = " colspan=" . $open_td_colspan; |
---|
59 | if ($this->widthinput) { $addwidthinput = " width='" . $this->widthinput . "'"; } |
---|
60 | echo "\n\t\t<td" . $addwidthinput . $addcolspan2 . ">"; |
---|
61 | } |
---|
62 | |
---|
63 | echo "\n\t\t\t<span id='span_id_" . $this->name . "'>"; |
---|
64 | if ($tipo == "input") { $this->input(); } |
---|
65 | if ($tipo == "select") { $this->select(); } |
---|
66 | if ($tipo == "checkbox") { $this->checkbox(); } |
---|
67 | if ($tipo == "radio") { $this->radio(); } |
---|
68 | if ($tipo == "textarea") { $this->textarea(); } |
---|
69 | if ($tipo == "arquivo") { $this->arquivo(); } |
---|
70 | if ($tipo == "button") { $this->button(); } |
---|
71 | echo "</span>"; |
---|
72 | if ($closetd) echo "\n\t\t</td>"; |
---|
73 | if ($closetr) echo "\n\t</tr>\n"; |
---|
74 | |
---|
75 | return $this->htmlForm; |
---|
76 | } |
---|
77 | |
---|
78 | function formInput($options = array()){ |
---|
79 | //$this->input(); |
---|
80 | return $this->makeDisplayHTML($options); |
---|
81 | } |
---|
82 | |
---|
83 | function formSelect($options){ |
---|
84 | //$this->select(); |
---|
85 | return $this->makeDisplayHTML($options,"select"); |
---|
86 | } |
---|
87 | function formCheckbox($options){ |
---|
88 | //$this->checkbox(); |
---|
89 | return $this->makeDisplayHTML($options,"checkbox"); |
---|
90 | } |
---|
91 | function formRadio($options){ |
---|
92 | //$this->radio(); |
---|
93 | return $this->makeDisplayHTML($options,"radio"); |
---|
94 | } |
---|
95 | function formHidden() { |
---|
96 | echo "\n\t\t\t" . $this->input(); |
---|
97 | } |
---|
98 | function formTextArea($options){ |
---|
99 | // $this->textArea(); |
---|
100 | return $this->makeDisplayHTML($options,"textarea"); |
---|
101 | } |
---|
102 | function formButton($options){ |
---|
103 | //$this->button(); |
---|
104 | return $this->makeDisplayHTML($options,"button"); |
---|
105 | } |
---|
106 | function formSubTitulo() { |
---|
107 | echo "\n\t\t</td>\n\t</tr>\n\t</table>\n\t<table width='100%'>\n\t<tr>\n\t\t<td>\n\t\t\t <br><br>\n\t\t</td>\n\t</tr>\n\t<tr class='tableSubTitulo'>\n\t\t<td colspan='1000'><h2>" . $this->value . "</h2></td>\n\t</tr>\n\t<tr><td> </td></tr>"; |
---|
108 | } |
---|
109 | function formDiv() { |
---|
110 | echo "\n\t\t</td>\n\t</tr>\n\t</table>\n\t<table width='100%'>\n\t\n\t<div id='" . $this->value . "'></div>\n\t"; |
---|
111 | } |
---|
112 | function formArquivo($options) { |
---|
113 | //$this->arquivo(); |
---|
114 | return $this->makeDisplayHTML($options,"arquivo"); |
---|
115 | } |
---|
116 | function setLabel($label){ |
---|
117 | $this->label = $label; |
---|
118 | } |
---|
119 | |
---|
120 | } |
---|
121 | |
---|
122 | |
---|
123 | |
---|
124 | ?> |
---|