source: tags/release-1_4_0RC2/category.php @ 18245

Last change on this file since 18245 was 688, checked in by plg, 19 years ago
  • use template->parse instead of pparse. (exceptions for install.php and upgrade.php)
  • bug fixed : queries time and count were not displayed on a redirection
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.0 KB
Line 
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-2005 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $RCSfile$
9// | last update   : $Date: 2005-01-13 10:18:49 +0000 (Thu, 13 Jan 2005) $
10// | last modifier : $Author: plg $
11// | revision      : $Revision: 688 $
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
29define('PHPWG_ROOT_PATH','./');
30include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
31//---------------------------------------------------------------------- logout
32if ( isset( $_GET['act'] )
33     and $_GET['act'] == 'logout'
34     and isset( $_COOKIE['id'] ) )
35{
36  // cookie deletion if exists
37  setcookie( 'id', '', 0, cookie_path() );
38  $url = 'category.php';
39  redirect( $url );
40}
41//-------------------------------------------------- access authorization check
42if (isset($_GET['cat']))
43{
44  check_cat_id($_GET['cat']);
45}
46check_login_authorization();
47if (isset($page['cat']) and is_numeric($page['cat']))
48{
49  check_restrictions($page['cat']);
50}
51//-------------------------------------------------------------- initialization
52// detection of the start picture to display
53if ( !isset( $_GET['start'] )
54     or !is_numeric( $_GET['start'] )
55     or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) )
56{
57  $page['start'] = 0;
58}
59else
60{
61  $page['start'] = $_GET['start'];
62}
63
64// Sometimes, a "num" is provided in the URL. It is the number
65// of the picture to show. This picture must be in the thumbnails page.
66// We have to find the right $page['start'] that show the num picture
67// in this category
68if ( isset( $_GET['num'] )
69     and is_numeric( $_GET['num'] )
70     and $_GET['num'] >= 0 )
71{
72  $page['start'] = floor( $_GET['num'] / $user['nb_image_page'] );
73  $page['start']*= $user['nb_image_page'];
74}
75
76initialize_category();
77
78// creation of the array containing the cat ids to expand in the menu
79// $page['tab_expand'] contains an array with the category ids
80// $page['expand'] contains the string to display in URL with comma
81$page['tab_expand'] = array();
82if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
83{
84  // the category displayed (in the URL cat=23) must be seen in the menu ->
85  // parent categories must be expanded
86  $uppercats = explode( ',', $page['uppercats'] );
87  foreach ( $uppercats as $uppercat ) {
88    array_push( $page['tab_expand'], $uppercat );
89  }
90}
91// in case of expanding all authorized cats $page['tab_expand'] is empty
92if ( $user['expand'] )
93{
94  $page['tab_expand'] = array();
95}
96//----------------------------------------------------- template initialization
97//
98// Start output of page
99//
100$title = $page['title'];
101include(PHPWG_ROOT_PATH.'include/page_header.php');
102
103$template->set_filenames( array('category'=>'category.tpl') );
104//-------------------------------------------------------------- category title
105if (isset($page['cat']) and is_numeric($page['cat']))
106{
107  $template_title = get_cat_display_name($page['cat_name'],
108                                         'category.php?cat=',
109                                         false);
110}
111else
112{
113  $template_title = $page['title'];
114}
115
116if ( isset( $page['cat_nb_images'] ) and $page['cat_nb_images'] > 0 )
117{
118  $template_title.= ' ['.$page['cat_nb_images'].']';
119}
120
121$icon_recent = get_icon(date('Y-m-d'));
122
123$template->assign_vars(array(
124  'NB_PICTURE' => count_user_total_images(),
125  'TITLE' => $template_title,
126  'USERNAME' => $user['username'],
127  'TOP_NUMBER'=>$conf['top_number'],
128  'MENU_CATEGORIES_CONTENT'=>get_categories_menu(),
129
130  'L_CATEGORIES' => $lang['categories'],
131  'L_HINT_CATEGORY' => $lang['hint_category'],
132  'L_SUBCAT' => $lang['sub-cat'],
133  'L_IMG_AVAILABLE' => $lang['images_available'],
134  'L_TOTAL' => $lang['total'],
135  'L_SPECIAL_CATEGORIES' => $lang['special_categories'],
136  'L_SUMMARY' => $lang['title_menu'],
137  'L_UPLOAD' => $lang['upload_picture'],
138  'L_COMMENT' => $lang['comments'],
139  'L_IDENTIFY' => $lang['identification'],
140  'L_SUBMIT' => $lang['menu_login'],
141  'L_USERNAME' => $lang['login'],
142  'L_PASSWORD' => $lang['password'],
143  'L_HELLO' => $lang['hello'],
144  'L_REGISTER' => $lang['ident_register'],
145  'L_LOGIN' => $lang['menu_login'],
146  'L_LOGOUT' => $lang['logout'],
147  'L_ADMIN' => $lang['admin'],
148  'L_ADMIN_HINT' => $lang['hint_admin'],
149  'L_PROFILE' => $lang['customize'],
150  'L_PROFILE_HINT' => $lang['hint_customize'],
151  'L_REMEMBER_ME' => $lang['remember_me'],
152 
153  'F_IDENTIFY' => add_session_id( PHPWG_ROOT_PATH.'identification.php' ),
154  'T_RECENT' => $icon_recent,
155
156  'U_HOME' => add_session_id( PHPWG_ROOT_PATH.'category.php' ),
157  'U_REGISTER' => add_session_id( PHPWG_ROOT_PATH.'register.php' ),
158  'U_LOGOUT' => PHPWG_ROOT_PATH.'category.php?act=logout',
159  'U_ADMIN'=>add_session_id( PHPWG_ROOT_PATH.'admin.php' ),
160  'U_PROFILE'=>add_session_id(PHPWG_ROOT_PATH.'profile.php?'.str_replace( '&', '&amp;', $_SERVER['QUERY_STRING'] ))
161  )
162);
163//---------------------------------------------------------- special categories
164// favorites categories
165if ( !$user['is_the_guest'] )
166{
167  $template->assign_block_vars('username', array());
168
169  $template->assign_block_vars(
170    'special_cat',
171    array(
172      'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=fav'),
173      'TITLE' => $lang['favorite_cat_hint'],
174      'NAME' => $lang['favorite_cat']
175      ));
176}
177// most visited
178$template->assign_block_vars(
179  'special_cat',
180  array(
181    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=most_visited'),
182    'TITLE' => $lang['most_visited_cat_hint'],
183    'NAME' => $conf['top_number'].' '.$lang['most_visited_cat']
184    ));
185// best rated
186$template->assign_block_vars(
187  'special_cat',
188  array(
189    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=best_rated'),
190    'TITLE' => $lang['best_rated_cat_hint'],
191    'NAME' => $conf['top_number'].' '.$lang['best_rated_cat']
192    ));
193// random
194$template->assign_block_vars(
195  'special_cat',
196  array(
197    'URL' => add_session_id(PHPWG_ROOT_PATH.'random.php'),
198    'TITLE' => $lang['random_cat_hint'],
199    'NAME' => $lang['random_cat']
200    ));
201// recent pics
202$template->assign_block_vars(
203  'special_cat',
204  array(
205    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=recent_pics'),
206    'TITLE' => $lang['recent_pics_cat_hint'],
207    'NAME' => $lang['recent_pics_cat']
208    ));
209// recent cats
210$template->assign_block_vars(
211  'special_cat',
212  array(
213    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=recent_cats'),
214    'TITLE' => $lang['recent_cats_cat_hint'],
215    'NAME' => $lang['recent_cats_cat']
216    ));
217// calendar
218$template->assign_block_vars(
219  'special_cat',
220  array(
221    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=calendar'),
222    'TITLE' => $lang['calendar_hint'],
223    'NAME' => $lang['calendar']
224    ));
225//--------------------------------------------------------------------- summary
226
227if ( !$user['is_the_guest'] )
228{
229  $template->assign_block_vars('logout',array());
230  // administration link
231  if ( $user['status'] == 'admin' )
232  {
233    $template->assign_block_vars('logout.admin', array());
234  }
235}
236else
237{
238  $template->assign_block_vars('login',array());
239  if ($conf['authorize_remembering'])
240  {
241    $template->assign_block_vars('login.remember_me',array());
242  }
243}
244
245// search link
246$template->assign_block_vars('summary', array(
247'TITLE'=>$lang['hint_search'],
248'NAME'=>$lang['search'],
249'U_SUMMARY'=>add_session_id( 'search.php' ),
250));
251
252// comments link
253$template->assign_block_vars('summary', array(
254'TITLE'=>$lang['hint_comments'],
255'NAME'=>$lang['comments'],
256'U_SUMMARY'=>add_session_id( 'comments.php' ),
257));
258
259// about link
260$template->assign_block_vars('summary', array(
261'TITLE'=>$lang['hint_about'],
262'NAME'=>$lang['about'],
263'U_SUMMARY'=>add_session_id( 'about.php?'.str_replace( '&', '&amp;', $_SERVER['QUERY_STRING'] ) )
264));
265
266//------------------------------------------------------ main part : thumbnails
267if (isset($page['cat'])
268    and ((is_numeric($page['cat']) and $page['cat_nb_images'] != 0)
269         or in_array($page['cat'],
270                     array('search'
271                           ,'most_visited'
272                           ,'recent_pics'
273                           ,'best_rated'
274                           ,'list'
275                           ,'fav'
276                       ))))
277{
278  include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
279}
280elseif (isset($page['cat']) and $page['cat'] == 'calendar')
281{
282  include(PHPWG_ROOT_PATH.'include/category_calendar.inc.php');
283}
284elseif (isset($page['cat']) and $page['cat'] == 'recent_cats')
285{
286  include(PHPWG_ROOT_PATH.'include/category_recent_cats.inc.php');
287}
288else
289{
290  include(PHPWG_ROOT_PATH.'include/category_subcats.inc.php');
291}
292//------------------------------------------------------- category informations
293if ( isset ( $page['cat'] ) )
294{
295  // upload a picture in the category
296  if (is_numeric($page['cat'])
297      and $page['cat_site_id'] == 1
298      and $page['cat_dir'] != ''
299      and $page['cat_uploadable'])
300  {
301    $url = PHPWG_ROOT_PATH.'upload.php?cat='.$page['cat'];
302    $template->assign_block_vars(
303      'upload',
304      array('U_UPLOAD'=>add_session_id( $url ))
305      );
306  }
307
308  if ( $page['navigation_bar'] != ''
309       or ( isset( $page['comment'] ) and $page['comment'] != '' ) )
310  {
311    $template->assign_block_vars('cat_infos',array());
312  }
313 
314  // navigation bar
315  if ( $page['navigation_bar'] != '' )
316  { 
317    $template->assign_block_vars(
318      'cat_infos.navigation',
319      array('NAV_BAR' => $page['navigation_bar'])
320      );
321  }
322  // category comment
323  if ( isset( $page['comment'] ) and $page['comment'] != '' )
324  {
325    $template->assign_block_vars(
326      'cat_infos.comment',
327      array('COMMENTS' => $page['comment'])
328      );
329  }
330}
331//------------------------------------------------------------ log informations
332pwg_log( 'category', $page['title'] );
333mysql_close();
334
335$template->parse('category');
336include(PHPWG_ROOT_PATH.'include/page_tail.php');
337?>
Note: See TracBrowser for help on using the repository browser.