source: trunk/index.php @ 1655

Last change on this file since 1655 was 1655, checked in by rvelices, 17 years ago
  • plugins admin menu appear now in the admin page menubar
  • plugins are loaded immediately after loading the config (allow

them to hack more of pwg like user init, template init etc...)

  • trigger event format_exif_data (for picture display only)
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.8 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-2006 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $RCSfile$
9// | last update   : $Date: 2006-12-14 00:58:57 +0000 (Thu, 14 Dec 2006) $
10// | last modifier : $Author: rvelices $
11// | revision      : $Revision: 1655 $
12// +-----------------------------------------------------------------------+
13// | This program is free software; you can redistribute it and/or modify  |
14// | it under the terms of the GNU General Public License as published by  |
15// | the Free Software Foundation                                          |
16// |                                                                       |
17// | This program is distributed in the hope that it will be useful, but   |
18// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
19// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
20// | General Public License for more details.                              |
21// |                                                                       |
22// | You should have received a copy of the GNU General Public License     |
23// | along with this program; if not, write to the Free Software           |
24// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
25// | USA.                                                                  |
26// +-----------------------------------------------------------------------+
27
28//--------------------------------------------------------------------- include
29define('PHPWG_ROOT_PATH','./');
30include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
31include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
32
33trigger_action('loc_begin_index');
34
35// +-----------------------------------------------------------------------+
36// | Check Access and exit when user status is not ok                      |
37// +-----------------------------------------------------------------------+
38check_status(ACCESS_GUEST);
39
40//---------------------------------------------- change of image display order
41if (isset($_GET['image_order']))
42{
43  if ( (int)$_GET['image_order'] > 0)
44  {
45    pwg_set_session_var('image_order', (int)$_GET['image_order']);
46  }
47  else
48  {
49    pwg_unset_session_var('image_order');
50  }
51  redirect(
52    duplicate_index_url(
53      array(),        // nothing to redefine
54      array('start')  // changing display order goes back to section first page
55      )
56    );
57}
58//-------------------------------------------------------------- initialization
59// detection of the start picture to display
60if (!isset($page['start']))
61{
62  $page['start'] = 0;
63}
64
65// access authorization check
66if (isset($page['category']))
67{
68  check_restrictions($page['category']);
69}
70
71if (isset($page['cat_nb_images'])
72    and $page['cat_nb_images'] > $user['nb_image_page'])
73{
74  $page['navigation_bar'] = create_navigation_bar(
75    duplicate_index_url(array(), array('start')),
76    $page['cat_nb_images'],
77    $page['start'],
78    $user['nb_image_page'],
79    true
80    );
81}
82else
83{
84  $page['navigation_bar'] = '';
85}
86
87// caddie filling :-)
88if (isset($_GET['caddie']))
89{
90  fill_caddie($page['items']);
91  // redirect();
92}
93
94//----------------------------------------------------- template initialization
95//
96// Start output of page
97//
98$title = $page['title'];
99$page['body_id'] = 'theCategoryPage';
100
101$template->set_filenames( array('index'=>'index.tpl') );
102//-------------------------------------------------------------- category title
103$template_title = $page['title'];
104if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0)
105{
106  $template_title.= ' ['.$page['cat_nb_images'].']';
107}
108
109if (isset($_GET['filter_local_mode']))
110{
111  $page['filter_local_mode'] = ($_GET['filter_local_mode'] == 'start');
112}
113else
114{
115  $page['filter_local_mode'] = pwg_get_session_var('filter_local_mode', false);
116}
117
118$page['filter_local_mode'] = (($page['filter_local_mode']) and
119                              ($page['section'] == 'categories') and
120                              (!isset($page['chronology_field'])));
121pwg_set_session_var('filter_local_mode', $page['filter_local_mode']);
122
123if ($page['filter_local_mode'])
124{
125  $template->assign_block_vars(
126    'stop_filter_local_mode',
127    array(
128      'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_local_mode' => 'stop'))
129      )
130    );
131}
132else
133{
134  $template->assign_block_vars(
135    'start_filter_local_mode',
136    array(
137      'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_local_mode' => 'start'))
138      )
139    );
140}
141
142if (isset($_GET['filter_global_mode']))
143{
144  $user['filter_global_mode'] = ($_GET['filter_global_mode'] == 'start');
145  pwg_set_session_var('filter_global_mode', $user['filter_global_mode']);
146}
147else
148{
149  $user['filter_global_mode'] = pwg_get_session_var('filter_global_mode', false);
150}
151
152if ($user['filter_global_mode'])
153{
154  $template->assign_block_vars(
155    'stop_filter_global_mode',
156    array(
157      'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_global_mode' => 'stop'))
158      )
159    );
160}
161else
162{
163  $template->assign_block_vars(
164    'start_filter_global_mode',
165    array(
166      'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_global_mode' => 'start'))
167      )
168    );
169}
170
171if (!isset($page['chronology_field']))
172{
173  $chronology_params =
174      array(
175          'chronology_field' => 'created',
176          'chronology_style' => 'monthly',
177          'chronology_view' => 'list',
178      );
179  $template->assign_block_vars(
180    'mode_created',
181    array(
182      'URL' => duplicate_index_url( $chronology_params, array('start') )
183      )
184    );
185
186  $chronology_params['chronology_field'] = 'posted';
187  $template->assign_block_vars(
188    'mode_posted',
189    array(
190      'URL' => duplicate_index_url( $chronology_params, array('start') )
191      )
192    );
193}
194else
195{
196  $template->assign_block_vars(
197    'mode_normal',
198    array(
199      'URL' => duplicate_index_url( array(), array('chronology_field','start') )
200      )
201    );
202
203  if ($page['chronology_field'] == 'created')
204  {
205    $chronology_field = 'posted';
206  }
207  else
208  {
209    $chronology_field = 'created';
210  }
211  $url = duplicate_index_url(
212            array('chronology_field'=>$chronology_field ),
213            array('chronology_date', 'start')
214          );
215  $template->assign_block_vars(
216    'mode_'.$chronology_field,
217    array('URL' => $url )
218    );
219}
220// include menubar
221include(PHPWG_ROOT_PATH.'include/menubar.inc.php');
222
223$template->assign_vars(
224  array(
225    'TITLE' => $template_title
226    )
227  );
228
229if ('search' == $page['section'])
230{
231  $template->assign_block_vars(
232    'search_rules',
233    array(
234      'URL' => get_root_url().'search_rules.php?search_id='.$page['search'],
235      )
236    );
237}
238
239if (isset($page['category']) and is_admin())
240{
241  $template->assign_block_vars(
242    'edit',
243    array(
244      'URL' =>
245        get_root_url().'admin.php?page=cat_modify'
246        .'&amp;cat_id='.$page['category']
247      )
248    );
249}
250
251if (is_admin() and !empty($page['items']) )
252{
253    $template->assign_block_vars(
254      'caddie',
255      array(
256        'URL' =>
257          add_url_params(duplicate_index_url(), array('caddie'=>1) )
258        )
259      );
260  }
261
262if ( $page['section']=='search' and $page['start']==0 )
263{
264  $tags = get_common_tags($page['items'],
265      $conf['content_tag_cloud_items_number'], null);
266  if ( count($tags)>1 )
267  {
268    $template->assign_block_vars('related_tags', array() );
269
270    $tags = add_level_to_tags($tags);
271    foreach ($tags as $tag)
272    {
273      $template->assign_block_vars(
274      'related_tags.tag', array(
275        'URL' => make_index_url(
276          array(
277            'tags' => array(
278              array(
279                'id' => $tag['tag_id'],
280                'url_name' => $tag['url_name'],
281                ),
282              )
283            )
284          ),
285        'NAME' => $tag['name'],
286        'TITLE' => sprintf(
287          l10n('%d pictures are also linked to current tags'),
288          $tag['counter']
289          ),
290        'CLASS' => 'tagLevel'.$tag['level']
291        )
292      );
293    }
294  }
295}
296
297//------------------------------------------------------ main part : thumbnails
298if (isset($page['thumbnails_include']))
299{
300  include(PHPWG_ROOT_PATH.$page['thumbnails_include']);
301}
302//------------------------------------------------------- category informations
303
304// navigation bar
305if ($page['navigation_bar'] != '')
306{
307  $template->assign_block_vars(
308    'cat_infos.navigation',
309    array(
310      'NAV_BAR' => $page['navigation_bar'],
311      )
312    );
313}
314
315if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0
316    and $page['section'] != 'most_visited'
317    and $page['section'] != 'best_rated')
318{
319  // image order
320  $template->assign_block_vars( 'preferred_image_order', array() );
321
322  $order_idx = pwg_get_session_var( 'image_order', 0 );
323
324  $orders = get_category_preferred_image_orders();
325  for ($i = 0; $i < count($orders); $i++)
326  {
327    if ($orders[$i][2])
328    {
329      $template->assign_block_vars(
330        'preferred_image_order.order',
331        array(
332          'DISPLAY' => $orders[$i][0],
333          'URL' => add_url_params( duplicate_index_url(), array('image_order'=>$i) ),
334          'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''),
335          )
336        );
337    }
338  }
339}
340
341// category comment
342if (isset($page['comment']) and $page['comment'] != '')
343{
344  $template->assign_block_vars(
345    'cat_infos.comment',
346    array(
347      'COMMENTS' => $page['comment']
348      )
349    );
350  $header_infos['COMMENT'] = strip_tags($page['comment']);
351}
352//------------------------------------------------------------ log informations
353pwg_log('category', $page['title']);
354
355include(PHPWG_ROOT_PATH.'include/page_header.php');
356trigger_action('loc_end_index');
357$template->parse('index');
358include(PHPWG_ROOT_PATH.'include/page_tail.php');
359?>
Note: See TracBrowser for help on using the repository browser.