Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

default.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 $t = new eZTemplate( "kernel/ezsurvey/admin/" . $ini->variable( "eZSurveyMain", "AdminTemplateDir" ),
13 "kernel/ezsurvey/admin/intl", $Language, "default.php" );
14
15 $t->set_file( "default_tpl", "default.tpl" );
16 $t->setAllStrings();
17
18 $t->set_block( "default_tpl", "value_list_tpl", "value_list" );
19 $t->set_block( "value_list_tpl", "yesno_tpl", "yesno" );
20 $t->set_block( "value_list_tpl", "radio_tpl", "radio" );
21 $t->set_block( "value_list_tpl", "checkbox_tpl", "checkbox" );
22 $t->set_block( "value_list_tpl", "text_tpl", "text" );
23 $t->set_block( "value_list_tpl", "essay_tpl", "essay" );
24 $t->set_block( "value_list_tpl", "numeric_tpl", "numeric" );
25
26 $t->set_block( "value_list_tpl", "dropdown_tpl", "dropdown" );
27 $t->set_block( "dropdown_tpl", "dropdown_item_tpl", "dropdown_item" );
28
29 $SurveyID = $url_array[3];
30 $QuestionID = $url_array[4];
31
32 $t->set_var( "survey_id", $SurveyID );
33 $t->set_var( "question_id", $QuestionID );
34
35 $t->set_var( "yesno", "" );
36 $t->set_var( "checkbox", "" );
37 $t->set_var( "radio", "" );
38 $t->set_var( "dropdown", "" );
39 $t->set_var( "text", "" );
40 $t->set_var( "essay", "" );
41 $t->set_var( "numeric", "" );
42
43 $question = new eZQuestion( $QuestionID );
44
45 // retira default
46 if ( isset( $Clear ) )
47 {
48 $question->setInitial( "" );
49 $question->store();
50 }
51
52 // gravar altera��es
53 if ( (isset( $Store ) || isset( $OK )) && isset( $Value ) )
54 {
55 switch ( $question->questionTypeID() )
56 {
57 case $question->TYPE_YESNO:
58 case $question->TYPE_TEXTBOX:
59 case $question->TYPE_TEXTAREA:
60 case $question->TYPE_RADIO:
61 case $question->TYPE_DROPDOWN:
62 case $question->TYPE_NUMERIC:
63 {
64 $question->setInitial( $Value[0] );
65 $question->store();
66 }
67 break;
68
69 case $question->TYPE_CHECKBOX:
70 {
71 $question->setInitial( implode( ";", $Value ) );
72 $question->store();
73 }
74 break;
75 }
76 }
77
78 if( isset( $OK ) )
79 {
80 eZHTTPTool::header( "Location: /survey/surveyedit/edit/$SurveyID" );
81 exit();
82 }
83
84 if ( $question->hasChoices() )
85 {
86 $questionChoice_array = $question->questionChoices();
87 }
88
89 // apresentar default
90 switch ( $question->questionTypeID() )
91 {
92 // Yes/No
93 case $question->TYPE_YESNO:
94 {
95 $t->set_var( "selected_n", "" );
96 $t->set_var( "selected_y", "" );
97
98 if ( $question->initial() == "Y" )
99 {
100 $t->set_var( "selected_y", "checked" );
101 }
102 elseif ( $question->initial() == "N" )
103 {
104 $t->set_var( "selected_n", "checked" );
105 }
106
107 $t->parse( "yesno", "yesno_tpl" );
108 }
109 break;
110
111 // Texto
112 case $question->TYPE_TEXTBOX:
113 {
114 $t->set_var( "size", $question->length() );
115 $t->set_var( "default", $question->initial() );
116 $t->parse( "text", "text_tpl" );
117 }
118 break;
119
120 // Essay
121 case $question->TYPE_TEXTAREA:
122 {
123 $t->set_var( "default", $question->initial() );
124 $t->parse( "essay", "essay_tpl" );
125 }
126 break;
127
128 // radio
129 case $question->TYPE_RADIO:
130 {
131 $i = 0;
132 foreach( $questionChoice_array as $questionItem )
133 {
134 if ($i++ % 2)
135 $t->set_var( "td_class", "bgdark" );
136 else
137 $t->set_var( "td_class", "bglight" );
138
139 // default
140 if ( $question->initial() == $questionItem->id() )
141 $t->set_var( "selected", "checked" );
142 else
143 $t->set_var( "selected", "" );
144
145 $t->set_var( "value", $questionItem->id() );
146 $t->set_var( "value_name", $questionItem->content() );
147 $t->parse( "radio", "radio_tpl", true );
148 }
149 }
150 break;
151
152 // checkbox
153 case $question->TYPE_CHECKBOX:
154 {
155 $i = 0;
156 $default = explode( ";", $question->initial() );
157 foreach( $questionChoice_array as $questionItem )
158 {
159 if ($i++ % 2)
160 $t->set_var( "td_class", "bgdark" );
161 else
162 $t->set_var( "td_class", "bglight" );
163
164 // default
165 if ( in_array( $questionItem->id(), $default ) )
166 $t->set_var( "selected", "checked" );
167 else
168 $t->set_var( "selected", "" );
169
170 $t->set_var( "value", $questionItem->id() );
171 $t->set_var( "value_name", $questionItem->content() );
172 $t->parse( "checkbox", "checkbox_tpl", true );
173 }
174 }
175 break;
176
177 // dropdown
178 case $question->TYPE_DROPDOWN:
179 {
180 $i = 0;
181 // � opcional
182 if ( ! $question->isRequired() )
183 {
184 $t->set_var( "value", "" );
185 $t->set_var( "value_name", "" );
186 $t->parse( "dropdown_item", "dropdown_item_tpl", true );
187 }
188
189 foreach( $questionChoice_array as $questionItem )
190 {
191 if ($i++ % 2)
192 $t->set_var( "td_class", "bgdark" );
193 else
194 $t->set_var( "td_class", "bglight" );
195
196 // default
197 if ( $question->initial() == $questionItem->id() )
198 $t->set_var( "selected", "selected" );
199 else
200 $t->set_var( "selected", "" );
201
202 $t->set_var( "value", $questionItem->id() );
203 $t->set_var( "value_name", $questionItem->content() );
204 $t->parse( "dropdown_item", "dropdown_item_tpl", true );
205 }
206 $t->parse( "dropdown", "dropdown_tpl" );
207 }
208 break;
209
210 // Num�rico
211 case $question->TYPE_NUMERIC:
212 {
213 $t->set_var( "size", $question->length() );
214 $t->set_var( "value", $question->initial() );
215 $t->parse( "numeric", "numeric_tpl" );
216 }
217 break;
218 }
219
220 $t->parse( "value_list", "value_list_tpl" );
221
222 $t->pparse( "output", "default_tpl" );
223
224 ?>
$i
$i
Definition: admin/adlist.php:91
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZQuestion
Definition: ezquestion.php:11
eZTemplate
Definition: eztemplate.php:107
$t
$t
Definition: default.php:12
$QuestionID
$QuestionID
Definition: default.php:30
$Language
$Language
Definition: default.php:10
$ini
$ini
Definition: default.php:9
$question
$question
Definition: default.php:43
$SurveyID
$SurveyID
Definition: default.php:29
$url_array
$url_array
Definition: ezaddress/admin/datasupplier.php:34
$Value
$Value
Definition: ezquestionchoice.php:118
exit
exit
Definition: folder.php:81
$questionChoice_array
$questionChoice_array
Definition: values.php:69
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.