source: trunk/index.php @ 1627

Last change on this file since 1627 was 1627, checked in by chrisaga, 17 years ago

improve page header : slightly prettier title and

first implementation of meta tags and rel links (see the wiki specs)
some code improvements are still need.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.2 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 16:46:15 +0000 (Sat, 02 Dec 2006) $
10// | last modifier : $Author: chrisaga $
11// | revision      : $Revision: 1627 $
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']);
69}
70
71if (isset($page['cat_nb_images'])
72    and $page['cat_nb_images'] > $user['nb_image_page'])
73{
74  $page['navigation_bar'] = create_navigation_bar(
75    duplicate_index_url(array(), array('start')),
76    $page['cat_nb_images'],
77    $page['start'],
78    $user['nb_image_page'],
79    true
80    );
81}
82else
83{
84  $page['navigation_bar'] = '';
85}
86
87// caddie filling :-)
88if (isset($_GET['caddie']))
89{
90  fill_caddie($page['items']);
91  // redirect();
92}
93
94//----------------------------------------------------- template initialization
95//
96// Start output of page
97//
98$title = $page['title'];
99$page['body_id'] = 'theCategoryPage';
100
101$template->set_filenames( array('index'=>'index.tpl') );
102//-------------------------------------------------------------- category title
103$template_title = $page['title'];
104if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0)
105{
106  $template_title.= ' ['.$page['cat_nb_images'].']';
107}
108
109if (!isset($page['chronology_field']))
110{
111  $chronology_params =
112      array(
113          'chronology_field' => 'created',
114          'chronology_style' => 'monthly',
115          'chronology_view' => 'list',
116      );
117  $template->assign_block_vars(
118    'mode_created',
119    array(
120      'URL' => duplicate_index_url( $chronology_params, array('start') )
121      )
122    );
123
124  $chronology_params['chronology_field'] = 'posted';
125  $template->assign_block_vars(
126    'mode_posted',
127    array(
128      'URL' => duplicate_index_url( $chronology_params, array('start') )
129      )
130    );
131}
132else
133{
134  $template->assign_block_vars(
135    'mode_normal',
136    array(
137      'URL' => duplicate_index_url( array(), array('chronology_field','start') )
138      )
139    );
140
141  if ($page['chronology_field'] == 'created')
142  {
143    $chronology_field = 'posted';
144  }
145  else
146  {
147    $chronology_field = 'created';
148  }
149  $url = duplicate_index_url(
150            array('chronology_field'=>$chronology_field ),
151            array('chronology_date', 'start')
152          );
153  $template->assign_block_vars(
154    'mode_'.$chronology_field,
155    array('URL' => $url )
156    );
157}
158// include menubar
159include(PHPWG_ROOT_PATH.'include/menubar.inc.php');
160
161$template->assign_vars(
162  array(
163    'TITLE' => $template_title
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
200if ( $page['section']=='search' and $page['start']==0 )
201{
202  $tags = get_common_tags($page['items'],
203      $conf['content_tag_cloud_items_number'], null);
204  if ( count($tags)>1 )
205  {
206    $template->assign_block_vars('related_tags', array() );
207
208    $tags = add_level_to_tags($tags);
209    foreach ($tags as $tag)
210    {
211      $template->assign_block_vars(
212      'related_tags.tag', array(
213        'URL' => make_index_url(
214          array(
215            'tags' => array(
216              array(
217                'id' => $tag['tag_id'],
218                'url_name' => $tag['url_name'],
219                ),
220              )
221            )
222          ),
223        'NAME' => $tag['name'],
224        'TITLE' => sprintf(
225          l10n('%d pictures are also linked to current tags'),
226          $tag['counter']
227          ),
228        'CLASS' => 'tagLevel'.$tag['level']
229        )
230      );
231    }
232  }
233}
234
235//------------------------------------------------------ main part : thumbnails
236if (isset($page['thumbnails_include']))
237{
238  include(PHPWG_ROOT_PATH.$page['thumbnails_include']);
239}
240//------------------------------------------------------- category informations
241
242// navigation bar
243if ($page['navigation_bar'] != '')
244{
245  $template->assign_block_vars(
246    'cat_infos.navigation',
247    array(
248      'NAV_BAR' => $page['navigation_bar'],
249      )
250    );
251}
252
253if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0
254    and $page['section'] != 'most_visited'
255    and $page['section'] != 'best_rated')
256{
257  // image order
258  $template->assign_block_vars( 'preferred_image_order', array() );
259
260  $order_idx = pwg_get_session_var( 'image_order', 0 );
261
262  $orders = get_category_preferred_image_orders();
263  for ($i = 0; $i < count($orders); $i++)
264  {
265    if ($orders[$i][2])
266    {
267      $template->assign_block_vars(
268        'preferred_image_order.order',
269        array(
270          'DISPLAY' => $orders[$i][0],
271          'URL' => add_url_params( duplicate_index_url(), array('image_order'=>$i) ),
272          'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''),
273          )
274        );
275    }
276  }
277}
278
279// category comment
280if (isset($page['comment']) and $page['comment'] != '')
281{
282  $template->assign_block_vars(
283    'cat_infos.comment',
284    array(
285      'COMMENTS' => $page['comment']
286      )
287    );
288  $header_infos['COMMENT'] = strip_tags($page['comment']);
289}
290//------------------------------------------------------------ log informations
291pwg_log('category', $page['title']);
292
293trigger_action('loc_end_index');
294include(PHPWG_ROOT_PATH.'include/page_header.php');
295$template->parse('index');
296include(PHPWG_ROOT_PATH.'include/page_tail.php');
297?>
Note: See TracBrowser for help on using the repository browser.