source: branches/1.7/include/menubar.inc.php @ 4636

Last change on this file since 4636 was 2414, checked in by rvelices, 16 years ago
  • tags improvement : pass to templates all fields in table #tags (handy for plugins such as type tags)
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 9.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-2007 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | file          : $Id: menubar.inc.php 2414 2008-07-02 01:13:12Z rvelices $
8// | last update   : $Date: 2008-07-02 01:13:12 +0000 (Wed, 02 Jul 2008) $
9// | last modifier : $Author: rvelices $
10// | revision      : $Revision: 2414 $
11// +-----------------------------------------------------------------------+
12// | This program is free software; you can redistribute it and/or modify  |
13// | it under the terms of the GNU General Public License as published by  |
14// | the Free Software Foundation                                          |
15// |                                                                       |
16// | This program is distributed in the hope that it will be useful, but   |
17// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
18// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
19// | General Public License for more details.                              |
20// |                                                                       |
21// | You should have received a copy of the GNU General Public License     |
22// | along with this program; if not, write to the Free Software           |
23// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
24// | USA.                                                                  |
25// +-----------------------------------------------------------------------+
26
27/**
28 * This file is included by the main page to show the menu bar
29 *
30 */
31$template->set_filenames(
32  array(
33    'menubar' => 'menubar.tpl',
34    )
35  );
36
37trigger_action('loc_begin_menubar');
38
39$template->assign_vars(
40  array(
41    'NB_PICTURE' => $user['nb_total_images'],
42    'USERNAME' => $user['username'],
43    'MENU_CATEGORIES_CONTENT' => get_categories_menu(),
44    'F_IDENTIFY' => get_root_url().'identification.php',
45    'U_CATEGORIES' => make_index_url(array('section' => 'categories')),
46    'U_REGISTER' => get_root_url().'register.php',
47    'U_LOST_PASSWORD' => get_root_url().'password.php',
48    'U_LOGOUT' => get_root_url().'?act=logout',
49    'U_ADMIN'=> get_root_url().'admin.php',
50    'U_PROFILE'=> get_root_url().'profile.php',
51    )
52  );
53
54//-------------------------------------------------------------- external links
55foreach ($conf['links'] as $url => $url_data)
56{
57  if (!is_array($url_data))
58  {
59    $url_data = array('label' => $url_data);
60  }
61
62  if
63    (
64      (!isset($url_data['eval_visible']))
65      or
66      (eval($url_data['eval_visible']))
67    )
68  {
69    $template->assign_block_vars(
70      'links.link',
71      array(
72        'URL' => $url,
73        'LABEL' => $url_data['label']
74        )
75      );
76    if (!isset($url_data['new_window']) or $url_data['new_window'])
77    {
78      $template->assign_block_vars(
79        'links.link.new_window',
80        array(
81          'name' => (isset($url_data['nw_name']) ? $url_data['nw_name'] : ''),
82          'features' => (isset($url_data['nw_features']) ? $url_data['nw_features'] : '')
83          )
84        );
85    }
86  }
87}
88
89//------------------------------------------------------------------------ filter
90if (!empty($conf['filter_pages']) and get_filter_page_value('used'))
91{
92  if ($filter['enabled'])
93  {
94    $template->assign_block_vars(
95      'stop_filter',
96      array(
97        'URL' => add_url_params(make_index_url(array()), array('filter' => 'stop'))
98        )
99      );
100  }
101  else
102  {
103    $template->assign_block_vars(
104      'start_filter',
105      array(
106        'URL' => add_url_params(make_index_url(array()), array('filter' => 'start-recent-'.$user['recent_period']))
107        )
108      );
109  }
110}
111
112//------------------------------------------------------------------------ tags
113if ('tags' == $page['section'])
114{
115  // display tags associated to currently tagged items, less current tags
116  $tags = array();
117  if ( !empty($page['items']) )
118  {
119    $tags = get_common_tags($page['items'],
120        $conf['menubar_tag_cloud_items_number'], $page['tag_ids']);
121  }
122
123  $tags = add_level_to_tags($tags);
124
125  foreach ($tags as $tag)
126  {
127    $template->assign_block_vars(
128      'tags.tag',
129      array_merge(
130        $tag,
131        array(
132          'URL' => make_index_url(
133            array(
134              'tags' => array($tag)
135              )
136            ),
137
138          'NAME' => $tag['name'],
139
140          'TITLE' => l10n('See pictures linked to this tag only'),
141
142          'CLASS' => 'tagLevel'.$tag['level']
143          )
144        )
145      );
146
147    $template->assign_block_vars(
148      'tags.tag.add',
149      array(
150        'URL' => make_index_url(
151          array(
152            'tags' => array_merge(
153              $page['tags'],
154              array($tag)
155              )
156            )
157          ),
158        'TITLE' => l10n_dec(
159            '%d picture is also linked to current tags',
160            '%d pictures are also linked to current tags',
161            $tag['counter']),
162        )
163      );
164
165  }
166}
167//---------------------------------------------------------- special categories
168// favorites categories
169if ( !$user['is_the_guest'] )
170{
171  $template->assign_block_vars('username', array());
172
173  $template->assign_block_vars(
174    'special_cat',
175    array(
176      'URL' => make_index_url(array('section' => 'favorites')),
177      'TITLE' => l10n('favorite_cat_hint'),
178      'NAME' => l10n('favorite_cat')
179      ));
180}
181// most visited
182$template->assign_block_vars(
183  'special_cat',
184  array(
185    'URL' => make_index_url(array('section' => 'most_visited')),
186    'TITLE' => l10n('most_visited_cat_hint'),
187    'NAME' => l10n('most_visited_cat')
188    ));
189// best rated
190if ($conf['rate'])
191{
192  $template->assign_block_vars(
193    'special_cat',
194    array(
195      'URL' => make_index_url(array('section' => 'best_rated')),
196      'TITLE' => l10n('best_rated_cat_hint'),
197      'NAME' => l10n('best_rated_cat')
198      )
199    );
200}
201// random
202$template->assign_block_vars(
203  'special_cat',
204  array(
205    'URL' => get_root_url().'random.php',
206    'TITLE' => l10n('random_cat_hint'),
207    'NAME' => l10n('random_cat'),
208    'REL'=> 'rel="nofollow"'
209    ));
210
211// recent pics
212$template->assign_block_vars(
213  'special_cat',
214  array(
215    'URL' => make_index_url(array('section' => 'recent_pics')),
216    'TITLE' => l10n('recent_pics_cat_hint'),
217    'NAME' => l10n('recent_pics_cat'),
218    ));
219// recent cats
220$template->assign_block_vars(
221  'special_cat',
222  array(
223    'URL' => make_index_url(array('section' => 'recent_cats')),
224    'TITLE' => l10n('recent_cats_cat_hint'),
225    'NAME' => l10n('recent_cats_cat'),
226    ));
227
228// calendar
229$template->assign_block_vars(
230  'special_cat',
231  array(
232    'URL' =>
233      make_index_url(
234        array(
235          'chronology_field' => ($conf['calendar_datefield']=='date_available'
236                                  ? 'posted' : 'created'),
237           'chronology_style'=> 'monthly',
238           'chronology_view' => 'calendar'
239        )
240      ),
241    'TITLE' => l10n('calendar_hint'),
242    'NAME' => l10n('calendar'),
243    'REL'=> 'rel="nofollow"'
244    )
245  );
246//--------------------------------------------------------------------- summary
247
248if ($user['is_the_guest'])
249{
250  $template->assign_block_vars('login', array());
251
252  $template->assign_block_vars('quickconnect', array());
253  if ($conf['authorize_remembering'])
254  {
255    $template->assign_block_vars('quickconnect.remember_me', array());
256  }
257  if ($conf['allow_user_registration'])
258  {
259    $template->assign_block_vars('register', array());
260    $template->assign_block_vars('quickconnect.register', array());
261  }
262}
263else
264{
265  $template->assign_block_vars('hello', array());
266
267  if (is_autorize_status(ACCESS_CLASSIC))
268  {
269    $template->assign_block_vars('profile', array());
270  }
271
272  // the logout link has no meaning with Apache authentication : it is not
273  // possible to logout with this kind of authentication.
274  if (!$conf['apache_authentication'])
275  {
276    $template->assign_block_vars('logout', array());
277  }
278
279  if (is_admin())
280  {
281    $template->assign_block_vars('admin', array());
282  }
283}
284
285// tags link
286$template->assign_block_vars(
287  'summary',
288  array(
289    'TITLE' => l10n('See available tags'),
290    'NAME' => l10n('Tags'),
291    'U_SUMMARY'=> get_root_url().'tags.php',
292    )
293  );
294
295// search link
296$template->assign_block_vars(
297  'summary',
298  array(
299    'TITLE'=>l10n('hint_search'),
300    'NAME'=>l10n('search'),
301    'U_SUMMARY'=> get_root_url().'search.php',
302    'REL'=> 'rel="search"'
303    )
304  );
305$template->assign_block_vars( 'summary.quick_search',  array() );
306
307// comments link
308$template->assign_block_vars(
309  'summary',
310  array(
311    'TITLE'=>l10n('hint_comments'),
312    'NAME'=>l10n('comments'),
313    'U_SUMMARY'=> get_root_url().'comments.php',
314    )
315  );
316
317// about link
318$template->assign_block_vars(
319  'summary',
320  array(
321    'TITLE'     => l10n('about_page_title'),
322    'NAME'      => l10n('About'),
323    'U_SUMMARY' => get_root_url().'about.php',
324    )
325  );
326
327// notification
328$template->assign_block_vars(
329  'summary',
330  array(
331    'TITLE'=>l10n('RSS feed'),
332    'NAME'=>l10n('Notification'),
333    'U_SUMMARY'=> get_root_url().'notification.php',
334    'REL'=> 'rel="nofollow"'
335    )
336  );
337
338if (isset($page['category']) and $page['category']['uploadable'] )
339{ // upload a picture in the category
340  $url = get_root_url().'upload.php?cat='.$page['category']['id'];
341  $template->assign_block_vars(
342    'upload',
343    array(
344      'U_UPLOAD'=> $url
345      )
346    );
347}
348
349trigger_action('loc_end_menubar');
350$template->assign_var_from_handle('MENUBAR', 'menubar');
351?>
Note: See TracBrowser for help on using the repository browser.