source: trunk/index.php @ 1537

Last change on this file since 1537 was 1537, checked in by rvelices, 18 years ago

feature 519: quick search (first version)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.4 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-08-15 02:06:06 +0000 (Tue, 15 Aug 2006) $
10// | last modifier : $Author: rvelices $
11// | revision      : $Revision: 1537 $
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';
96include(PHPWG_ROOT_PATH.'include/page_header.php');
97
98$template->set_filenames( array('index'=>'index.tpl') );
99//-------------------------------------------------------------- category title
100$template_title = $page['title'];
101if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0)
102{
103  $template_title.= ' ['.$page['cat_nb_images'].']';
104}
105
106$icon_recent = get_icon(date('Y-m-d'));
107
108if (!isset($page['chronology_field']))
109{
110  $chronology_params =
111      array(
112          'chronology_field' => 'created',
113          'chronology_style' => 'monthly',
114          'chronology_view' => 'list',
115      );
116  $template->assign_block_vars(
117    'mode_created',
118    array(
119      'URL' => duplicate_index_url( $chronology_params, array('start') )
120      )
121    );
122
123  $chronology_params['chronology_field'] = 'posted';
124  $template->assign_block_vars(
125    'mode_posted',
126    array(
127      'URL' => duplicate_index_url( $chronology_params, array('start') )
128      )
129    );
130}
131else
132{
133  $template->assign_block_vars(
134    'mode_normal',
135    array(
136      'URL' => duplicate_index_url( array(), array('chronology_field','start') )
137      )
138    );
139
140  if ($page['chronology_field'] == 'created')
141  {
142    $chronology_field = 'posted';
143  }
144  else
145  {
146    $chronology_field = 'created';
147  }
148  $url = duplicate_index_url(
149            array('chronology_field'=>$chronology_field ),
150            array('chronology_date', 'start')
151          );
152  $template->assign_block_vars(
153    'mode_'.$chronology_field,
154    array('URL' => $url )
155    );
156}
157// include menubar
158include(PHPWG_ROOT_PATH.'include/menubar.inc.php');
159
160$template->assign_vars(
161  array(
162    'TITLE' => $template_title,
163    'TOP_NUMBER' => $conf['top_number'],        // still used ?
164    'T_RECENT' => $icon_recent,                 // still used ?
165    )
166  );
167
168if ('search' == $page['section'])
169{
170  $template->assign_block_vars(
171    'search_rules',
172    array(
173      'URL' => get_root_url().'search_rules.php?search_id='.$page['search'],
174      )
175    );
176}
177
178if (isset($page['category']) and is_admin())
179{
180  $template->assign_block_vars(
181    'edit',
182    array(
183      'URL' =>
184        get_root_url().'admin.php?page=cat_modify'
185        .'&amp;cat_id='.$page['category']
186      )
187    );
188}
189
190if (is_admin() and !empty($page['items']) )
191{
192    $template->assign_block_vars(
193      'caddie',
194      array(
195        'URL' =>
196          add_url_params(duplicate_index_url(), array('caddie'=>1) )
197        )
198      );
199  }
200
201if ( $page['section']=='search' and $page['start']==0 )
202{
203  $tags = get_common_tags($page['items'],
204      $conf['content_tag_cloud_items_number'], null);
205  if ( count($tags)>1 )
206  {
207    $template->assign_block_vars('related_tags', array() );
208
209    $tags = add_level_to_tags($tags);
210    foreach ($tags as $tag)
211    {
212      $template->assign_block_vars(
213      'related_tags.tag', array(
214        'URL' => make_index_url(
215          array(
216            'tags' => array(
217              array(
218                'id' => $tag['tag_id'],
219                'url_name' => $tag['url_name'],
220                ),
221              )
222            )
223          ),
224        'NAME' => $tag['name'],
225        'TITLE' => sprintf(
226          l10n('%d pictures are also linked to current tags'),
227          $tag['counter']
228          ),
229        'CLASS' => 'tagLevel'.$tag['level']
230        )
231      );
232    }
233  }
234}
235
236//------------------------------------------------------ main part : thumbnails
237if (isset($page['thumbnails_include']))
238{
239  include(PHPWG_ROOT_PATH.$page['thumbnails_include']);
240}
241//------------------------------------------------------- category informations
242if (
243  $page['navigation_bar'] != ''
244  or (isset($page['comment']) and $page['comment'] != '')
245  )
246{
247  $template->assign_block_vars('cat_infos',array());
248}
249// navigation bar
250if ($page['navigation_bar'] != '')
251{
252  $template->assign_block_vars(
253    'cat_infos.navigation',
254    array(
255      'NAV_BAR' => $page['navigation_bar'],
256      )
257    );
258}
259
260if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0
261    and $page['section'] != 'most_visited'
262    and $page['section'] != 'best_rated')
263{
264  // image order
265  $template->assign_block_vars( 'preferred_image_order', array() );
266
267  $order_idx = isset($_COOKIE['pwg_image_order'])
268    ? $_COOKIE['pwg_image_order']
269    : 0
270    ;
271
272  $orders = get_category_preferred_image_orders();
273  for ($i = 0; $i < count($orders); $i++)
274  {
275    if ($orders[$i][2])
276    {
277      $template->assign_block_vars(
278        'preferred_image_order.order',
279        array(
280          'DISPLAY' => $orders[$i][0],
281          'URL' => add_url_params( duplicate_index_url(), array('image_order'=>$i) ),
282          'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''),
283          )
284        );
285    }
286  }
287}
288
289if (isset($page['category']))
290{
291  // category comment
292  if (isset($page['comment']) and $page['comment'] != '')
293  {
294    $template->assign_block_vars(
295      'cat_infos.comment',
296      array(
297        'COMMENTS' => $page['comment']
298        )
299      );
300  }
301}
302//------------------------------------------------------------ log informations
303pwg_log('category', $page['title']);
304
305$template->parse('index');
306include(PHPWG_ROOT_PATH.'include/page_tail.php');
307?>
Note: See TracBrowser for help on using the repository browser.