aboutsummaryrefslogtreecommitdiffstats
path: root/include/menubar.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2008-08-28 00:32:39 +0000
committerrvelices <rv-github@modusoptimus.com>2008-08-28 00:32:39 +0000
commitabb2f22b2e96a89a44ad9d36db3bf612c6f88b9f (patch)
treeca36d7b1bd7035f9952c4f564406eaa87c954cdb /include/menubar.inc.php
parent7f956e71b91f32ff6ca87ea6a0f56cc0f02c7005 (diff)
- based on test_menu by grum (thanks to you) - integration of dynamic menu bar to pwg
- the menubar is composed now of dynamic blocks that can be ordered/hidden - plugins can add their own blocks git-svn-id: http://piwigo.org/svn/trunk@2488 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/menubar.inc.php')
-rw-r--r--include/menubar.inc.php467
1 files changed, 232 insertions, 235 deletions
diff --git a/include/menubar.inc.php b/include/menubar.inc.php
index 0ff64827e..b04a960a8 100644
--- a/include/menubar.inc.php
+++ b/include/menubar.inc.php
@@ -25,281 +25,278 @@
* This file is included by the main page to show the menu bar
*
*/
-$template->set_filenames(
- array(
- 'menubar' => 'menubar.tpl',
- )
- );
-trigger_action('loc_begin_menubar');
+include_once(PHPWG_ROOT_PATH.'include/block.class.php');
-$template->assign(
- array(
- 'NB_PICTURE' => $user['nb_total_images'],
- 'MENU_CATEGORIES_CONTENT' => get_categories_menu(),
- 'U_CATEGORIES' => make_index_url(array('section' => 'categories')),
- 'U_LOST_PASSWORD' => get_root_url().'password.php',
- 'U_UPLOAD' => get_upload_menu_link()
- )
- );
+initialize_menu();
-//-------------------------------------------------------------- external links
-foreach ($conf['links'] as $url => $url_data)
+function initialize_menu()
{
- if (!is_array($url_data))
- {
- $url_data = array('label' => $url_data);
- }
+ global $page, $conf, $user, $template, $filter;
- if
- (
- (!isset($url_data['eval_visible']))
- or
- (eval($url_data['eval_visible']))
- )
- {
- $tpl_var = array(
- 'URL' => $url,
- 'LABEL' => $url_data['label']
- );
+ $menu = new BlockManager("menubar");
+ $menu->load_registered_blocks();
+ $menu->prepare_display();
- if (!isset($url_data['new_window']) or $url_data['new_window'])
+//--------------------------------------------------------------- external links
+ if ( ($block=$menu->get_block('mbLinks')) and !empty($conf['links']) )
+ {
+ $data = array();
+ foreach ($conf['links'] as $url => $url_data)
{
- $tpl_var['new_window'] =
- array(
- 'NAME' => (isset($url_data['nw_name']) ? $url_data['nw_name'] : ''),
- 'FEATURES' => (isset($url_data['nw_features']) ? $url_data['nw_features'] : '')
- );
+ if (!is_array($url_data))
+ {
+ $url_data = array('label' => $url_data);
+ }
+
+ if
+ (
+ (!isset($url_data['eval_visible']))
+ or
+ (eval($url_data['eval_visible']))
+ )
+ {
+ $tpl_var = array(
+ 'URL' => $url,
+ 'LABEL' => $url_data['label']
+ );
+
+ if (!isset($url_data['new_window']) or $url_data['new_window'])
+ {
+ $tpl_var['new_window'] =
+ array(
+ 'NAME' => (isset($url_data['nw_name']) ? $url_data['nw_name'] : ''),
+ 'FEATURES' => (isset($url_data['nw_features']) ? $url_data['nw_features'] : '')
+ );
+ }
+ $data[] = $tpl_var;
+ }
}
- $template->append('links', $tpl_var);
+ $block->template = 'menubar_links.tpl';
+ $block->data = $data;
}
-}
+//-------------------------------------------------------------- categories
+ $block = $menu->get_block('mbCategories');
//------------------------------------------------------------------------ filter
-if (!empty($conf['filter_pages']) and get_filter_page_value('used'))
-{
- if ($filter['enabled'])
+ if (!empty($conf['filter_pages']) and get_filter_page_value('used'))
{
- $template->assign(
- 'U_STOP_FILTER',
- add_url_params(make_index_url(array()), array('filter' => 'stop'))
- );
+ if ($filter['enabled'])
+ {
+ $template->assign(
+ 'U_STOP_FILTER',
+ add_url_params(make_index_url(array()), array('filter' => 'stop'))
+ );
+ }
+ else
+ {
+ $template->assign(
+ 'U_START_FILTER',
+ add_url_params(make_index_url(array()), array('filter' => 'start-recent-'.$user['recent_period']))
+ );
+ }
}
- else
+
+ if ( $block!=null )
{
- $template->assign(
- 'U_START_FILTER',
- add_url_params(make_index_url(array()), array('filter' => 'start-recent-'.$user['recent_period']))
- );
+ $block->data = array(
+ 'NB_PICTURE' => $user['nb_total_images'],
+ 'MENU_CATEGORIES_CONTENT' => get_categories_menu(),
+ 'U_CATEGORIES' => make_index_url(array('section' => 'categories')),
+ 'U_UPLOAD' => get_upload_menu_link()
+ );
+ $block->template = 'menubar_categories.tpl';
}
-}
//------------------------------------------------------------------------ tags
-if ('tags' == @$page['section'])
-{
- // display tags associated to currently tagged items, less current tags
- $tags = array();
- if ( !empty($page['items']) )
+ $block = $menu->get_block('mbTags');
+ if ( $block!=null and 'tags'==@$page['section'] and !empty($page['items']) )
{
$tags = get_common_tags($page['items'],
- $conf['menubar_tag_cloud_items_number'], $page['tag_ids']);
- }
+ $conf['menubar_tag_cloud_items_number'], $page['tag_ids']);
+ $tags = add_level_to_tags($tags);
- $tags = add_level_to_tags($tags);
+ foreach ($tags as $tag)
+ {
+ $block->data[] =
+ array_merge( $tag,
+ array(
+ 'URL' => make_index_url(
+ array(
+ 'tags' => array($tag)
+ )
+ ),
+ 'U_ADD' => make_index_url(
+ array(
+ 'tags' => array_merge(
+ $page['tags'],
+ array($tag)
+ )
+ )
+ ),
+ )
+ );
+ }
+ $block->template = 'menubar_tags.tpl';
+ }
- foreach ($tags as $tag)
+//----------------------------------------------------------- special categories
+ if ( ($block = $menu->get_block('mbSpecials')) != null )
{
- $template->append(
- 'related_tags',
- array_merge( $tag,
+ if ( !is_a_guest() )
+ {// favorites
+ $block->data['favorites'] =
array(
- 'URL' => make_index_url(
- array(
- 'tags' => array($tag)
- )
- ),
+ 'URL' => make_index_url(array('section' => 'favorites')),
+ 'TITLE' => l10n('favorite_cat_hint'),
+ 'NAME' => l10n('favorite_cat')
+ );
+ }
- 'U_ADD' => make_index_url(
- array(
- 'tags' => array_merge(
- $page['tags'],
- array($tag)
- )
- )
- ),
- )
- )
+ $block->data['most_visited'] =
+ array(
+ 'URL' => make_index_url(array('section' => 'most_visited')),
+ 'TITLE' => l10n('most_visited_cat_hint'),
+ 'NAME' => l10n('most_visited_cat')
);
- }
-}
-//---------------------------------------------------------- special categories
-// favorites categories
-if ( !is_a_guest() )
-{
- $template->append(
- 'special_categories',
- array(
- 'URL' => make_index_url(array('section' => 'favorites')),
- 'TITLE' => l10n('favorite_cat_hint'),
- 'NAME' => l10n('favorite_cat')
- ));
-}
-// most visited
-$template->append(
- 'special_categories',
- array(
- 'URL' => make_index_url(array('section' => 'most_visited')),
- 'TITLE' => l10n('most_visited_cat_hint'),
- 'NAME' => l10n('most_visited_cat')
- ));
-// best rated
-if ($conf['rate'])
-{
- $template->append(
- 'special_categories',
- array(
- 'URL' => make_index_url(array('section' => 'best_rated')),
- 'TITLE' => l10n('best_rated_cat_hint'),
- 'NAME' => l10n('best_rated_cat')
- )
- );
-}
-// random
-$template->append(
- 'special_categories',
- array(
- 'URL' => get_root_url().'random.php',
- 'TITLE' => l10n('random_cat_hint'),
- 'NAME' => l10n('random_cat'),
- 'REL'=> 'rel="nofollow"'
- ));
-// recent pics
-$template->append(
- 'special_categories',
- array(
- 'URL' => make_index_url(array('section' => 'recent_pics')),
- 'TITLE' => l10n('recent_pics_cat_hint'),
- 'NAME' => l10n('recent_pics_cat'),
- ));
-// recent cats
-$template->append(
- 'special_categories',
- array(
- 'URL' => make_index_url(array('section' => 'recent_cats')),
- 'TITLE' => l10n('recent_cats_cat_hint'),
- 'NAME' => l10n('recent_cats_cat'),
- ));
-
-// calendar
-$template->append(
- 'special_categories',
- array(
- 'URL' =>
- make_index_url(
+ if ($conf['rate'])
+ {
+ $block->data['best_rated'] =
array(
- 'chronology_field' => ($conf['calendar_datefield']=='date_available'
- ? 'posted' : 'created'),
- 'chronology_style'=> 'monthly',
- 'chronology_view' => 'calendar'
- )
- ),
- 'TITLE' => l10n('calendar_hint'),
- 'NAME' => l10n('calendar'),
- 'REL'=> 'rel="nofollow"'
- )
- );
-//--------------------------------------------------------------------- summary
+ 'URL' => make_index_url(array('section' => 'best_rated')),
+ 'TITLE' => l10n('best_rated_cat_hint'),
+ 'NAME' => l10n('best_rated_cat')
+ );
+ }
-if (is_a_guest())
-{
- $template->assign(
+ $block->data['random'] =
array(
- 'U_IDENTIFY' => get_root_url().'identification.php',
- 'AUTHORIZE_REMEMBERING' => $conf['authorize_remembering']
- )
- );
+ 'URL' => get_root_url().'random.php',
+ 'TITLE' => l10n('random_cat_hint'),
+ 'NAME' => l10n('random_cat'),
+ 'REL'=> 'rel="nofollow"'
+ );
- if ($conf['allow_user_registration'])
- {
- $template->assign( 'U_REGISTER', get_root_url().'register.php');
- }
-}
-else
-{
- $template->assign('USERNAME', $user['username']);
+ $block->data['recent_pics'] =
+ array(
+ 'URL' => make_index_url(array('section' => 'recent_pics')),
+ 'TITLE' => l10n('recent_pics_cat_hint'),
+ 'NAME' => l10n('recent_pics_cat'),
+ );
- if (is_autorize_status(ACCESS_CLASSIC))
- {
- $template->assign('U_PROFILE', get_root_url().'profile.php');
- }
+ $block->data['recent_cats'] =
+ array(
+ 'URL' => make_index_url(array('section' => 'recent_cats')),
+ 'TITLE' => l10n('recent_cats_cat_hint'),
+ 'NAME' => l10n('recent_cats_cat'),
+ );
- // the logout link has no meaning with Apache authentication : it is not
- // possible to logout with this kind of authentication.
- if (!$conf['apache_authentication'])
- {
- $template->assign('U_LOGOUT', get_root_url().'?act=logout');
+
+ $block->data['calendar'] =
+ array(
+ 'URL' =>
+ make_index_url(
+ array(
+ 'chronology_field' => ($conf['calendar_datefield']=='date_available'
+ ? 'posted' : 'created'),
+ 'chronology_style'=> 'monthly',
+ 'chronology_view' => 'calendar'
+ )
+ ),
+ 'TITLE' => l10n('calendar_hint'),
+ 'NAME' => l10n('calendar'),
+ 'REL'=> 'rel="nofollow"'
+ );
+ $block->template = 'menubar_specials.tpl';
}
- if (is_admin())
+
+//---------------------------------------------------------------------- summary
+ if ( ($block=$menu->get_block('mbMenu')) != null )
{
- $template->assign('U_ADMIN', get_root_url().'admin.php');
- }
-}
+ // tags link
+ $block->data['tags'] =
+ array(
+ 'TITLE' => l10n('See available tags'),
+ 'NAME' => l10n('Tags'),
+ 'URL'=> get_root_url().'tags.php',
+ );
-// tags link
-$template->append(
- 'summaries',
- array(
- 'TITLE' => l10n('See available tags'),
- 'NAME' => l10n('Tags'),
- 'U_SUMMARY'=> get_root_url().'tags.php',
- )
- );
+ // search link
+ $block->data['search'] =
+ array(
+ 'TITLE'=>l10n('hint_search'),
+ 'NAME'=>l10n('Search'),
+ 'URL'=> get_root_url().'search.php',
+ 'REL'=> 'rel="search"'
+ );
-// search link
-$template->append(
- 'summaries',
- array(
- 'TITLE'=>l10n('hint_search'),
- 'NAME'=>l10n('Search'),
- 'U_SUMMARY'=> get_root_url().'search.php',
- 'REL'=> 'rel="search"'
- )
- );
+ // comments link
+ $block->data['comments'] =
+ array(
+ 'TITLE'=>l10n('hint_comments'),
+ 'NAME'=>l10n('comments'),
+ 'URL'=> get_root_url().'comments.php',
+ );
-// comments link
-$template->append(
- 'summaries',
- array(
- 'TITLE'=>l10n('hint_comments'),
- 'NAME'=>l10n('comments'),
- 'U_SUMMARY'=> get_root_url().'comments.php',
- )
- );
+ // about link
+ $block->data['about'] =
+ array(
+ 'TITLE' => l10n('about_page_title'),
+ 'NAME' => l10n('About'),
+ 'URL' => get_root_url().'about.php',
+ );
-// about link
-$template->append(
- 'summaries',
- array(
- 'TITLE' => l10n('about_page_title'),
- 'NAME' => l10n('About'),
- 'U_SUMMARY' => get_root_url().'about.php',
- )
- );
+ // notification
+ $block->data['rss'] =
+ array(
+ 'TITLE'=>l10n('RSS feed'),
+ 'NAME'=>l10n('Notification'),
+ 'URL'=> get_root_url().'notification.php',
+ 'REL'=> 'rel="nofollow"'
+ );
+ $block->template = 'menubar_menu.tpl';
+ }
-// notification
-$template->append(
- 'summaries',
- array(
- 'TITLE'=>l10n('RSS feed'),
- 'NAME'=>l10n('Notification'),
- 'U_SUMMARY'=> get_root_url().'notification.php',
- 'REL'=> 'rel="nofollow"'
- )
- );
-trigger_action('loc_end_menubar');
-$template->assign_var_from_handle('MENUBAR', 'menubar');
+//--------------------------------------------------------------- identification
+ if (is_a_guest())
+ {
+ $template->assign(
+ array(
+ 'U_LOGIN' => get_root_url().'identification.php',
+ 'AUTHORIZE_REMEMBERING' => $conf['authorize_remembering']
+ )
+ );
+ if ($conf['allow_user_registration'])
+ {
+ $template->assign( 'U_REGISTER', get_root_url().'register.php');
+ }
+ }
+ else
+ {
+ $template->assign('USERNAME', $user['username']);
+ if (is_autorize_status(ACCESS_CLASSIC))
+ {
+ $template->assign('U_PROFILE', get_root_url().'profile.php');
+ }
+ // the logout link has no meaning with Apache authentication : it is not
+ // possible to logout with this kind of authentication.
+ if (!$conf['apache_authentication'])
+ {
+ $template->assign('U_LOGOUT', get_root_url().'?act=logout');
+ }
+ if (is_admin())
+ {
+ $template->assign('U_ADMIN', get_root_url().'admin.php');
+ }
+ }
+ if ( ($block=$menu->get_block('mbIdentification')) != null )
+ {
+ $block->template = 'menubar_identification.tpl';
+ }
+ $menu->apply('MENUBAR', 'menubar.tpl' );
+}
?>