source: trunk/category.php @ 528

Last change on this file since 528 was 514, checked in by z0rglub, 20 years ago
  • bug correction : when coming from picture.php on a picture of category.php page superior to the first, the right page was displayed (the one including the element) but the navigation bar was always saying we were on the first page
  • distinguish CSS classes span.dateSelected and span.pageNumberSelected
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.2 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// |                             category.php                              |
4// +-----------------------------------------------------------------------+
5// | application   : PhpWebGallery <http://phpwebgallery.net>              |
6// | branch        : BSF (Best So Far)                                     |
7// +-----------------------------------------------------------------------+
8// | file          : $RCSfile$
9// | last update   : $Date: 2004-09-04 08:07:33 +0000 (Sat, 04 Sep 2004) $
10// | last modifier : $Author: z0rglub $
11// | revision      : $Revision: 514 $
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'] ) ) check_cat_id( $_GET['cat'] );
43check_login_authorization();
44if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
45{
46  check_restrictions( $page['cat'] );
47}
48//-------------------------------------------------------------- initialization
49// detection of the start picture to display
50if ( !isset( $_GET['start'] )
51     or !is_numeric( $_GET['start'] )
52     or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) )
53{
54  $page['start'] = 0;
55}
56else
57{
58  $page['start'] = $_GET['start'];
59}
60
61// Sometimes, a "num" is provided in the URL. It is the number
62// of the picture to show. This picture must be in the thumbnails page.
63// We have to find the right $page['start'] that show the num picture
64// in this category
65if ( isset( $_GET['num'] )
66     and is_numeric( $_GET['num'] )
67     and $_GET['num'] >= 0 )
68{
69  $page['start'] = floor( $_GET['num'] / $user['nb_image_page'] );
70  $page['start']*= $user['nb_image_page'];
71}
72
73initialize_category();
74
75// creation of the array containing the cat ids to expand in the menu
76// $page['tab_expand'] contains an array with the category ids
77// $page['expand'] contains the string to display in URL with comma
78$page['tab_expand'] = array();
79if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
80{
81  // the category displayed (in the URL cat=23) must be seen in the menu ->
82  // parent categories must be expanded
83  $uppercats = explode( ',', $page['uppercats'] );
84  foreach ( $uppercats as $uppercat ) {
85    array_push( $page['tab_expand'], $uppercat );
86  }
87}
88// in case of expanding all authorized cats $page['tab_expand'] is empty
89if ( $user['expand'] )
90{
91  $page['tab_expand'] = array();
92}
93
94// creating the structure of the categories (useful for displaying the menu)
95// creating the plain structure : array of all the available categories and
96// their relative informations, see the definition of the function
97// get_user_plain_structure for further details.
98$page['plain_structure'] = get_user_plain_structure();
99$page['structure'] = create_user_structure( '' );
100$page['structure'] = update_structure( $page['structure'] );
101//----------------------------------------------------- template initialization
102//
103// Start output of page
104//
105$title = $page['title'];
106include(PHPWG_ROOT_PATH.'include/page_header.php');
107
108$template->set_filenames( array('category'=>'category.tpl') );
109
110//-------------------------------------------------------------- category title
111if ( !isset( $page['title'] ) )
112{
113  $page['title'] = $lang['no_category'];
114}
115$template_title = $page['title'];
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$page['menu'] = '';
124foreach ($page['structure'] as $category)
125{
126  $page['menu'].= get_html_menu_category($category);
127}
128
129$template->assign_vars(array(
130  'NB_PICTURE' => count_user_total_images(),
131  'TITLE' => $template_title,
132  'USERNAME' => $user['username'],
133  'TOP_NUMBER'=>$conf['top_number'],
134  'MENU_CATEGORIES_CONTENT'=>$page['menu'],
135
136  'L_CATEGORIES' => $lang['categories'],
137  'L_HINT_CATEGORY' => $lang['hint_category'],
138  'L_SUBCAT' => $lang['sub-cat'],
139  'L_IMG_AVAILABLE' => $lang['images_available'],
140  'L_TOTAL' => $lang['total'],
141  'L_SPECIAL_CATEGORIES' => $lang['special_categories'],
142  'L_SUMMARY' => $lang['title_menu'],
143  'L_UPLOAD' => $lang['upload_picture'],
144  'L_COMMENT' => $lang['comments'],
145  'L_IDENTIFY' => $lang['ident_title'],
146  'L_SUBMIT' => $lang['menu_login'],
147  'L_USERNAME' => $lang['login'],
148  'L_PASSWORD' => $lang['password'],
149  'L_HELLO' => $lang['hello'],
150  'L_LOGOUT' => $lang['logout'],
151  'L_ADMIN' => $lang['admin'],
152  'L_ADMIN_HINT' => $lang['hint_admin'],
153  'L_PROFILE' => $lang['customize'],
154  'L_PROFILE_HINT' => $lang['hint_customize'],
155 
156  'F_IDENTIFY' => add_session_id( PHPWG_ROOT_PATH.'identification.php' ),
157 
158  'T_COLLAPSED' => $user['lien_collapsed'],
159  'T_RECENT' => $icon_recent,
160
161  'U_HOME' => add_session_id( PHPWG_ROOT_PATH.'category.php' ),
162  'U_LOGOUT' => PHPWG_ROOT_PATH.'category.php?act=logout',
163  'U_ADMIN'=>add_session_id( PHPWG_ROOT_PATH.'admin.php' ),
164  'U_PROFILE'=>add_session_id(PHPWG_ROOT_PATH.'profile.php?'.str_replace( '&', '&amp;', $_SERVER['QUERY_STRING'] ))
165  )
166);
167//---------------------------------------------------------- special categories
168// favorites categories
169if ( !$user['is_the_guest'] )
170{
171  $template->assign_block_vars('username', array());
172
173  $template->assign_block_vars(
174    'special_cat',
175    array(
176      'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=fav'),
177      'TITLE' => $lang['favorite_cat_hint'],
178      'NAME' => $lang['favorite_cat']
179      ));
180}
181// most visited
182$template->assign_block_vars(
183  'special_cat',
184  array(
185    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=most_visited'),
186    'TITLE' => $lang['most_visited_cat_hint'],
187    'NAME' => $conf['top_number'].' '.$lang['most_visited_cat']
188    ));
189// best rated
190$template->assign_block_vars(
191  'special_cat',
192  array(
193    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=best_rated'),
194    'TITLE' => $lang['best_rated_cat_hint'],
195    'NAME' => $conf['top_number'].' '.$lang['best_rated_cat']
196    ));
197// random
198$template->assign_block_vars(
199  'special_cat',
200  array(
201    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=random'),
202    'TITLE' => $lang['random_cat_hint'],
203    'NAME' => $lang['random_cat']
204    ));
205// recent pics
206$template->assign_block_vars(
207  'special_cat',
208  array(
209    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=recent_pics'),
210    'TITLE' => $lang['recent_pics_cat_hint'],
211    'NAME' => $lang['recent_pics_cat']
212    ));
213// recent cats
214$template->assign_block_vars(
215  'special_cat',
216  array(
217    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=recent_cats'),
218    'TITLE' => $lang['recent_cats_cat_hint'],
219    'NAME' => $lang['recent_cats_cat']
220    ));
221// calendar
222$template->assign_block_vars(
223  'special_cat',
224  array(
225    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=calendar'),
226    'TITLE' => $lang['calendar_hint'],
227    'NAME' => $lang['calendar']
228    ));
229//--------------------------------------------------------------------- summary
230
231if ( !$user['is_the_guest'] )
232{
233  $template->assign_block_vars('logout',array());
234  // administration link
235  if ( $user['status'] == 'admin' )
236  {
237    $template->assign_block_vars('logout.admin', array());
238  }
239}
240else
241{
242  $template->assign_block_vars('login',array());
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                           ,'random'
275                       ))))
276{
277  include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
278}
279elseif (isset($page['cat']) and $page['cat'] == 'calendar')
280{
281  include(PHPWG_ROOT_PATH.'include/category_calendar.inc.php');
282}
283elseif (isset($page['cat']) and $page['cat'] == 'recent_cats')
284{
285  include(PHPWG_ROOT_PATH.'include/category_recent_cats.inc.php');
286}
287else
288{
289  include(PHPWG_ROOT_PATH.'include/category_subcats.inc.php');
290}
291//------------------------------------------------------- category informations
292if ( isset ( $page['cat'] ) )
293{
294  // upload a picture in the category
295  if ( is_numeric( $page['cat'] )
296       and $page['cat_site_id'] == 1
297       and $conf['upload_available']
298       and $page['cat_uploadable'] )
299  {
300    $url = PHPWG_ROOT_PATH.'upload.php?cat='.$page['cat'];
301    $template->assign_block_vars(
302      'upload',
303      array('U_UPLOAD'=>add_session_id( $url ))
304      );
305  }
306
307  if ( $page['navigation_bar'] != ''
308       or ( isset( $page['comment'] ) and $page['comment'] != '' ) )
309  {
310    $template->assign_block_vars('cat_infos',array());
311  }
312 
313  // navigation bar
314  if ( $page['navigation_bar'] != '' )
315  { 
316    $template->assign_block_vars(
317      'cat_infos.navigation',
318      array('NAV_BAR' => $page['navigation_bar'])
319      );
320  }
321  // category comment
322  if ( isset( $page['comment'] ) and $page['comment'] != '' )
323  {
324    $template->assign_block_vars(
325      'cat_infos.comment',
326      array('COMMENTS' => $page['comment'])
327      );
328  }
329}
330//------------------------------------------------------------ log informations
331pwg_log( 'category', $page['title'] );
332mysql_close();
333
334$template->pparse('category');
335include(PHPWG_ROOT_PATH.'include/page_tail.php');
336?>
Note: See TracBrowser for help on using the repository browser.