source: branches/branch-1_6/index.php @ 1406

Last change on this file since 1406 was 1367, checked in by chrisaga, 18 years ago

Improve : split menubar from main template (index.tpl) = feature 354

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.2 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-06-19 17:53:48 +0000 (Mon, 19 Jun 2006) $
10// | last modifier : $Author: chrisaga $
11// | revision      : $Revision: 1367 $
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();
[1144]47  setcookie(session_name(),'',0,
48      ini_get('session.cookie_path'), ini_get('session.cookie_domain') );
[1092]49  redirect( make_index_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'] : '',
[1113]58    0, cookie_path()
[1036]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
[1109]112$template->set_filenames( array('index'=>'index.tpl') );
[351]113//-------------------------------------------------------------- category title
[1120]114$template_title = $page['title'];
[1082]115if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0)
[428]116{
117  $template_title.= ' ['.$page['cat_nb_images'].']';
118}
[2]119
[452]120$icon_recent = get_icon(date('Y-m-d'));
[436]121
[1090]122if (!isset($page['chronology_field']))
[1047]123{
[1090]124  $chronology_params =
125      array(
126          'chronology_field' => 'created',
127          'chronology_style' => 'monthly',
128          'chronology_view' => 'list',
129      );
[1050]130  $template->assign_block_vars(
[1059]131    'mode_created',
[1082]132    array(
[1090]133      'URL' => duplicate_index_URL( $chronology_params, array('start') )
[1082]134      )
[1050]135    );
[1083]136
[1090]137  $chronology_params['chronology_field'] = 'posted';
[1059]138  $template->assign_block_vars(
139    'mode_posted',
[1082]140    array(
[1090]141      'URL' => duplicate_index_URL( $chronology_params, array('start') )
[1082]142      )
[1059]143    );
[1047]144}
[1050]145else
146{
147  $template->assign_block_vars(
[1059]148    'mode_normal',
[1082]149    array(
[1090]150      'URL' => duplicate_index_URL( array(), array('chronology_field','start') )
[1082]151      )
[1050]152    );
[1059]153
[1090]154  if ($page['chronology_field'] == 'created')
[1059]155  {
[1090]156    $chronology_field = 'posted';
[1059]157  }
158  else
159  {
[1090]160    $chronology_field = 'created';
[1059]161  }
[1086]162  $url = duplicate_index_URL(
[1090]163            array('chronology_field'=>$chronology_field ),
[1086]164            array('chronology_date', 'start')
165          );
166  $template->assign_block_vars(
[1090]167    'mode_'.$chronology_field,
[1086]168    array('URL' => $url )
169    );
[1050]170}
[1367]171// include menubar
172include(PHPWG_ROOT_PATH.'include/menubar.inc.php');
[1047]173
[850]174$template->assign_vars(
175  array(
[1082]176    'TITLE' => $template_title,
[1367]177    'TOP_NUMBER' => $conf['top_number'],        // still used ?
178    'T_RECENT' => $icon_recent,                 // still used ?
[1082]179    )
180  );
[1059]181
[1082]182if ('search' == $page['section'])
[1015]183{
184  $template->assign_block_vars(
185    'search_rules',
186    array(
[1092]187      'URL' => get_root_url().'search_rules.php?search_id='.$page['search'],
[1015]188      )
189    );
190}
[797]191
[1082]192if (isset($page['category']) and is_admin())
[834]193{
194  $template->assign_block_vars(
195    'edit',
196    array(
197      'URL' =>
[1090]198        get_root_url().'admin.php?page=cat_modify'
[1082]199        .'&amp;cat_id='.$page['category']
[834]200      )
201    );
202}
203
[1092]204if (is_admin() and !empty($page['items']) )
205{
206    $template->assign_block_vars(
207      'caddie',
208      array(
209        'URL' =>
[1094]210          add_url_params(duplicate_index_url(), array('caddie'=>1) )
[1092]211        )
212      );
213  }
214
[441]215//------------------------------------------------------ main part : thumbnails
[1082]216if (isset($page['thumbnails_include']))
[1047]217{
218  include(PHPWG_ROOT_PATH.$page['thumbnails_include']);
219}
[2]220//------------------------------------------------------- category informations
[1082]221if (
222  $page['navigation_bar'] != ''
223  or (isset($page['comment']) and $page['comment'] != '')
224  )
[1047]225{
226  $template->assign_block_vars('cat_infos',array());
227}
228// navigation bar
[1082]229if ($page['navigation_bar'] != '')
[1059]230{
[1047]231  $template->assign_block_vars(
232    'cat_infos.navigation',
[1082]233    array(
234      'NAV_BAR' => $page['navigation_bar'],
235      )
[1047]236    );
237}
[1051]238
[1082]239if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0
240    and $page['section'] != 'most_visited'
241    and $page['section'] != 'best_rated')
[1051]242{
243  // image order
244  $template->assign_block_vars( 'preferred_image_order', array() );
245
[1082]246  $order_idx = isset($_COOKIE['pwg_image_order'])
247    ? $_COOKIE['pwg_image_order']
248    : 0
249    ;
[1051]250
251  $orders = get_category_preferred_image_orders();
[1082]252  for ($i = 0; $i < count($orders); $i++)
[1051]253  {
254    if ($orders[$i][2])
255    {
[1082]256      $template->assign_block_vars(
257        'preferred_image_order.order',
258        array(
259          'DISPLAY' => $orders[$i][0],
[1094]260          'URL' => add_url_params( duplicate_index_URL(), array('image_order'=>$i) ),
[1082]261          'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''),
262          )
263        );
[1051]264    }
265  }
266}
267
[1082]268if (isset($page['category']))
[2]269{
[394]270  // upload a picture in the category
[1082]271  if ($page['cat_uploadable'])
[2]272  {
[1092]273    $url = get_root_url().'upload.php?cat='.$page['category'];
[428]274    $template->assign_block_vars(
275      'upload',
[1082]276      array(
277        'U_UPLOAD'=> $url
278        )
[428]279      );
[2]280  }
[1083]281
[351]282  // category comment
[1082]283  if (isset($page['comment']) and $page['comment'] != '')
[351]284  {
[428]285    $template->assign_block_vars(
286      'cat_infos.comment',
[1082]287      array(
288        'COMMENTS' => $page['comment']
289        )
[428]290      );
[351]291  }
[2]292}
293//------------------------------------------------------------ log informations
[1082]294pwg_log('category', $page['title']);
[345]295
[1109]296$template->parse('index');
[369]297include(PHPWG_ROOT_PATH.'include/page_tail.php');
[362]298?>
Note: See TracBrowser for help on using the repository browser.