source: trunk/category.php @ 536

Last change on this file since 536 was 533, checked in by gweltas, 20 years ago
  • Small update of category.tpl
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.1 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-23 17:14:04 +0000 (Thu, 23 Sep 2004) $
10// | last modifier : $Author: gweltas $
11// | revision      : $Revision: 533 $
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  'T_RECENT' => $icon_recent,
158
159  'U_HOME' => add_session_id( PHPWG_ROOT_PATH.'category.php' ),
160  'U_LOGOUT' => PHPWG_ROOT_PATH.'category.php?act=logout',
161  'U_ADMIN'=>add_session_id( PHPWG_ROOT_PATH.'admin.php' ),
162  'U_PROFILE'=>add_session_id(PHPWG_ROOT_PATH.'profile.php?'.str_replace( '&', '&amp;', $_SERVER['QUERY_STRING'] ))
163  )
164);
165//---------------------------------------------------------- special categories
166// favorites categories
167if ( !$user['is_the_guest'] )
168{
169  $template->assign_block_vars('username', array());
170
171  $template->assign_block_vars(
172    'special_cat',
173    array(
174      'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=fav'),
175      'TITLE' => $lang['favorite_cat_hint'],
176      'NAME' => $lang['favorite_cat']
177      ));
178}
179// most visited
180$template->assign_block_vars(
181  'special_cat',
182  array(
183    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=most_visited'),
184    'TITLE' => $lang['most_visited_cat_hint'],
185    'NAME' => $conf['top_number'].' '.$lang['most_visited_cat']
186    ));
187// best rated
188$template->assign_block_vars(
189  'special_cat',
190  array(
191    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=best_rated'),
192    'TITLE' => $lang['best_rated_cat_hint'],
193    'NAME' => $conf['top_number'].' '.$lang['best_rated_cat']
194    ));
195// random
196$template->assign_block_vars(
197  'special_cat',
198  array(
199    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=random'),
200    'TITLE' => $lang['random_cat_hint'],
201    'NAME' => $lang['random_cat']
202    ));
203// recent pics
204$template->assign_block_vars(
205  'special_cat',
206  array(
207    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=recent_pics'),
208    'TITLE' => $lang['recent_pics_cat_hint'],
209    'NAME' => $lang['recent_pics_cat']
210    ));
211// recent cats
212$template->assign_block_vars(
213  'special_cat',
214  array(
215    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=recent_cats'),
216    'TITLE' => $lang['recent_cats_cat_hint'],
217    'NAME' => $lang['recent_cats_cat']
218    ));
219// calendar
220$template->assign_block_vars(
221  'special_cat',
222  array(
223    'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=calendar'),
224    'TITLE' => $lang['calendar_hint'],
225    'NAME' => $lang['calendar']
226    ));
227//--------------------------------------------------------------------- summary
228
229if ( !$user['is_the_guest'] )
230{
231  $template->assign_block_vars('logout',array());
232  // administration link
233  if ( $user['status'] == 'admin' )
234  {
235    $template->assign_block_vars('logout.admin', array());
236  }
237}
238else
239{
240  $template->assign_block_vars('login',array());
241}
242
243// search link
244$template->assign_block_vars('summary', array(
245'TITLE'=>$lang['hint_search'],
246'NAME'=>$lang['search'],
247'U_SUMMARY'=>add_session_id( 'search.php' ),
248));
249
250// comments link
251$template->assign_block_vars('summary', array(
252'TITLE'=>$lang['hint_comments'],
253'NAME'=>$lang['comments'],
254'U_SUMMARY'=>add_session_id( 'comments.php' ),
255));
256
257// about link
258$template->assign_block_vars('summary', array(
259'TITLE'=>$lang['hint_about'],
260'NAME'=>$lang['about'],
261'U_SUMMARY'=>add_session_id( 'about.php?'.str_replace( '&', '&amp;', $_SERVER['QUERY_STRING'] ) )
262));
263
264//------------------------------------------------------ main part : thumbnails
265if (isset($page['cat'])
266    and ((is_numeric($page['cat']) and $page['cat_nb_images'] != 0)
267         or in_array($page['cat'],
268                     array('search'
269                           ,'most_visited'
270                           ,'recent_pics'
271                           ,'best_rated'
272                           ,'random'
273                       ))))
274{
275  include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
276}
277elseif (isset($page['cat']) and $page['cat'] == 'calendar')
278{
279  include(PHPWG_ROOT_PATH.'include/category_calendar.inc.php');
280}
281elseif (isset($page['cat']) and $page['cat'] == 'recent_cats')
282{
283  include(PHPWG_ROOT_PATH.'include/category_recent_cats.inc.php');
284}
285else
286{
287  include(PHPWG_ROOT_PATH.'include/category_subcats.inc.php');
288}
289//------------------------------------------------------- category informations
290if ( isset ( $page['cat'] ) )
291{
292  // upload a picture in the category
293  if ( is_numeric( $page['cat'] )
294       and $page['cat_site_id'] == 1
295       and $conf['upload_available']
296       and $page['cat_uploadable'] )
297  {
298    $url = PHPWG_ROOT_PATH.'upload.php?cat='.$page['cat'];
299    $template->assign_block_vars(
300      'upload',
301      array('U_UPLOAD'=>add_session_id( $url ))
302      );
303  }
304
305  if ( $page['navigation_bar'] != ''
306       or ( isset( $page['comment'] ) and $page['comment'] != '' ) )
307  {
308    $template->assign_block_vars('cat_infos',array());
309  }
310 
311  // navigation bar
312  if ( $page['navigation_bar'] != '' )
313  { 
314    $template->assign_block_vars(
315      'cat_infos.navigation',
316      array('NAV_BAR' => $page['navigation_bar'])
317      );
318  }
319  // category comment
320  if ( isset( $page['comment'] ) and $page['comment'] != '' )
321  {
322    $template->assign_block_vars(
323      'cat_infos.comment',
324      array('COMMENTS' => $page['comment'])
325      );
326  }
327}
328//------------------------------------------------------------ log informations
329pwg_log( 'category', $page['title'] );
330mysql_close();
331
332$template->pparse('category');
333include(PHPWG_ROOT_PATH.'include/page_tail.php');
334?>
Note: See TracBrowser for help on using the repository browser.