source: trunk/include/menubar.inc.php @ 1652

Last change on this file since 1652 was 1652, checked in by rvelices, 17 years ago
  • feature 599: option to forbid user registration
  • 1 language cleanup
  • added page_forbidden function (sends 403)
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • 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          : $Id: menubar.inc.php 1652 2006-12-13 01:05:38Z rvelices $
9// | last update   : $Date: 2006-12-13 01:05:38 +0000 (Wed, 13 Dec 2006) $
10// | last modifier : $Author: rvelices $
11// | revision      : $Revision: 1652 $
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/**
29 * This file is included by the main page to show the menu bar
30 *
31 */
32$template->set_filenames(
33  array(
34    'menubar' => 'menubar.tpl',
35    )
36  );
37
38trigger_action('loc_begin_menubar');
39
40$template->assign_vars(
41  array(
42    'NB_PICTURE' => $user['nb_total_images'],
43    'USERNAME' => $user['username'],
44    'MENU_CATEGORIES_CONTENT' => get_categories_menu(),
45    'F_IDENTIFY' => get_root_url().'identification.php',
46    'U_HOME' => make_index_url(),
47    'U_REGISTER' => get_root_url().'register.php',
48    'U_LOST_PASSWORD' => get_root_url().'password.php',
49    'U_LOGOUT' => get_root_url().'?act=logout',
50    'U_ADMIN'=> get_root_url().'admin.php',
51    'U_PROFILE'=> get_root_url().'profile.php',
52    )
53  );
54
55//-------------------------------------------------------------- external links
56foreach ($conf['links'] as $url => $label)
57{
58  $template->assign_block_vars(
59    'links.link',
60    array(
61      'URL' => $url,
62      'LABEL' => $label
63      )
64    );
65}
66//------------------------------------------------------------------------ tags
67if ('tags' == $page['section'])
68{
69  // display tags associated to currently tagged items, less current tags
70  $tags = array();
71  if ( !empty($page['items']) )
72  {
73    $tags = get_common_tags($page['items'],
74        $conf['menubar_tag_cloud_items_number'], $page['tag_ids']);
75  }
76
77  $tags = add_level_to_tags($tags);
78
79  foreach ($tags as $tag)
80  {
81    $template->assign_block_vars(
82      'tags.tag',
83      array(
84        'URL' => make_index_url(
85          array(
86            'tags' => array(
87              array(
88                'id' => $tag['tag_id'],
89                'url_name' => $tag['url_name'],
90                ),
91              )
92            )
93          ),
94
95        'NAME' => $tag['name'],
96
97        'TITLE' => l10n('See pictures linked to this tag only'),
98
99        'CLASS' => 'tagLevel'.$tag['level']
100        )
101      );
102
103    $template->assign_block_vars(
104      'tags.tag.add',
105      array(
106        'URL' => make_index_url(
107          array(
108            'tags' => array_merge(
109              $page['tags'],
110              array(
111                array(
112                  'id' => $tag['tag_id'],
113                  'url_name' => $tag['url_name'],
114                  ),
115                )
116              )
117            )
118          ),
119        'TITLE' => sprintf(
120          l10n('%d pictures are also linked to current tags'),
121          $tag['counter']
122          ),
123        )
124      );
125
126  }
127}
128//---------------------------------------------------------- special categories
129// favorites categories
130if ( !$user['is_the_guest'] )
131{
132  $template->assign_block_vars('username', array());
133
134  $template->assign_block_vars(
135    'special_cat',
136    array(
137      'URL' => make_index_url(array('section' => 'favorites')),
138      'TITLE' => $lang['favorite_cat_hint'],
139      'NAME' => $lang['favorite_cat']
140      ));
141}
142// most visited
143$template->assign_block_vars(
144  'special_cat',
145  array(
146    'URL' => make_index_url(array('section' => 'most_visited')),
147    'TITLE' => $lang['most_visited_cat_hint'],
148    'NAME' => $lang['most_visited_cat']
149    ));
150// best rated
151if ($conf['rate'])
152{
153  $template->assign_block_vars(
154    'special_cat',
155    array(
156      'URL' => make_index_url(array('section' => 'best_rated')),
157      'TITLE' => $lang['best_rated_cat_hint'],
158      'NAME' => $lang['best_rated_cat']
159      )
160    );
161}
162// random
163$template->assign_block_vars(
164  'special_cat',
165  array(
166    'URL' => get_root_url().'random.php',
167    'TITLE' => $lang['random_cat_hint'],
168    'NAME' => $lang['random_cat']
169    ));
170
171// recent pics
172$template->assign_block_vars(
173  'special_cat',
174  array(
175    'URL' => make_index_url(array('section' => 'recent_pics')),
176    'TITLE' => $lang['recent_pics_cat_hint'],
177    'NAME' => $lang['recent_pics_cat']
178    ));
179// recent cats
180$template->assign_block_vars(
181  'special_cat',
182  array(
183    'URL' => make_index_url(array('section' => 'recent_cats')),
184    'TITLE' => $lang['recent_cats_cat_hint'],
185    'NAME' => $lang['recent_cats_cat']
186    ));
187
188// calendar
189$template->assign_block_vars(
190  'special_cat',
191  array(
192    'URL' =>
193      make_index_url(
194        array(
195          'chronology_field' => ($conf['calendar_datefield']=='date_available'
196                                  ? 'posted' : 'created'),
197           'chronology_style'=> 'monthly',
198           'chronology_view' => 'calendar'
199        )
200      ),
201    'TITLE' => $lang['calendar_hint'],
202    'NAME' => $lang['calendar']
203    )
204  );
205//--------------------------------------------------------------------- summary
206
207if ($user['is_the_guest'])
208{
209  $template->assign_block_vars('login', array());
210
211  $template->assign_block_vars('quickconnect', array());
212  if ($conf['authorize_remembering'])
213  {
214    $template->assign_block_vars('quickconnect.remember_me', array());
215  }
216  if ($conf['allow_user_registration'])
217  {
218    $template->assign_block_vars('register', array());
219    $template->assign_block_vars('quickconnect.register', array());
220  }
221}
222else
223{
224  $template->assign_block_vars('hello', array());
225
226  if (is_autorize_status(ACCESS_CLASSIC))
227  {
228    $template->assign_block_vars('profile', array());
229  }
230
231  // the logout link has no meaning with Apache authentication : it is not
232  // possible to logout with this kind of authentication.
233  if (!$conf['apache_authentication'])
234  {
235    $template->assign_block_vars('logout', array());
236  }
237
238  if (is_admin())
239  {
240    $template->assign_block_vars('admin', array());
241  }
242}
243
244// tags link
245$template->assign_block_vars(
246  'summary',
247  array(
248    'TITLE' => l10n('See available tags'),
249    'NAME' => l10n('Tags'),
250    'U_SUMMARY'=> get_root_url().'tags.php',
251    )
252  );
253
254// search link
255$template->assign_block_vars(
256  'summary',
257  array(
258    'TITLE'=>$lang['hint_search'],
259    'NAME'=>$lang['search'],
260    'U_SUMMARY'=> get_root_url().'search.php',
261    'REL'=> 'rel="search"'
262    )
263  );
264$template->assign_block_vars( 'summary.quick_search',  array() );
265
266// comments link
267$template->assign_block_vars(
268  'summary',
269  array(
270    'TITLE'=>$lang['hint_comments'],
271    'NAME'=>$lang['comments'],
272    'U_SUMMARY'=> get_root_url().'comments.php',
273    )
274  );
275
276// about link
277$template->assign_block_vars(
278  'summary',
279  array(
280    'TITLE'     => $lang['about_page_title'],
281    'NAME'      => $lang['About'],
282    'U_SUMMARY' => get_root_url().'about.php',
283    )
284  );
285
286// notification
287$template->assign_block_vars(
288  'summary',
289  array(
290    'TITLE'=>l10n('RSS feed'),
291    'NAME'=>l10n('Notification'),
292    'U_SUMMARY'=> get_root_url().'notification.php',
293    'REL'=> 'rel="nofollow"'
294    )
295  );
296
297if (isset($page['category']) and $page['cat_uploadable'] )
298{ // upload a picture in the category
299  $url = get_root_url().'upload.php?cat='.$page['category'];
300  $template->assign_block_vars(
301    'upload',
302    array(
303      'U_UPLOAD'=> $url
304      )
305    );
306}
307
308trigger_action('loc_end_menubar');
309$template->assign_var_from_handle('MENUBAR', 'menubar');
310?>
Note: See TracBrowser for help on using the repository browser.