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

Last change on this file since 8528 was 8223, checked in by patdenice, 13 years ago

merge r8222 from branch 2.1 to trunk
bug 2078: Links must not be displayed in menubar if empty.

  • Property svn:eol-style set to LF
File size: 9.9 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2010 Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24/**
25 * This file is included by the main page to show the menu bar
26 *
27 */
28
29include_once(PHPWG_ROOT_PATH.'include/block.class.php');
30
31initialize_menu();
32
33function initialize_menu()
34{
35  global $page, $conf, $user, $template, $filter;
36
37  $menu = new BlockManager("menubar");
38  $menu->load_registered_blocks();
39  $menu->prepare_display();
40
41//--------------------------------------------------------------- external links
42  if ( ($block=$menu->get_block('mbLinks')) and !empty($conf['links']) )
43  {
44    $block->data = array();
45    foreach ($conf['links'] as $url => $url_data)
46    {
47      if (!is_array($url_data))
48      {
49        $url_data = array('label' => $url_data);
50      }
51
52      if
53        (
54          (!isset($url_data['eval_visible']))
55          or
56          (eval($url_data['eval_visible']))
57        )
58      {
59        $tpl_var = array(
60            'URL' => $url,
61            'LABEL' => $url_data['label']
62          );
63
64        if (!isset($url_data['new_window']) or $url_data['new_window'])
65        {
66          $tpl_var['new_window'] =
67            array(
68              'NAME' => (isset($url_data['nw_name']) ? $url_data['nw_name'] : ''),
69              'FEATURES' => (isset($url_data['nw_features']) ? $url_data['nw_features'] : '')
70            );
71        }
72        $block->data[] = $tpl_var;
73      }
74    }
75    if ( !empty($block->data) )
76    {
77      $block->template = 'menubar_links.tpl';
78    }
79  }
80
81//-------------------------------------------------------------- categories
82  $block = $menu->get_block('mbCategories');
83//------------------------------------------------------------------------ filter
84  if ($conf['menubar_filter_icon'] and !empty($conf['filter_pages']) and get_filter_page_value('used'))
85  {
86    if ($filter['enabled'])
87    {
88      $template->assign(
89        'U_STOP_FILTER',
90        add_url_params(make_index_url(array()), array('filter' => 'stop'))
91        );
92    }
93    else
94    {
95      $template->assign(
96        'U_START_FILTER',
97        add_url_params(make_index_url(array()), array('filter' => 'start-recent-'.$user['recent_period']))
98        );
99    }
100  }
101
102  if ( $block!=null )
103  {
104    $block->data = array(
105      'NB_PICTURE' => $user['nb_total_images'],
106      'MENU_CATEGORIES' => get_categories_menu(),
107      'U_CATEGORIES' => make_index_url(array('section' => 'categories')),
108      'U_UPLOAD' => get_upload_menu_link()
109    );
110    $block->template = 'menubar_categories.tpl';
111  }
112
113//------------------------------------------------------------------------ tags
114  $block = $menu->get_block('mbTags');
115  if ( $block!=null and !empty($page['items']) )
116  {
117    if ('tags'==@$page['section'])
118    {
119      $tags = get_common_tags(
120        $page['items'],
121        $conf['menubar_tag_cloud_items_number'],
122        $page['tag_ids']
123        );
124      $tags = add_level_to_tags($tags);
125
126      foreach ($tags as $tag)
127      {
128        $block->data[] = array_merge(
129          $tag,
130          array(
131            'U_ADD' => make_index_url(
132              array(
133                'tags' => array_merge(
134                  $page['tags'],
135                  array($tag)
136                  )
137                )
138              ),
139            'URL' => make_index_url( array( 'tags' => array($tag) )
140              ),
141            )
142          );
143      }
144    }
145    else
146    {
147      $selection = array_slice( $page['items'], $page['start'], $page['nb_image_page'] );
148      $tags = add_level_to_tags( get_common_tags($selection, $conf['content_tag_cloud_items_number']) );
149      foreach ($tags as $tag)
150      {
151        $block->data[] =
152        array_merge( $tag,
153          array(
154            'URL' => make_index_url( array( 'tags' => array($tag) ) ),
155          )
156        );
157      }
158    }
159    if ( !empty($block->data) )
160    {
161      $block->template = 'menubar_tags.tpl';
162    }
163  }
164
165//----------------------------------------------------------- special categories
166  if ( ($block = $menu->get_block('mbSpecials')) != null )
167  {
168    if ( !is_a_guest() )
169    {// favorites
170      $block->data['favorites'] =
171        array(
172          'URL' => make_index_url(array('section' => 'favorites')),
173          'TITLE' => l10n('display my favorites pictures'),
174          'NAME' => l10n('My favorites')
175          );
176    }
177
178    $block->data['most_visited'] =
179      array(
180        'URL' => make_index_url(array('section' => 'most_visited')),
181        'TITLE' => l10n('display most visited pictures'),
182        'NAME' => l10n('Most visited')
183      );
184
185    if ($conf['rate'])
186    {
187       $block->data['best_rated'] =
188        array(
189          'URL' => make_index_url(array('section' => 'best_rated')),
190          'TITLE' => l10n('display best rated items'),
191          'NAME' => l10n('Best rated')
192        );
193    }
194
195    $block->data['random'] =
196      array(
197        'URL' => get_root_url().'random.php',
198        'TITLE' => l10n('display a set of random pictures'),
199        'NAME' => l10n('Random pictures'),
200        'REL'=> 'rel="nofollow"'
201      );
202
203    $block->data['recent_pics'] =
204      array(
205        'URL' => make_index_url(array('section' => 'recent_pics')),
206        'TITLE' => l10n('display most recent pictures'),
207        'NAME' => l10n('Recent pictures'),
208      );
209
210    $block->data['recent_cats'] =
211      array(
212        'URL' => make_index_url(array('section' => 'recent_cats')),
213        'TITLE' => l10n('display recently updated albums'),
214        'NAME' => l10n('Recent albums'),
215      );
216
217
218    $block->data['calendar'] =
219      array(
220        'URL' =>
221          make_index_url(
222            array(
223              'chronology_field' => ($conf['calendar_datefield']=='date_available'
224                                      ? 'posted' : 'created'),
225               'chronology_style'=> 'monthly',
226               'chronology_view' => 'calendar'
227            )
228          ),
229        'TITLE' => l10n('display each day with pictures, month per month'),
230        'NAME' => l10n('Calendar'),
231        'REL'=> 'rel="nofollow"'
232      );
233    $block->template = 'menubar_specials.tpl';
234  }
235
236
237//---------------------------------------------------------------------- summary
238  if ( ($block=$menu->get_block('mbMenu')) != null )
239  {
240    // quick search block will be displayed only if data['qsearch'] is set
241    // to "yes"
242    $block->data['qsearch']=true;
243
244    // tags link
245    $block->data['tags'] =
246      array(
247        'TITLE' => l10n('See available tags'),
248        'NAME' => l10n('Tags'),
249        'URL'=> get_root_url().'tags.php',
250      );
251
252    // search link
253    $block->data['search'] =
254      array(
255        'TITLE'=>l10n('search'),
256        'NAME'=>l10n('Search'),
257        'URL'=> get_root_url().'search.php',
258        'REL'=> 'rel="search"'
259      );
260
261    // comments link
262    $block->data['comments'] =
263      array(
264        'TITLE'=>l10n('See last users comments'),
265        'NAME'=>l10n('Comments'),
266        'URL'=> get_root_url().'comments.php',
267      );
268
269    // about link
270    $block->data['about'] =
271      array(
272        'TITLE'     => l10n('About Piwigo'),
273        'NAME'      => l10n('About'),
274        'URL' => get_root_url().'about.php',
275      );
276
277    // notification
278    $block->data['rss'] =
279      array(
280        'TITLE'=>l10n('RSS feed'),
281        'NAME'=>l10n('Notification'),
282        'URL'=> get_root_url().'notification.php',
283        'REL'=> 'rel="nofollow"'
284      );
285    $block->template = 'menubar_menu.tpl';
286  }
287
288
289//--------------------------------------------------------------- identification
290  if (is_a_guest())
291  {
292    $template->assign(
293        array(
294          'U_LOGIN' => get_root_url().'identification.php',
295          'U_LOST_PASSWORD' => get_root_url().'password.php',
296          'AUTHORIZE_REMEMBERING' => $conf['authorize_remembering']
297        )
298      );
299    if ($conf['allow_user_registration'])
300    {
301      $template->assign( 'U_REGISTER', get_root_url().'register.php');
302    }
303  }
304  else
305  {
306    $template->assign('USERNAME', stripslashes($user['username']));
307    if (is_autorize_status(ACCESS_CLASSIC))
308    {
309      $template->assign('U_PROFILE', get_root_url().'profile.php');
310    }
311
312    // the logout link has no meaning with Apache authentication : it is not
313    // possible to logout with this kind of authentication.
314    if (!$conf['apache_authentication'])
315    {
316      $template->assign('U_LOGOUT', get_root_url().'?act=logout');
317    }
318    if (is_admin())
319    {
320      $template->assign('U_ADMIN', get_root_url().'admin.php');
321    }
322  }
323  if ( ($block=$menu->get_block('mbIdentification')) != null )
324  {
325    $block->template = 'menubar_identification.tpl';
326  }
327  $menu->apply('MENUBAR',  'menubar.tpl' );
328}
329?>
Note: See TracBrowser for help on using the repository browser.