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
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
5// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | file          : $Id: index.php 2117 2007-10-02 05:38:54Z rvelices $
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  |
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.                                                                  |
25// +-----------------------------------------------------------------------+
26
27//--------------------------------------------------------------------- include
28define('PHPWG_ROOT_PATH','./');
29include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
30include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
31
32trigger_action('loc_begin_index');
33
34// +-----------------------------------------------------------------------+
35// | Check Access and exit when user status is not ok                      |
36// +-----------------------------------------------------------------------+
37check_status(ACCESS_GUEST);
38
39//---------------------------------------------- change of image display order
40if (isset($_GET['image_order']))
41{
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  }
50  redirect(
51    duplicate_index_url(
52      array(),        // nothing to redefine
53      array('start')  // changing display order goes back to section first page
54      )
55    );
56}
57//-------------------------------------------------------------- initialization
58// detection of the start picture to display
59if (!isset($page['start']))
60{
61  $page['start'] = 0;
62}
63
64// access authorization check
65if (isset($page['category']))
66{
67  check_restrictions($page['category']['id']);
68}
69
70if ( count($page['items']) > $user['nb_image_page'])
71{
72  $page['navigation_bar'] = create_navigation_bar(
73    duplicate_index_url(array(), array('start')),
74    count($page['items']),
75    $page['start'],
76    $user['nb_image_page'],
77    true
78    );
79}
80else
81{
82  $page['navigation_bar'] = '';
83}
84
85// caddie filling :-)
86if (isset($_GET['caddie']))
87{
88  fill_caddie($page['items']);
89  redirect(duplicate_index_url());
90}
91
92//----------------------------------------------------- template initialization
93//
94// Start output of page
95//
96$title = $page['title'];
97$page['body_id'] = 'theCategoryPage';
98
99$template->set_filenames( array('index'=>'index.tpl') );
100//-------------------------------------------------------------- category title
101$template_title = $page['title'];
102if ( count($page['items']) > 0)
103{
104  $template_title.= ' ['.count($page['items']).']';
105}
106
107if (isset($page['flat']) or isset($page['chronology_field']))
108{
109  $template->assign_block_vars(
110    'mode_normal',
111    array(
112      'URL' => duplicate_index_url( array(), array('chronology_field', 'start', 'flat') )
113      )
114    );
115}
116
117if (!isset($page['flat']) and 'categories' == $page['section'])
118{
119  $template->assign_block_vars(
120    'flat',
121    array(
122      'URL' => duplicate_index_url(array('flat' => ''), array('start', 'chronology_field'))
123      )
124    );
125}
126
127if (!isset($page['chronology_field']))
128{
129  $chronology_params =
130      array(
131          'chronology_field' => 'created',
132          'chronology_style' => 'monthly',
133          'chronology_view' => 'list',
134      );
135  $template->assign_block_vars(
136    'mode_created',
137    array(
138      'URL' => duplicate_index_url( $chronology_params, array('start', 'flat') )
139      )
140    );
141
142  $chronology_params['chronology_field'] = 'posted';
143  $template->assign_block_vars(
144    'mode_posted',
145    array(
146      'URL' => duplicate_index_url( $chronology_params, array('start', 'flat') )
147      )
148    );
149}
150else
151{
152  if ($page['chronology_field'] == 'created')
153  {
154    $chronology_field = 'posted';
155  }
156  else
157  {
158    $chronology_field = 'created';
159  }
160  $url = duplicate_index_url(
161            array('chronology_field'=>$chronology_field ),
162            array('chronology_date', 'start', 'flat')
163          );
164  $template->assign_block_vars(
165    'mode_'.$chronology_field,
166    array('URL' => $url )
167    );
168}
169// include menubar
170include(PHPWG_ROOT_PATH.'include/menubar.inc.php');
171
172$template->assign_vars(
173  array(
174    'TITLE' => $template_title
175    )
176  );
177
178if ('search' == $page['section'])
179{
180  $template->assign_block_vars(
181    'search_rules',
182    array(
183      'URL' => get_root_url().'search_rules.php?search_id='.$page['search'],
184      )
185    );
186}
187
188if (isset($page['category']) and is_admin())
189{
190  $template->assign_block_vars(
191    'edit',
192    array(
193      'URL' =>
194        get_root_url().'admin.php?page=cat_modify'
195        .'&amp;cat_id='.$page['category']['id']
196      )
197    );
198}
199
200if (is_admin() and !empty($page['items']) )
201{
202    $template->assign_block_vars(
203      'caddie',
204      array(
205        'URL' =>
206          add_url_params(duplicate_index_url(), array('caddie'=>1) )
207        )
208      );
209  }
210
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(
226            'tags' => array($tag)
227            )
228          ),
229        'NAME' => $tag['name'],
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']),
234        'CLASS' => 'tagLevel'.$tag['level']
235        )
236      );
237    }
238  }
239}
240
241//------------------------------------------------------ main part : thumbnails
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  )
247{
248  include(PHPWG_ROOT_PATH.'include/category_cats.inc.php');
249}
250if ( !empty($page['items']) )
251{
252  include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
253}
254//------------------------------------------------------- category informations
255
256// navigation bar
257if ($page['navigation_bar'] != '')
258{
259  $template->assign_block_vars(
260    'cat_infos.navigation',
261    array(
262      'NAV_BAR' => $page['navigation_bar'],
263      )
264    );
265}
266
267if ( count($page['items']) > 0
268    and $page['section'] != 'most_visited'
269    and $page['section'] != 'best_rated')
270{
271  // image order
272  $template->assign_block_vars( 'preferred_image_order', array() );
273
274  $order_idx = pwg_get_session_var( 'image_order', 0 );
275
276  $orders = get_category_preferred_image_orders();
277  for ($i = 0; $i < count($orders); $i++)
278  {
279    if ($orders[$i][2])
280    {
281      $template->assign_block_vars(
282        'preferred_image_order.order',
283        array(
284          'DISPLAY' => $orders[$i][0],
285          'URL' => add_url_params( duplicate_index_url(), array('image_order'=>$i) ),
286          'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''),
287          )
288        );
289    }
290  }
291}
292
293// category comment
294if (isset($page['comment']) and $page['comment'] != '')
295{
296  $template->assign_block_vars(
297    'cat_infos.comment',
298    array(
299      'COMMENTS' => $page['comment']
300      )
301    );
302  $header_infos['COMMENT'] = strip_tags($page['comment']);
303}
304//------------------------------------------------------------ log informations
305pwg_log();
306
307include(PHPWG_ROOT_PATH.'include/page_header.php');
308trigger_action('loc_end_index');
309$template->parse('index');
310include(PHPWG_ROOT_PATH.'include/page_tail.php');
311?>
Note: See TracBrowser for help on using the repository browser.