source: trunk/index.php @ 9899

Last change on this file since 9899 was 8728, checked in by plg, 14 years ago

Happy new year 2011

Change "Piwigo - a PHP based picture gallery" into "Piwigo - a PHP based photo gallery"

  • Property svn:eol-style set to LF
File size: 8.8 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2011 Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24//--------------------------------------------------------------------- include
25define('PHPWG_ROOT_PATH','./');
26include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
27include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
28
29// Check Access and exit when user status is not ok
30check_status(ACCESS_GUEST);
31
32if (!isset($page['start']))
33{
34  $page['start'] = 0;
35}
36
37// access authorization check
38if (isset($page['category']))
39{
40  check_restrictions($page['category']['id']);
41}
42
43trigger_action('loc_begin_index');
44
45//---------------------------------------------- change of image display order
46if (isset($_GET['image_order']))
47{
48  if ( (int)$_GET['image_order'] > 0)
49  {
50    pwg_set_session_var('image_order', (int)$_GET['image_order']);
51  }
52  else
53  {
54    pwg_unset_session_var('image_order');
55  }
56  redirect(
57    duplicate_index_url(
58      array(),        // nothing to redefine
59      array('start')  // changing display order goes back to section first page
60      )
61    );
62}
63//-------------------------------------------------------------- initialization
64
65$page['navigation_bar'] = array();
66if (count($page['items']) > $page['nb_image_page'])
67{
68  $page['navigation_bar'] = create_navigation_bar(
69    duplicate_index_url(array(), array('start')),
70    count($page['items']),
71    $page['start'],
72    $page['nb_image_page'],
73    true
74    );
75}
76
77// caddie filling :-)
78if (isset($_GET['caddie']))
79{
80  fill_caddie($page['items']);
81  redirect(duplicate_index_url());
82}
83
84//----------------------------------------------------- template initialization
85//
86// Start output of page
87//
88$title = $page['title'];
89$page['body_id'] = 'theCategoryPage';
90
91$template->set_filenames( array('index'=>'index.tpl') );
92//-------------------------------------------------------------- category title
93$template_title = $page['title'];
94if (count($page['items']) > 0)
95{
96  $template_title.= ' ['.count($page['items']).']';
97}
98$template->assign('TITLE', $template_title);
99
100if (isset($page['flat']) or isset($page['chronology_field']))
101{
102  $template->assign(
103    'U_MODE_NORMAL',
104    duplicate_index_url( array(), array('chronology_field', 'start', 'flat') )
105    );
106}
107
108if ($conf['index_flat_icon'] and !isset($page['flat']) and 'categories' == $page['section'])
109{
110  $template->assign(
111    'U_MODE_FLAT',
112    duplicate_index_url(array('flat' => ''), array('start', 'chronology_field'))
113    );
114}
115
116if (!isset($page['chronology_field']))
117{
118  $chronology_params =
119      array(
120          'chronology_field' => 'created',
121          'chronology_style' => 'monthly',
122          'chronology_view' => 'list',
123      );
124  if ($conf['index_created_date_icon'])
125  {
126    $template->assign(
127      'U_MODE_CREATED',
128      duplicate_index_url( $chronology_params, array('start', 'flat') )
129      );
130  }
131  if ($conf['index_posted_date_icon'])
132  {
133    $chronology_params['chronology_field'] = 'posted';
134    $template->assign(
135      'U_MODE_POSTED',
136      duplicate_index_url( $chronology_params, array('start', 'flat') )
137      );
138  }
139}
140else
141{
142  if ($page['chronology_field'] == 'created')
143  {
144    $chronology_field = 'posted';
145  }
146  else
147  {
148    $chronology_field = 'created';
149  }
150  if ($conf['index_'.$chronology_field.'_date_icon'])
151  {
152    $url = duplicate_index_url(
153              array('chronology_field'=>$chronology_field ),
154              array('chronology_date', 'start', 'flat')
155            );
156    $template->assign(
157        'U_MODE_'.strtoupper($chronology_field),
158        $url
159      );
160  }
161}
162
163if ('search' == $page['section'])
164{
165  $template->assign(
166    'U_SEARCH_RULES',
167    get_root_url().'search_rules.php?search_id='.$page['search']
168    );
169}
170
171if (isset($page['category']) and is_admin())
172{
173  $template->assign(
174    'U_EDIT',
175     get_root_url().'admin.php?page=cat_modify'
176        .'&amp;cat_id='.$page['category']['id']
177    );
178}
179
180if (is_admin() and !empty($page['items']))
181{
182  $template->assign(
183    'U_CADDIE',
184     add_url_params(duplicate_index_url(), array('caddie'=>1) )
185    );
186}
187
188if ( $page['section']=='search' and $page['start']==0 and
189    !isset($page['chronology_field']) and isset($page['qsearch_details']) )
190{
191  $template->assign('QUERY_SEARCH',
192    htmlspecialchars($page['qsearch_details']['q']) );
193
194  $cats = array_merge(
195      (array)@$page['qsearch_details']['matching_cats_no_images'],
196      (array)@$page['qsearch_details']['matching_cats'] );
197  if (count($cats))
198  {
199    usort($cats, 'name_compare');
200    $hints = array();
201    foreach ( $cats as $cat )
202    {
203      $hints[] = get_cat_display_name( array($cat), '', false );
204    }
205    $template->assign( 'category_search_results', $hints);
206  }
207
208  $tags = (array)@$page['qsearch_details']['matching_tags'];
209  if (count($tags))
210  {
211    usort($tags, 'name_compare');
212    $hints = array();
213    foreach ( $tags as $tag )
214    {
215      $hints[] =
216        '<a href="' . make_index_url(array('tags'=>array($tag))) . '">'
217        .$tag['name']
218        .'</a>';
219    }
220    $template->assign( 'tag_search_results', $hints);
221  }
222}
223
224// navigation bar
225$template->assign( 'navbar', $page['navigation_bar'] );
226
227if ( $conf['index_sort_order_input']
228    and count($page['items']) > 0
229    and $page['section'] != 'most_visited'
230    and $page['section'] != 'best_rated')
231{
232  // image order
233  $order_idx = pwg_get_session_var( 'image_order', 0 );
234
235  $url = add_url_params(
236          duplicate_index_url(),
237          array('image_order' => '')
238        );
239  foreach (get_category_preferred_image_orders() as $order_id => $order)
240  {
241    if ($order[2])
242    {
243      $template->append(
244        'image_orders',
245        array(
246          'DISPLAY' => $order[0],
247          'URL' => $url.$order_id,
248          'SELECTED' => ($order_idx == $order_id ? true:false),
249          )
250        );
251    }
252  }
253}
254
255// category comment
256if ($page['start']==0 and !isset($page['chronology_field']) and !empty($page['comment']) )
257{
258  $template->assign('CONTENT_DESCRIPTION', $page['comment'] );
259}
260
261// include menubar
262include( PHPWG_ROOT_PATH.'include/menubar.inc.php');
263
264if ( isset($page['category']['count_categories']) and $page['category']['count_categories']==0 )
265{// count_categories might be computed by menubar - if the case unassign flat link if no sub albums
266        $template->clear_assign('U_MODE_FLAT');
267}
268
269//------------------------------------------------------ main part : thumbnails
270if ( 0==$page['start']
271    and !isset($page['flat'])
272    and !isset($page['chronology_field'])
273    and ('recent_cats'==$page['section'] or 'categories'==$page['section'])
274    and (!isset($page['category']['count_categories']) or $page['category']['count_categories']>0 )
275  )
276{
277  include(PHPWG_ROOT_PATH.'include/category_cats.inc.php');
278}
279if ( !empty($page['items']) )
280{
281  include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
282}
283//------------------------------------------------------- category informations
284
285// slideshow
286// execute after init thumbs in order to have all picture informations
287if (!empty($page['cat_slideshow_url']))
288{
289  if (isset($_GET['slideshow']))
290  {
291    redirect($page['cat_slideshow_url']);
292  }
293  elseif ($conf['index_slideshow_icon'])
294  {
295    $template->assign('U_SLIDESHOW', $page['cat_slideshow_url']);
296  }
297}
298
299include(PHPWG_ROOT_PATH.'include/page_header.php');
300trigger_action('loc_end_index');
301$template->pparse('index');
302//------------------------------------------------------------ log informations
303pwg_log();
304include(PHPWG_ROOT_PATH.'include/page_tail.php');
305?>
Note: See TracBrowser for help on using the repository browser.