source: branches/1.7/index.php @ 29868

Last change on this file since 29868 was 2354, checked in by patdenice, 16 years ago

Merge from trunk revision 2353.
000819: "First" link was mapped with home navigation button
Add trigger_event for menubar.php file in index.php
Minor language correction.

  • 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 2354 2008-05-20 00:58:32Z patdenice $
8// | last update   : $Date: 2008-05-20 00:58:32 +0000 (Tue, 20 May 2008) $
9// | last modifier : $Author: patdenice $
10// | revision      : $Revision: 2354 $
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(trigger_event('menubar_file',
171  PHPWG_ROOT_PATH.'include/menubar.inc.php'));
172
173$template->assign_vars(
174  array(
175    'TITLE' => $template_title
176    )
177  );
178
179if ('search' == $page['section'])
180{
181  $template->assign_block_vars(
182    'search_rules',
183    array(
184      'URL' => get_root_url().'search_rules.php?search_id='.$page['search'],
185      )
186    );
187}
188
189if (isset($page['category']) and is_admin())
190{
191  $template->assign_block_vars(
192    'edit',
193    array(
194      'URL' =>
195        get_root_url().'admin.php?page=cat_modify'
196        .'&amp;cat_id='.$page['category']['id']
197      )
198    );
199}
200
201if (is_admin() and !empty($page['items']) )
202{
203    $template->assign_block_vars(
204      'caddie',
205      array(
206        'URL' =>
207          add_url_params(duplicate_index_url(), array('caddie'=>1) )
208        )
209      );
210  }
211
212if ( $page['section']=='search' and $page['start']==0 )
213{
214  $tags = get_common_tags($page['items'],
215      $conf['content_tag_cloud_items_number'], null);
216  if ( count($tags)>1 )
217  {
218    $template->assign_block_vars('related_tags', array() );
219
220    $tags = add_level_to_tags($tags);
221    foreach ($tags as $tag)
222    {
223      $template->assign_block_vars(
224      'related_tags.tag', array(
225        'URL' => make_index_url(
226          array(
227            'tags' => array($tag)
228            )
229          ),
230        'NAME' => $tag['name'],
231        'TITLE' => l10n_dec(
232            '%d picture are also linked to current tags',
233            '%d pictures are also linked to current tags',
234            $tag['counter']),
235        'CLASS' => 'tagLevel'.$tag['level']
236        )
237      );
238    }
239  }
240}
241
242//------------------------------------------------------ main part : thumbnails
243if ( 0==$page['start']
244    and !isset($page['flat'])
245    and !isset($page['chronology_field'])
246    and ('recent_cats'==$page['section'] or 'categories'==$page['section'])
247  )
248{
249  include(PHPWG_ROOT_PATH.'include/category_cats.inc.php');
250}
251if ( !empty($page['items']) )
252{
253  include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
254}
255//------------------------------------------------------- category informations
256
257// navigation bar
258if ($page['navigation_bar'] != '')
259{
260  $template->assign_block_vars(
261    'cat_infos.navigation',
262    array(
263      'NAV_BAR' => $page['navigation_bar'],
264      )
265    );
266}
267
268if ( count($page['items']) > 0
269    and $page['section'] != 'most_visited'
270    and $page['section'] != 'best_rated')
271{
272  // image order
273  $template->assign_block_vars( 'preferred_image_order', array() );
274
275  $order_idx = pwg_get_session_var( 'image_order', 0 );
276
277  $orders = get_category_preferred_image_orders();
278  for ($i = 0; $i < count($orders); $i++)
279  {
280    if ($orders[$i][2])
281    {
282      $template->assign_block_vars(
283        'preferred_image_order.order',
284        array(
285          'DISPLAY' => $orders[$i][0],
286          'URL' => add_url_params( duplicate_index_url(), array('image_order'=>$i) ),
287          'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''),
288          )
289        );
290    }
291  }
292}
293
294// category comment
295if (isset($page['comment']) and $page['comment'] != '')
296{
297  $template->assign_block_vars(
298    'cat_infos.comment',
299    array(
300      'COMMENTS' => $page['comment']
301      )
302    );
303  $header_infos['COMMENT'] = strip_tags($page['comment']);
304}
305//------------------------------------------------------------ log informations
306pwg_log();
307
308include(PHPWG_ROOT_PATH.'include/page_header.php');
309trigger_action('loc_end_index');
310$template->parse('index');
311include(PHPWG_ROOT_PATH.'include/page_tail.php');
312?>
Note: See TracBrowser for help on using the repository browser.