source: trunk/index.php @ 13244

Last change on this file since 13244 was 13062, checked in by plg, 12 years ago

feature 2368: also add canonical URL on index page.

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