source: trunk/index.php @ 18462

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

feature:2614 pagination on albums
return to old fashioned way (one query in category_cats), restoring recent_cats feature and "menubar optimization", rename "starta" into "startcat"

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