source: trunk/index.php @ 1503

Last change on this file since 1503 was 1503, checked in by nikrou, 18 years ago

function names are case-insensitive but it's a good idea to call functions
as they appear in their declaration.
So all functions names that manipulate url like make_index_url()
are write with lowercase

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.1 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-2006 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $RCSfile$
9// | last update   : $Date: 2006-07-26 21:00:16 +0000 (Wed, 26 Jul 2006) $
10// | last modifier : $Author: nikrou $
11// | revision      : $Revision: 1503 $
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' );
31include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
32
33// +-----------------------------------------------------------------------+
34// | Check Access and exit when user status is not ok                      |
35// +-----------------------------------------------------------------------+
36check_status(ACCESS_GUEST);
37
38//---------------------------------------------------------------------- logout
39if ( isset( $_GET['act'] )
40     and $_GET['act'] == 'logout'
41     and isset( $_COOKIE[session_name()] ) )
42{
43  // cookie deletion if exists
44  $_SESSION = array();
45  session_unset();
46  session_destroy();
47  setcookie(session_name(),'',0,
48      ini_get('session.cookie_path'), ini_get('session.cookie_domain') );
49  redirect( make_index_url() );
50}
51if ($user['is_the_guest'] and !$conf['guest_access'])
52{
53  redirect (get_root_url().'identification.php');
54}
55
56//---------------------------------------------- change of image display order
57if (isset($_GET['image_order']))
58{
59  setcookie(
60    'pwg_image_order',
61    $_GET['image_order'] > 0 ? $_GET['image_order'] : '',
62    0, cookie_path()
63    );
64
65  redirect(
66    duplicate_index_url(
67      array(),        // nothing to redefine
68      array('start')  // changing display order goes back to section first page
69      )
70    );
71}
72//-------------------------------------------------------------- initialization
73// detection of the start picture to display
74if (!isset($page['start']))
75{
76  $page['start'] = 0;
77}
78
79// access authorization check
80if (isset($page['category']))
81{
82  check_restrictions($page['category']);
83}
84
85if (isset($page['cat_nb_images'])
86    and $page['cat_nb_images'] > $user['nb_image_page'])
87{
88  $page['navigation_bar'] = create_navigation_bar(
89    duplicate_index_url(array(), array('start')),
90    $page['cat_nb_images'],
91    $page['start'],
92    $user['nb_image_page'],
93    true
94    );
95}
96else
97{
98  $page['navigation_bar'] = '';
99}
100
101// caddie filling :-)
102if (isset($_GET['caddie']))
103{
104  fill_caddie($page['items']);
105  // redirect();
106}
107
108//----------------------------------------------------- template initialization
109//
110// Start output of page
111//
112$title = $page['title'];
113$page['body_id'] = 'theCategoryPage';
114include(PHPWG_ROOT_PATH.'include/page_header.php');
115
116$template->set_filenames( array('index'=>'index.tpl') );
117//-------------------------------------------------------------- category title
118$template_title = $page['title'];
119if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0)
120{
121  $template_title.= ' ['.$page['cat_nb_images'].']';
122}
123
124$icon_recent = get_icon(date('Y-m-d'));
125
126if (!isset($page['chronology_field']))
127{
128  $chronology_params =
129      array(
130          'chronology_field' => 'created',
131          'chronology_style' => 'monthly',
132          'chronology_view' => 'list',
133      );
134  $template->assign_block_vars(
135    'mode_created',
136    array(
137      'URL' => duplicate_index_url( $chronology_params, array('start') )
138      )
139    );
140
141  $chronology_params['chronology_field'] = 'posted';
142  $template->assign_block_vars(
143    'mode_posted',
144    array(
145      'URL' => duplicate_index_url( $chronology_params, array('start') )
146      )
147    );
148}
149else
150{
151  $template->assign_block_vars(
152    'mode_normal',
153    array(
154      'URL' => duplicate_index_url( array(), array('chronology_field','start') )
155      )
156    );
157
158  if ($page['chronology_field'] == 'created')
159  {
160    $chronology_field = 'posted';
161  }
162  else
163  {
164    $chronology_field = 'created';
165  }
166  $url = duplicate_index_url(
167            array('chronology_field'=>$chronology_field ),
168            array('chronology_date', 'start')
169          );
170  $template->assign_block_vars(
171    'mode_'.$chronology_field,
172    array('URL' => $url )
173    );
174}
175// include menubar
176include(PHPWG_ROOT_PATH.'include/menubar.inc.php');
177
178$template->assign_vars(
179  array(
180    'TITLE' => $template_title,
181    'TOP_NUMBER' => $conf['top_number'],        // still used ?
182    'T_RECENT' => $icon_recent,                 // still used ?
183    )
184  );
185
186if ('search' == $page['section'])
187{
188  $template->assign_block_vars(
189    'search_rules',
190    array(
191      'URL' => get_root_url().'search_rules.php?search_id='.$page['search'],
192      )
193    );
194}
195
196if (isset($page['category']) and is_admin())
197{
198  $template->assign_block_vars(
199    'edit',
200    array(
201      'URL' =>
202        get_root_url().'admin.php?page=cat_modify'
203        .'&amp;cat_id='.$page['category']
204      )
205    );
206}
207
208if (is_admin() and !empty($page['items']) )
209{
210    $template->assign_block_vars(
211      'caddie',
212      array(
213        'URL' =>
214          add_url_params(duplicate_index_url(), array('caddie'=>1) )
215        )
216      );
217  }
218
219//------------------------------------------------------ main part : thumbnails
220if (isset($page['thumbnails_include']))
221{
222  include(PHPWG_ROOT_PATH.$page['thumbnails_include']);
223}
224//------------------------------------------------------- category informations
225if (
226  $page['navigation_bar'] != ''
227  or (isset($page['comment']) and $page['comment'] != '')
228  )
229{
230  $template->assign_block_vars('cat_infos',array());
231}
232// navigation bar
233if ($page['navigation_bar'] != '')
234{
235  $template->assign_block_vars(
236    'cat_infos.navigation',
237    array(
238      'NAV_BAR' => $page['navigation_bar'],
239      )
240    );
241}
242
243if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0
244    and $page['section'] != 'most_visited'
245    and $page['section'] != 'best_rated')
246{
247  // image order
248  $template->assign_block_vars( 'preferred_image_order', array() );
249
250  $order_idx = isset($_COOKIE['pwg_image_order'])
251    ? $_COOKIE['pwg_image_order']
252    : 0
253    ;
254
255  $orders = get_category_preferred_image_orders();
256  for ($i = 0; $i < count($orders); $i++)
257  {
258    if ($orders[$i][2])
259    {
260      $template->assign_block_vars(
261        'preferred_image_order.order',
262        array(
263          'DISPLAY' => $orders[$i][0],
264          'URL' => add_url_params( duplicate_index_url(), array('image_order'=>$i) ),
265          'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''),
266          )
267        );
268    }
269  }
270}
271
272if (isset($page['category']))
273{
274  // category comment
275  if (isset($page['comment']) and $page['comment'] != '')
276  {
277    $template->assign_block_vars(
278      'cat_infos.comment',
279      array(
280        'COMMENTS' => $page['comment']
281        )
282      );
283  }
284}
285//------------------------------------------------------------ log informations
286pwg_log('category', $page['title']);
287
288$template->parse('index');
289include(PHPWG_ROOT_PATH.'include/page_tail.php');
290?>
Note: See TracBrowser for help on using the repository browser.