source: trunk/category.php @ 1056

Last change on this file since 1056 was 1056, checked in by rvelices, 18 years ago

fix: remove all php warnings and notices

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.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-2005 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $RCSfile$
9// | last update   : $Date: 2006-02-24 01:16:30 +0000 (Fri, 24 Feb 2006) $
10// | last modifier : $Author: rvelices $
11// | revision      : $Revision: 1056 $
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[session_name()] ) )
35{
36  // cookie deletion if exists
37  $_SESSION = array();
38  session_unset();
39  session_destroy();
40  setcookie(session_name(),'',0, cookie_path() );
41  $url = 'category.php';
42  redirect( $url );
43}
44//---------------------------------------------- change of image display order
45if (isset($_GET['image_order']))
46{
47  setcookie(
48    'pwg_image_order', 
49    $_GET['image_order'] > 0 ? $_GET['image_order'] : '',
50    0
51    );
52 
53  redirect(
54    PHPWG_ROOT_PATH
55    .'category.php'
56    .get_query_string_diff(array('image_order'))
57    );
58}
59//-------------------------------------------------------------- initialization
60// detection of the start picture to display
61if ( !isset( $_GET['start'] )
62     or !is_numeric( $_GET['start'] )
63     or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) )
64{
65  $page['start'] = 0;
66}
67else
68{
69  $page['start'] = $_GET['start'];
70}
71
72include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
73
74// access authorization check
75if (isset($page['cat']) and is_numeric($page['cat']))
76{
77  check_restrictions($page['cat']);
78}
79
80if ( isset($page['cat_nb_images'])
81    and $page['cat_nb_images'] > $user['nb_image_page'])
82{
83  // $nav_url is used to create the navigation bar
84  $nav_url = PHPWG_ROOT_PATH.'category.php?';
85  if ( isset($page['cat']) )
86  {
87    $nav_url .= 'cat='.$page['cat'].'&amp;';
88
89    switch ($page['cat'])
90    {
91      case 'search':
92      {
93        $nav_url.= 'search='.$_GET['search'].'&amp;';
94        break;
95      }
96      case 'list':
97      {
98        $nav_url.= 'list='.$_GET['list'].'&amp;';
99        break;
100      }
101    }
102  }
103
104  if ( isset($_GET['calendar']) )
105  {
106    $nav_url.= 'calendar='.$_GET['calendar'];
107  }
108  else
109  {
110    $nav_url = preg_replace('/&amp;$/', '', $nav_url);
111  }
112 
113  $page['navigation_bar'] = create_navigation_bar(
114    $nav_url,
115    $page['cat_nb_images'],
116    $page['start'],
117    $user['nb_image_page'],
118    'back'
119    );
120}
121else
122{
123  $page['navigation_bar'] = '';
124}
125
126// caddie filling :-)
127if (isset($_GET['caddie']))
128{
129  fill_caddie($page['items']);
130}
131
132//----------------------------------------------------- template initialization
133//
134// Start output of page
135//
136$title = $page['title'];
137$page['body_id'] = 'theCategoryPage';
138include(PHPWG_ROOT_PATH.'include/page_header.php');
139
140$template->set_filenames( array('category'=>'category.tpl') );
141//-------------------------------------------------------------- category title
142if (isset($page['cat']) and is_numeric($page['cat']))
143{
144  $template_title = get_cat_display_name($page['cat_name'],
145                                         'category.php?cat=',
146                                         false);
147}
148else
149{
150  $template_title = $page['title'];
151}
152
153if ( isset( $page['cat_nb_images'] ) and $page['cat_nb_images'] > 0 )
154{
155  $template_title.= ' ['.$page['cat_nb_images'].']';
156}
157
158$icon_recent = get_icon(date('Y-m-d'));
159
160$calendar_view_link = PHPWG_ROOT_PATH.'category.php'
161                        .get_query_string_diff(array('start','calendar'));
162if ( ! isset($_GET['calendar']) )
163{
164  $calendar_view_link .= (empty($_GET)? '?':'&' ) . 'calendar=';
165  $template->assign_block_vars(
166    'calendar_view',
167    array( 'URL' => $calendar_view_link )
168    );
169}
170else
171{
172  $template->assign_block_vars(
173    'normal_view',
174    array( 'URL' => $calendar_view_link )
175    );
176}
177
178$template->assign_vars(
179  array(
180  'NB_PICTURE' => count_user_total_images(),
181  'TITLE' => $template_title,
182  'USERNAME' => $user['username'],
183  'TOP_NUMBER'=>$conf['top_number'],
184  'MENU_CATEGORIES_CONTENT'=>get_categories_menu(),
185
186  'L_CATEGORIES' => $lang['categories'],
187  'L_HINT_CATEGORY' => $lang['hint_category'],
188  'L_SUBCAT' => $lang['sub-cat'],
189  'L_IMG_AVAILABLE' => $lang['images_available'],
190  'L_TOTAL' => $lang['total'],
191  'L_SPECIAL_CATEGORIES' => $lang['special_categories'],
192  'L_SUMMARY' => $lang['title_menu'],
193  'L_UPLOAD' => $lang['upload_picture'],
194  'L_COMMENT' => $lang['comments'],
195  'L_IDENTIFY' => $lang['identification'],
196  'L_PASSWORD' => $lang['password'],
197  'L_HELLO' => $lang['hello'],
198  'L_REGISTER' => $lang['ident_register'],
199  'L_LOGOUT' => $lang['logout'],
200  'L_ADMIN' => $lang['admin'],
201  'L_ADMIN_HINT' => $lang['hint_admin'],
202  'L_PROFILE' => $lang['customize'],
203  'L_PROFILE_HINT' => $lang['hint_customize'],
204  'L_REMEMBER_ME' => $lang['remember_me'],
205 
206  'F_IDENTIFY' => PHPWG_ROOT_PATH.'identification.php',
207  'T_RECENT' => $icon_recent,
208
209  'U_HOME' => PHPWG_ROOT_PATH.'category.php',
210  'U_REGISTER' => PHPWG_ROOT_PATH.'register.php',
211  'U_LOST_PASSWORD' => PHPWG_ROOT_PATH.'password.php',
212  'U_LOGOUT' => PHPWG_ROOT_PATH.'category.php?act=logout',
213  'U_ADMIN'=> PHPWG_ROOT_PATH.'admin.php',
214  'U_PROFILE'=> PHPWG_ROOT_PATH.'profile.php',
215  )
216);
217
218if (isset($page['cat']) and 'search' == $page['cat'])
219{
220  $template->assign_block_vars(
221    'search_rules',
222    array(
223      'URL' => PHPWG_ROOT_PATH.'/search_rules.php?search_id='.$_GET['search'],
224      )
225    );
226}
227//-------------------------------------------------------------- external links
228if (count($conf['links']) > 0)
229{
230  $template->assign_block_vars('links', array());
231
232  foreach ($conf['links'] as $url => $label)
233  {
234    $template->assign_block_vars(
235      'links.link',
236      array(
237        'URL' => $url,
238        'LABEL' => $label
239        ));
240  }
241}
242//---------------------------------------------------------- special categories
243// favorites categories
244if ( !$user['is_the_guest'] )
245{
246  $template->assign_block_vars('username', array());
247
248  $template->assign_block_vars(
249    'special_cat',
250    array(
251      'URL' => PHPWG_ROOT_PATH.'category.php?cat=fav',
252      'TITLE' => $lang['favorite_cat_hint'],
253      'NAME' => $lang['favorite_cat']
254      ));
255}
256// most visited
257$template->assign_block_vars(
258  'special_cat',
259  array(
260    'URL' => PHPWG_ROOT_PATH.'category.php?cat=most_visited',
261    'TITLE' => $lang['most_visited_cat_hint'],
262    'NAME' => $lang['most_visited_cat']
263    ));
264// best rated
265if ($conf['rate'])
266{
267  $template->assign_block_vars(
268    'special_cat',
269    array(
270      'URL' => PHPWG_ROOT_PATH.'category.php?cat=best_rated',
271      'TITLE' => $lang['best_rated_cat_hint'],
272      'NAME' => $lang['best_rated_cat']
273      )
274    );
275}
276// random
277$template->assign_block_vars(
278  'special_cat',
279  array(
280    'URL' => PHPWG_ROOT_PATH.'random.php',
281    'TITLE' => $lang['random_cat_hint'],
282    'NAME' => $lang['random_cat']
283    ));
284// recent pics
285$template->assign_block_vars(
286  'special_cat',
287  array(
288    'URL' => PHPWG_ROOT_PATH.'category.php?cat=recent_pics',
289    'TITLE' => $lang['recent_pics_cat_hint'],
290    'NAME' => $lang['recent_pics_cat']
291    ));
292// recent cats
293$template->assign_block_vars(
294  'special_cat',
295  array(
296    'URL' => PHPWG_ROOT_PATH.'category.php?cat=recent_cats',
297    'TITLE' => $lang['recent_cats_cat_hint'],
298    'NAME' => $lang['recent_cats_cat']
299    ));
300// calendar
301$template->assign_block_vars(
302  'special_cat',
303  array(
304    'URL' => PHPWG_ROOT_PATH.'category.php?calendar=m-c',
305    'TITLE' => $lang['calendar_hint'],
306    'NAME' => $lang['calendar']
307    ));
308//--------------------------------------------------------------------- summary
309
310if ($user['is_the_guest'])
311{
312  $template->assign_block_vars('register', array());
313  $template->assign_block_vars('login', array());
314 
315  $template->assign_block_vars('quickconnect', array());
316  if ($conf['authorize_remembering'])
317  {
318    $template->assign_block_vars('quickconnect.remember_me', array());
319  }
320}
321else
322{
323  $template->assign_block_vars('hello', array());
324  $template->assign_block_vars('profile', array());
325
326  // the logout link has no meaning with Apache authentication : it is not
327  // possible to logout with this kind of authentication.
328  if (!$conf['apache_authentication'])
329  {
330    $template->assign_block_vars('logout', array());
331  }
332
333  if ('admin' == $user['status'])
334  {
335    $template->assign_block_vars('admin', array());
336  }
337}
338
339// search link
340$template->assign_block_vars('summary', array(
341'TITLE'=>$lang['hint_search'],
342'NAME'=>$lang['search'],
343'U_SUMMARY'=> 'search.php',
344'REL'=> 'rel="search"'
345));
346
347// comments link
348$template->assign_block_vars('summary', array(
349'TITLE'=>$lang['hint_comments'],
350'NAME'=>$lang['comments'],
351'U_SUMMARY'=> 'comments.php',
352));
353
354// about link
355$template->assign_block_vars('summary', array(
356'TITLE'=>$lang['about_page_title'],
357'NAME'=>$lang['About'],
358'U_SUMMARY'=> 'about.php?'.str_replace( '&', '&amp;', $_SERVER['QUERY_STRING'] ) 
359));
360
361// notification
362$template->assign_block_vars(
363  'summary',
364  array(
365    'TITLE'=>l10n('notification'),
366    'NAME'=>l10n('Notification'),
367    'U_SUMMARY'=> PHPWG_ROOT_PATH.'notification.php',
368    'REL'=> 'rel="nofollow"'
369));
370
371if (isset($page['cat'])
372    and is_numeric($page['cat'])
373    and 'admin' == $user['status'])
374{
375  $template->assign_block_vars(
376    'edit',
377    array(
378      'URL' =>
379          PHPWG_ROOT_PATH.'admin.php?page=cat_modify'
380          .'&amp;cat_id='.$page['cat']
381      )
382    );
383}
384
385//------------------------------------------------------ main part : thumbnails
386if ( isset($page['thumbnails_include']) )
387{
388  include(PHPWG_ROOT_PATH.$page['thumbnails_include']);
389}
390//------------------------------------------------------- category informations
391if ( $page['navigation_bar'] != ''
392     or ( isset( $page['comment'] ) and $page['comment'] != '' ) )
393{
394  $template->assign_block_vars('cat_infos',array());
395}
396// navigation bar
397if ( $page['navigation_bar'] != '' )
398{ 
399  $template->assign_block_vars(
400    'cat_infos.navigation',
401    array('NAV_BAR' => $page['navigation_bar'])
402    );
403}
404
405if ( ( isset($page['cat_nb_images']) and $page['cat_nb_images']>0 ) 
406     and 
407    ( !isset($page['cat']) 
408      or ($page['cat'] != 'most_visited' and $page['cat'] != 'best_rated') )
409   )
410{
411  // image order
412  $template->assign_block_vars( 'preferred_image_order', array() );
413
414  $order_idx = isset($_COOKIE['pwg_image_order']) ? 
415                   $_COOKIE['pwg_image_order'] : 0;
416
417  $orders = get_category_preferred_image_orders();
418  for ( $i = 0; $i < count($orders); $i++)
419  {
420    if ($orders[$i][2])
421    {
422      $url = PHPWG_ROOT_PATH.'category.php'
423               .get_query_string_diff(array('image_order'));
424      $url .= '&amp;image_order='.$i;
425      $template->assign_block_vars( 'preferred_image_order.order', array(
426        'DISPLAY' => $orders[$i][0],
427        'URL' => $url,
428        'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : '' ),
429        ) );
430    }
431  }
432}
433
434if ( isset ( $page['cat'] ) )
435{
436  // upload a picture in the category
437  if (is_numeric($page['cat'])
438      and $page['cat_site_id'] == 1
439      and $page['cat_dir'] != ''
440      and $page['cat_uploadable'])
441  {
442    $url = PHPWG_ROOT_PATH.'upload.php?cat='.$page['cat'];
443    $template->assign_block_vars(
444      'upload',
445      array('U_UPLOAD'=> $url )
446      );
447  }
448  // category comment
449  if ( isset( $page['comment'] ) and $page['comment'] != '' )
450  {
451    $template->assign_block_vars(
452      'cat_infos.comment',
453      array('COMMENTS' => $page['comment'])
454      );
455  }
456}
457//------------------------------------------------------------ log informations
458pwg_log( 'category', $page['title'] );
459
460$template->parse('category');
461include(PHPWG_ROOT_PATH.'include/page_tail.php');
462?>
Note: See TracBrowser for help on using the repository browser.