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

Last change on this file since 1595 was 1595, checked in by rvelices, 17 years ago
  • added trigger_action in menubar and page_tail (begin and end)
  • small cosmetic change in menubar to simplify life for some plugin features
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • 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          : $Id: menubar.inc.php 1595 2006-11-07 00:55:36Z rvelices $
9// | last update   : $Date: 2006-11-07 00:55:36 +0000 (Tue, 07 Nov 2006) $
10// | last modifier : $Author: rvelices $
11// | revision      : $Revision: 1595 $
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// recent pics
171$template->assign_block_vars(
172  'special_cat',
173  array(
174    'URL' => make_index_url(array('section' => 'recent_pics')),
175    'TITLE' => $lang['recent_pics_cat_hint'],
176    'NAME' => $lang['recent_pics_cat']
177    ));
178// recent cats
179$template->assign_block_vars(
180  'special_cat',
181  array(
182    'URL' => make_index_url(array('section' => 'recent_cats')),
183    'TITLE' => $lang['recent_cats_cat_hint'],
184    'NAME' => $lang['recent_cats_cat']
185    ));
186
187// calendar
188$template->assign_block_vars(
189  'special_cat',
190  array(
191    'URL' =>
192      make_index_url(
193        array(
194          'chronology_field' => ($conf['calendar_datefield']=='date_available'
195                                  ? 'posted' : 'created'),
196           'chronology_style'=> 'monthly',
197           'chronology_view' => 'calendar'
198        )
199      ),
200    'TITLE' => $lang['calendar_hint'],
201    'NAME' => $lang['calendar']
202    )
203  );
204//--------------------------------------------------------------------- summary
205
206if ($user['is_the_guest'])
207{
208  $template->assign_block_vars('register', array());
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}
217else
218{
219  $template->assign_block_vars('hello', array());
220
221  if (is_autorize_status(ACCESS_CLASSIC))
222  {
223    $template->assign_block_vars('profile', array());
224  }
225
226  // the logout link has no meaning with Apache authentication : it is not
227  // possible to logout with this kind of authentication.
228  if (!$conf['apache_authentication'])
229  {
230    $template->assign_block_vars('logout', array());
231  }
232
233  if (is_admin())
234  {
235    $template->assign_block_vars('admin', array());
236  }
237}
238
239// tags link
240$template->assign_block_vars(
241  'summary',
242  array(
243    'TITLE' => l10n('See available tags'),
244    'NAME' => l10n('Tags'),
245    'U_SUMMARY'=> get_root_url().'tags.php',
246    )
247  );
248
249// search link
250$template->assign_block_vars(
251  'summary',
252  array(
253    'TITLE'=>$lang['hint_search'],
254    'NAME'=>$lang['search'],
255    'U_SUMMARY'=> get_root_url().'search.php',
256    'REL'=> 'rel="search"'
257    )
258  );
259$template->assign_block_vars( 'summary.quick_search',  array() );
260
261// comments link
262$template->assign_block_vars(
263  'summary',
264  array(
265    'TITLE'=>$lang['hint_comments'],
266    'NAME'=>$lang['comments'],
267    'U_SUMMARY'=> get_root_url().'comments.php',
268    )
269  );
270
271// about link
272$template->assign_block_vars(
273  'summary',
274  array(
275    'TITLE'     => $lang['about_page_title'],
276    'NAME'      => $lang['About'],
277    'U_SUMMARY' => get_root_url().'about.php',
278    )
279  );
280
281// notification
282$template->assign_block_vars(
283  'summary',
284  array(
285    'TITLE'=>l10n('notification'),
286    'NAME'=>l10n('Notification'),
287    'U_SUMMARY'=> get_root_url().'notification.php',
288    'REL'=> 'rel="nofollow"'
289    )
290  );
291
292if (isset($page['category']) and $page['cat_uploadable'] )
293{ // upload a picture in the category
294  $url = get_root_url().'upload.php?cat='.$page['category'];
295  $template->assign_block_vars(
296    'upload',
297    array(
298      'U_UPLOAD'=> $url
299      )
300    );
301}
302
303trigger_action('loc_end_menubar');
304$template->assign_var_from_handle('MENUBAR', 'menubar');
305?>
Note: See TracBrowser for help on using the repository browser.