MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mtabbedform2.class
Ir para a documentação deste ficheiro.
1<?php
2#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3# @title
4# Tabbed Form 2
5#
6# @description
7#
8#
9#
10# @topics form, tabbedform
11#
12# @created
13# 2003/06/11
14#
15# @organisation
16# MIOLO - Miolo Development Team - SOLIS/UNIVATES
17#
18# @legal
19# CopyLeft (L) 2003 SOLIS - Cooperativa de Solucoes Livres
20# Licensed under GPL (see COPYING.TXT or FSF at www.fsf.org for
21# further details)
22#
23# @contributors
24# Vilson Cristiano Gartner [author] [vgartner@univates.br]
25#
26# @maintainers
27# Vilson Cristiano Gartner [author] [vgartner@univates.br]
28# Thomas Spriestersbach [author] [ts@interact2000.com.br]
29#
30# @history
31# See history in CVS repository:
32# http://codigolivre.org.br/cvs/?group_id=70
33#
34# @Id $Id: tabbedform2.class,v 1.1 2003/06/17 20:04:57 vgartner Exp $
35#---------------------------------------------------------------------
36
41class MTabbedForm2 extends MForm
42{
43 // member variables
47 var $pages;
48
52 var $css='tab';
53
54
59 // class constructor
70 function __construct($title='',$action='')
71 {
72 parent::__construct($title,$action);
73 $this->css = 'tab';
74 }
75
85 function SetCSS($file='')
86 {
87 if ( ! $file )
88 {
89 $file = 'tab';
90 }
91
92 $this->css = $file;
93 }
94
95
107 {
108 $n = count($fields);
109
110 //Add prefix 'frm_' which identifies form variables and
111 //distinguishes them from other possible variables
112 for ( $i=0; $i<$n; $i++ )
113 {
114 if ( $fields[$i]->name )
115 {
116 $fields[$i]->name = $fields[$i]->name;
117
118 if ( is_subclass_of($fields[$i],'radiobutton') || is_subclass_of($fields[$i],'checkbox') )
119 {
120 $fields[$i]->checked = ( $_REQUEST[$fields[$i]->name] == "{$fields[$i]->value}" );
121 }
122 else if ( ! $fields[$i]->value )
123 {
124 $fields[$i]->value = $_REQUEST[$fields[$i]->name];
125 }
126
127 $fields[$i]->value = $this->EscapeValue($fields[$i]->value);
128 }
129 }
130
131 $this->pages[$title] = $fields;
132 }
133
134
135 //
136 // returns a plain list of all fields contained in the form
137 //
145 function GetFieldList()
146 {
147 $fields = array();
148
149 foreach($this->pages as $page)
150 {
151 $fields = array_merge($fields,$this->_GetFieldList($page));
152 }
153
154 return $fields;
155 }
156
157
158 //
159 // Generate form body
160 //
168 function GenerateBody()
169 {
170 // optionally generate errors
171 if ( $this->HasErrors() )
172 {
173 $this->GenerateErrors();
174 }
175
176 $hidden = null;
177
178 echo '<script type="text/javascript" src="scripts/tabpane.js"></script>';
179 echo "<link type=\"text/css\" rel=\"StyleSheet\" href=\"/theme/miolo/{$this->css}.css\" />";
180
181 echo "<form name=\"{$this->name}\" method=\"{$this->method}\" action=\"{$this->action}\"" .
182 " onSubmit=\"return {$this->name}_onSubmit();\">\n";
183
184 echo "<div class=\"tab-pane\" id=\"tab-pane-1\">\n";
185 $n = 0;
186
187 foreach($this->pages as $page)
188 {
189 $title = array_keys($this->pages);
190
191 echo "<div class=\"tab-page\">\n";
192 echo "<h2 class=\"tab\">". $title[$n] ."</h2>\n";
193
194 //$this->LayoutFormFields($page,$hidden);
195 $this->GenerateLayoutFields($hidden);
196 vaR_dump($hidden);
197
198 echo "</div>\n";
199 $n += 1;
200 }
201
202 echo '<script type="text/javascript">';
203 echo ' setupAllTabs();';
204 echo '</script>';
205
206 if ( $this->buttons )
207 {
208 foreach ( $this->buttons as $b )
209 {
210 $b->Generate();
211 }
212 }
213
214 if ( $this->reset )
215 {
216 echo(" <input type=\"reset\">\n");
217 }
218
219 if ( $this->return )
220 {
221 echo(" <input name=\"return\" type=\"button\" value=\"Retornar\" onclick=\"javascript:history.go(-1)\">\n");
222 }
223
224 if ( $hidden )
225 {
226 echo " <!-- START OF HIDDEN FIELDS -->\n";
227
228 foreach ( $hidden as $h )
229 {
230 echo " ";
231 $h->Generate();
232 echo "\n";
233 }
234
235 echo " <!-- END OF HIDDEN FIELDS -->\n";
236 }
237
238 echo "</form>\n";
239
240 $this->GenerateScript();
241
242 }
243
251 function generateInner()
252 { global $MIOLO;
253
254 if ( !isset($this->buttons) )
255 {
256 if ($this->defaultButton)
257 {
258 $this->buttons[] = new FormButton( FORM_SUBMIT_BTN_NAME, 'Enviar','SUBMIT');
259 }
260 }
261 //$title = HtmlPainter::GenerateToString($this->GenerateTitle());
262 $body = HtmlPainter::GenerateToString($this->GenerateBody());
263 $footer = HtmlPainter::GenerateToString($this->GenerateFooter());
264
265 $f = new Div('', array($title,$body,$footer), 'formBox');
267 }
268
269 function generate()
270 {
271 $this->generateInner();
272 }
273
275 {
276 }
277
278
279 function setCurrentPage()
280 {
281 }
282
283
284}
285
286?>
GenerateElements($elements, $separator='', $method='Generate')
Definição mform.class:9
GenerateLayoutFields(&$hidden)
Definição mform.class:1968
GenerateScript()
Definição mform.class:2242
HasErrors()
Definição mform.class:1325
$action
Definição mform.class:18
$fields
Definição mform.class:33
$footer
Definição mform.class:58
GenerateFooter()
Definição mform.class:1954
$title
Definição mform.class:13
GenerateErrors()
Definição mform.class:1855
SetCSS($file='')
AddPage($title, $fields)
__construct($title='', $action='')
const FORM_SUBMIT_BTN_NAME
Definição mform.class:2