source: trunk/category.php @ 631

Last change on this file since 631 was 631, checked in by gweltas, 19 years ago
  • User control panel update (user side)
  • User control panel update (admin side)
  • Add of registration link on the main page
  • Minor bug correction for group management
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.8 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-2004 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $RCSfile$
9// | last update   : $Date: 2004-12-03 16:30:12 +0000 (Fri, 03 Dec 2004) $
10// | last modifier : $Author: gweltas $
11// | revision      : $Revision: 631 $
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['title'] ) )
106{
107  $page['title'] = $lang['no_category'];
108}
109$template_title = $page['title'];
110if ( isset( $page['cat_nb_images'] ) and $page['cat_nb_images'] > 0 )
111{
112  $template_title.= ' ['.$page['cat_nb_images'].']';
113}
114
115$icon_recent = get_icon(date('Y-m-d'));
116
117$template->assign_vars(array(
118  'NB_PICTURE' => count_user_total_images(),
119  'TITLE' => $template_title,
120  'USERNAME' => $user['username'],
121  'TOP_NUMBER'=>$conf['top_number'],
122  'MENU_CATEGORIES_CONTENT'=>get_categories_menu(),
123
124  'L_CATEGORIES' => $lang['categories'],
125  'L_HINT_CATEGORY' => $lang['hint_category'],
126  'L_SUBCAT' => $lang['sub-cat'],
127  'L_IMG_AVAILABLE' => $lang['images_available'],
128  'L_TOTAL' => $lang['total'],
129  'L_SPECIAL_CATEGORIES' => $lang['special_categories'],
130  'L_SUMMARY' => $lang['title_menu'],
131  'L_UPLOAD' => $lang['upload_picture'],
132  'L_COMMENT' => $lang['comments'],
133  'L_IDENTIFY' => $lang['ident_title'],
134  'L_SUBMIT' => $lang['menu_login'],
135  'L_USERNAME' => $lang['login'],
136  'L_PASSWORD' => $lang['password'],
137  'L_HELLO' => $lang['hello'],
138        'L_REGISTER' => $lang['ident_register'],
139        'L_LOGIN' => $lang['menu_login'],
140  'L_LOGOUT' => $lang['logout'],
141  'L_ADMIN' => $lang['admin'],
142  'L_ADMIN_HINT' => $lang['hint_admin'],
143  'L_PROFILE' => $lang['customize'],
144  'L_PROFILE_HINT' => $lang['hint_customize'],
145  'L_REMEMBER_ME' => $lang['remember_me'],
146 
147  'F_IDENTIFY' => add_session_id( PHPWG_ROOT_PATH.'identification.php' ),
148  'T_RECENT' => $icon_recent,
149
150  'U_HOME' => add_session_id( PHPWG_ROOT_PATH.'category.php' ),
151        'U_REGISTER' => add_session_id( PHPWG_ROOT_PATH.'register.php' ),
152  'U_LOGOUT' => PHPWG_ROOT_PATH.'category.php?act=logout',
153  'U_ADMIN'=>add_session_id( PHPWG_ROOT_PATH.'admin.php' ),
154  'U_PROFILE'=>add_session_id(PHPWG_ROOT_PATH.'profile.php?'.str_replace( '&', '&amp;', $_SERVER['QUERY_STRING'] ))
155  )
156);
157//---------------------------------------------------------- special categories
158// favorites categories
159if ( !$user['is_the_guest'] )
160{
161  $template->assign_block_vars('username', array());
162
163  $template->assign_block_vars(
164    'special_cat',
165    array(
166      'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=fav'),
167      'TITLE' => $lang['favorite_cat_hint'],
168      'NAME' => $lang['favorite_cat']
169      ));
170}
171// most visited
172$template->assign_block_vars(
173  'special_cat',
174  array(
175    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=most_visited'),
176    'TITLE' => $lang['most_visited_cat_hint'],
177    'NAME' => $conf['top_number'].' '.$lang['most_visited_cat']
178    ));
179// best rated
180$template->assign_block_vars(
181  'special_cat',
182  array(
183    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=best_rated'),
184    'TITLE' => $lang['best_rated_cat_hint'],
185    'NAME' => $conf['top_number'].' '.$lang['best_rated_cat']
186    ));
187// random
188$template->assign_block_vars(
189  'special_cat',
190  array(
191    'URL' => add_session_id(PHPWG_ROOT_PATH.'random.php'),
192    'TITLE' => $lang['random_cat_hint'],
193    'NAME' => $lang['random_cat']
194    ));
195// recent pics
196$template->assign_block_vars(
197  'special_cat',
198  array(
199    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=recent_pics'),
200    'TITLE' => $lang['recent_pics_cat_hint'],
201    'NAME' => $lang['recent_pics_cat']
202    ));
203// recent cats
204$template->assign_block_vars(
205  'special_cat',
206  array(
207    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=recent_cats'),
208    'TITLE' => $lang['recent_cats_cat_hint'],
209    'NAME' => $lang['recent_cats_cat']
210    ));
211// calendar
212$template->assign_block_vars(
213  'special_cat',
214  array(
215    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=calendar'),
216    'TITLE' => $lang['calendar_hint'],
217    'NAME' => $lang['calendar']
218    ));
219//--------------------------------------------------------------------- summary
220
221if ( !$user['is_the_guest'] )
222{
223  $template->assign_block_vars('logout',array());
224  // administration link
225  if ( $user['status'] == 'admin' )
226  {
227    $template->assign_block_vars('logout.admin', array());
228  }
229}
230else
231{
232  $template->assign_block_vars('login',array());
233  if ($conf['authorize_remembering'])
234  {
235    $template->assign_block_vars('login.remember_me',array());
236  }
237}
238
239// search link
240$template->assign_block_vars('summary', array(
241'TITLE'=>$lang['hint_search'],
242'NAME'=>$lang['search'],
243'U_SUMMARY'=>add_session_id( 'search.php' ),
244));
245
246// comments link
247$template->assign_block_vars('summary', array(
248'TITLE'=>$lang['hint_comments'],
249'NAME'=>$lang['comments'],
250'U_SUMMARY'=>add_session_id( 'comments.php' ),
251));
252
253// about link
254$template->assign_block_vars('summary', array(
255'TITLE'=>$lang['hint_about'],
256'NAME'=>$lang['about'],
257'U_SUMMARY'=>add_session_id( 'about.php?'.str_replace( '&', '&amp;', $_SERVER['QUERY_STRING'] ) )
258));
259
260//------------------------------------------------------ main part : thumbnails
261if (isset($page['cat'])
262    and ((is_numeric($page['cat']) and $page['cat_nb_images'] != 0)
263         or in_array($page['cat'],
264                     array('search'
265                           ,'most_visited'
266                           ,'recent_pics'
267                           ,'best_rated'
268                           ,'list'
269                           ,'fav'
270                       ))))
271{
272  include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
273}
274elseif (isset($page['cat']) and $page['cat'] == 'calendar')
275{
276  include(PHPWG_ROOT_PATH.'include/category_calendar.inc.php');
277}
278elseif (isset($page['cat']) and $page['cat'] == 'recent_cats')
279{
280  include(PHPWG_ROOT_PATH.'include/category_recent_cats.inc.php');
281}
282else
283{
284  include(PHPWG_ROOT_PATH.'include/category_subcats.inc.php');
285}
286//------------------------------------------------------- category informations
287if ( isset ( $page['cat'] ) )
288{
289  // upload a picture in the category
290  if (is_numeric($page['cat'])
291      and $page['cat_site_id'] == 1
292      and $page['cat_dir'] != ''
293      and $page['cat_uploadable'])
294  {
295    $url = PHPWG_ROOT_PATH.'upload.php?cat='.$page['cat'];
296    $template->assign_block_vars(
297      'upload',
298      array('U_UPLOAD'=>add_session_id( $url ))
299      );
300  }
301
302  if ( $page['navigation_bar'] != ''
303       or ( isset( $page['comment'] ) and $page['comment'] != '' ) )
304  {
305    $template->assign_block_vars('cat_infos',array());
306  }
307 
308  // navigation bar
309  if ( $page['navigation_bar'] != '' )
310  { 
311    $template->assign_block_vars(
312      'cat_infos.navigation',
313      array('NAV_BAR' => $page['navigation_bar'])
314      );
315  }
316  // category comment
317  if ( isset( $page['comment'] ) and $page['comment'] != '' )
318  {
319    $template->assign_block_vars(
320      'cat_infos.comment',
321      array('COMMENTS' => $page['comment'])
322      );
323  }
324}
325//------------------------------------------------------------ log informations
326pwg_log( 'category', $page['title'] );
327mysql_close();
328
329$template->pparse('category');
330include(PHPWG_ROOT_PATH.'include/page_tail.php');
331?>
Note: See TracBrowser for help on using the repository browser.