source: trunk/index.php @ 4000

Last change on this file since 4000 was 3282, checked in by plg, 16 years ago

change: according to topic:15067, svn:keywords property was removed

  • Property svn:eol-style set to LF
File size: 8.4 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2009 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
67$page['navigation_bar'] = array();
68if (count($page['items']) > $user['nb_image_page'])
69{
70  $page['navigation_bar'] = create_navigation_bar(
71    duplicate_index_url(array(), array('start')),
72    count($page['items']),
73    $page['start'],
74    $page['nb_image_page'],
75    true
76    );
77}
78
79// caddie filling :-)
80if (isset($_GET['caddie']))
81{
82  fill_caddie($page['items']);
83  redirect(duplicate_index_url());
84}
85
86//----------------------------------------------------- template initialization
87//
88// Start output of page
89//
90$title = $page['title'];
91$page['body_id'] = 'theCategoryPage';
92
93$template->set_filenames( array('index'=>'index.tpl') );
94//-------------------------------------------------------------- category title
95$template_title = $page['title'];
96if (count($page['items']) > 0)
97{
98  $template_title.= ' ['.count($page['items']).']';
99}
100$template->assign('TITLE', $template_title);
101
102if (isset($page['flat']) or isset($page['chronology_field']))
103{
104  $template->assign(
105    'U_MODE_NORMAL',
106    duplicate_index_url( array(), array('chronology_field', 'start', 'flat') )
107    );
108}
109
110if (!isset($page['flat']) and 'categories' == $page['section'])
111{
112  $template->assign(
113    'U_MODE_FLAT',
114    duplicate_index_url(array('flat' => ''), array('start', 'chronology_field'))
115    );
116}
117
118if (!isset($page['chronology_field']))
119{
120  $chronology_params =
121      array(
122          'chronology_field' => 'created',
123          'chronology_style' => 'monthly',
124          'chronology_view' => 'list',
125      );
126  $template->assign(
127    'U_MODE_CREATED',
128    duplicate_index_url( $chronology_params, array('start', 'flat') )
129    );
130
131  $chronology_params['chronology_field'] = 'posted';
132  $template->assign(
133    'U_MODE_POSTED',
134    duplicate_index_url( $chronology_params, array('start', 'flat') )
135    );
136}
137else
138{
139  if ($page['chronology_field'] == 'created')
140  {
141    $chronology_field = 'posted';
142  }
143  else
144  {
145    $chronology_field = 'created';
146  }
147  $url = duplicate_index_url(
148            array('chronology_field'=>$chronology_field ),
149            array('chronology_date', 'start', 'flat')
150          );
151  $template->assign(
152      'U_MODE_'.strtoupper($chronology_field),
153      $url
154    );
155}
156
157if ('search' == $page['section'])
158{
159  $template->assign(
160    'U_SEARCH_RULES',
161    get_root_url().'search_rules.php?search_id='.$page['search']
162    );
163}
164
165if (isset($page['category']) and is_admin())
166{
167  $template->assign(
168    'U_EDIT',
169     get_root_url().'admin.php?page=cat_modify'
170        .'&amp;cat_id='.$page['category']['id']
171    );
172}
173
174if (is_admin() and !empty($page['items']))
175{
176  $template->assign(
177    'U_CADDIE',
178     add_url_params(duplicate_index_url(), array('caddie'=>1) )
179    );
180}
181
182if ( $page['section']=='search' and $page['start']==0 and
183    !isset($page['chronology_field']) and isset($page['qsearch_details']) )
184{
185  $template->assign('QUERY_SEARCH',
186    htmlspecialchars($page['qsearch_details']['q']) );
187
188  $cats = array_merge(
189      (array)@$page['qsearch_details']['matching_cats_no_images'],
190      (array)@$page['qsearch_details']['matching_cats'] );
191  if (count($cats))
192  {
193    usort($cats, 'name_compare');
194    $hints = array();
195    foreach ( $cats as $cat )
196    {
197      $hints[] = get_cat_display_name( array($cat), '', false );
198    }
199    $template->assign( 'category_search_results', $hints);
200  }
201
202  $tags = (array)@$page['qsearch_details']['matching_tags'];
203  if (count($tags))
204  {
205    usort($tags, 'name_compare');
206    $hints = array();
207    foreach ( $tags as $tag )
208    {
209      $hints[] =
210        '<a href="' . make_index_url(array('tags'=>array($tag))) . '">'
211        .$tag['name']
212        .'</a>';
213    }
214    $template->assign( 'tag_search_results', $hints);
215  }
216}
217
218// navigation bar
219$template->assign( 'navbar', $page['navigation_bar'] );
220
221if ( count($page['items']) > 0
222    and $page['section'] != 'most_visited'
223    and $page['section'] != 'best_rated')
224{
225  // image order
226  $order_idx = pwg_get_session_var( 'image_order', 0 );
227
228  $url = add_url_params(
229          duplicate_index_url(),
230          array('image_order' => '')
231        );
232  foreach (get_category_preferred_image_orders() as $order_id => $order)
233  {
234    if ($order[2])
235    {
236      $template->append(
237        'image_orders',
238        array(
239          'DISPLAY' => $order[0],
240          'URL' => $url.$order_id,
241          'SELECTED' => ($order_idx == $order_id ? true:false),
242          )
243        );
244    }
245  }
246}
247
248// category comment
249if (isset($page['comment']) and $page['comment'] != '')
250{
251  $template->assign('CONTENT_DESCRIPTION', $page['comment'] );
252}
253
254// include menubar
255include( PHPWG_ROOT_PATH.'include/menubar.inc.php');
256
257//------------------------------------------------------ main part : thumbnails
258if ( 0==$page['start']
259    and !isset($page['flat'])
260    and !isset($page['chronology_field'])
261    and ('recent_cats'==$page['section'] or 'categories'==$page['section'])
262    and (!isset($page['category']['count_categories']) or $page['category']['count_categories']>0 )
263  )
264{
265  include(PHPWG_ROOT_PATH.'include/category_cats.inc.php');
266}
267if ( !empty($page['items']) )
268{
269  include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
270}
271//------------------------------------------------------- category informations
272
273// slideshow
274// execute after init thumbs in order to have all picture informations
275if (!empty($page['cat_slideshow_url']))
276{
277  if (isset($_GET['slideshow']))
278  {
279    redirect($page['cat_slideshow_url']);
280  }
281  else
282  {
283    $template->assign('U_SLIDESHOW', $page['cat_slideshow_url']);
284  }
285}
286
287include(PHPWG_ROOT_PATH.'include/page_header.php');
288trigger_action('loc_end_index');
289$template->pparse('index');
290//------------------------------------------------------------ log informations
291pwg_log();
292include(PHPWG_ROOT_PATH.'include/page_tail.php');
293?>
Note: See TracBrowser for help on using the repository browser.