Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

preview.php
Go to the documentation of this file.
1 <?php
4 // include_once( "classes/INIFile.php" );
5 // include_once( "classes/eztemplate.php" );
6 // include_once( "ezsurvey/classes/ezsurvey.php" );
7 // include_once( "ezsurvey/classes/ezquestion.php" );
8
9 $ini =& eZINI::instance( 'site.ini' );
10 $Language = $ini->variable( "eZSurveyMain", "Language" );
11
12 $SurveyID = $url_array[3];
13 $Page = $url_array[4];
14
15 $t = new eZTemplate( "kernel/ezsurvey/admin/" . $ini->variable( "eZSurveyMain", "AdminTemplateDir" ),
16 "kernel/ezsurvey/admin/intl", $Language, "preview.php" );
17
18 $t->set_file( "preview_tpl", "preview.tpl" );
19 $t->setAllStrings();
20
21 $t->set_block( "preview_tpl", "subtitle_section_tpl", "subtitle_section" );
22
23 $t->set_block( "preview_tpl", "value_list_tpl", "value_list" );
24 $t->set_block( "value_list_tpl", "yesno_tpl", "yesno" );
25
26 $t->set_block( "value_list_tpl", "radio_tpl", "radio" );
27 $t->set_block( "radio_tpl", "radio_item_tpl", "radio_item" );
28 $t->set_block( "radio_tpl", "radio_other_tpl", "radio_other" );
29
30 $t->set_block( "value_list_tpl", "checkbox_tpl", "checkbox" );
31 $t->set_block( "checkbox_tpl", "checkbox_item_tpl", "checkbox_item" );
32 $t->set_block( "checkbox_tpl", "checkbox_other_tpl", "checkbox_other" );
33
34 $t->set_block( "value_list_tpl", "rate_tpl", "rate" );
35 $t->set_block( "rate_tpl", "rate_item_tpl", "rate_item" );
36
37 $t->set_block( "value_list_tpl", "text_tpl", "text" );
38 $t->set_block( "value_list_tpl", "essay_tpl", "essay" );
39 $t->set_block( "value_list_tpl", "date_tpl", "date" );
40 $t->set_block( "value_list_tpl", "numeric_tpl", "numeric" );
41
42 $t->set_block( "value_list_tpl", "dropdown_tpl", "dropdown" );
43 $t->set_block( "dropdown_tpl", "dropdown_item_tpl", "dropdown_item" );
44
45 $t->set_block( "preview_tpl", "next_page_button_tpl", "next_page_button" );
46 $t->set_block( "preview_tpl", "previous_page_button_tpl", "previous_page_button" );
47
48 $t->set_var( "survey_id", $SurveyID );
49 $t->set_var( "subtitle_section", "" );
50 $t->set_var( "value_list", "" );
51
52 if ( $Page == "" )
53 {
54 $Page = 1;
55 }
56
57 if ( isset( $OK ) )
58 {
59 eZHTTPTool::header( "Location: /survey/surveyedit/edit/$SurveyID" );
60 exit();
61 }
62
63 if ( isset( $NextPage ) )
64 {
65 $Page++;
66 }
67 if ( isset( $PreviousPage ) )
68 {
69 $Page--;
70 }
71
72 $survey = new eZSurvey( $SurveyID );
73
74 $t->set_var( "title", $survey->title() );
75
76 if ( $survey->subTitle() != "" )
77 {
78 $t->set_var( "subtitle", $survey->subTitle() );
79 $t->parse( "subtitle_section", "subtitle_section_tpl" );
80 }
81
82 $t->set_var( "info", $survey->info() );
83
84 $totalPages = $survey->numberOfPages();
85 $t->set_var( "page_number", $Page );
86 $t->set_var( "page_total", $totalPages );
87
88 $question_array = $survey->surveyQuestions( "Position", $Page );
89
90 $position = 0;
91 foreach ( $question_array as $questionItem )
92 {
93 // limpar as vari�veis
94 $t->set_var( "yesno", "" );
95 $t->set_var( "checkbox", "" );
96 $t->set_var( "radio", "" );
97 $t->set_var( "dropdown", "" );
98 $t->set_var( "rate", "" );
99 $t->set_var( "text", "" );
100 $t->set_var( "essay", "" );
101 $t->set_var( "date", "" );
102 $t->set_var( "numeric", "" );
103
104 $t->set_var( "id", $position++ );
105
106 $t->set_var( "question_name", $questionItem->content() );
107
108 if ( $questionItem->hasChoices() )
109 {
110 $questionChoice_array = $questionItem->questionChoices();
111 }
112
113 // apresentar default
114 switch ( $questionItem->questionTypeID() )
115 {
116 // Yes/No
117 case "1":
118 {
119 if ( $questionItem->initial() == "Y" )
120 {
121 $t->set_var( "selected_y", "checked" );
122 $t->set_var( "selected_n", "" );
123 }
124 else
125 {
126 $t->set_var( "selected_y", "" );
127 $t->set_var( "selected_n", "checked" );
128 }
129
130 $t->parse( "yesno", "yesno_tpl" );
131 }
132 break;
133
134 // Texto
135 case "2":
136 {
137 $t->set_var( "size", $questionItem->length() );
138 $t->set_var( "default", $questionItem->initial() );
139 $t->parse( "text", "text_tpl" );
140 }
141 break;
142
143 // Essay
144 case "3":
145 {
146 $t->set_var( "default", $questionItem->initial() );
147 $t->parse( "essay", "essay_tpl" );
148 }
149 break;
150
151 // radio
152 case "4":
153 {
154 $i = 0;
155 foreach( $questionChoice_array as $questionChoiceItem )
156 {
157 // default
158 if ( $questionItem->initial() == $questionChoiceItem->id() )
159 $t->set_var( "selected", "checked" );
160 else
161 $t->set_var( "selected", "" );
162
163 $t->set_var( "value", $questionChoiceItem->id() );
164 $t->set_var( "value_name", $questionChoiceItem->content() );
165
166
167 // other
168 if ( $questionChoiceItem->isOther() )
169 {
170 $t->set_var( "radio_item", "" );
171 $t->parse( "radio_other", "radio_other_tpl" );
172 }
173 else
174 {
175 $t->set_var( "radio_other", "" );
176 $t->parse( "radio_item", "radio_item_tpl" );
177 }
178
179 $t->parse( "radio", "radio_tpl", true );
180 }
181 }
182 break;
183
184 // checkbox
185 case "5":
186 {
187 $i = 0;
188 $default = explode( ";", $questionItem->initial() );
189 foreach( $questionChoice_array as $questionChoiceItem )
190 {
191 // default
192 if ( in_array( $questionChoiceItem->id(), $default ) )
193 $t->set_var( "selected", "checked" );
194 else
195 $t->set_var( "selected", "" );
196
197 $t->set_var( "value", $questionChoiceItem->id() );
198 $t->set_var( "value_name", $questionChoiceItem->content() );
199
200 // other
201 if ( $questionChoiceItem->isOther() )
202 {
203 $t->set_var( "checkbox_item", "" );
204 $t->parse( "checkbox_other", "checkbox_other_tpl" );
205 }
206 else
207 {
208 $t->set_var( "checkbox_other", "" );
209 $t->parse( "checkbox_item", "checkbox_item_tpl" );
210 }
211
212 $t->parse( "checkbox", "checkbox_tpl", true );
213 }
214 }
215 break;
216
217 // dropdown
218 case "6":
219 {
220 $i = 0;
221 // � opcional
222 if ( ! $questionItem->isRequired() )
223 {
224 $t->set_var( "value", "" );
225 $t->set_var( "value_name", "" );
226 $t->parse( "dropdown_item", "dropdown_item_tpl", true );
227 }
228
229 foreach( $questionChoice_array as $questionChoiceItem )
230 {
231 // default
232 if ( $questionItem->initial() == $questionChoiceItem->id() )
233 $t->set_var( "selected", "selected" );
234 else
235 $t->set_var( "selected", "" );
236
237 $t->set_var( "value", $questionChoiceItem->id() );
238 $t->set_var( "value_name", $questionChoiceItem->content() );
239 $t->parse( "dropdown_item", "dropdown_item_tpl", true );
240 }
241 $t->parse( "dropdown", "dropdown_tpl" );
242 }
243 break;
244
245 // rate
246 case "8":
247 {
248 $i = 0;
249 $t->set_var( "rate_item", "" );
250 foreach( $questionChoice_array as $questionChoiceItem )
251 {
252 $t->set_var( "value_name", $questionChoiceItem->content() );
253 $t->set_var( "id2", $i++ );
254 $t->parse( "rate_item", "rate_item_tpl", true );
255 }
256 $t->parse( "rate", "rate_tpl" );
257 }
258 break;
259
260 // Data
261 case "9":
262 {
263 $t->set_var( "size", $questionItem->length() );
264 $t->parse( "date", "date_tpl" );
265 }
266 break;
267
268 // Num�rico
269 case "10":
270 {
271 $t->set_var( "size", $questionItem->length() );
272 $t->set_var( "default", $questionItem->initial() );
273 $t->parse( "numeric", "numeric_tpl" );
274 }
275 break;
276 }
277
278 $t->parse( "value_list", "value_list_tpl", true );
279 }
280
281 // Next page button
282 if ( $Page < $totalPages )
283 $t->parse( "next_page_button", "next_page_button_tpl" );
284 else
285 $t->set_var( "next_page_button", "" );
286
287 // Previous page button
288 if ( $Page > 1 )
289 $t->parse( "previous_page_button", "previous_page_button_tpl" );
290 else
291 $t->set_var( "previous_page_button", "" );
292
293 $t->pparse( "output", "preview_tpl" );
294
295 ?>
$i
$i
Definition: admin/adlist.php:91
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZSurvey
Definition: ezsurvey.php:8
eZTemplate
Definition: eztemplate.php:107
$url_array
$url_array
Definition: ezaddress/admin/datasupplier.php:34
exit
exit
Definition: folder.php:81
$t
$t
Definition: preview.php:15
$position
$position
Definition: preview.php:90
$Language
$Language
Definition: preview.php:10
$ini
$ini
Definition: preview.php:9
$totalPages
$totalPages
Definition: preview.php:84
$Page
$Page
Definition: preview.php:13
$question_array
$question_array
Definition: preview.php:88
$survey
if( $Page=="") if(isset( $OK)) if(isset( $NextPage)) if(isset( $PreviousPage)) $survey
Definition: preview.php:72
$SurveyID
$SurveyID
Definition: preview.php:12
$questionChoice_array
$questionChoice_array
Definition: values.php:69
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.