source: trunk/index.php @ 12922

Last change on this file since 12922 was 12908, checked in by rvelices, 12 years ago

feature 2548 multisize - ability to choose displayed size on index page
-added some logs on i.php (configurable) to measure the perf

  • Property svn:eol-style set to LF
File size: 9.6 KB
RevLine 
[2]1<?php
[351]2// +-----------------------------------------------------------------------+
[8728]3// | Piwigo - a PHP based photo gallery                                    |
[351]4// +-----------------------------------------------------------------------+
[12908]5// | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
[2342]6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
[351]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  |
[352]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.                                                                  |
[351]22// +-----------------------------------------------------------------------+
[2]23
[352]24//--------------------------------------------------------------------- include
[364]25define('PHPWG_ROOT_PATH','./');
26include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
[1084]27include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
[1072]28
[8401]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
[1604]43trigger_action('loc_begin_index');
44
[1059]45//---------------------------------------------- change of image display order
[1036]46if (isset($_GET['image_order']))
[614]47{
[1623]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  }
[1036]56  redirect(
[1503]57    duplicate_index_url(
[1084]58      array(),        // nothing to redefine
59      array('start')  // changing display order goes back to section first page
[1082]60      )
[1036]61    );
[614]62}
[12908]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}
[2]71//-------------------------------------------------------------- initialization
[345]72
[3172]73$page['navigation_bar'] = array();
[8432]74if (count($page['items']) > $page['nb_image_page'])
[1036]75{
76  $page['navigation_bar'] = create_navigation_bar(
[1503]77    duplicate_index_url(array(), array('start')),
[1820]78    count($page['items']),
[1036]79    $page['start'],
[3117]80    $page['nb_image_page'],
[1084]81    true
[1036]82    );
83}
84
[755]85// caddie filling :-)
86if (isset($_GET['caddie']))
87{
[1036]88  fill_caddie($page['items']);
[2114]89  redirect(duplicate_index_url());
[755]90}
91
[2]92//----------------------------------------------------- template initialization
[345]93//
94// Start output of page
95//
96$title = $page['title'];
[850]97$page['body_id'] = 'theCategoryPage';
[345]98
[1109]99$template->set_filenames( array('index'=>'index.tpl') );
[351]100//-------------------------------------------------------------- category title
[1120]101$template_title = $page['title'];
[2218]102if (count($page['items']) > 0)
[428]103{
[1820]104  $template_title.= ' ['.count($page['items']).']';
[428]105}
[2231]106$template->assign('TITLE', $template_title);
[2]107
[1800]108if (isset($page['flat']) or isset($page['chronology_field']))
[1648]109{
[2231]110  $template->assign(
111    'U_MODE_NORMAL',
112    duplicate_index_url( array(), array('chronology_field', 'start', 'flat') )
[1648]113    );
114}
115
[5293]116if ($conf['index_flat_icon'] and !isset($page['flat']) and 'categories' == $page['section'])
[1651]117{
[2231]118  $template->assign(
119    'U_MODE_FLAT',
120    duplicate_index_url(array('flat' => ''), array('start', 'chronology_field'))
[1651]121    );
122}
123
[1090]124if (!isset($page['chronology_field']))
[1047]125{
[1090]126  $chronology_params =
127      array(
128          'chronology_field' => 'created',
129          'chronology_style' => 'monthly',
130          'chronology_view' => 'list',
131      );
[5293]132  if ($conf['index_created_date_icon'])
133  {
134    $template->assign(
135      'U_MODE_CREATED',
136      duplicate_index_url( $chronology_params, array('start', 'flat') )
137      );
138  }
139  if ($conf['index_posted_date_icon'])
140  {
141    $chronology_params['chronology_field'] = 'posted';
142    $template->assign(
143      'U_MODE_POSTED',
144      duplicate_index_url( $chronology_params, array('start', 'flat') )
145      );
146  }
[1047]147}
[1050]148else
149{
[1090]150  if ($page['chronology_field'] == 'created')
[1059]151  {
[1090]152    $chronology_field = 'posted';
[1059]153  }
154  else
155  {
[1090]156    $chronology_field = 'created';
[1059]157  }
[5293]158  if ($conf['index_'.$chronology_field.'_date_icon'])
159  {
160    $url = duplicate_index_url(
161              array('chronology_field'=>$chronology_field ),
162              array('chronology_date', 'start', 'flat')
163            );
164    $template->assign(
165        'U_MODE_'.strtoupper($chronology_field),
166        $url
167      );
168  }
[1050]169}
[1047]170
[1082]171if ('search' == $page['section'])
[1015]172{
[2231]173  $template->assign(
174    'U_SEARCH_RULES',
175    get_root_url().'search_rules.php?search_id='.$page['search']
[1015]176    );
177}
[797]178
[1082]179if (isset($page['category']) and is_admin())
[834]180{
[2231]181  $template->assign(
182    'U_EDIT',
183     get_root_url().'admin.php?page=cat_modify'
[1861]184        .'&amp;cat_id='.$page['category']['id']
[834]185    );
186}
187
[2218]188if (is_admin() and !empty($page['items']))
[1092]189{
[2231]190  $template->assign(
191    'U_CADDIE',
192     add_url_params(duplicate_index_url(), array('caddie'=>1) )
[2135]193    );
194}
195
196if ( $page['section']=='search' and $page['start']==0 and
197    !isset($page['chronology_field']) and isset($page['qsearch_details']) )
198{
[2231]199  $template->assign('QUERY_SEARCH',
[2135]200    htmlspecialchars($page['qsearch_details']['q']) );
201
[2138]202  $cats = array_merge(
[2135]203      (array)@$page['qsearch_details']['matching_cats_no_images'],
204      (array)@$page['qsearch_details']['matching_cats'] );
[2138]205  if (count($cats))
[2135]206  {
[2138]207    usort($cats, 'name_compare');
[2135]208    $hints = array();
[2138]209    foreach ( $cats as $cat )
[2135]210    {
[2770]211      $hints[] = get_cat_display_name( array($cat), '', false );
[2135]212    }
[2231]213    $template->assign( 'category_search_results', $hints);
[1092]214  }
215
[2138]216  $tags = (array)@$page['qsearch_details']['matching_tags'];
[2135]217  if (count($tags))
[1537]218  {
[2135]219    usort($tags, 'name_compare');
220    $hints = array();
221    foreach ( $tags as $tag )
[1537]222    {
[2135]223      $hints[] =
224        '<a href="' . make_index_url(array('tags'=>array($tag))) . '">'
[12553]225        .trigger_event('render_tag_name', $tag['name'])
[2135]226        .'</a>';
227    }
[2231]228    $template->assign( 'tag_search_results', $hints);
[1537]229  }
230}
231
[1047]232// navigation bar
[3172]233$template->assign( 'navbar', $page['navigation_bar'] );
[1051]234
[5293]235if ( $conf['index_sort_order_input']
236    and count($page['items']) > 0
[1082]237    and $page['section'] != 'most_visited'
238    and $page['section'] != 'best_rated')
[1051]239{
240  // image order
[1623]241  $order_idx = pwg_get_session_var( 'image_order', 0 );
[1051]242
[3146]243  $url = add_url_params(
244          duplicate_index_url(),
245          array('image_order' => '')
246        );
247  foreach (get_category_preferred_image_orders() as $order_id => $order)
[1051]248  {
[2517]249    if ($order[2])
[1051]250    {
[2231]251      $template->append(
252        'image_orders',
[1082]253        array(
[2517]254          'DISPLAY' => $order[0],
[3146]255          'URL' => $url.$order_id,
[2517]256          'SELECTED' => ($order_idx == $order_id ? true:false),
[1082]257          )
258        );
[1051]259    }
260  }
261}
262
[12908]263if ( count($page['items']) > 0 )
264{
265  $url = add_url_params(
266          duplicate_index_url(),
267          array('display' => '')
268        );
269  $selected_type = pwg_get_session_var('index_deriv', IMG_THUMB);
270  $type_map = ImageStdParams::get_defined_type_map();
271  unset($type_map[IMG_XXLARGE], $type_map[IMG_XLARGE]);
272  foreach($type_map as $params)
273  {
274    $template->append(
275      'image_derivatives',
276      array(
277        'DISPLAY' => l10n($params->type),
278        'URL' => $url.$params->type,
279        'SELECTED' => ($params->type == $selected_type ? true:false),
280        )
281      );
282  }
283}
284
[1604]285// category comment
[8401]286if ($page['start']==0 and !isset($page['chronology_field']) and !empty($page['comment']) )
[2]287{
[2231]288  $template->assign('CONTENT_DESCRIPTION', $page['comment'] );
[2]289}
[2586]290
291// include menubar
292include( PHPWG_ROOT_PATH.'include/menubar.inc.php');
293
[8463]294if ( isset($page['category']['count_categories']) and $page['category']['count_categories']==0 )
295{// count_categories might be computed by menubar - if the case unassign flat link if no sub albums
296        $template->clear_assign('U_MODE_FLAT');
297}
298
[2586]299//------------------------------------------------------ main part : thumbnails
300if ( 0==$page['start']
301    and !isset($page['flat'])
302    and !isset($page['chronology_field'])
303    and ('recent_cats'==$page['section'] or 'categories'==$page['section'])
304    and (!isset($page['category']['count_categories']) or $page['category']['count_categories']>0 )
305  )
306{
307  include(PHPWG_ROOT_PATH.'include/category_cats.inc.php');
308}
309if ( !empty($page['items']) )
310{
311  include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
312}
313//------------------------------------------------------- category informations
314
315// slideshow
316// execute after init thumbs in order to have all picture informations
317if (!empty($page['cat_slideshow_url']))
318{
319  if (isset($_GET['slideshow']))
320  {
321    redirect($page['cat_slideshow_url']);
322  }
[5293]323  elseif ($conf['index_slideshow_icon'])
[2586]324  {
325    $template->assign('U_SLIDESHOW', $page['cat_slideshow_url']);
326  }
327}
328
[1655]329include(PHPWG_ROOT_PATH.'include/page_header.php');
[1604]330trigger_action('loc_end_index');
[2231]331$template->pparse('index');
[2699]332//------------------------------------------------------------ log informations
333pwg_log();
[369]334include(PHPWG_ROOT_PATH.'include/page_tail.php');
[362]335?>
Note: See TracBrowser for help on using the repository browser.