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

Last change on this file since 13170 was 12922, checked in by mistic100, 12 years ago

update Piwigo headers to 2012, last change before the expected (or not) apocalypse

  • Property svn:eol-style set to LF
File size: 9.9 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2012 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    );
109    $block->template = 'menubar_categories.tpl';
110  }
111
112//------------------------------------------------------------------------ tags
113  $block = $menu->get_block('mbTags');
114  if ( $block!=null and !empty($page['items']) )
115  {
116    if ('tags'==@$page['section'])
117    {
118      $tags = get_common_tags(
119        $page['items'],
120        $conf['menubar_tag_cloud_items_number'],
121        $page['tag_ids']
122        );
123      $tags = add_level_to_tags($tags);
124
125      foreach ($tags as $tag)
126      {
127        $block->data[] = array_merge(
128          $tag,
129          array(
130            'U_ADD' => make_index_url(
131              array(
132                'tags' => array_merge(
133                  $page['tags'],
134                  array($tag)
135                  )
136                )
137              ),
138            'URL' => make_index_url( array( 'tags' => array($tag) )
139              ),
140            )
141          );
142      }
143    }
144    else
145    {
146      $selection = array_slice( $page['items'], $page['start'], $page['nb_image_page'] );
147      $tags = add_level_to_tags( get_common_tags($selection, $conf['content_tag_cloud_items_number']) );
148      foreach ($tags as $tag)
149      {
150        $block->data[] =
151        array_merge( $tag,
152          array(
153            'URL' => make_index_url( array( 'tags' => array($tag) ) ),
154          )
155        );
156      }
157    }
158    if ( !empty($block->data) )
159    {
160      $block->template = 'menubar_tags.tpl';
161    }
162  }
163
164//----------------------------------------------------------- special categories
165  if ( ($block = $menu->get_block('mbSpecials')) != null )
166  {
167    if ( !is_a_guest() )
168    {// favorites
169      $block->data['favorites'] =
170        array(
171          'URL' => make_index_url(array('section' => 'favorites')),
172          'TITLE' => l10n('display your favorites photos'),
173          'NAME' => l10n('Your favorites')
174          );
175    }
176
177    $block->data['most_visited'] =
178      array(
179        'URL' => make_index_url(array('section' => 'most_visited')),
180        'TITLE' => l10n('display most visited photos'),
181        'NAME' => l10n('Most visited')
182      );
183
184    if ($conf['rate'])
185    {
186       $block->data['best_rated'] =
187        array(
188          'URL' => make_index_url(array('section' => 'best_rated')),
189          'TITLE' => l10n('display best rated photos'),
190          'NAME' => l10n('Best rated')
191        );
192    }
193
194    $block->data['random'] =
195      array(
196        'URL' => get_root_url().'random.php',
197        'TITLE' => l10n('display a set of random photos'),
198        'NAME' => l10n('Random photos'),
199        'REL'=> 'rel="nofollow"'
200      );
201
202    $block->data['recent_pics'] =
203      array(
204        'URL' => make_index_url(array('section' => 'recent_pics')),
205        'TITLE' => l10n('display most recent photos'),
206        'NAME' => l10n('Recent photos'),
207      );
208
209    $block->data['recent_cats'] =
210      array(
211        'URL' => make_index_url(array('section' => 'recent_cats')),
212        'TITLE' => l10n('display recently updated albums'),
213        'NAME' => l10n('Recent albums'),
214      );
215
216
217    $block->data['calendar'] =
218      array(
219        'URL' =>
220          make_index_url(
221            array(
222              'chronology_field' => ($conf['calendar_datefield']=='date_available'
223                                      ? 'posted' : 'created'),
224               'chronology_style'=> 'monthly',
225               'chronology_view' => 'calendar'
226            )
227          ),
228        'TITLE' => l10n('display each day with photos, month per month'),
229        'NAME' => l10n('Calendar'),
230        'REL'=> 'rel="nofollow"'
231      );
232    $block->template = 'menubar_specials.tpl';
233  }
234
235
236//---------------------------------------------------------------------- summary
237  if ( ($block=$menu->get_block('mbMenu')) != null )
238  {
239    // quick search block will be displayed only if data['qsearch'] is set
240    // to "yes"
241    $block->data['qsearch']=true;
242
243    // tags link
244    $block->data['tags'] =
245      array(
246        'TITLE' => l10n('display available tags'),
247        'NAME' => l10n('Tags'),
248        'URL'=> get_root_url().'tags.php',
249      );
250
251    // search link
252    $block->data['search'] =
253      array(
254        'TITLE'=>l10n('search'),
255        'NAME'=>l10n('Search'),
256        'URL'=> get_root_url().'search.php',
257        'REL'=> 'rel="search"'
258      );
259
260    if ($conf['activate_comments'])
261    {
262      // comments link
263      $block->data['comments'] =
264        array(
265          'TITLE'=>l10n('display last user comments'),
266          'NAME'=>l10n('Comments'),
267          'URL'=> get_root_url().'comments.php',
268        );
269    }
270
271    // about link
272    $block->data['about'] =
273      array(
274        'TITLE'     => l10n('About Piwigo'),
275        'NAME'      => l10n('About'),
276        'URL' => get_root_url().'about.php',
277      );
278
279    // notification
280    $block->data['rss'] =
281      array(
282        'TITLE'=>l10n('RSS feed'),
283        'NAME'=>l10n('Notification'),
284        'URL'=> get_root_url().'notification.php',
285        'REL'=> 'rel="nofollow"'
286      );
287    $block->template = 'menubar_menu.tpl';
288  }
289
290
291//--------------------------------------------------------------- identification
292  if (is_a_guest())
293  {
294    $template->assign(
295        array(
296          'U_LOGIN' => get_root_url().'identification.php',
297          'U_LOST_PASSWORD' => get_root_url().'password.php',
298          'AUTHORIZE_REMEMBERING' => $conf['authorize_remembering']
299        )
300      );
301    if ($conf['allow_user_registration'])
302    {
303      $template->assign( 'U_REGISTER', get_root_url().'register.php');
304    }
305  }
306  else
307  {
308    $template->assign('USERNAME', stripslashes($user['username']));
309    if (is_autorize_status(ACCESS_CLASSIC))
310    {
311      $template->assign('U_PROFILE', get_root_url().'profile.php');
312    }
313
314    // the logout link has no meaning with Apache authentication : it is not
315    // possible to logout with this kind of authentication.
316    if (!$conf['apache_authentication'])
317    {
318      $template->assign('U_LOGOUT', get_root_url().'?act=logout');
319    }
320    if (is_admin())
321    {
322      $template->assign('U_ADMIN', get_root_url().'admin.php');
323    }
324  }
325  if ( ($block=$menu->get_block('mbIdentification')) != null )
326  {
327    $block->template = 'menubar_identification.tpl';
328  }
329  $menu->apply('MENUBAR',  'menubar.tpl' );
330}
331?>
Note: See TracBrowser for help on using the repository browser.