source: trunk/index.php @ 6136

Last change on this file since 6136 was 5293, checked in by patdenice, 15 years ago

Feature 1533: Change "General" by "Options" in Configuration menu.
Change "Default Display" tab by "Guest Settings" tab.
Add display tab in Configuration/Option menu.

Allow to activate/deactivate a lot of display features:

On main page:
# Display only recently posted images
# Sort order
# Display all elements in all sub-categories
# Display a calendar by posted date
# Display a calendar by creation date
# Slideshow

On photo page:
# Show file metadata
# slideshow
# Add this image to your favorites
# Navigation Bar
# Navigation Thumbnails

File size: 8.7 KB
RevLine 
[2]1<?php
[351]2// +-----------------------------------------------------------------------+
[2342]3// | Piwigo - a PHP based picture gallery                                  |
[351]4// +-----------------------------------------------------------------------+
[5196]5// | Copyright(C) 2008-2010 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
[1604]29trigger_action('loc_begin_index');
30
[1072]31// +-----------------------------------------------------------------------+
32// | Check Access and exit when user status is not ok                      |
33// +-----------------------------------------------------------------------+
34check_status(ACCESS_GUEST);
35
[1059]36//---------------------------------------------- change of image display order
[1036]37if (isset($_GET['image_order']))
[614]38{
[1623]39  if ( (int)$_GET['image_order'] > 0)
40  {
41    pwg_set_session_var('image_order', (int)$_GET['image_order']);
42  }
43  else
44  {
45    pwg_unset_session_var('image_order');
46  }
[1036]47  redirect(
[1503]48    duplicate_index_url(
[1084]49      array(),        // nothing to redefine
50      array('start')  // changing display order goes back to section first page
[1082]51      )
[1036]52    );
[614]53}
[2]54//-------------------------------------------------------------- initialization
[345]55// detection of the start picture to display
[1082]56if (!isset($page['start']))
[514]57{
[345]58  $page['start'] = 0;
[514]59}
[345]60
[1036]61// access authorization check
[1082]62if (isset($page['category']))
[1036]63{
[1861]64  check_restrictions($page['category']['id']);
[1036]65}
66
[3172]67$page['navigation_bar'] = array();
[2218]68if (count($page['items']) > $user['nb_image_page'])
[1036]69{
70  $page['navigation_bar'] = create_navigation_bar(
[1503]71    duplicate_index_url(array(), array('start')),
[1820]72    count($page['items']),
[1036]73    $page['start'],
[3117]74    $page['nb_image_page'],
[1084]75    true
[1036]76    );
77}
78
[755]79// caddie filling :-)
80if (isset($_GET['caddie']))
81{
[1036]82  fill_caddie($page['items']);
[2114]83  redirect(duplicate_index_url());
[755]84}
85
[2]86//----------------------------------------------------- template initialization
[345]87//
88// Start output of page
89//
90$title = $page['title'];
[850]91$page['body_id'] = 'theCategoryPage';
[345]92
[1109]93$template->set_filenames( array('index'=>'index.tpl') );
[351]94//-------------------------------------------------------------- category title
[1120]95$template_title = $page['title'];
[2218]96if (count($page['items']) > 0)
[428]97{
[1820]98  $template_title.= ' ['.count($page['items']).']';
[428]99}
[2231]100$template->assign('TITLE', $template_title);
[2]101
[1800]102if (isset($page['flat']) or isset($page['chronology_field']))
[1648]103{
[2231]104  $template->assign(
105    'U_MODE_NORMAL',
106    duplicate_index_url( array(), array('chronology_field', 'start', 'flat') )
[1648]107    );
108}
109
[5293]110if ($conf['index_flat_icon'] and !isset($page['flat']) and 'categories' == $page['section'])
[1651]111{
[2231]112  $template->assign(
113    'U_MODE_FLAT',
114    duplicate_index_url(array('flat' => ''), array('start', 'chronology_field'))
[1651]115    );
116}
117
[1090]118if (!isset($page['chronology_field']))
[1047]119{
[1090]120  $chronology_params =
121      array(
122          'chronology_field' => 'created',
123          'chronology_style' => 'monthly',
124          'chronology_view' => 'list',
125      );
[5293]126  if ($conf['index_created_date_icon'])
127  {
128    $template->assign(
129      'U_MODE_CREATED',
130      duplicate_index_url( $chronology_params, array('start', 'flat') )
131      );
132  }
133  if ($conf['index_posted_date_icon'])
134  {
135    $chronology_params['chronology_field'] = 'posted';
136    $template->assign(
137      'U_MODE_POSTED',
138      duplicate_index_url( $chronology_params, array('start', 'flat') )
139      );
140  }
[1047]141}
[1050]142else
143{
[1090]144  if ($page['chronology_field'] == 'created')
[1059]145  {
[1090]146    $chronology_field = 'posted';
[1059]147  }
148  else
149  {
[1090]150    $chronology_field = 'created';
[1059]151  }
[5293]152  if ($conf['index_'.$chronology_field.'_date_icon'])
153  {
154    $url = duplicate_index_url(
155              array('chronology_field'=>$chronology_field ),
156              array('chronology_date', 'start', 'flat')
157            );
158    $template->assign(
159        'U_MODE_'.strtoupper($chronology_field),
160        $url
161      );
162  }
[1050]163}
[1047]164
[1082]165if ('search' == $page['section'])
[1015]166{
[2231]167  $template->assign(
168    'U_SEARCH_RULES',
169    get_root_url().'search_rules.php?search_id='.$page['search']
[1015]170    );
171}
[797]172
[1082]173if (isset($page['category']) and is_admin())
[834]174{
[2231]175  $template->assign(
176    'U_EDIT',
177     get_root_url().'admin.php?page=cat_modify'
[1861]178        .'&amp;cat_id='.$page['category']['id']
[834]179    );
180}
181
[2218]182if (is_admin() and !empty($page['items']))
[1092]183{
[2231]184  $template->assign(
185    'U_CADDIE',
186     add_url_params(duplicate_index_url(), array('caddie'=>1) )
[2135]187    );
188}
189
190if ( $page['section']=='search' and $page['start']==0 and
191    !isset($page['chronology_field']) and isset($page['qsearch_details']) )
192{
[2231]193  $template->assign('QUERY_SEARCH',
[2135]194    htmlspecialchars($page['qsearch_details']['q']) );
195
[2138]196  $cats = array_merge(
[2135]197      (array)@$page['qsearch_details']['matching_cats_no_images'],
198      (array)@$page['qsearch_details']['matching_cats'] );
[2138]199  if (count($cats))
[2135]200  {
[2138]201    usort($cats, 'name_compare');
[2135]202    $hints = array();
[2138]203    foreach ( $cats as $cat )
[2135]204    {
[2770]205      $hints[] = get_cat_display_name( array($cat), '', false );
[2135]206    }
[2231]207    $template->assign( 'category_search_results', $hints);
[1092]208  }
209
[2138]210  $tags = (array)@$page['qsearch_details']['matching_tags'];
[2135]211  if (count($tags))
[1537]212  {
[2135]213    usort($tags, 'name_compare');
214    $hints = array();
215    foreach ( $tags as $tag )
[1537]216    {
[2135]217      $hints[] =
218        '<a href="' . make_index_url(array('tags'=>array($tag))) . '">'
219        .$tag['name']
220        .'</a>';
221    }
[2231]222    $template->assign( 'tag_search_results', $hints);
[1537]223  }
224}
225
[1047]226// navigation bar
[3172]227$template->assign( 'navbar', $page['navigation_bar'] );
[1051]228
[5293]229if ( $conf['index_sort_order_input']
230    and count($page['items']) > 0
[1082]231    and $page['section'] != 'most_visited'
232    and $page['section'] != 'best_rated')
[1051]233{
234  // image order
[1623]235  $order_idx = pwg_get_session_var( 'image_order', 0 );
[1051]236
[3146]237  $url = add_url_params(
238          duplicate_index_url(),
239          array('image_order' => '')
240        );
241  foreach (get_category_preferred_image_orders() as $order_id => $order)
[1051]242  {
[2517]243    if ($order[2])
[1051]244    {
[2231]245      $template->append(
246        'image_orders',
[1082]247        array(
[2517]248          'DISPLAY' => $order[0],
[3146]249          'URL' => $url.$order_id,
[2517]250          'SELECTED' => ($order_idx == $order_id ? true:false),
[1082]251          )
252        );
[1051]253    }
254  }
255}
256
[1604]257// category comment
258if (isset($page['comment']) and $page['comment'] != '')
[2]259{
[2231]260  $template->assign('CONTENT_DESCRIPTION', $page['comment'] );
[2]261}
[2586]262
263// include menubar
264include( PHPWG_ROOT_PATH.'include/menubar.inc.php');
265
266//------------------------------------------------------ main part : thumbnails
267if ( 0==$page['start']
268    and !isset($page['flat'])
269    and !isset($page['chronology_field'])
270    and ('recent_cats'==$page['section'] or 'categories'==$page['section'])
271    and (!isset($page['category']['count_categories']) or $page['category']['count_categories']>0 )
272  )
273{
274  include(PHPWG_ROOT_PATH.'include/category_cats.inc.php');
275}
276if ( !empty($page['items']) )
277{
278  include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
279}
280//------------------------------------------------------- category informations
281
282// slideshow
283// execute after init thumbs in order to have all picture informations
284if (!empty($page['cat_slideshow_url']))
285{
286  if (isset($_GET['slideshow']))
287  {
288    redirect($page['cat_slideshow_url']);
289  }
[5293]290  elseif ($conf['index_slideshow_icon'])
[2586]291  {
292    $template->assign('U_SLIDESHOW', $page['cat_slideshow_url']);
293  }
294}
295
[1655]296include(PHPWG_ROOT_PATH.'include/page_header.php');
[1604]297trigger_action('loc_end_index');
[2231]298$template->pparse('index');
[2699]299//------------------------------------------------------------ log informations
300pwg_log();
[369]301include(PHPWG_ROOT_PATH.'include/page_tail.php');
[362]302?>
Note: See TracBrowser for help on using the repository browser.