source: branches/2.0/index.php @ 3278

Last change on this file since 3278 was 3147, checked in by rvelices, 15 years ago

merge 3145-3146 from trunk
Last (I hope) paranoic optims ...

  • move get_uysername and get_groupname from public to admin/functions.inc.php
  • optim in index.php
  • tags.tpl does not need smarty modifier included
  • move func get_comment_post_key from functions_comment to functions (avoid extra inclusion every time on picture page)
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 8.4 KB
RevLine 
[2]1<?php
[351]2// +-----------------------------------------------------------------------+
[2342]3// | Piwigo - a PHP based picture gallery                                  |
[351]4// +-----------------------------------------------------------------------+
[3046]5// | Copyright(C) 2008-2009 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
[2218]67if (count($page['items']) > $user['nb_image_page'])
[1036]68{
69  $page['navigation_bar'] = create_navigation_bar(
[1503]70    duplicate_index_url(array(), array('start')),
[1820]71    count($page['items']),
[1036]72    $page['start'],
[3118]73    $page['nb_image_page'],
[1084]74    true
[1036]75    );
76}
77else
78{
79  $page['navigation_bar'] = '';
80}
81
[755]82// caddie filling :-)
83if (isset($_GET['caddie']))
84{
[1036]85  fill_caddie($page['items']);
[2114]86  redirect(duplicate_index_url());
[755]87}
88
[2]89//----------------------------------------------------- template initialization
[345]90//
91// Start output of page
92//
93$title = $page['title'];
[850]94$page['body_id'] = 'theCategoryPage';
[345]95
[1109]96$template->set_filenames( array('index'=>'index.tpl') );
[351]97//-------------------------------------------------------------- category title
[1120]98$template_title = $page['title'];
[2218]99if (count($page['items']) > 0)
[428]100{
[1820]101  $template_title.= ' ['.count($page['items']).']';
[428]102}
[2231]103$template->assign('TITLE', $template_title);
[2]104
[1800]105if (isset($page['flat']) or isset($page['chronology_field']))
[1648]106{
[2231]107  $template->assign(
108    'U_MODE_NORMAL',
109    duplicate_index_url( array(), array('chronology_field', 'start', 'flat') )
[1648]110    );
111}
112
[1800]113if (!isset($page['flat']) and 'categories' == $page['section'])
[1651]114{
[2231]115  $template->assign(
116    'U_MODE_FLAT',
117    duplicate_index_url(array('flat' => ''), array('start', 'chronology_field'))
[1651]118    );
119}
120
[1090]121if (!isset($page['chronology_field']))
[1047]122{
[1090]123  $chronology_params =
124      array(
125          'chronology_field' => 'created',
126          'chronology_style' => 'monthly',
127          'chronology_view' => 'list',
128      );
[2231]129  $template->assign(
130    'U_MODE_CREATED',
131    duplicate_index_url( $chronology_params, array('start', 'flat') )
[1050]132    );
[1083]133
[1090]134  $chronology_params['chronology_field'] = 'posted';
[2231]135  $template->assign(
136    'U_MODE_POSTED',
137    duplicate_index_url( $chronology_params, array('start', 'flat') )
[1059]138    );
[1047]139}
[1050]140else
141{
[1090]142  if ($page['chronology_field'] == 'created')
[1059]143  {
[1090]144    $chronology_field = 'posted';
[1059]145  }
146  else
147  {
[1090]148    $chronology_field = 'created';
[1059]149  }
[1503]150  $url = duplicate_index_url(
[1090]151            array('chronology_field'=>$chronology_field ),
[1800]152            array('chronology_date', 'start', 'flat')
[1086]153          );
[2231]154  $template->assign(
155      'U_MODE_'.strtoupper($chronology_field),
156      $url
[1086]157    );
[1050]158}
[1047]159
[1082]160if ('search' == $page['section'])
[1015]161{
[2231]162  $template->assign(
163    'U_SEARCH_RULES',
164    get_root_url().'search_rules.php?search_id='.$page['search']
[1015]165    );
166}
[797]167
[1082]168if (isset($page['category']) and is_admin())
[834]169{
[2231]170  $template->assign(
171    'U_EDIT',
172     get_root_url().'admin.php?page=cat_modify'
[1861]173        .'&amp;cat_id='.$page['category']['id']
[834]174    );
175}
176
[2218]177if (is_admin() and !empty($page['items']))
[1092]178{
[2231]179  $template->assign(
180    'U_CADDIE',
181     add_url_params(duplicate_index_url(), array('caddie'=>1) )
[2135]182    );
183}
184
185if ( $page['section']=='search' and $page['start']==0 and
186    !isset($page['chronology_field']) and isset($page['qsearch_details']) )
187{
[2231]188  $template->assign('QUERY_SEARCH',
[2135]189    htmlspecialchars($page['qsearch_details']['q']) );
190
[2138]191  $cats = array_merge(
[2135]192      (array)@$page['qsearch_details']['matching_cats_no_images'],
193      (array)@$page['qsearch_details']['matching_cats'] );
[2138]194  if (count($cats))
[2135]195  {
[2138]196    usort($cats, 'name_compare');
[2135]197    $hints = array();
[2138]198    foreach ( $cats as $cat )
[2135]199    {
[2769]200      $hints[] = get_cat_display_name( array($cat), '', false );
[2135]201    }
[2231]202    $template->assign( 'category_search_results', $hints);
[1092]203  }
204
[2138]205  $tags = (array)@$page['qsearch_details']['matching_tags'];
[2135]206  if (count($tags))
[1537]207  {
[2135]208    usort($tags, 'name_compare');
209    $hints = array();
210    foreach ( $tags as $tag )
[1537]211    {
[2135]212      $hints[] =
213        '<a href="' . make_index_url(array('tags'=>array($tag))) . '">'
214        .$tag['name']
215        .'</a>';
216    }
[2231]217    $template->assign( 'tag_search_results', $hints);
[1537]218  }
219}
220
[1047]221// navigation bar
[2231]222$template->assign( 'NAV_BAR', $page['navigation_bar'] );
[1051]223
[1820]224if ( count($page['items']) > 0
[1082]225    and $page['section'] != 'most_visited'
226    and $page['section'] != 'best_rated')
[1051]227{
228  // image order
[1623]229  $order_idx = pwg_get_session_var( 'image_order', 0 );
[1051]230
[3147]231  $url = add_url_params(
232          duplicate_index_url(),
233          array('image_order' => '')
234        );
235  foreach (get_category_preferred_image_orders() as $order_id => $order)
[1051]236  {
[2517]237    if ($order[2])
[1051]238    {
[2231]239      $template->append(
240        'image_orders',
[1082]241        array(
[2517]242          'DISPLAY' => $order[0],
[3147]243          'URL' => $url.$order_id,
[2517]244          'SELECTED' => ($order_idx == $order_id ? true:false),
[1082]245          )
246        );
[1051]247    }
248  }
249}
250
[1604]251// category comment
252if (isset($page['comment']) and $page['comment'] != '')
[2]253{
[2231]254  $template->assign('CONTENT_DESCRIPTION', $page['comment'] );
[2]255}
[2586]256
257// include menubar
258include( PHPWG_ROOT_PATH.'include/menubar.inc.php');
259
260//------------------------------------------------------ main part : thumbnails
261if ( 0==$page['start']
262    and !isset($page['flat'])
263    and !isset($page['chronology_field'])
264    and ('recent_cats'==$page['section'] or 'categories'==$page['section'])
265    and (!isset($page['category']['count_categories']) or $page['category']['count_categories']>0 )
266  )
267{
268  include(PHPWG_ROOT_PATH.'include/category_cats.inc.php');
269}
270if ( !empty($page['items']) )
271{
272  include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
273}
274//------------------------------------------------------- category informations
275
276// slideshow
277// execute after init thumbs in order to have all picture informations
278if (!empty($page['cat_slideshow_url']))
279{
280  if (isset($_GET['slideshow']))
281  {
282    redirect($page['cat_slideshow_url']);
283  }
284  else
285  {
286    $template->assign('U_SLIDESHOW', $page['cat_slideshow_url']);
287  }
288}
289
[1655]290include(PHPWG_ROOT_PATH.'include/page_header.php');
[1604]291trigger_action('loc_end_index');
[2231]292$template->pparse('index');
[2699]293//------------------------------------------------------------ log informations
294pwg_log();
[369]295include(PHPWG_ROOT_PATH.'include/page_tail.php');
[362]296?>
Note: See TracBrowser for help on using the repository browser.