source: trunk/category.php @ 1088

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

URL rewrite for chronology: uses $pagechronology and
$pagechronology_date. $pagechronology is an array with 'field',
'style' and 'view' keys. This is step 1.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.5 KB
RevLine 
[2]1<?php
[351]2// +-----------------------------------------------------------------------+
[593]3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
[1058]5// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
[351]6// +-----------------------------------------------------------------------+
[593]7// | branch        : BSF (Best So Far)
[351]8// | file          : $RCSfile$
9// | last update   : $Date: 2006-03-17 04:13:19 +0000 (Fri, 17 Mar 2006) $
10// | last modifier : $Author: rvelices $
11// | revision      : $Revision: 1086 $
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  |
[352]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.                                                                  |
[351]26// +-----------------------------------------------------------------------+
[2]27
[352]28//--------------------------------------------------------------------- include
[364]29define('PHPWG_ROOT_PATH','./');
30include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
[1084]31include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
[1072]32
33// +-----------------------------------------------------------------------+
34// | Check Access and exit when user status is not ok                      |
35// +-----------------------------------------------------------------------+
36check_status(ACCESS_GUEST);
37
[45]38//---------------------------------------------------------------------- logout
[345]39if ( isset( $_GET['act'] )
40     and $_GET['act'] == 'logout'
[1004]41     and isset( $_COOKIE[session_name()] ) )
[45]42{
43  // cookie deletion if exists
[1004]44  $_SESSION = array();
45  session_unset();
46  session_destroy();
[1029]47  setcookie(session_name(),'',0, cookie_path() );
[45]48  $url = 'category.php';
[405]49  redirect( $url );
[45]50}
[1084]51
[1059]52//---------------------------------------------- change of image display order
[1036]53if (isset($_GET['image_order']))
[614]54{
[1036]55  setcookie(
[1059]56    'pwg_image_order',
[1036]57    $_GET['image_order'] > 0 ? $_GET['image_order'] : '',
58    0
59    );
[1059]60
[1036]61  redirect(
[1084]62    duplicate_index_URL(
63      array(),        // nothing to redefine
64      array('start')  // changing display order goes back to section first page
[1082]65      )
[1036]66    );
[614]67}
[2]68//-------------------------------------------------------------- initialization
[345]69// detection of the start picture to display
[1082]70if (!isset($page['start']))
[514]71{
[345]72  $page['start'] = 0;
[514]73}
[345]74
[1036]75// access authorization check
[1082]76if (isset($page['category']))
[1036]77{
[1082]78  check_restrictions($page['category']);
[1036]79}
80
[1082]81if (isset($page['cat_nb_images'])
[1036]82    and $page['cat_nb_images'] > $user['nb_image_page'])
83{
84  $page['navigation_bar'] = create_navigation_bar(
[1082]85    duplicate_index_URL(array(), array('start')),
[1036]86    $page['cat_nb_images'],
87    $page['start'],
88    $user['nb_image_page'],
[1084]89    true
[1036]90    );
91}
92else
93{
94  $page['navigation_bar'] = '';
95}
96
[755]97// caddie filling :-)
98if (isset($_GET['caddie']))
99{
[1036]100  fill_caddie($page['items']);
[1082]101  // redirect();
[755]102}
103
[2]104//----------------------------------------------------- template initialization
[345]105//
106// Start output of page
107//
108$title = $page['title'];
[850]109$page['body_id'] = 'theCategoryPage';
[369]110include(PHPWG_ROOT_PATH.'include/page_header.php');
[345]111
[351]112$template->set_filenames( array('category'=>'category.tpl') );
113//-------------------------------------------------------------- category title
[1082]114if (isset($page['category']))
[351]115{
[1082]116  $template_title = get_cat_display_name(
117    $page['cat_name'],
118    'category.php?/category/',
119    false
120    );
[657]121}
[663]122else
123{
124  $template_title = $page['title'];
125}
[657]126
[1082]127if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0)
[428]128{
129  $template_title.= ' ['.$page['cat_nb_images'].']';
130}
[2]131
[452]132$icon_recent = get_icon(date('Y-m-d'));
[436]133
[1086]134if (!isset($page['chronology']))
[1047]135{
[1086]136  $chronology =
137    array(
138      'chronology' =>
139        array(
140          'field' => 'created',
141          'style' => 'monthly',
142          'view' => 'list',
143        )
144    );
[1050]145  $template->assign_block_vars(
[1059]146    'mode_created',
[1082]147    array(
[1086]148      'URL' => duplicate_index_URL( $chronology, array('start') )
[1082]149      )
[1050]150    );
[1083]151
[1086]152  $chronology['chronology']['field'] = 'posted';
[1059]153  $template->assign_block_vars(
154    'mode_posted',
[1082]155    array(
[1086]156      'URL' => duplicate_index_URL( $chronology, array('start') )
[1082]157      )
[1059]158    );
[1047]159}
[1050]160else
161{
162  $template->assign_block_vars(
[1059]163    'mode_normal',
[1082]164    array(
[1086]165      'URL' => duplicate_index_URL( array(), array('chronology','start') )
[1082]166      )
[1050]167    );
[1059]168
[1086]169  $chronology = $page['chronology'];
170  if ($chronology['field'] == 'created')
[1059]171  {
[1086]172    $chronology['field'] = 'posted';
[1059]173  }
174  else
175  {
[1086]176    $chronology['field'] = 'created';
[1059]177  }
[1086]178  $url = duplicate_index_URL(
179            array(
180              'chronology'=>$chronology
181            ),
182            array('chronology_date', 'start')
183          );
184  $template->assign_block_vars(
185    'mode_'.$chronology['field'],
186    array('URL' => $url )
187    );
[1050]188}
[1047]189
[850]190$template->assign_vars(
191  array(
[1082]192    'NB_PICTURE' => $user['nb_total_images'],
193    'TITLE' => $template_title,
194    'USERNAME' => $user['username'],
195    'TOP_NUMBER' => $conf['top_number'],
196    'MENU_CATEGORIES_CONTENT' => get_categories_menu(),
[2]197
[1082]198    'F_IDENTIFY' => PHPWG_ROOT_PATH.'identification.php',
199    'T_RECENT' => $icon_recent,
[1083]200
[1082]201    'U_HOME' => make_index_URL(),
202    'U_REGISTER' => PHPWG_ROOT_PATH.'register.php',
203    'U_LOST_PASSWORD' => PHPWG_ROOT_PATH.'password.php',
204    'U_LOGOUT' => make_index_URL().'&amp;act=logout',
205    'U_ADMIN'=> PHPWG_ROOT_PATH.'admin.php',
206    'U_PROFILE'=> PHPWG_ROOT_PATH.'profile.php',
207    )
208  );
[1059]209
[1082]210if ('search' == $page['section'])
[1015]211{
212  $template->assign_block_vars(
213    'search_rules',
214    array(
[1082]215      'URL' => PHPWG_ROOT_PATH.'/search_rules.php?search_id='.$page['search'],
[1015]216      )
217    );
218}
[797]219//-------------------------------------------------------------- external links
220if (count($conf['links']) > 0)
221{
222  $template->assign_block_vars('links', array());
223
224  foreach ($conf['links'] as $url => $label)
225  {
226    $template->assign_block_vars(
227      'links.link',
228      array(
229        'URL' => $url,
230        'LABEL' => $label
[1082]231        )
232      );
[797]233  }
234}
[510]235//---------------------------------------------------------- special categories
236// favorites categories
[2]237if ( !$user['is_the_guest'] )
238{
[364]239  $template->assign_block_vars('username', array());
[510]240
241  $template->assign_block_vars(
242    'special_cat',
243    array(
[1082]244      'URL' => make_index_URL(array('section' => 'favorites')),
[510]245      'TITLE' => $lang['favorite_cat_hint'],
246      'NAME' => $lang['favorite_cat']
247      ));
[2]248}
[510]249// most visited
250$template->assign_block_vars(
251  'special_cat',
252  array(
[1082]253    'URL' => make_index_URL(array('section' => 'most_visited')),
[510]254    'TITLE' => $lang['most_visited_cat_hint'],
[733]255    'NAME' => $lang['most_visited_cat']
[510]256    ));
257// best rated
[869]258if ($conf['rate'])
259{
260  $template->assign_block_vars(
261    'special_cat',
262    array(
[1082]263      'URL' => make_index_URL(array('section' => 'best_rated')),
[869]264      'TITLE' => $lang['best_rated_cat_hint'],
265      'NAME' => $lang['best_rated_cat']
266      )
267    );
268}
[510]269// random
270$template->assign_block_vars(
271  'special_cat',
272  array(
[1004]273    'URL' => PHPWG_ROOT_PATH.'random.php',
[510]274    'TITLE' => $lang['random_cat_hint'],
275    'NAME' => $lang['random_cat']
276    ));
277// recent pics
278$template->assign_block_vars(
279  'special_cat',
280  array(
[1082]281    'URL' => make_index_URL(array('section' => 'recent_pics')),
[510]282    'TITLE' => $lang['recent_pics_cat_hint'],
283    'NAME' => $lang['recent_pics_cat']
284    ));
285// recent cats
286$template->assign_block_vars(
287  'special_cat',
288  array(
[1082]289    'URL' => make_index_URL(array('section' => 'recent_cats')),
[510]290    'TITLE' => $lang['recent_cats_cat_hint'],
291    'NAME' => $lang['recent_cats_cat']
292    ));
[1082]293
[510]294// calendar
295$template->assign_block_vars(
296  'special_cat',
297  array(
[1082]298    'URL' =>
[1086]299      make_index_URL(
300        array(
301          'chronology'=>
302            array(
303              'field' => ($conf['calendar_datefield']=='date_available' ? 'posted' : 'created'),
304              'style' => 'monthly',
305              'view' => 'calendar'
306            )
307        )
308      ),
[510]309    'TITLE' => $lang['calendar_hint'],
310    'NAME' => $lang['calendar']
[1082]311    )
312  );
[2]313//--------------------------------------------------------------------- summary
[375]314
[804]315if ($user['is_the_guest'])
[2]316{
[804]317  $template->assign_block_vars('register', array());
318  $template->assign_block_vars('login', array());
[1059]319
[804]320  $template->assign_block_vars('quickconnect', array());
321  if ($conf['authorize_remembering'])
[375]322  {
[804]323    $template->assign_block_vars('quickconnect.remember_me', array());
[375]324  }
[2]325}
326else
327{
[804]328  $template->assign_block_vars('hello', array());
329
[1072]330  if (is_autorize_status(ACCESS_CLASSIC))
331  {
332    $template->assign_block_vars('profile', array());
333  }
334
[804]335  // the logout link has no meaning with Apache authentication : it is not
336  // possible to logout with this kind of authentication.
337  if (!$conf['apache_authentication'])
[555]338  {
[804]339    $template->assign_block_vars('logout', array());
[555]340  }
[804]341
[1070]342  if (is_admin())
[804]343  {
344    $template->assign_block_vars('admin', array());
345  }
[2]346}
[351]347
[2]348// search link
[1082]349$template->assign_block_vars(
350  'summary',
351  array(
352    'TITLE'=>$lang['hint_search'],
353    'NAME'=>$lang['search'],
354    'U_SUMMARY'=> 'search.php',
355    'REL'=> 'rel="search"'
356    )
357  );
[351]358
[166]359// comments link
[1082]360$template->assign_block_vars(
361  'summary',
362  array(
363    'TITLE'=>$lang['hint_comments'],
364    'NAME'=>$lang['comments'],
365    'U_SUMMARY'=> 'comments.php',
366    )
367  );
[351]368
[2]369// about link
[1082]370$template->assign_block_vars(
371  'summary',
372  array(
373    'TITLE'     => $lang['about_page_title'],
374    'NAME'      => $lang['About'],
375    'U_SUMMARY' => 'about.php?'.str_replace(
376      '&',
377      '&amp;',
378      $_SERVER['QUERY_STRING']
379      )
380    )
381  );
[351]382
[833]383// notification
[801]384$template->assign_block_vars(
385  'summary',
386  array(
[833]387    'TITLE'=>l10n('notification'),
388    'NAME'=>l10n('Notification'),
[1031]389    'U_SUMMARY'=> PHPWG_ROOT_PATH.'notification.php',
390    'REL'=> 'rel="nofollow"'
[1082]391    )
392  );
[801]393
[1082]394if (isset($page['category']) and is_admin())
[834]395{
396  $template->assign_block_vars(
397    'edit',
398    array(
399      'URL' =>
[1082]400        PHPWG_ROOT_PATH.'admin.php?page=cat_modify'
401        .'&amp;cat_id='.$page['category']
[834]402      )
403    );
404}
405
[441]406//------------------------------------------------------ main part : thumbnails
[1082]407if (isset($page['thumbnails_include']))
[1047]408{
409  include(PHPWG_ROOT_PATH.$page['thumbnails_include']);
410}
[2]411//------------------------------------------------------- category informations
[1082]412if (
413  $page['navigation_bar'] != ''
414  or (isset($page['comment']) and $page['comment'] != '')
415  )
[1047]416{
417  $template->assign_block_vars('cat_infos',array());
418}
419// navigation bar
[1082]420if ($page['navigation_bar'] != '')
[1059]421{
[1047]422  $template->assign_block_vars(
423    'cat_infos.navigation',
[1082]424    array(
425      'NAV_BAR' => $page['navigation_bar'],
426      )
[1047]427    );
428}
[1051]429
[1082]430if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0
431    and $page['section'] != 'most_visited'
432    and $page['section'] != 'best_rated')
[1051]433{
434  // image order
435  $template->assign_block_vars( 'preferred_image_order', array() );
436
[1082]437  $order_idx = isset($_COOKIE['pwg_image_order'])
438    ? $_COOKIE['pwg_image_order']
439    : 0
440    ;
[1051]441
442  $orders = get_category_preferred_image_orders();
[1082]443  for ($i = 0; $i < count($orders); $i++)
[1051]444  {
445    if ($orders[$i][2])
446    {
[1082]447      $template->assign_block_vars(
448        'preferred_image_order.order',
449        array(
450          'DISPLAY' => $orders[$i][0],
451          'URL' => duplicate_index_URL().'&amp;image_order='.$i,
452          'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''),
453          )
454        );
[1051]455    }
456  }
457}
458
[1082]459if (isset($page['category']))
[2]460{
[394]461  // upload a picture in the category
[1082]462  if ($page['cat_uploadable'])
[2]463  {
[1082]464    $url = PHPWG_ROOT_PATH.'upload.php?cat='.$page['category'];
[428]465    $template->assign_block_vars(
466      'upload',
[1082]467      array(
468        'U_UPLOAD'=> $url
469        )
[428]470      );
[2]471  }
[1083]472
[351]473  // category comment
[1082]474  if (isset($page['comment']) and $page['comment'] != '')
[351]475  {
[428]476    $template->assign_block_vars(
477      'cat_infos.comment',
[1082]478      array(
479        'COMMENTS' => $page['comment']
480        )
[428]481      );
[351]482  }
[2]483}
484//------------------------------------------------------------ log informations
[1082]485pwg_log('category', $page['title']);
[345]486
[688]487$template->parse('category');
[369]488include(PHPWG_ROOT_PATH.'include/page_tail.php');
[362]489?>
Note: See TracBrowser for help on using the repository browser.