source: trunk/index.php @ 1604

Last change on this file since 1604 was 1604, checked in by rvelices, 17 years ago
  • Property svn:eol-style set to native
  • 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-2006 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $RCSfile$
9// | last update   : $Date: 2006-11-10 01:10:42 +0000 (Fri, 10 Nov 2006) $
10// | last modifier : $Author: rvelices $
11// | revision      : $Revision: 1604 $
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  setcookie(
44    'pwg_image_order',
45    $_GET['image_order'] > 0 ? $_GET['image_order'] : '',
46    0, cookie_path()
47    );
48
49  redirect(
50    duplicate_index_url(
51      array(),        // nothing to redefine
52      array('start')  // changing display order goes back to section first page
53      )
54    );
55}
56//-------------------------------------------------------------- initialization
57// detection of the start picture to display
58if (!isset($page['start']))
59{
60  $page['start'] = 0;
61}
62
63// access authorization check
64if (isset($page['category']))
65{
66  check_restrictions($page['category']);
67}
68
69if (isset($page['cat_nb_images'])
70    and $page['cat_nb_images'] > $user['nb_image_page'])
71{
72  $page['navigation_bar'] = create_navigation_bar(
73    duplicate_index_url(array(), array('start')),
74    $page['cat_nb_images'],
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();
90}
91
92//----------------------------------------------------- template initialization
93//
94// Start output of page
95//
96$title = $page['title'];
97$page['body_id'] = 'theCategoryPage';
98include(PHPWG_ROOT_PATH.'include/page_header.php');
99
100$template->set_filenames( array('index'=>'index.tpl') );
101//-------------------------------------------------------------- category title
102$template_title = $page['title'];
103if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0)
104{
105  $template_title.= ' ['.$page['cat_nb_images'].']';
106}
107
108$icon_recent = get_icon(date('Y-m-d'));
109
110if (!isset($page['chronology_field']))
111{
112  $chronology_params =
113      array(
114          'chronology_field' => 'created',
115          'chronology_style' => 'monthly',
116          'chronology_view' => 'list',
117      );
118  $template->assign_block_vars(
119    'mode_created',
120    array(
121      'URL' => duplicate_index_url( $chronology_params, array('start') )
122      )
123    );
124
125  $chronology_params['chronology_field'] = 'posted';
126  $template->assign_block_vars(
127    'mode_posted',
128    array(
129      'URL' => duplicate_index_url( $chronology_params, array('start') )
130      )
131    );
132}
133else
134{
135  $template->assign_block_vars(
136    'mode_normal',
137    array(
138      'URL' => duplicate_index_url( array(), array('chronology_field','start') )
139      )
140    );
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')
153          );
154  $template->assign_block_vars(
155    'mode_'.$chronology_field,
156    array('URL' => $url )
157    );
158}
159// include menubar
160include(PHPWG_ROOT_PATH.'include/menubar.inc.php');
161
162$template->assign_vars(
163  array(
164    'TITLE' => $template_title,
165    'TOP_NUMBER' => $conf['top_number'],        // still used ?
166    'T_RECENT' => $icon_recent,                 // still used ?
167    )
168  );
169
170if ('search' == $page['section'])
171{
172  $template->assign_block_vars(
173    'search_rules',
174    array(
175      'URL' => get_root_url().'search_rules.php?search_id='.$page['search'],
176      )
177    );
178}
179
180if (isset($page['category']) and is_admin())
181{
182  $template->assign_block_vars(
183    'edit',
184    array(
185      'URL' =>
186        get_root_url().'admin.php?page=cat_modify'
187        .'&amp;cat_id='.$page['category']
188      )
189    );
190}
191
192if (is_admin() and !empty($page['items']) )
193{
194    $template->assign_block_vars(
195      'caddie',
196      array(
197        'URL' =>
198          add_url_params(duplicate_index_url(), array('caddie'=>1) )
199        )
200      );
201  }
202
203if ( $page['section']=='search' and $page['start']==0 )
204{
205  $tags = get_common_tags($page['items'],
206      $conf['content_tag_cloud_items_number'], null);
207  if ( count($tags)>1 )
208  {
209    $template->assign_block_vars('related_tags', array() );
210
211    $tags = add_level_to_tags($tags);
212    foreach ($tags as $tag)
213    {
214      $template->assign_block_vars(
215      'related_tags.tag', array(
216        'URL' => make_index_url(
217          array(
218            'tags' => array(
219              array(
220                'id' => $tag['tag_id'],
221                'url_name' => $tag['url_name'],
222                ),
223              )
224            )
225          ),
226        'NAME' => $tag['name'],
227        'TITLE' => sprintf(
228          l10n('%d pictures are also linked to current tags'),
229          $tag['counter']
230          ),
231        'CLASS' => 'tagLevel'.$tag['level']
232        )
233      );
234    }
235  }
236}
237
238//------------------------------------------------------ main part : thumbnails
239if (isset($page['thumbnails_include']))
240{
241  include(PHPWG_ROOT_PATH.$page['thumbnails_include']);
242}
243//------------------------------------------------------- category informations
244
245// navigation bar
246if ($page['navigation_bar'] != '')
247{
248  $template->assign_block_vars(
249    'cat_infos.navigation',
250    array(
251      'NAV_BAR' => $page['navigation_bar'],
252      )
253    );
254}
255
256if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0
257    and $page['section'] != 'most_visited'
258    and $page['section'] != 'best_rated')
259{
260  // image order
261  $template->assign_block_vars( 'preferred_image_order', array() );
262
263  $order_idx = isset($_COOKIE['pwg_image_order'])
264    ? $_COOKIE['pwg_image_order']
265    : 0
266    ;
267
268  $orders = get_category_preferred_image_orders();
269  for ($i = 0; $i < count($orders); $i++)
270  {
271    if ($orders[$i][2])
272    {
273      $template->assign_block_vars(
274        'preferred_image_order.order',
275        array(
276          'DISPLAY' => $orders[$i][0],
277          'URL' => add_url_params( duplicate_index_url(), array('image_order'=>$i) ),
278          'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''),
279          )
280        );
281    }
282  }
283}
284
285// category comment
286if (isset($page['comment']) and $page['comment'] != '')
287{
288  $template->assign_block_vars(
289    'cat_infos.comment',
290    array(
291      'COMMENTS' => $page['comment']
292      )
293    );
294}
295//------------------------------------------------------------ log informations
296pwg_log('category', $page['title']);
297
298trigger_action('loc_end_index');
299$template->parse('index');
300include(PHPWG_ROOT_PATH.'include/page_tail.php');
301?>
Note: See TracBrowser for help on using the repository browser.