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

Last change on this file since 5703 was 5703, checked in by plg, 14 years ago

feature 1583: replace add_tag.png icon by a simple "+" character in the
"related tags" block. Only keep one link for each tag in the "related tags"
block.

File size: 9.3 KB
RevLine 
[1367]1<?php
2// +-----------------------------------------------------------------------+
[2297]3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
[5196]5// | Copyright(C) 2008-2010 Piwigo Team                  http://piwigo.org |
[2297]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// +-----------------------------------------------------------------------+
[1367]23
24/**
25 * This file is included by the main page to show the menu bar
26 *
[1436]27 */
[1367]28
[2488]29include_once(PHPWG_ROOT_PATH.'include/block.class.php');
[1595]30
[2488]31initialize_menu();
[1367]32
[2488]33function initialize_menu()
[1367]34{
[2488]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']) )
[1728]43  {
[2488]44    $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        $data[] = $tpl_var;
73      }
74    }
75    $block->template = 'menubar_links.tpl';
76    $block->data = $data;
[1728]77  }
78
[2488]79//-------------------------------------------------------------- categories
80  $block = $menu->get_block('mbCategories');
81//------------------------------------------------------------------------ filter
[5293]82  if ($conf['menubar_filter_icon'] and !empty($conf['filter_pages']) and get_filter_page_value('used'))
[1728]83  {
[2488]84    if ($filter['enabled'])
[1728]85    {
[2488]86      $template->assign(
87        'U_STOP_FILTER',
88        add_url_params(make_index_url(array()), array('filter' => 'stop'))
[1743]89        );
[1728]90    }
[2488]91    else
92    {
93      $template->assign(
94        'U_START_FILTER',
95        add_url_params(make_index_url(array()), array('filter' => 'start-recent-'.$user['recent_period']))
96        );
97    }
[1728]98  }
[1677]99
[2488]100  if ( $block!=null )
[1722]101  {
[2488]102    $block->data = array(
103      'NB_PICTURE' => $user['nb_total_images'],
[3171]104      'MENU_CATEGORIES' => get_categories_menu(),
[2488]105      'U_CATEGORIES' => make_index_url(array('section' => 'categories')),
106      'U_UPLOAD' => get_upload_menu_link()
107    );
108    $block->template = 'menubar_categories.tpl';
[1722]109  }
[1677]110
[1367]111//------------------------------------------------------------------------ tags
[2488]112  $block = $menu->get_block('mbTags');
113  if ( $block!=null and 'tags'==@$page['section'] and !empty($page['items']) )
[1367]114  {
[5703]115    $tags = get_common_tags(
116      $page['items'],
117      $conf['menubar_tag_cloud_items_number'],
118      $page['tag_ids']
119      );
[2488]120    $tags = add_level_to_tags($tags);
121
122    foreach ($tags as $tag)
123    {
[5703]124      $block->data[] = array_merge(
125        $tag,
126        array(
127          'U_ADD' => make_index_url(
128            array(
129              'tags' => array_merge(
130                $page['tags'],
131                array($tag)
[2488]132                )
[5703]133              )
134            ),
135          )
[2488]136        );
137    }
138    $block->template = 'menubar_tags.tpl';
[1367]139  }
140
[2488]141//----------------------------------------------------------- special categories
142  if ( ($block = $menu->get_block('mbSpecials')) != null )
[1367]143  {
[2488]144    if ( !is_a_guest() )
145    {// favorites
146      $block->data['favorites'] =
[2409]147        array(
[2488]148          'URL' => make_index_url(array('section' => 'favorites')),
[5021]149          'TITLE' => l10n('display my favorites pictures'),
150          'NAME' => l10n('My favorites')
[2488]151          );
152    }
[1367]153
[2488]154    $block->data['most_visited'] =
155      array(
156        'URL' => make_index_url(array('section' => 'most_visited')),
[5021]157        'TITLE' => l10n('display most visited pictures'),
158        'NAME' => l10n('Most visited')
[1367]159      );
160
[2488]161    if ($conf['rate'])
162    {
163       $block->data['best_rated'] =
[1367]164        array(
[2488]165          'URL' => make_index_url(array('section' => 'best_rated')),
[5021]166          'TITLE' => l10n('display best rated items'),
167          'NAME' => l10n('Best rated')
[2488]168        );
169    }
[1367]170
[2488]171    $block->data['random'] =
[2231]172      array(
[2488]173        'URL' => get_root_url().'random.php',
[5021]174        'TITLE' => l10n('display a set of random pictures'),
175        'NAME' => l10n('Random pictures'),
[2488]176        'REL'=> 'rel="nofollow"'
177      );
[1367]178
[2488]179    $block->data['recent_pics'] =
180      array(
181        'URL' => make_index_url(array('section' => 'recent_pics')),
[5021]182        'TITLE' => l10n('display most recent pictures'),
183        'NAME' => l10n('Recent pictures'),
[2488]184      );
[1367]185
[2488]186    $block->data['recent_cats'] =
187      array(
188        'URL' => make_index_url(array('section' => 'recent_cats')),
[5021]189        'TITLE' => l10n('display recently updated categories'),
190        'NAME' => l10n('Recent categories'),
[2488]191      );
[1367]192
[2488]193
194    $block->data['calendar'] =
195      array(
196        'URL' =>
197          make_index_url(
198            array(
199              'chronology_field' => ($conf['calendar_datefield']=='date_available'
200                                      ? 'posted' : 'created'),
201               'chronology_style'=> 'monthly',
202               'chronology_view' => 'calendar'
203            )
204          ),
[5021]205        'TITLE' => l10n('display each day with pictures, month per month'),
206        'NAME' => l10n('Calendar'),
[2488]207        'REL'=> 'rel="nofollow"'
208      );
209    $block->template = 'menubar_specials.tpl';
[1367]210  }
211
[2488]212
213//---------------------------------------------------------------------- summary
214  if ( ($block=$menu->get_block('mbMenu')) != null )
[1367]215  {
[2810]216    // quick search block will be displayed only if data['qsearch'] is set
217    // to "yes"
[2813]218    $block->data['qsearch']=true;
[2810]219
[2488]220    // tags link
221    $block->data['tags'] =
222      array(
223        'TITLE' => l10n('See available tags'),
224        'NAME' => l10n('Tags'),
225        'URL'=> get_root_url().'tags.php',
226      );
[1367]227
[2488]228    // search link
229    $block->data['search'] =
230      array(
[5021]231        'TITLE'=>l10n('search'),
[2488]232        'NAME'=>l10n('Search'),
233        'URL'=> get_root_url().'search.php',
234        'REL'=> 'rel="search"'
235      );
[1367]236
[2488]237    // comments link
238    $block->data['comments'] =
239      array(
[5021]240        'TITLE'=>l10n('See last users comments'),
241        'NAME'=>l10n('Comments'),
[2488]242        'URL'=> get_root_url().'comments.php',
243      );
[1367]244
[2488]245    // about link
246    $block->data['about'] =
247      array(
[5021]248        'TITLE'     => l10n('About Piwigo'),
[2488]249        'NAME'      => l10n('About'),
250        'URL' => get_root_url().'about.php',
251      );
[1367]252
[2488]253    // notification
254    $block->data['rss'] =
255      array(
256        'TITLE'=>l10n('RSS feed'),
257        'NAME'=>l10n('Notification'),
258        'URL'=> get_root_url().'notification.php',
259        'REL'=> 'rel="nofollow"'
260      );
261    $block->template = 'menubar_menu.tpl';
262  }
[1367]263
[1436]264
[2488]265//--------------------------------------------------------------- identification
266  if (is_a_guest())
267  {
268    $template->assign(
269        array(
270          'U_LOGIN' => get_root_url().'identification.php',
[2515]271          'U_LOST_PASSWORD' => get_root_url().'password.php',
[2488]272          'AUTHORIZE_REMEMBERING' => $conf['authorize_remembering']
273        )
274      );
275    if ($conf['allow_user_registration'])
276    {
277      $template->assign( 'U_REGISTER', get_root_url().'register.php');
278    }
279  }
280  else
281  {
[4304]282    $template->assign('USERNAME', stripslashes($user['username']));
[2488]283    if (is_autorize_status(ACCESS_CLASSIC))
284    {
285      $template->assign('U_PROFILE', get_root_url().'profile.php');
286    }
[2325]287
[2488]288    // the logout link has no meaning with Apache authentication : it is not
289    // possible to logout with this kind of authentication.
290    if (!$conf['apache_authentication'])
291    {
292      $template->assign('U_LOGOUT', get_root_url().'?act=logout');
293    }
294    if (is_admin())
295    {
296      $template->assign('U_ADMIN', get_root_url().'admin.php');
297    }
298  }
299  if ( ($block=$menu->get_block('mbIdentification')) != null )
300  {
301    $block->template = 'menubar_identification.tpl';
302  }
303  $menu->apply('MENUBAR',  'menubar.tpl' );
304}
[1367]305?>
Note: See TracBrowser for help on using the repository browser.