source: trunk/index.php @ 2287

Last change on this file since 2287 was 2231, checked in by rvelices, 17 years ago
  • index.tpl, menubar.tpl, mainpage_categories.tpl and month_calendar.tpl go smarty
  • better template debugging tweak (the smarty console is shown only once at the end)
  • 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// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
5// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | file          : $Id: index.php 2231 2008-03-01 13:12:07Z rvelices $
8// | last update   : $Date: 2008-03-01 13:12:07 +0000 (Sat, 01 Mar 2008) $
9// | last modifier : $Author: rvelices $
10// | revision      : $Revision: 2231 $
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$template->assign('TITLE', $template_title);
107
108if (isset($page['flat']) or isset($page['chronology_field']))
109{
110  $template->assign(
111    'U_MODE_NORMAL',
112    duplicate_index_url( array(), array('chronology_field', 'start', 'flat') )
113    );
114}
115
116if (!isset($page['flat']) and 'categories' == $page['section'])
117{
118  $template->assign(
119    'U_MODE_FLAT',
120    duplicate_index_url(array('flat' => ''), array('start', 'chronology_field'))
121    );
122}
123
124if (!isset($page['chronology_field']))
125{
126  $chronology_params =
127      array(
128          'chronology_field' => 'created',
129          'chronology_style' => 'monthly',
130          'chronology_view' => 'list',
131      );
132  $template->assign(
133    'U_MODE_CREATED',
134    duplicate_index_url( $chronology_params, array('start', 'flat') )
135    );
136
137  $chronology_params['chronology_field'] = 'posted';
138  $template->assign(
139    'U_MODE_POSTED',
140    duplicate_index_url( $chronology_params, array('start', 'flat') )
141    );
142}
143else
144{
145  if ($page['chronology_field'] == 'created')
146  {
147    $chronology_field = 'posted';
148  }
149  else
150  {
151    $chronology_field = 'created';
152  }
153  $url = duplicate_index_url(
154            array('chronology_field'=>$chronology_field ),
155            array('chronology_date', 'start', 'flat')
156          );
157  $template->assign(
158      'U_MODE_'.strtoupper($chronology_field),
159      $url
160    );
161}
162// include menubar
163include(PHPWG_ROOT_PATH.'include/menubar.inc.php');
164
165if ('search' == $page['section'])
166{
167  $template->assign(
168    'U_SEARCH_RULES',
169    get_root_url().'search_rules.php?search_id='.$page['search']
170    );
171}
172
173if (isset($page['category']) and is_admin())
174{
175  $template->assign(
176    'U_EDIT',
177     get_root_url().'admin.php?page=cat_modify'
178        .'&amp;cat_id='.$page['category']['id']
179    );
180}
181
182if (is_admin() and !empty($page['items']))
183{
184  $template->assign(
185    'U_CADDIE',
186     add_url_params(duplicate_index_url(), array('caddie'=>1) )
187    );
188}
189
190if ( $page['section']=='search' and $page['start']==0 and
191    !isset($page['chronology_field']) and isset($page['qsearch_details']) )
192{
193  $template->assign('QUERY_SEARCH',
194    htmlspecialchars($page['qsearch_details']['q']) );
195
196  $cats = array_merge(
197      (array)@$page['qsearch_details']['matching_cats_no_images'],
198      (array)@$page['qsearch_details']['matching_cats'] );
199  if (count($cats))
200  {
201    usort($cats, 'name_compare');
202    $hints = array();
203    foreach ( $cats as $cat )
204    {
205      $hints[] = get_cat_display_name( array($cat) );
206    }
207    $template->assign( 'category_search_results', $hints);
208  }
209
210  $tags = (array)@$page['qsearch_details']['matching_tags'];
211  if (count($tags))
212  {
213    usort($tags, 'name_compare');
214    $hints = array();
215    foreach ( $tags as $tag )
216    {
217      $hints[] =
218        '<a href="' . make_index_url(array('tags'=>array($tag))) . '">'
219        .$tag['name']
220        .'</a>';
221    }
222    $template->assign( 'tag_search_results', $hints);
223  }
224}
225
226//------------------------------------------------------ main part : thumbnails
227if ( 0==$page['start']
228    and !isset($page['flat'])
229    and !isset($page['chronology_field'])
230    and ('recent_cats'==$page['section'] or 'categories'==$page['section'])
231  )
232{
233  include(PHPWG_ROOT_PATH.'include/category_cats.inc.php');
234}
235if ( !empty($page['items']) )
236{
237  include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
238}
239//------------------------------------------------------- category informations
240
241// slideshow
242// execute after init thumbs in order to have all picture informations
243if (!empty($page['cat_slideshow_url']))
244{
245  if (isset($_GET['slideshow']))
246  {
247    redirect($page['cat_slideshow_url']);
248  }
249  else
250  {
251    $template->assign('U_SLIDESHOW', $page['cat_slideshow_url']);
252  }
253}
254
255// navigation bar
256$template->assign( 'NAV_BAR', $page['navigation_bar'] );
257
258if ( count($page['items']) > 0
259    and $page['section'] != 'most_visited'
260    and $page['section'] != 'best_rated')
261{
262  // image order
263  $order_idx = pwg_get_session_var( 'image_order', 0 );
264
265  $orders = get_category_preferred_image_orders();
266  for ($i = 0; $i < count($orders); $i++)
267  {
268    if ($orders[$i][2])
269    {
270      $template->append(
271        'image_orders',
272        array(
273          'DISPLAY' => $orders[$i][0],
274          'URL' => add_url_params( duplicate_index_url(), array('image_order'=>$i) ),
275          'SELECTED' => ($order_idx==$i ? true:false),
276          )
277        );
278    }
279  }
280}
281
282// category comment
283if (isset($page['comment']) and $page['comment'] != '')
284{
285  $template->assign('CONTENT_DESCRIPTION', $page['comment'] );
286}
287//------------------------------------------------------------ log informations
288pwg_log();
289
290include(PHPWG_ROOT_PATH.'include/page_header.php');
291trigger_action('loc_end_index');
292$template->pparse('index');
293include(PHPWG_ROOT_PATH.'include/page_tail.php');
294?>
Note: See TracBrowser for help on using the repository browser.