source: trunk/index.php @ 18640

Last change on this file since 18640 was 18637, checked in by rvelices, 12 years ago

bug 2772: remove "Home" from html title pages on index pages

  • Property svn:eol-style set to LF
File size: 9.7 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
32
33// access authorization check
34if (isset($page['category']))
35{
36  check_restrictions($page['category']['id']);
37}
[13872]38if ($page['start']>0 && $page['start']>=count($page['items']))
39{
40  page_not_found('', duplicate_index_url(array('start'=>0)));
41}
[8401]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
[18165]73// navigation bar
[3172]74$page['navigation_bar'] = array();
[8432]75if (count($page['items']) > $page['nb_image_page'])
[1036]76{
77  $page['navigation_bar'] = create_navigation_bar(
[1503]78    duplicate_index_url(array(), array('start')),
[1820]79    count($page['items']),
[1036]80    $page['start'],
[3117]81    $page['nb_image_page'],
[18165]82    true, 'start'
[1036]83    );
84}
85
[18462]86$template->assign('thumb_navbar', $page['navigation_bar'] );
[18165]87
[755]88// caddie filling :-)
89if (isset($_GET['caddie']))
90{
[1036]91  fill_caddie($page['items']);
[2114]92  redirect(duplicate_index_url());
[755]93}
94
[13458]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);
[13062]104
[2]105//----------------------------------------------------- template initialization
[345]106//
107// Start output of page
108//
109$title = $page['title'];
[850]110$page['body_id'] = 'theCategoryPage';
[345]111
[1109]112$template->set_filenames( array('index'=>'index.tpl') );
[351]113//-------------------------------------------------------------- category title
[18637]114$template_title = $page['section_title'];
[2218]115if (count($page['items']) > 0)
[428]116{
[1820]117  $template_title.= ' ['.count($page['items']).']';
[428]118}
[2231]119$template->assign('TITLE', $template_title);
[2]120
[1800]121if (isset($page['flat']) or isset($page['chronology_field']))
[1648]122{
[2231]123  $template->assign(
124    'U_MODE_NORMAL',
125    duplicate_index_url( array(), array('chronology_field', 'start', 'flat') )
[1648]126    );
127}
128
[5293]129if ($conf['index_flat_icon'] and !isset($page['flat']) and 'categories' == $page['section'])
[1651]130{
[2231]131  $template->assign(
132    'U_MODE_FLAT',
133    duplicate_index_url(array('flat' => ''), array('start', 'chronology_field'))
[1651]134    );
135}
136
[1090]137if (!isset($page['chronology_field']))
[1047]138{
[1090]139  $chronology_params =
140      array(
141          'chronology_field' => 'created',
142          'chronology_style' => 'monthly',
143          'chronology_view' => 'list',
144      );
[5293]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  }
[1047]160}
[1050]161else
162{
[1090]163  if ($page['chronology_field'] == 'created')
[1059]164  {
[1090]165    $chronology_field = 'posted';
[1059]166  }
167  else
168  {
[1090]169    $chronology_field = 'created';
[1059]170  }
[5293]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  }
[1050]182}
[1047]183
[1082]184if ('search' == $page['section'])
[1015]185{
[2231]186  $template->assign(
187    'U_SEARCH_RULES',
188    get_root_url().'search_rules.php?search_id='.$page['search']
[1015]189    );
190}
[797]191
[1082]192if (isset($page['category']) and is_admin())
[834]193{
[2231]194  $template->assign(
195    'U_EDIT',
[13025]196    get_root_url().'admin.php?page=album-'.$page['category']['id']
[834]197    );
198}
199
[2218]200if (is_admin() and !empty($page['items']))
[1092]201{
[2231]202  $template->assign(
203    'U_CADDIE',
204     add_url_params(duplicate_index_url(), array('caddie'=>1) )
[2135]205    );
206}
207
208if ( $page['section']=='search' and $page['start']==0 and
209    !isset($page['chronology_field']) and isset($page['qsearch_details']) )
210{
[2231]211  $template->assign('QUERY_SEARCH',
[2135]212    htmlspecialchars($page['qsearch_details']['q']) );
213
[2138]214  $cats = array_merge(
[2135]215      (array)@$page['qsearch_details']['matching_cats_no_images'],
216      (array)@$page['qsearch_details']['matching_cats'] );
[2138]217  if (count($cats))
[2135]218  {
[2138]219    usort($cats, 'name_compare');
[2135]220    $hints = array();
[2138]221    foreach ( $cats as $cat )
[2135]222    {
[2770]223      $hints[] = get_cat_display_name( array($cat), '', false );
[2135]224    }
[2231]225    $template->assign( 'category_search_results', $hints);
[1092]226  }
227
[2138]228  $tags = (array)@$page['qsearch_details']['matching_tags'];
[18636]229  foreach ( $tags as $tag )
[1537]230  {
[18636]231    $tag['URL'] = make_index_url(array('tags'=>array($tag)));
232    $template->append( 'tag_search_results', $tag);
[1537]233  }
234}
235
[1051]236
[5293]237if ( $conf['index_sort_order_input']
238    and count($page['items']) > 0
[1082]239    and $page['section'] != 'most_visited'
240    and $page['section'] != 'best_rated')
[1051]241{
242  // image order
[1623]243  $order_idx = pwg_get_session_var( 'image_order', 0 );
[1051]244
[3146]245  $url = add_url_params(
246          duplicate_index_url(),
247          array('image_order' => '')
248        );
249  foreach (get_category_preferred_image_orders() as $order_id => $order)
[1051]250  {
[2517]251    if ($order[2])
[1051]252    {
[2231]253      $template->append(
254        'image_orders',
[1082]255        array(
[2517]256          'DISPLAY' => $order[0],
[3146]257          'URL' => $url.$order_id,
[2517]258          'SELECTED' => ($order_idx == $order_id ? true:false),
[1082]259          )
260        );
[1051]261    }
262  }
263}
264
[1604]265// category comment
[8401]266if ($page['start']==0 and !isset($page['chronology_field']) and !empty($page['comment']) )
[2]267{
[2231]268  $template->assign('CONTENT_DESCRIPTION', $page['comment'] );
[2]269}
[2586]270
271// include menubar
272include( PHPWG_ROOT_PATH.'include/menubar.inc.php');
273
[8463]274if ( isset($page['category']['count_categories']) and $page['category']['count_categories']==0 )
275{// count_categories might be computed by menubar - if the case unassign flat link if no sub albums
276        $template->clear_assign('U_MODE_FLAT');
277}
278
[2586]279//------------------------------------------------------ main part : thumbnails
[18462]280if ( 0==$page['start']
281  and !isset($page['flat'])
282  and !isset($page['chronology_field'])
283  and ('recent_cats'==$page['section'] or 'categories'==$page['section'])
284  and (!isset($page['category']['count_categories']) or $page['category']['count_categories']>0 )
285)
[2586]286{
287  include(PHPWG_ROOT_PATH.'include/category_cats.inc.php');
288}
[18462]289
[2586]290if ( !empty($page['items']) )
291{
292  include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
[16987]293  $url = add_url_params(
294          duplicate_index_url(),
295          array('display' => '')
296        );
297  $selected_type = $template->get_template_vars('derivative_params')->type;
298  $template->clear_assign( 'derivative_params' );
299  $type_map = ImageStdParams::get_defined_type_map();
300  unset($type_map[IMG_XXLARGE], $type_map[IMG_XLARGE]);
301  foreach($type_map as $params)
302  {
303    $template->append(
304      'image_derivatives',
305      array(
306        'DISPLAY' => l10n($params->type),
307        'URL' => $url.$params->type,
308        'SELECTED' => ($params->type == $selected_type ? true:false),
309        )
310      );
311  }
[2586]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');
[15578]331include(PHPWG_ROOT_PATH.'include/page_messages.php');
[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.