source: trunk/index.php @ 1722

Last change on this file since 1722 was 1722, checked in by rub, 18 years ago

There are no filter enabled if filter configuration is empty (no icon, no functions, ...)
New system for the filter page configuration

View mode flat_recent_cat becomes flat_cat (recent period is removed because global filter is sufficient)

Recent period of global filter must be defined "after" start parameter (default value is $userrecent_period).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.5 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-2007 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $Id: index.php 1722 2007-01-15 00:09:14Z rub $
9// | last update   : $Date: 2007-01-15 00:09:14 +0000 (Mon, 15 Jan 2007) $
10// | last modifier : $Author: rub $
11// | revision      : $Revision: 1722 $
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';
100
101$template->set_filenames( array('index'=>'index.tpl') );
102//-------------------------------------------------------------- category title
103$template_title = $page['title'];
104if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0)
105{
106  $template_title.= ' ['.$page['cat_nb_images'].']';
107}
108
109if (isset($page['flat_cat']) or isset($page['chronology_field']))
110{
111  $template->assign_block_vars(
112    'mode_normal',
113    array(
114      'URL' => duplicate_index_url( array(), array('chronology_field', 'start', 'flat_cat') )
115      )
116    );
117}
118
119if (!isset($page['flat_cat']) and 'categories' == $page['section'])
120{
121  $template->assign_block_vars(
122    'flat_cat',
123    array(
124      'URL' => duplicate_index_url(array('flat_cat' => ''), array('start', 'chronology_field'))
125      )
126    );
127}
128
129if (!isset($page['chronology_field']))
130{
131  $chronology_params =
132      array(
133          'chronology_field' => 'created',
134          'chronology_style' => 'monthly',
135          'chronology_view' => 'list',
136      );
137  $template->assign_block_vars(
138    'mode_created',
139    array(
140      'URL' => duplicate_index_url( $chronology_params, array('start', 'flat_cat') )
141      )
142    );
143
144  $chronology_params['chronology_field'] = 'posted';
145  $template->assign_block_vars(
146    'mode_posted',
147    array(
148      'URL' => duplicate_index_url( $chronology_params, array('start', 'flat_cat') )
149      )
150    );
151}
152else
153{
154  if ($page['chronology_field'] == 'created')
155  {
156    $chronology_field = 'posted';
157  }
158  else
159  {
160    $chronology_field = 'created';
161  }
162  $url = duplicate_index_url(
163            array('chronology_field'=>$chronology_field ),
164            array('chronology_date', 'start', 'flat_cat')
165          );
166  $template->assign_block_vars(
167    'mode_'.$chronology_field,
168    array('URL' => $url )
169    );
170}
171// include menubar
172include(PHPWG_ROOT_PATH.'include/menubar.inc.php');
173
174$template->assign_vars(
175  array(
176    'TITLE' => $template_title
177    )
178  );
179
180if ('search' == $page['section'])
181{
182  $template->assign_block_vars(
183    'search_rules',
184    array(
185      'URL' => get_root_url().'search_rules.php?search_id='.$page['search'],
186      )
187    );
188}
189
190if (isset($page['category']) and is_admin())
191{
192  $template->assign_block_vars(
193    'edit',
194    array(
195      'URL' =>
196        get_root_url().'admin.php?page=cat_modify'
197        .'&amp;cat_id='.$page['category']
198      )
199    );
200}
201
202if (is_admin() and !empty($page['items']) )
203{
204    $template->assign_block_vars(
205      'caddie',
206      array(
207        'URL' =>
208          add_url_params(duplicate_index_url(), array('caddie'=>1) )
209        )
210      );
211  }
212
213if ( $page['section']=='search' and $page['start']==0 )
214{
215  $tags = get_common_tags($page['items'],
216      $conf['content_tag_cloud_items_number'], null);
217  if ( count($tags)>1 )
218  {
219    $template->assign_block_vars('related_tags', array() );
220
221    $tags = add_level_to_tags($tags);
222    foreach ($tags as $tag)
223    {
224      $template->assign_block_vars(
225      'related_tags.tag', array(
226        'URL' => make_index_url(
227          array(
228            'tags' => array(
229              array(
230                'id' => $tag['tag_id'],
231                'url_name' => $tag['url_name'],
232                ),
233              )
234            )
235          ),
236        'NAME' => $tag['name'],
237        'TITLE' => sprintf(
238          l10n('%d pictures are also linked to current tags'),
239          $tag['counter']
240          ),
241        'CLASS' => 'tagLevel'.$tag['level']
242        )
243      );
244    }
245  }
246}
247
248//------------------------------------------------------ main part : thumbnails
249if (isset($page['thumbnails_include']))
250{
251  include(PHPWG_ROOT_PATH.$page['thumbnails_include']);
252}
253//------------------------------------------------------- category informations
254
255// navigation bar
256if ($page['navigation_bar'] != '')
257{
258  $template->assign_block_vars(
259    'cat_infos.navigation',
260    array(
261      'NAV_BAR' => $page['navigation_bar'],
262      )
263    );
264}
265
266if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0
267    and $page['section'] != 'most_visited'
268    and $page['section'] != 'best_rated')
269{
270  // image order
271  $template->assign_block_vars( 'preferred_image_order', array() );
272
273  $order_idx = pwg_get_session_var( 'image_order', 0 );
274
275  $orders = get_category_preferred_image_orders();
276  for ($i = 0; $i < count($orders); $i++)
277  {
278    if ($orders[$i][2])
279    {
280      $template->assign_block_vars(
281        'preferred_image_order.order',
282        array(
283          'DISPLAY' => $orders[$i][0],
284          'URL' => add_url_params( duplicate_index_url(), array('image_order'=>$i) ),
285          'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''),
286          )
287        );
288    }
289  }
290}
291
292// category comment
293if (isset($page['comment']) and $page['comment'] != '')
294{
295  $template->assign_block_vars(
296    'cat_infos.comment',
297    array(
298      'COMMENTS' => $page['comment']
299      )
300    );
301  $header_infos['COMMENT'] = strip_tags($page['comment']);
302}
303//------------------------------------------------------------ log informations
304pwg_log('category', $page['title']);
305
306include(PHPWG_ROOT_PATH.'include/page_header.php');
307trigger_action('loc_end_index');
308$template->parse('index');
309include(PHPWG_ROOT_PATH.'include/page_tail.php');
310?>
Note: See TracBrowser for help on using the repository browser.