source: trunk/index.php @ 1884

Last change on this file since 1884 was 1861, checked in by rvelices, 18 years ago
  • refactoring pagecategory before 1.7 release

pagecategory is not an id anymore, but an associative array of category info
all of pagecat_xxx or pageuppercats merged into one
simplifies calls to make_index_url
give plugins a clean start for page variables for version 1.7

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.5 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-2007 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $Id: index.php 1861 2007-02-27 01:56:16Z rvelices $
9// | last update   : $Date: 2007-02-27 01:56:16 +0000 (Tue, 27 Feb 2007) $
10// | last modifier : $Author: rvelices $
11// | revision      : $Revision: 1861 $
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']['id']);
69}
70
71if ( count($page['items']) > $user['nb_image_page'])
72{
73  $page['navigation_bar'] = create_navigation_bar(
74    duplicate_index_url(array(), array('start')),
75    count($page['items']),
76    $page['start'],
77    $user['nb_image_page'],
78    true
79    );
80}
81else
82{
83  $page['navigation_bar'] = '';
84}
85
86// caddie filling :-)
87if (isset($_GET['caddie']))
88{
89  fill_caddie($page['items']);
90  // redirect();
91}
92
93//----------------------------------------------------- template initialization
94//
95// Start output of page
96//
97$title = $page['title'];
98$page['body_id'] = 'theCategoryPage';
99
100$template->set_filenames( array('index'=>'index.tpl') );
101//-------------------------------------------------------------- category title
102$template_title = $page['title'];
103if ( count($page['items']) > 0)
104{
105  $template_title.= ' ['.count($page['items']).']';
106}
107
108if (isset($page['flat']) or isset($page['chronology_field']))
109{
110  $template->assign_block_vars(
111    'mode_normal',
112    array(
113      'URL' => duplicate_index_url( array(), array('chronology_field', 'start', 'flat') )
114      )
115    );
116}
117
118if (!isset($page['flat']) and 'categories' == $page['section'])
119{
120  $template->assign_block_vars(
121    'flat',
122    array(
123      'URL' => duplicate_index_url(array('flat' => ''), array('start', 'chronology_field'))
124      )
125    );
126}
127
128if (!isset($page['chronology_field']))
129{
130  $chronology_params =
131      array(
132          'chronology_field' => 'created',
133          'chronology_style' => 'monthly',
134          'chronology_view' => 'list',
135      );
136  $template->assign_block_vars(
137    'mode_created',
138    array(
139      'URL' => duplicate_index_url( $chronology_params, array('start', 'flat') )
140      )
141    );
142
143  $chronology_params['chronology_field'] = 'posted';
144  $template->assign_block_vars(
145    'mode_posted',
146    array(
147      'URL' => duplicate_index_url( $chronology_params, array('start', 'flat') )
148      )
149    );
150}
151else
152{
153  if ($page['chronology_field'] == 'created')
154  {
155    $chronology_field = 'posted';
156  }
157  else
158  {
159    $chronology_field = 'created';
160  }
161  $url = duplicate_index_url(
162            array('chronology_field'=>$chronology_field ),
163            array('chronology_date', 'start', 'flat')
164          );
165  $template->assign_block_vars(
166    'mode_'.$chronology_field,
167    array('URL' => $url )
168    );
169}
170// include menubar
171include(PHPWG_ROOT_PATH.'include/menubar.inc.php');
172
173$template->assign_vars(
174  array(
175    'TITLE' => $template_title
176    )
177  );
178
179if ('search' == $page['section'])
180{
181  $template->assign_block_vars(
182    'search_rules',
183    array(
184      'URL' => get_root_url().'search_rules.php?search_id='.$page['search'],
185      )
186    );
187}
188
189if (isset($page['category']) and is_admin())
190{
191  $template->assign_block_vars(
192    'edit',
193    array(
194      'URL' =>
195        get_root_url().'admin.php?page=cat_modify'
196        .'&amp;cat_id='.$page['category']['id']
197      )
198    );
199}
200
201if (is_admin() and !empty($page['items']) )
202{
203    $template->assign_block_vars(
204      'caddie',
205      array(
206        'URL' =>
207          add_url_params(duplicate_index_url(), array('caddie'=>1) )
208        )
209      );
210  }
211
212if ( $page['section']=='search' and $page['start']==0 )
213{
214  $tags = get_common_tags($page['items'],
215      $conf['content_tag_cloud_items_number'], null);
216  if ( count($tags)>1 )
217  {
218    $template->assign_block_vars('related_tags', array() );
219
220    $tags = add_level_to_tags($tags);
221    foreach ($tags as $tag)
222    {
223      $template->assign_block_vars(
224      'related_tags.tag', array(
225        'URL' => make_index_url(
226          array(
227            'tags' => array($tag)
228            )
229          ),
230        'NAME' => $tag['name'],
231        'TITLE' => sprintf(
232          l10n('%d pictures are also linked to current tags'),
233          $tag['counter']
234          ),
235        'CLASS' => 'tagLevel'.$tag['level']
236        )
237      );
238    }
239  }
240}
241
242//------------------------------------------------------ main part : thumbnails
243if ( 0==$page['start']
244    and !isset($page['flat'])
245    and !isset($page['chronology_field'])
246    and ('recent_cats'==$page['section'] or 'categories'==$page['section'])
247  )
248{
249  include(PHPWG_ROOT_PATH.'include/category_cats.inc.php');
250}
251if ( !empty($page['items']) )
252{
253  include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
254}
255//------------------------------------------------------- category informations
256
257// navigation bar
258if ($page['navigation_bar'] != '')
259{
260  $template->assign_block_vars(
261    'cat_infos.navigation',
262    array(
263      'NAV_BAR' => $page['navigation_bar'],
264      )
265    );
266}
267
268if ( count($page['items']) > 0
269    and $page['section'] != 'most_visited'
270    and $page['section'] != 'best_rated')
271{
272  // image order
273  $template->assign_block_vars( 'preferred_image_order', array() );
274
275  $order_idx = pwg_get_session_var( 'image_order', 0 );
276
277  $orders = get_category_preferred_image_orders();
278  for ($i = 0; $i < count($orders); $i++)
279  {
280    if ($orders[$i][2])
281    {
282      $template->assign_block_vars(
283        'preferred_image_order.order',
284        array(
285          'DISPLAY' => $orders[$i][0],
286          'URL' => add_url_params( duplicate_index_url(), array('image_order'=>$i) ),
287          'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''),
288          )
289        );
290    }
291  }
292}
293
294// category comment
295if (isset($page['comment']) and $page['comment'] != '')
296{
297  $template->assign_block_vars(
298    'cat_infos.comment',
299    array(
300      'COMMENTS' => $page['comment']
301      )
302    );
303  $header_infos['COMMENT'] = strip_tags($page['comment']);
304}
305//------------------------------------------------------------ log informations
306pwg_log();
307
308include(PHPWG_ROOT_PATH.'include/page_header.php');
309trigger_action('loc_end_index');
310$template->parse('index');
311include(PHPWG_ROOT_PATH.'include/page_tail.php');
312?>
Note: See TracBrowser for help on using the repository browser.