1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
5 | // | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | branch : BSF (Best So Far) |
---|
8 | // | file : $RCSfile$ |
---|
9 | // | last update : $Date: 2006-03-17 04:13:19 +0000 (Fri, 17 Mar 2006) $ |
---|
10 | // | last modifier : $Author: rvelices $ |
---|
11 | // | revision : $Revision: 1086 $ |
---|
12 | // +-----------------------------------------------------------------------+ |
---|
13 | // | This program is free software; you can redistribute it and/or modify | |
---|
14 | // | it under the terms of the GNU General Public License as published by | |
---|
15 | // | the Free Software Foundation | |
---|
16 | // | | |
---|
17 | // | This program is distributed in the hope that it will be useful, but | |
---|
18 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
19 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
20 | // | 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, | |
---|
25 | // | USA. | |
---|
26 | // +-----------------------------------------------------------------------+ |
---|
27 | |
---|
28 | //--------------------------------------------------------------------- include |
---|
29 | define('PHPWG_ROOT_PATH','./'); |
---|
30 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
31 | include(PHPWG_ROOT_PATH.'include/section_init.inc.php'); |
---|
32 | |
---|
33 | // +-----------------------------------------------------------------------+ |
---|
34 | // | Check Access and exit when user status is not ok | |
---|
35 | // +-----------------------------------------------------------------------+ |
---|
36 | check_status(ACCESS_GUEST); |
---|
37 | |
---|
38 | //---------------------------------------------------------------------- logout |
---|
39 | if ( isset( $_GET['act'] ) |
---|
40 | and $_GET['act'] == 'logout' |
---|
41 | and isset( $_COOKIE[session_name()] ) ) |
---|
42 | { |
---|
43 | // cookie deletion if exists |
---|
44 | $_SESSION = array(); |
---|
45 | session_unset(); |
---|
46 | session_destroy(); |
---|
47 | setcookie(session_name(),'',0, cookie_path() ); |
---|
48 | $url = 'category.php'; |
---|
49 | redirect( $url ); |
---|
50 | } |
---|
51 | |
---|
52 | //---------------------------------------------- change of image display order |
---|
53 | if (isset($_GET['image_order'])) |
---|
54 | { |
---|
55 | setcookie( |
---|
56 | 'pwg_image_order', |
---|
57 | $_GET['image_order'] > 0 ? $_GET['image_order'] : '', |
---|
58 | 0 |
---|
59 | ); |
---|
60 | |
---|
61 | redirect( |
---|
62 | duplicate_index_URL( |
---|
63 | array(), // nothing to redefine |
---|
64 | array('start') // changing display order goes back to section first page |
---|
65 | ) |
---|
66 | ); |
---|
67 | } |
---|
68 | //-------------------------------------------------------------- initialization |
---|
69 | // detection of the start picture to display |
---|
70 | if (!isset($page['start'])) |
---|
71 | { |
---|
72 | $page['start'] = 0; |
---|
73 | } |
---|
74 | |
---|
75 | // access authorization check |
---|
76 | if (isset($page['category'])) |
---|
77 | { |
---|
78 | check_restrictions($page['category']); |
---|
79 | } |
---|
80 | |
---|
81 | if (isset($page['cat_nb_images']) |
---|
82 | and $page['cat_nb_images'] > $user['nb_image_page']) |
---|
83 | { |
---|
84 | $page['navigation_bar'] = create_navigation_bar( |
---|
85 | duplicate_index_URL(array(), array('start')), |
---|
86 | $page['cat_nb_images'], |
---|
87 | $page['start'], |
---|
88 | $user['nb_image_page'], |
---|
89 | true |
---|
90 | ); |
---|
91 | } |
---|
92 | else |
---|
93 | { |
---|
94 | $page['navigation_bar'] = ''; |
---|
95 | } |
---|
96 | |
---|
97 | // caddie filling :-) |
---|
98 | if (isset($_GET['caddie'])) |
---|
99 | { |
---|
100 | fill_caddie($page['items']); |
---|
101 | // redirect(); |
---|
102 | } |
---|
103 | |
---|
104 | //----------------------------------------------------- template initialization |
---|
105 | // |
---|
106 | // Start output of page |
---|
107 | // |
---|
108 | $title = $page['title']; |
---|
109 | $page['body_id'] = 'theCategoryPage'; |
---|
110 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
111 | |
---|
112 | $template->set_filenames( array('category'=>'category.tpl') ); |
---|
113 | //-------------------------------------------------------------- category title |
---|
114 | if (isset($page['category'])) |
---|
115 | { |
---|
116 | $template_title = get_cat_display_name( |
---|
117 | $page['cat_name'], |
---|
118 | 'category.php?/category/', |
---|
119 | false |
---|
120 | ); |
---|
121 | } |
---|
122 | else |
---|
123 | { |
---|
124 | $template_title = $page['title']; |
---|
125 | } |
---|
126 | |
---|
127 | if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0) |
---|
128 | { |
---|
129 | $template_title.= ' ['.$page['cat_nb_images'].']'; |
---|
130 | } |
---|
131 | |
---|
132 | $icon_recent = get_icon(date('Y-m-d')); |
---|
133 | |
---|
134 | if (!isset($page['chronology'])) |
---|
135 | { |
---|
136 | $chronology = |
---|
137 | array( |
---|
138 | 'chronology' => |
---|
139 | array( |
---|
140 | 'field' => 'created', |
---|
141 | 'style' => 'monthly', |
---|
142 | 'view' => 'list', |
---|
143 | ) |
---|
144 | ); |
---|
145 | $template->assign_block_vars( |
---|
146 | 'mode_created', |
---|
147 | array( |
---|
148 | 'URL' => duplicate_index_URL( $chronology, array('start') ) |
---|
149 | ) |
---|
150 | ); |
---|
151 | |
---|
152 | $chronology['chronology']['field'] = 'posted'; |
---|
153 | $template->assign_block_vars( |
---|
154 | 'mode_posted', |
---|
155 | array( |
---|
156 | 'URL' => duplicate_index_URL( $chronology, array('start') ) |
---|
157 | ) |
---|
158 | ); |
---|
159 | } |
---|
160 | else |
---|
161 | { |
---|
162 | $template->assign_block_vars( |
---|
163 | 'mode_normal', |
---|
164 | array( |
---|
165 | 'URL' => duplicate_index_URL( array(), array('chronology','start') ) |
---|
166 | ) |
---|
167 | ); |
---|
168 | |
---|
169 | $chronology = $page['chronology']; |
---|
170 | if ($chronology['field'] == 'created') |
---|
171 | { |
---|
172 | $chronology['field'] = 'posted'; |
---|
173 | } |
---|
174 | else |
---|
175 | { |
---|
176 | $chronology['field'] = 'created'; |
---|
177 | } |
---|
178 | $url = duplicate_index_URL( |
---|
179 | array( |
---|
180 | 'chronology'=>$chronology |
---|
181 | ), |
---|
182 | array('chronology_date', 'start') |
---|
183 | ); |
---|
184 | $template->assign_block_vars( |
---|
185 | 'mode_'.$chronology['field'], |
---|
186 | array('URL' => $url ) |
---|
187 | ); |
---|
188 | } |
---|
189 | |
---|
190 | $template->assign_vars( |
---|
191 | array( |
---|
192 | 'NB_PICTURE' => $user['nb_total_images'], |
---|
193 | 'TITLE' => $template_title, |
---|
194 | 'USERNAME' => $user['username'], |
---|
195 | 'TOP_NUMBER' => $conf['top_number'], |
---|
196 | 'MENU_CATEGORIES_CONTENT' => get_categories_menu(), |
---|
197 | |
---|
198 | 'F_IDENTIFY' => PHPWG_ROOT_PATH.'identification.php', |
---|
199 | 'T_RECENT' => $icon_recent, |
---|
200 | |
---|
201 | 'U_HOME' => make_index_URL(), |
---|
202 | 'U_REGISTER' => PHPWG_ROOT_PATH.'register.php', |
---|
203 | 'U_LOST_PASSWORD' => PHPWG_ROOT_PATH.'password.php', |
---|
204 | 'U_LOGOUT' => make_index_URL().'&act=logout', |
---|
205 | 'U_ADMIN'=> PHPWG_ROOT_PATH.'admin.php', |
---|
206 | 'U_PROFILE'=> PHPWG_ROOT_PATH.'profile.php', |
---|
207 | ) |
---|
208 | ); |
---|
209 | |
---|
210 | if ('search' == $page['section']) |
---|
211 | { |
---|
212 | $template->assign_block_vars( |
---|
213 | 'search_rules', |
---|
214 | array( |
---|
215 | 'URL' => PHPWG_ROOT_PATH.'/search_rules.php?search_id='.$page['search'], |
---|
216 | ) |
---|
217 | ); |
---|
218 | } |
---|
219 | //-------------------------------------------------------------- external links |
---|
220 | if (count($conf['links']) > 0) |
---|
221 | { |
---|
222 | $template->assign_block_vars('links', array()); |
---|
223 | |
---|
224 | foreach ($conf['links'] as $url => $label) |
---|
225 | { |
---|
226 | $template->assign_block_vars( |
---|
227 | 'links.link', |
---|
228 | array( |
---|
229 | 'URL' => $url, |
---|
230 | 'LABEL' => $label |
---|
231 | ) |
---|
232 | ); |
---|
233 | } |
---|
234 | } |
---|
235 | //---------------------------------------------------------- special categories |
---|
236 | // favorites categories |
---|
237 | if ( !$user['is_the_guest'] ) |
---|
238 | { |
---|
239 | $template->assign_block_vars('username', array()); |
---|
240 | |
---|
241 | $template->assign_block_vars( |
---|
242 | 'special_cat', |
---|
243 | array( |
---|
244 | 'URL' => make_index_URL(array('section' => 'favorites')), |
---|
245 | 'TITLE' => $lang['favorite_cat_hint'], |
---|
246 | 'NAME' => $lang['favorite_cat'] |
---|
247 | )); |
---|
248 | } |
---|
249 | // most visited |
---|
250 | $template->assign_block_vars( |
---|
251 | 'special_cat', |
---|
252 | array( |
---|
253 | 'URL' => make_index_URL(array('section' => 'most_visited')), |
---|
254 | 'TITLE' => $lang['most_visited_cat_hint'], |
---|
255 | 'NAME' => $lang['most_visited_cat'] |
---|
256 | )); |
---|
257 | // best rated |
---|
258 | if ($conf['rate']) |
---|
259 | { |
---|
260 | $template->assign_block_vars( |
---|
261 | 'special_cat', |
---|
262 | array( |
---|
263 | 'URL' => make_index_URL(array('section' => 'best_rated')), |
---|
264 | 'TITLE' => $lang['best_rated_cat_hint'], |
---|
265 | 'NAME' => $lang['best_rated_cat'] |
---|
266 | ) |
---|
267 | ); |
---|
268 | } |
---|
269 | // random |
---|
270 | $template->assign_block_vars( |
---|
271 | 'special_cat', |
---|
272 | array( |
---|
273 | 'URL' => PHPWG_ROOT_PATH.'random.php', |
---|
274 | 'TITLE' => $lang['random_cat_hint'], |
---|
275 | 'NAME' => $lang['random_cat'] |
---|
276 | )); |
---|
277 | // recent pics |
---|
278 | $template->assign_block_vars( |
---|
279 | 'special_cat', |
---|
280 | array( |
---|
281 | 'URL' => make_index_URL(array('section' => 'recent_pics')), |
---|
282 | 'TITLE' => $lang['recent_pics_cat_hint'], |
---|
283 | 'NAME' => $lang['recent_pics_cat'] |
---|
284 | )); |
---|
285 | // recent cats |
---|
286 | $template->assign_block_vars( |
---|
287 | 'special_cat', |
---|
288 | array( |
---|
289 | 'URL' => make_index_URL(array('section' => 'recent_cats')), |
---|
290 | 'TITLE' => $lang['recent_cats_cat_hint'], |
---|
291 | 'NAME' => $lang['recent_cats_cat'] |
---|
292 | )); |
---|
293 | |
---|
294 | // calendar |
---|
295 | $template->assign_block_vars( |
---|
296 | 'special_cat', |
---|
297 | array( |
---|
298 | 'URL' => |
---|
299 | make_index_URL( |
---|
300 | array( |
---|
301 | 'chronology'=> |
---|
302 | array( |
---|
303 | 'field' => ($conf['calendar_datefield']=='date_available' ? 'posted' : 'created'), |
---|
304 | 'style' => 'monthly', |
---|
305 | 'view' => 'calendar' |
---|
306 | ) |
---|
307 | ) |
---|
308 | ), |
---|
309 | 'TITLE' => $lang['calendar_hint'], |
---|
310 | 'NAME' => $lang['calendar'] |
---|
311 | ) |
---|
312 | ); |
---|
313 | //--------------------------------------------------------------------- summary |
---|
314 | |
---|
315 | if ($user['is_the_guest']) |
---|
316 | { |
---|
317 | $template->assign_block_vars('register', array()); |
---|
318 | $template->assign_block_vars('login', array()); |
---|
319 | |
---|
320 | $template->assign_block_vars('quickconnect', array()); |
---|
321 | if ($conf['authorize_remembering']) |
---|
322 | { |
---|
323 | $template->assign_block_vars('quickconnect.remember_me', array()); |
---|
324 | } |
---|
325 | } |
---|
326 | else |
---|
327 | { |
---|
328 | $template->assign_block_vars('hello', array()); |
---|
329 | |
---|
330 | if (is_autorize_status(ACCESS_CLASSIC)) |
---|
331 | { |
---|
332 | $template->assign_block_vars('profile', array()); |
---|
333 | } |
---|
334 | |
---|
335 | // the logout link has no meaning with Apache authentication : it is not |
---|
336 | // possible to logout with this kind of authentication. |
---|
337 | if (!$conf['apache_authentication']) |
---|
338 | { |
---|
339 | $template->assign_block_vars('logout', array()); |
---|
340 | } |
---|
341 | |
---|
342 | if (is_admin()) |
---|
343 | { |
---|
344 | $template->assign_block_vars('admin', array()); |
---|
345 | } |
---|
346 | } |
---|
347 | |
---|
348 | // search link |
---|
349 | $template->assign_block_vars( |
---|
350 | 'summary', |
---|
351 | array( |
---|
352 | 'TITLE'=>$lang['hint_search'], |
---|
353 | 'NAME'=>$lang['search'], |
---|
354 | 'U_SUMMARY'=> 'search.php', |
---|
355 | 'REL'=> 'rel="search"' |
---|
356 | ) |
---|
357 | ); |
---|
358 | |
---|
359 | // comments link |
---|
360 | $template->assign_block_vars( |
---|
361 | 'summary', |
---|
362 | array( |
---|
363 | 'TITLE'=>$lang['hint_comments'], |
---|
364 | 'NAME'=>$lang['comments'], |
---|
365 | 'U_SUMMARY'=> 'comments.php', |
---|
366 | ) |
---|
367 | ); |
---|
368 | |
---|
369 | // about link |
---|
370 | $template->assign_block_vars( |
---|
371 | 'summary', |
---|
372 | array( |
---|
373 | 'TITLE' => $lang['about_page_title'], |
---|
374 | 'NAME' => $lang['About'], |
---|
375 | 'U_SUMMARY' => 'about.php?'.str_replace( |
---|
376 | '&', |
---|
377 | '&', |
---|
378 | $_SERVER['QUERY_STRING'] |
---|
379 | ) |
---|
380 | ) |
---|
381 | ); |
---|
382 | |
---|
383 | // notification |
---|
384 | $template->assign_block_vars( |
---|
385 | 'summary', |
---|
386 | array( |
---|
387 | 'TITLE'=>l10n('notification'), |
---|
388 | 'NAME'=>l10n('Notification'), |
---|
389 | 'U_SUMMARY'=> PHPWG_ROOT_PATH.'notification.php', |
---|
390 | 'REL'=> 'rel="nofollow"' |
---|
391 | ) |
---|
392 | ); |
---|
393 | |
---|
394 | if (isset($page['category']) and is_admin()) |
---|
395 | { |
---|
396 | $template->assign_block_vars( |
---|
397 | 'edit', |
---|
398 | array( |
---|
399 | 'URL' => |
---|
400 | PHPWG_ROOT_PATH.'admin.php?page=cat_modify' |
---|
401 | .'&cat_id='.$page['category'] |
---|
402 | ) |
---|
403 | ); |
---|
404 | } |
---|
405 | |
---|
406 | //------------------------------------------------------ main part : thumbnails |
---|
407 | if (isset($page['thumbnails_include'])) |
---|
408 | { |
---|
409 | include(PHPWG_ROOT_PATH.$page['thumbnails_include']); |
---|
410 | } |
---|
411 | //------------------------------------------------------- category informations |
---|
412 | if ( |
---|
413 | $page['navigation_bar'] != '' |
---|
414 | or (isset($page['comment']) and $page['comment'] != '') |
---|
415 | ) |
---|
416 | { |
---|
417 | $template->assign_block_vars('cat_infos',array()); |
---|
418 | } |
---|
419 | // navigation bar |
---|
420 | if ($page['navigation_bar'] != '') |
---|
421 | { |
---|
422 | $template->assign_block_vars( |
---|
423 | 'cat_infos.navigation', |
---|
424 | array( |
---|
425 | 'NAV_BAR' => $page['navigation_bar'], |
---|
426 | ) |
---|
427 | ); |
---|
428 | } |
---|
429 | |
---|
430 | if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0 |
---|
431 | and $page['section'] != 'most_visited' |
---|
432 | and $page['section'] != 'best_rated') |
---|
433 | { |
---|
434 | // image order |
---|
435 | $template->assign_block_vars( 'preferred_image_order', array() ); |
---|
436 | |
---|
437 | $order_idx = isset($_COOKIE['pwg_image_order']) |
---|
438 | ? $_COOKIE['pwg_image_order'] |
---|
439 | : 0 |
---|
440 | ; |
---|
441 | |
---|
442 | $orders = get_category_preferred_image_orders(); |
---|
443 | for ($i = 0; $i < count($orders); $i++) |
---|
444 | { |
---|
445 | if ($orders[$i][2]) |
---|
446 | { |
---|
447 | $template->assign_block_vars( |
---|
448 | 'preferred_image_order.order', |
---|
449 | array( |
---|
450 | 'DISPLAY' => $orders[$i][0], |
---|
451 | 'URL' => duplicate_index_URL().'&image_order='.$i, |
---|
452 | 'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''), |
---|
453 | ) |
---|
454 | ); |
---|
455 | } |
---|
456 | } |
---|
457 | } |
---|
458 | |
---|
459 | if (isset($page['category'])) |
---|
460 | { |
---|
461 | // upload a picture in the category |
---|
462 | if ($page['cat_uploadable']) |
---|
463 | { |
---|
464 | $url = PHPWG_ROOT_PATH.'upload.php?cat='.$page['category']; |
---|
465 | $template->assign_block_vars( |
---|
466 | 'upload', |
---|
467 | array( |
---|
468 | 'U_UPLOAD'=> $url |
---|
469 | ) |
---|
470 | ); |
---|
471 | } |
---|
472 | |
---|
473 | // category comment |
---|
474 | if (isset($page['comment']) and $page['comment'] != '') |
---|
475 | { |
---|
476 | $template->assign_block_vars( |
---|
477 | 'cat_infos.comment', |
---|
478 | array( |
---|
479 | 'COMMENTS' => $page['comment'] |
---|
480 | ) |
---|
481 | ); |
---|
482 | } |
---|
483 | } |
---|
484 | //------------------------------------------------------------ log informations |
---|
485 | pwg_log('category', $page['title']); |
---|
486 | |
---|
487 | $template->parse('category'); |
---|
488 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
489 | ?> |
---|