source: trunk/index.php @ 1623

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