source: branches/branch-1_6-hk/index.php @ 3071

Last change on this file since 3071 was 1629, checked in by chrisaga, 18 years ago

merge from trunk r1626:1627 : meta and links in the header

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.6 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-02 18:28:12 +0000 (Sat, 02 Dec 2006) $
10// | last modifier : $Author: chrisaga $
11// | revision      : $Revision: 1629 $
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
33// +-----------------------------------------------------------------------+
34// | Check Access and exit when user status is not ok                      |
35// +-----------------------------------------------------------------------+
36check_status(ACCESS_GUEST);
37
38//---------------------------------------------- change of image display order
39if (isset($_GET['image_order']))
40{
41  setcookie(
42    'pwg_image_order',
43    $_GET['image_order'] > 0 ? $_GET['image_order'] : '',
44    0, cookie_path()
45    );
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']);
65}
66
67if (isset($page['cat_nb_images'])
68    and $page['cat_nb_images'] > $user['nb_image_page'])
69{
70  $page['navigation_bar'] = create_navigation_bar(
71    duplicate_index_url(array(), array('start')),
72    $page['cat_nb_images'],
73    $page['start'],
74    $user['nb_image_page'],
75    true
76    );
77}
78else
79{
80  $page['navigation_bar'] = '';
81}
82
83// caddie filling :-)
84if (isset($_GET['caddie']))
85{
86  fill_caddie($page['items']);
87  // redirect();
88}
89
90//----------------------------------------------------- template initialization
91//
92// Start output of page
93//
94$title = $page['title'];
95$page['body_id'] = 'theCategoryPage';
96
97$template->set_filenames( array('index'=>'index.tpl') );
98//-------------------------------------------------------------- category title
99$template_title = $page['title'];
100if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0)
101{
102  $template_title.= ' ['.$page['cat_nb_images'].']';
103}
104
105$icon_recent = get_icon(date('Y-m-d'));
106
107if (!isset($page['chronology_field']))
108{
109  $chronology_params =
110      array(
111          'chronology_field' => 'created',
112          'chronology_style' => 'monthly',
113          'chronology_view' => 'list',
114      );
115  $template->assign_block_vars(
116    'mode_created',
117    array(
118      'URL' => duplicate_index_url( $chronology_params, array('start') )
119      )
120    );
121
122  $chronology_params['chronology_field'] = 'posted';
123  $template->assign_block_vars(
124    'mode_posted',
125    array(
126      'URL' => duplicate_index_url( $chronology_params, array('start') )
127      )
128    );
129}
130else
131{
132  $template->assign_block_vars(
133    'mode_normal',
134    array(
135      'URL' => duplicate_index_url( array(), array('chronology_field','start') )
136      )
137    );
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')
150          );
151  $template->assign_block_vars(
152    'mode_'.$chronology_field,
153    array('URL' => $url )
154    );
155}
156// include menubar
157include(PHPWG_ROOT_PATH.'include/menubar.inc.php');
158
159$template->assign_vars(
160  array(
161    'TITLE' => $template_title,
162    'TOP_NUMBER' => $conf['top_number'],        // still used ?
163    'T_RECENT' => $icon_recent,                 // still used ?
164    )
165  );
166
167if ('search' == $page['section'])
168{
169  $template->assign_block_vars(
170    'search_rules',
171    array(
172      'URL' => get_root_url().'search_rules.php?search_id='.$page['search'],
173      )
174    );
175}
176
177if (isset($page['category']) and is_admin())
178{
179  $template->assign_block_vars(
180    'edit',
181    array(
182      'URL' =>
183        get_root_url().'admin.php?page=cat_modify'
184        .'&amp;cat_id='.$page['category']
185      )
186    );
187}
188
189if (is_admin() and !empty($page['items']) )
190{
191    $template->assign_block_vars(
192      'caddie',
193      array(
194        'URL' =>
195          add_url_params(duplicate_index_url(), array('caddie'=>1) )
196        )
197      );
198  }
199
200//------------------------------------------------------ main part : thumbnails
201if (isset($page['thumbnails_include']))
202{
203  include(PHPWG_ROOT_PATH.$page['thumbnails_include']);
204}
205//------------------------------------------------------- category informations
206if (
207  $page['navigation_bar'] != ''
208  or (isset($page['comment']) and $page['comment'] != '')
209  )
210{
211  $template->assign_block_vars('cat_infos',array());
212}
213// navigation bar
214if ($page['navigation_bar'] != '')
215{
216  $template->assign_block_vars(
217    'cat_infos.navigation',
218    array(
219      'NAV_BAR' => $page['navigation_bar'],
220      )
221    );
222}
223
224if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0
225    and $page['section'] != 'most_visited'
226    and $page['section'] != 'best_rated')
227{
228  // image order
229  $template->assign_block_vars( 'preferred_image_order', array() );
230
231  $order_idx = isset($_COOKIE['pwg_image_order'])
232    ? $_COOKIE['pwg_image_order']
233    : 0
234    ;
235
236  $orders = get_category_preferred_image_orders();
237  for ($i = 0; $i < count($orders); $i++)
238  {
239    if ($orders[$i][2])
240    {
241      $template->assign_block_vars(
242        'preferred_image_order.order',
243        array(
244          'DISPLAY' => $orders[$i][0],
245          'URL' => add_url_params( duplicate_index_url(), array('image_order'=>$i) ),
246          'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''),
247          )
248        );
249    }
250  }
251}
252
253if (isset($page['category']))
254{
255  // category comment
256  if (isset($page['comment']) and $page['comment'] != '')
257  {
258    $template->assign_block_vars(
259      'cat_infos.comment',
260      array(
261        'COMMENTS' => $page['comment']
262        )
263      );
264  }
265  $header_infos['COMMENT'] = strip_tags($page['comment']);
266}
267//------------------------------------------------------------ log informations
268pwg_log('category', $page['title']);
269
270include(PHPWG_ROOT_PATH.'include/page_header.php');
271$template->parse('index');
272include(PHPWG_ROOT_PATH.'include/page_tail.php');
273?>
Note: See TracBrowser for help on using the repository browser.