source: trunk/index.php @ 2117

Last change on this file since 2117 was 2117, checked in by rvelices, 17 years ago
  • render_category_description and render_category_literal_description events refactoring
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 8.5 KB
RevLine 
[2]1<?php
[351]2// +-----------------------------------------------------------------------+
[593]3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
[1711]5// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
[351]6// +-----------------------------------------------------------------------+
[1711]7// | file          : $Id: index.php 2117 2007-10-02 05:38:54Z rvelices $
[351]8// | last update   : $Date: 2007-10-02 05:38:54 +0000 (Tue, 02 Oct 2007) $
9// | last modifier : $Author: rvelices $
10// | revision      : $Revision: 2117 $
11// +-----------------------------------------------------------------------+
12// | This program is free software; you can redistribute it and/or modify  |
13// | it under the terms of the GNU General Public License as published by  |
[352]14// | the Free Software Foundation                                          |
15// |                                                                       |
16// | This program is distributed in the hope that it will be useful, but   |
17// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
18// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
19// | General Public License for more details.                              |
20// |                                                                       |
21// | You should have received a copy of the GNU General Public License     |
22// | along with this program; if not, write to the Free Software           |
23// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
24// | USA.                                                                  |
[351]25// +-----------------------------------------------------------------------+
[2]26
[352]27//--------------------------------------------------------------------- include
[364]28define('PHPWG_ROOT_PATH','./');
29include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
[1084]30include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
[1072]31
[1604]32trigger_action('loc_begin_index');
33
[1072]34// +-----------------------------------------------------------------------+
35// | Check Access and exit when user status is not ok                      |
36// +-----------------------------------------------------------------------+
37check_status(ACCESS_GUEST);
38
[1059]39//---------------------------------------------- change of image display order
[1036]40if (isset($_GET['image_order']))
[614]41{
[1623]42  if ( (int)$_GET['image_order'] > 0)
43  {
44    pwg_set_session_var('image_order', (int)$_GET['image_order']);
45  }
46  else
47  {
48    pwg_unset_session_var('image_order');
49  }
[1036]50  redirect(
[1503]51    duplicate_index_url(
[1084]52      array(),        // nothing to redefine
53      array('start')  // changing display order goes back to section first page
[1082]54      )
[1036]55    );
[614]56}
[2]57//-------------------------------------------------------------- initialization
[345]58// detection of the start picture to display
[1082]59if (!isset($page['start']))
[514]60{
[345]61  $page['start'] = 0;
[514]62}
[345]63
[1036]64// access authorization check
[1082]65if (isset($page['category']))
[1036]66{
[1861]67  check_restrictions($page['category']['id']);
[1036]68}
69
[1820]70if ( count($page['items']) > $user['nb_image_page'])
[1036]71{
72  $page['navigation_bar'] = create_navigation_bar(
[1503]73    duplicate_index_url(array(), array('start')),
[1820]74    count($page['items']),
[1036]75    $page['start'],
76    $user['nb_image_page'],
[1084]77    true
[1036]78    );
79}
80else
81{
82  $page['navigation_bar'] = '';
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'];
[1820]102if ( count($page['items']) > 0)
[428]103{
[1820]104  $template_title.= ' ['.count($page['items']).']';
[428]105}
[2]106
[1800]107if (isset($page['flat']) or isset($page['chronology_field']))
[1648]108{
109  $template->assign_block_vars(
[1677]110    'mode_normal',
[1648]111    array(
[1800]112      'URL' => duplicate_index_url( array(), array('chronology_field', 'start', 'flat') )
[1648]113      )
114    );
115}
116
[1800]117if (!isset($page['flat']) and 'categories' == $page['section'])
[1651]118{
119  $template->assign_block_vars(
[1800]120    'flat',
[1651]121    array(
[1800]122      'URL' => duplicate_index_url(array('flat' => ''), array('start', 'chronology_field'))
[1651]123      )
124    );
125}
126
[1090]127if (!isset($page['chronology_field']))
[1047]128{
[1090]129  $chronology_params =
130      array(
131          'chronology_field' => 'created',
132          'chronology_style' => 'monthly',
133          'chronology_view' => 'list',
134      );
[1050]135  $template->assign_block_vars(
[1059]136    'mode_created',
[1082]137    array(
[1800]138      'URL' => duplicate_index_url( $chronology_params, array('start', 'flat') )
[1082]139      )
[1050]140    );
[1083]141
[1090]142  $chronology_params['chronology_field'] = 'posted';
[1059]143  $template->assign_block_vars(
144    'mode_posted',
[1082]145    array(
[1800]146      'URL' => duplicate_index_url( $chronology_params, array('start', 'flat') )
[1082]147      )
[1059]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  }
[1503]160  $url = duplicate_index_url(
[1090]161            array('chronology_field'=>$chronology_field ),
[1800]162            array('chronology_date', 'start', 'flat')
[1086]163          );
164  $template->assign_block_vars(
[1090]165    'mode_'.$chronology_field,
[1086]166    array('URL' => $url )
167    );
[1050]168}
[1377]169// include menubar
170include(PHPWG_ROOT_PATH.'include/menubar.inc.php');
[1047]171
[850]172$template->assign_vars(
173  array(
[1624]174    'TITLE' => $template_title
[1082]175    )
176  );
[1059]177
[1082]178if ('search' == $page['section'])
[1015]179{
180  $template->assign_block_vars(
181    'search_rules',
182    array(
[1092]183      'URL' => get_root_url().'search_rules.php?search_id='.$page['search'],
[1015]184      )
185    );
186}
[797]187
[1082]188if (isset($page['category']) and is_admin())
[834]189{
190  $template->assign_block_vars(
191    'edit',
192    array(
193      'URL' =>
[1090]194        get_root_url().'admin.php?page=cat_modify'
[1861]195        .'&amp;cat_id='.$page['category']['id']
[834]196      )
197    );
198}
199
[1092]200if (is_admin() and !empty($page['items']) )
201{
202    $template->assign_block_vars(
203      'caddie',
204      array(
205        'URL' =>
[1094]206          add_url_params(duplicate_index_url(), array('caddie'=>1) )
[1092]207        )
208      );
209  }
210
[1537]211if ( $page['section']=='search' and $page['start']==0 )
212{
213  $tags = get_common_tags($page['items'],
214      $conf['content_tag_cloud_items_number'], null);
215  if ( count($tags)>1 )
216  {
217    $template->assign_block_vars('related_tags', array() );
218
219    $tags = add_level_to_tags($tags);
220    foreach ($tags as $tag)
221    {
222      $template->assign_block_vars(
223      'related_tags.tag', array(
224        'URL' => make_index_url(
225          array(
[1815]226            'tags' => array($tag)
[1537]227            )
228          ),
229        'NAME' => $tag['name'],
[1932]230        'TITLE' => l10n_dec(
231            '%d picture are also linked to current tags',
232            '%d pictures are also linked to current tags',
233            $tag['counter']),
[1537]234        'CLASS' => 'tagLevel'.$tag['level']
235        )
236      );
237    }
238  }
239}
240
[441]241//------------------------------------------------------ main part : thumbnails
[1820]242if ( 0==$page['start']
243    and !isset($page['flat'])
244    and !isset($page['chronology_field'])
245    and ('recent_cats'==$page['section'] or 'categories'==$page['section'])
246  )
[1047]247{
[1820]248  include(PHPWG_ROOT_PATH.'include/category_cats.inc.php');
[1047]249}
[1820]250if ( !empty($page['items']) )
251{
252  include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
253}
[2]254//------------------------------------------------------- category informations
[1604]255
[1047]256// navigation bar
[1082]257if ($page['navigation_bar'] != '')
[1059]258{
[1047]259  $template->assign_block_vars(
260    'cat_infos.navigation',
[1082]261    array(
262      'NAV_BAR' => $page['navigation_bar'],
263      )
[1047]264    );
265}
[1051]266
[1820]267if ( count($page['items']) > 0
[1082]268    and $page['section'] != 'most_visited'
269    and $page['section'] != 'best_rated')
[1051]270{
271  // image order
272  $template->assign_block_vars( 'preferred_image_order', array() );
273
[1623]274  $order_idx = pwg_get_session_var( 'image_order', 0 );
[1051]275
276  $orders = get_category_preferred_image_orders();
[1082]277  for ($i = 0; $i < count($orders); $i++)
[1051]278  {
279    if ($orders[$i][2])
280    {
[1082]281      $template->assign_block_vars(
282        'preferred_image_order.order',
283        array(
284          'DISPLAY' => $orders[$i][0],
[1503]285          'URL' => add_url_params( duplicate_index_url(), array('image_order'=>$i) ),
[1082]286          'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''),
287          )
288        );
[1051]289    }
290  }
291}
292
[1604]293// category comment
294if (isset($page['comment']) and $page['comment'] != '')
[2]295{
[1604]296  $template->assign_block_vars(
297    'cat_infos.comment',
298    array(
[2117]299      'COMMENTS' => $page['comment']
[1604]300      )
301    );
[1627]302  $header_infos['COMMENT'] = strip_tags($page['comment']);
[2]303}
304//------------------------------------------------------------ log informations
[1727]305pwg_log();
[345]306
[1655]307include(PHPWG_ROOT_PATH.'include/page_header.php');
[1604]308trigger_action('loc_end_index');
[1109]309$template->parse('index');
[369]310include(PHPWG_ROOT_PATH.'include/page_tail.php');
[362]311?>
Note: See TracBrowser for help on using the repository browser.