Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

quizlist.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: quizlist.php 8125 2001-10-31 12:11:58Z jhe $
5 //
6 // Created on: <28-May-2001 11:24:41 pkej>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // include_once( "classes/INIFile.php" );
28 // include_once( "classes/ezlist.php" );
29 // include_once( "classes/ezlocale.php" );
30 // include_once( "classes/eztemplate.php" );
31
32 // include_once( "ezquiz/classes/ezquizgame.php" );
33 // include_once( "ezquiz/classes/ezquizscore.php" );
34
35 $ini =& eZINI::instance( 'site.ini' );
36
37 $Language = $ini->variable( "eZQuizMain", "Language" );
38 $ListLimit = $ini->variable( "eZQuizMain", "ListLimit" );
39
40 $intl = new eZINI( "kernel/ezquiz/user/intl/". $Language . "/quiz.php.ini" );
41 $Limit = $ListLimit;
42
43 $t = new eZTemplate( "kernel/ezquiz/user/" . $ini->variable( "eZQuizMain", "TemplateDir" ),
44 "kernel/ezquiz/user/intl/", $Language, "quiz.php" );
45
46 $t->set_file( "quiz_list_page_tpl", "quizlist.tpl" );
47
48 $t->set_block( "quiz_list_page_tpl", "game_list_item_tpl", "game_list_item" );
49 $t->set_block( "game_list_item_tpl", "game_item_tpl", "game_item" );
50 $t->set_block( "quiz_list_page_tpl", "error_item_tpl", "error_item" );
51
52 $t->set_block( "game_item_tpl", "score_link_tpl", "score_link" );
53
54 $t->set_var( "game_start", "" );
55 $t->set_var( "game_stop", "" );
56 $t->set_var( "game_list_item", "" );
57 $t->set_var( "game_item", "" );
58 $t->set_var( "error_item", "" );
59
60 $game = new eZQuizGame();
61 $score = new eZQuizScore();
62
63 switch ( $Action )
64 {
65 case "list":
66 {
67 $games = $game->getAll( $Offset, $Limit );
68 $gameCount = $game->count();
69 $isGame = true;
70 $t->set_var( "header_of_page", "header_game_list" );
71 }
72 break;
73 case "future":
74 {
75 $games = $game->opensNext( $Offset, $Limit );
76 $gameCount = $game->numberOfOpenGames();
77 $isGame = true;
78 $t->set_var( "header_of_page", "header_future_game_list" );
79 }
80 break;
81 case "past":
82 {
83 $games = $game->closedGames( $Offset, $Limit );
84 $gameCount = $game->numberOfClosedGames();
85 $isGame = true;
86 $t->set_var( "header_of_page", "header_past_game_list" );
87 }
88 break;
89 case "open":
90 {
91 $scores = $score->getAllSavedByUser( $user, $Offset, $Limit );
92 $gameCount = $score->countAllSavedByUser( $user );
93 $isScore = true;
94 $t->set_var( "header_of_page", "header_open_game_list" );
95 }
96 break;
97 case "closed":
98 {
99 $scores = $score->getAllByUser( $user, $Offset, $Limit );
100 $gameCount = $score->countAllByUser( $user );
101 $isScore = true;
102 $t->set_var( "header_of_page", "header_closed_game_list" );
103 }
104 break;
105 }
106
107 if ( $isGame )
108 {
109 $count = count( $games );
110 }
111 else
112 {
113 $count = count( $scores );
114 }
115 $locale = new eZLocale( $Language );
116
117 if ( $count > 0 && $isGame )
118 {
119 $i = 0;
120 foreach ( $games as $game )
121 {
122 if ( ( $i % 2 ) == 0 )
123 {
124 $t->set_var( "td_class", "bglight" );
125 }
126 else
127 {
128 $t->set_var( "td_class", "bgdark" );
129 }
130
131 $t->set_var( "game_id", $game->id() );
132 $t->set_var( "game_name", $game->name() );
133 $t->set_var( "game_description", $game->description() );
134 $t->set_var( "game_questions", $game->numberOfQuestions() );
135 $t->set_var( "game_players", $game->numberOfPlayers() );
136 $start = $game->startDate();
137 $stop = $game->stopDate();
138
139 if ( $start->day() != 0 )
140 {
141 $t->set_var( "game_start", $locale->format( $start, true ) );
142 }
143
144 if ( $stop->day() != 0 )
145 {
146 $t->set_var( "game_stop", $locale->format( $stop, true ) );
147 }
148
149 if ( $game->isFutureGame() )
150 {
151 $t->set_var( "score_link", "&nbsp;" );
152 }
153 else
154 {
155 $t->parse( "score_link", "score_link_tpl" );
156 }
157
158
159 $t->parse( "game_item", "game_item_tpl", true );
160 $i++;
161 }
162 $t->parse( "game_list_item", "game_list_item_tpl" );
163 }
164 elseif ( $count > 0 && $isScore )
165 {
166 $i = 0;
167 foreach ( $scores as $score )
168 {
169 if ( ( $i % 2 ) == 0 )
170 {
171 $t->set_var( "td_class", "bglight" );
172 }
173 else
174 {
175 $t->set_var( "td_class", "bgdark" );
176 }
177
178 $game = $score->game();
179
180 $t->set_var( "game_id", $game->id() );
181 $t->set_var( "game_name", $game->name() );
182 $t->set_var( "game_description", $game->description() );
183 $t->set_var( "game_questions", $game->numberOfQuestions() );
184 $t->set_var( "game_players", $game->numberOfPlayers() );
185 $start = $game->startDate();
186 $stop = $game->stopDate();
187
188 if ( is_object( $start ) )
189 {
190 if ( $start->day() != 0 )
191 {
192 $t->set_var( "game_start", $locale->format( $start, true ) );
193 }
194 }
195
196 if ( is_object( $stop ) )
197 {
198 if ( $stop->day() != 0 )
199 {
200 $t->set_var( "game_stop", $locale->format( $stop, true ) );
201 }
202 }
203
204 if ( $game->isFutureGame() )
205 {
206 $t->set_var( "score_link", "&nbsp;" );
207 }
208 else
209 {
210 $t->parse( "score_link", "score_link_tpl" );
211 }
212
213
214 $t->parse( "game_item", "game_item_tpl", true );
215 $i++;
216 }
217 $t->parse( "game_list_item", "game_list_item_tpl" );
218 }
219 else
220 {
221 switch ( $Action )
222 {
223 case "list":
224 {
225 $error = "list_empty";
226 }
227 break;
228 case "future":
229 {
230 $error = "future_empty";
231 }
232 break;
233 case "past":
234 {
235 $error = "past_empty";
236 }
237 break;
238 case "open":
239 {
240 $error = "open_empty";
241 }
242 break;
243 case "closed":
244 {
245 $error = "closed_empty";
246 }
247 break;
248 default:
249 {
250 $error = true;
251 }
252 break;
253 }
254 }
255
256 if ( $error )
257 {
258 $GenerateStaticPage = false;
259 switch ( $error )
260 {
261 case "list_empty":
262 {
263 $t->set_var( "error_message", $intl->variable( "strings", "error_list_empty" ) );
264 $t->parse( "error_item", "error_item_tpl" );
265 }
266 break;
267 case "future_empty":
268 {
269 $t->set_var( "error_message", $intl->variable( "strings", "error_future_empty" ) );
270 $t->parse( "error_item", "error_item_tpl" );
271 }
272 break;
273 case "past_empty":
274 {
275 $t->set_var( "error_message", $intl->variable( "strings", "error_past_empty" ) );
276 $t->parse( "error_item", "error_item_tpl" );
277 }
278 break;
279 case "open_empty":
280 {
281 $t->set_var( "error_message", $intl->variable( "strings", "error_open_empty" ) );
282 $t->parse( "error_item", "error_item_tpl" );
283 }
284 break;
285 case "closed_empty":
286 {
287 $t->set_var( "error_message", $intl->variable( "strings", "error_closed_empty" ) );
288 $t->parse( "error_item", "error_item_tpl" );
289 }
290 break;
291 default:
292 {
293 $t->set_var( "error_message", $intl->variable( "strings", "error_undefined" ) );
294 $t->parse( "error_item", "error_item_tpl" );
295 }
296 break;
297 }
298 }
299
300 $t->setAllStrings();
301
302 eZList::drawNavigator( $t, $gameCount, $Limit, $Offset, "quiz_list_page_tpl" );
303
304 $t->pparse( "output", "quiz_list_page_tpl" );
305
306 ?>
$i
$i
Definition: admin/adlist.php:91
eZINI
Reads and writes .ini style configuration files.
eZList\drawNavigator
static drawNavigator(&$t, $total_types, $max_types, $index, $parent=false, $variables=false)
Definition: ezlist.php:401
eZLocale
Definition: ezlocale.php:119
eZQuizGame
Definition: ezquizgame.php:43
eZQuizScore
Definition: ezquizscore.php:43
eZTemplate
Definition: eztemplate.php:107
$Action
$Action
Definition: companysearch.php:80
$error
$error
Definition: ezarticle/admin/categoryedit.php:51
$Offset
$Offset
Definition: ezarticle/user/search.php:110
$count
$count
Definition: onlinetypelist.php:108
$Limit
$Limit
Definition: quizlist.php:41
$locale
$locale
Definition: quizlist.php:115
$t
$t
Definition: quizlist.php:43
$intl
$intl
Definition: quizlist.php:40
$ListLimit
$ListLimit
Definition: quizlist.php:38
$game
$game
Definition: quizlist.php:60
$Language
$Language
Definition: quizlist.php:37
$ini
$ini
Definition: quizlist.php:35
$score
$score
Definition: quizlist.php:61
$games
$games
Definition: quizopen.php:55
$GenerateStaticPage
$GenerateStaticPage
Definition: quizscores.php:95
$scores
$scores
Definition: quizscores.php:78
$user
$user
Definition: user/adlist.php:39
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.