source: trunk/index.php @ 18245

Last change on this file since 18245 was 18165, checked in by mistic100, 12 years ago

feature 2614: pagination on albums

  • Property svn:eol-style set to LF
File size: 10.1 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2012 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
32
33// access authorization check
34if (isset($page['category']))
35{
36  check_restrictions($page['category']['id']);
37}
38if ($page['start']>0 && $page['start']>=count($page['items']))
39{
40  page_not_found('', duplicate_index_url(array('start'=>0)));
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}
63if (isset($_GET['display']))
64{
65  $page['meta_robots']['noindex']=1;
66  if (array_key_exists($_GET['display'], ImageStdParams::get_defined_type_map()))
67  {
68    pwg_set_session_var('index_deriv', $_GET['display']);
69  }
70}
71//-------------------------------------------------------------- initialization
72
73// navigation bar
74$page['navigation_bar'] = array();
75if (count($page['items']) > $page['nb_image_page'])
76{
77  $page['navigation_bar'] = create_navigation_bar(
78    duplicate_index_url(array(), array('start')),
79    count($page['items']),
80    $page['start'],
81    $page['nb_image_page'],
82    true, 'start'
83    );
84}
85
86$page['cats_navigation_bar'] = array();
87if (count($page['categories']) > $conf['nb_categories_page'])
88{
89  $page['cats_navigation_bar'] = create_navigation_bar(
90    duplicate_index_url(array(), array('starta')),
91    count($page['categories']),
92    $page['starta'],
93    $conf['nb_categories_page'],
94    true, 'starta'
95    );
96}
97
98$template->assign( 'thumb_navbar', $page['navigation_bar'] );
99$template->assign( 'cats_navbar', $page['cats_navigation_bar'] );
100
101// caddie filling :-)
102if (isset($_GET['caddie']))
103{
104  fill_caddie($page['items']);
105  redirect(duplicate_index_url());
106}
107
108if (isset($page['is_homepage']) and $page['is_homepage'])
109{
110  $canonical_url = get_gallery_home_url();
111}
112else
113{
114  $canonical_url = duplicate_index_url();
115}
116$template->assign('U_CANONICAL', $canonical_url);
117
118//----------------------------------------------------- template initialization
119//
120// Start output of page
121//
122$title = $page['title'];
123$page['body_id'] = 'theCategoryPage';
124
125$template->set_filenames( array('index'=>'index.tpl') );
126//-------------------------------------------------------------- category title
127$template_title = $page['title'];
128if (count($page['items']) > 0)
129{
130  $template_title.= ' ['.count($page['items']).']';
131}
132$template->assign('TITLE', $template_title);
133
134if (isset($page['flat']) or isset($page['chronology_field']))
135{
136  $template->assign(
137    'U_MODE_NORMAL',
138    duplicate_index_url( array(), array('chronology_field', 'start', 'flat') )
139    );
140}
141
142if ($conf['index_flat_icon'] and !isset($page['flat']) and 'categories' == $page['section'])
143{
144  $template->assign(
145    'U_MODE_FLAT',
146    duplicate_index_url(array('flat' => ''), array('start', 'chronology_field'))
147    );
148}
149
150if (!isset($page['chronology_field']))
151{
152  $chronology_params =
153      array(
154          'chronology_field' => 'created',
155          'chronology_style' => 'monthly',
156          'chronology_view' => 'list',
157      );
158  if ($conf['index_created_date_icon'])
159  {
160    $template->assign(
161      'U_MODE_CREATED',
162      duplicate_index_url( $chronology_params, array('start', 'flat') )
163      );
164  }
165  if ($conf['index_posted_date_icon'])
166  {
167    $chronology_params['chronology_field'] = 'posted';
168    $template->assign(
169      'U_MODE_POSTED',
170      duplicate_index_url( $chronology_params, array('start', 'flat') )
171      );
172  }
173}
174else
175{
176  if ($page['chronology_field'] == 'created')
177  {
178    $chronology_field = 'posted';
179  }
180  else
181  {
182    $chronology_field = 'created';
183  }
184  if ($conf['index_'.$chronology_field.'_date_icon'])
185  {
186    $url = duplicate_index_url(
187              array('chronology_field'=>$chronology_field ),
188              array('chronology_date', 'start', 'flat')
189            );
190    $template->assign(
191        'U_MODE_'.strtoupper($chronology_field),
192        $url
193      );
194  }
195}
196
197if ('search' == $page['section'])
198{
199  $template->assign(
200    'U_SEARCH_RULES',
201    get_root_url().'search_rules.php?search_id='.$page['search']
202    );
203}
204
205if (isset($page['category']) and is_admin())
206{
207  $template->assign(
208    'U_EDIT',
209    get_root_url().'admin.php?page=album-'.$page['category']['id']
210    );
211}
212
213if (is_admin() and !empty($page['items']))
214{
215  $template->assign(
216    'U_CADDIE',
217     add_url_params(duplicate_index_url(), array('caddie'=>1) )
218    );
219}
220
221if ( $page['section']=='search' and $page['start']==0 and
222    !isset($page['chronology_field']) and isset($page['qsearch_details']) )
223{
224  $template->assign('QUERY_SEARCH',
225    htmlspecialchars($page['qsearch_details']['q']) );
226
227  $cats = array_merge(
228      (array)@$page['qsearch_details']['matching_cats_no_images'],
229      (array)@$page['qsearch_details']['matching_cats'] );
230  if (count($cats))
231  {
232    usort($cats, 'name_compare');
233    $hints = array();
234    foreach ( $cats as $cat )
235    {
236      $hints[] = get_cat_display_name( array($cat), '', false );
237    }
238    $template->assign( 'category_search_results', $hints);
239  }
240
241  $tags = (array)@$page['qsearch_details']['matching_tags'];
242  if (count($tags))
243  {
244    usort($tags, 'name_compare');
245    $hints = array();
246    foreach ( $tags as $tag )
247    {
248      $hints[] =
249        '<a href="' . make_index_url(array('tags'=>array($tag))) . '">'
250        .trigger_event('render_tag_name', $tag['name'])
251        .'</a>';
252    }
253    $template->assign( 'tag_search_results', $hints);
254  }
255}
256
257
258if ( $conf['index_sort_order_input']
259    and count($page['items']) > 0
260    and $page['section'] != 'most_visited'
261    and $page['section'] != 'best_rated')
262{
263  // image order
264  $order_idx = pwg_get_session_var( 'image_order', 0 );
265
266  $url = add_url_params(
267          duplicate_index_url(),
268          array('image_order' => '')
269        );
270  foreach (get_category_preferred_image_orders() as $order_id => $order)
271  {
272    if ($order[2])
273    {
274      $template->append(
275        'image_orders',
276        array(
277          'DISPLAY' => $order[0],
278          'URL' => $url.$order_id,
279          'SELECTED' => ($order_idx == $order_id ? true:false),
280          )
281        );
282    }
283  }
284}
285
286// category comment
287if ($page['start']==0 and !isset($page['chronology_field']) and !empty($page['comment']) )
288{
289  $template->assign('CONTENT_DESCRIPTION', $page['comment'] );
290}
291
292// include menubar
293include( PHPWG_ROOT_PATH.'include/menubar.inc.php');
294
295if ( isset($page['category']['count_categories']) and $page['category']['count_categories']==0 )
296{// count_categories might be computed by menubar - if the case unassign flat link if no sub albums
297        $template->clear_assign('U_MODE_FLAT');
298}
299
300//------------------------------------------------------ main part : thumbnails
301if ( !empty($page['categories']) )
302{
303  include(PHPWG_ROOT_PATH.'include/category_cats.inc.php');
304}
305if ( !empty($page['items']) )
306{
307  include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
308  $url = add_url_params(
309          duplicate_index_url(),
310          array('display' => '')
311        );
312  $selected_type = $template->get_template_vars('derivative_params')->type;
313  $template->clear_assign( 'derivative_params' );
314  $type_map = ImageStdParams::get_defined_type_map();
315  unset($type_map[IMG_XXLARGE], $type_map[IMG_XLARGE]);
316  foreach($type_map as $params)
317  {
318    $template->append(
319      'image_derivatives',
320      array(
321        'DISPLAY' => l10n($params->type),
322        'URL' => $url.$params->type,
323        'SELECTED' => ($params->type == $selected_type ? true:false),
324        )
325      );
326  }
327}
328//------------------------------------------------------- category informations
329
330// slideshow
331// execute after init thumbs in order to have all picture informations
332if (!empty($page['cat_slideshow_url']))
333{
334  if (isset($_GET['slideshow']))
335  {
336    redirect($page['cat_slideshow_url']);
337  }
338  elseif ($conf['index_slideshow_icon'])
339  {
340    $template->assign('U_SLIDESHOW', $page['cat_slideshow_url']);
341  }
342}
343
344include(PHPWG_ROOT_PATH.'include/page_header.php');
345trigger_action('loc_end_index');
346include(PHPWG_ROOT_PATH.'include/page_messages.php');
347$template->pparse('index');
348//------------------------------------------------------------ log informations
349pwg_log();
350include(PHPWG_ROOT_PATH.'include/page_tail.php');
351?>
Note: See TracBrowser for help on using the repository browser.