source: trunk/index.php @ 2497

Last change on this file since 2497 was 2488, checked in by rvelices, 16 years ago
  • based on test_menu by grum (thanks to you) - integration of dynamic menu bar to pwg
  • the menubar is composed now of dynamic blocks that can be ordered/hidden
  • plugins can add their own blocks
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 8.3 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008      Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
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  |
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.                                                                  |
22// +-----------------------------------------------------------------------+
23
24//--------------------------------------------------------------------- include
25define('PHPWG_ROOT_PATH','./');
26include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
27include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
28
29trigger_action('loc_begin_index');
30
31// +-----------------------------------------------------------------------+
32// | Check Access and exit when user status is not ok                      |
33// +-----------------------------------------------------------------------+
34check_status(ACCESS_GUEST);
35
36//---------------------------------------------- change of image display order
37if (isset($_GET['image_order']))
38{
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  }
47  redirect(
48    duplicate_index_url(
49      array(),        // nothing to redefine
50      array('start')  // changing display order goes back to section first page
51      )
52    );
53}
54//-------------------------------------------------------------- initialization
55// detection of the start picture to display
56if (!isset($page['start']))
57{
58  $page['start'] = 0;
59}
60
61// access authorization check
62if (isset($page['category']))
63{
64  check_restrictions($page['category']['id']);
65}
66
67if (count($page['items']) > $user['nb_image_page'])
68{
69  $page['navigation_bar'] = create_navigation_bar(
70    duplicate_index_url(array(), array('start')),
71    count($page['items']),
72    $page['start'],
73    $user['nb_image_page'],
74    true
75    );
76}
77else
78{
79  $page['navigation_bar'] = '';
80}
81
82// caddie filling :-)
83if (isset($_GET['caddie']))
84{
85  fill_caddie($page['items']);
86  redirect(duplicate_index_url());
87}
88
89//----------------------------------------------------- template initialization
90//
91// Start output of page
92//
93$title = $page['title'];
94$page['body_id'] = 'theCategoryPage';
95
96$template->set_filenames( array('index'=>'index.tpl') );
97//-------------------------------------------------------------- category title
98$template_title = $page['title'];
99if (count($page['items']) > 0)
100{
101  $template_title.= ' ['.count($page['items']).']';
102}
103$template->assign('TITLE', $template_title);
104
105if (isset($page['flat']) or isset($page['chronology_field']))
106{
107  $template->assign(
108    'U_MODE_NORMAL',
109    duplicate_index_url( array(), array('chronology_field', 'start', 'flat') )
110    );
111}
112
113if (!isset($page['flat']) and 'categories' == $page['section'])
114{
115  $template->assign(
116    'U_MODE_FLAT',
117    duplicate_index_url(array('flat' => ''), array('start', 'chronology_field'))
118    );
119}
120
121if (!isset($page['chronology_field']))
122{
123  $chronology_params =
124      array(
125          'chronology_field' => 'created',
126          'chronology_style' => 'monthly',
127          'chronology_view' => 'list',
128      );
129  $template->assign(
130    'U_MODE_CREATED',
131    duplicate_index_url( $chronology_params, array('start', 'flat') )
132    );
133
134  $chronology_params['chronology_field'] = 'posted';
135  $template->assign(
136    'U_MODE_POSTED',
137    duplicate_index_url( $chronology_params, array('start', 'flat') )
138    );
139}
140else
141{
142  if ($page['chronology_field'] == 'created')
143  {
144    $chronology_field = 'posted';
145  }
146  else
147  {
148    $chronology_field = 'created';
149  }
150  $url = duplicate_index_url(
151            array('chronology_field'=>$chronology_field ),
152            array('chronology_date', 'start', 'flat')
153          );
154  $template->assign(
155      'U_MODE_'.strtoupper($chronology_field),
156      $url
157    );
158}
159// include menubar
160include( PHPWG_ROOT_PATH.'include/menubar.inc.php');
161
162if ('search' == $page['section'])
163{
164  $template->assign(
165    'U_SEARCH_RULES',
166    get_root_url().'search_rules.php?search_id='.$page['search']
167    );
168}
169
170if (isset($page['category']) and is_admin())
171{
172  $template->assign(
173    'U_EDIT',
174     get_root_url().'admin.php?page=cat_modify'
175        .'&amp;cat_id='.$page['category']['id']
176    );
177}
178
179if (is_admin() and !empty($page['items']))
180{
181  $template->assign(
182    'U_CADDIE',
183     add_url_params(duplicate_index_url(), array('caddie'=>1) )
184    );
185}
186
187if ( $page['section']=='search' and $page['start']==0 and
188    !isset($page['chronology_field']) and isset($page['qsearch_details']) )
189{
190  $template->assign('QUERY_SEARCH',
191    htmlspecialchars($page['qsearch_details']['q']) );
192
193  $cats = array_merge(
194      (array)@$page['qsearch_details']['matching_cats_no_images'],
195      (array)@$page['qsearch_details']['matching_cats'] );
196  if (count($cats))
197  {
198    usort($cats, 'name_compare');
199    $hints = array();
200    foreach ( $cats as $cat )
201    {
202      $hints[] = get_cat_display_name( array($cat) );
203    }
204    $template->assign( 'category_search_results', $hints);
205  }
206
207  $tags = (array)@$page['qsearch_details']['matching_tags'];
208  if (count($tags))
209  {
210    usort($tags, 'name_compare');
211    $hints = array();
212    foreach ( $tags as $tag )
213    {
214      $hints[] =
215        '<a href="' . make_index_url(array('tags'=>array($tag))) . '">'
216        .$tag['name']
217        .'</a>';
218    }
219    $template->assign( 'tag_search_results', $hints);
220  }
221}
222
223//------------------------------------------------------ main part : thumbnails
224if ( 0==$page['start']
225    and !isset($page['flat'])
226    and !isset($page['chronology_field'])
227    and ('recent_cats'==$page['section'] or 'categories'==$page['section'])
228  )
229{
230  include(PHPWG_ROOT_PATH.'include/category_cats.inc.php');
231}
232if ( !empty($page['items']) )
233{
234  include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
235}
236//------------------------------------------------------- category informations
237
238// slideshow
239// execute after init thumbs in order to have all picture informations
240if (!empty($page['cat_slideshow_url']))
241{
242  if (isset($_GET['slideshow']))
243  {
244    redirect($page['cat_slideshow_url']);
245  }
246  else
247  {
248    $template->assign('U_SLIDESHOW', $page['cat_slideshow_url']);
249  }
250}
251
252// navigation bar
253$template->assign( 'NAV_BAR', $page['navigation_bar'] );
254
255if ( count($page['items']) > 0
256    and $page['section'] != 'most_visited'
257    and $page['section'] != 'best_rated')
258{
259  // image order
260  $order_idx = pwg_get_session_var( 'image_order', 0 );
261
262  $orders = get_category_preferred_image_orders();
263  for ($i = 0; $i < count($orders); $i++)
264  {
265    if ($orders[$i][2])
266    {
267      $template->append(
268        'image_orders',
269        array(
270          'DISPLAY' => $orders[$i][0],
271          'URL' => add_url_params( duplicate_index_url(), array('image_order'=>$i) ),
272          'SELECTED' => ($order_idx==$i ? true:false),
273          )
274        );
275    }
276  }
277}
278
279// category comment
280if (isset($page['comment']) and $page['comment'] != '')
281{
282  $template->assign('CONTENT_DESCRIPTION', $page['comment'] );
283}
284//------------------------------------------------------------ log informations
285pwg_log();
286
287include(PHPWG_ROOT_PATH.'include/page_header.php');
288trigger_action('loc_end_index');
289$template->pparse('index');
290include(PHPWG_ROOT_PATH.'include/page_tail.php');
291?>
Note: See TracBrowser for help on using the repository browser.