From 06a50ca8b099894fed024258c0c26e0cfad7a987 Mon Sep 17 00:00:00 2001 From: flop25 Date: Tue, 5 Sep 2017 14:47:27 +0200 Subject: [PATCH] Feature #759, choose to display all Tags and/or current ones This commit introduces a new config var and a minor change in a tpl (language key switch) It also change the default behaviour; can be set back to the previous one with $conf['menubar_tag_cloud_content'] = 'current_only' Potential Performance issue; test needed --- include/config_default.inc.php | 8 ++++++++ include/menubar.inc.php | 22 ++++++++++++++++++++-- themes/default/template/menubar_tags.tpl | 2 +- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/include/config_default.inc.php b/include/config_default.inc.php index 5bc8691d3..5bf61d70d 100644 --- a/include/config_default.inc.php +++ b/include/config_default.inc.php @@ -635,6 +635,14 @@ $conf['full_tag_cloud_items_number'] = 200; // cloud in the menubar. Only the most represented tags will be shown $conf['menubar_tag_cloud_items_number'] = 20; +// menubar_tag_cloud_content: 'always_all', 'current_only' or 'all_or_current' +// For the tag cloud in the menubar. +// 'always_all': tag cloud always displays all tags available to the user +// 'current_only': tag cloud always displays the tags from the current pictures +// 'all_or_current': when pictures are displayed, tag cloud shows their tags, but +// when none are displayed, all the tags available to the user are shown. +$conf['menubar_tag_cloud_content'] = 'all_or_current'; + // content_tag_cloud_items_number: number of related tags to show in the tag // cloud on the content page, when the current section is not a set of // tags. Only the most represented tags will be shown diff --git a/include/menubar.inc.php b/include/menubar.inc.php index 9fe2ceaab..6b9a183f2 100644 --- a/include/menubar.inc.php +++ b/include/menubar.inc.php @@ -118,7 +118,7 @@ function initialize_menu() //------------------------------------------------------------------------ tags $block = $menu->get_block('mbTags'); - if ( $block!=null and !empty($page['items']) and 'picture' != script_basename() ) + if ( $block!=null and 'picture' != script_basename() ) { if ('tags'==@$page['section']) { @@ -147,9 +147,26 @@ function initialize_menu() ) ); } + $template->assign( 'IS_RELATED', false); } - else + //displays all tags available for the current user + else if ($conf['menubar_tag_cloud_content'] == 'always_all' or ($conf['menubar_tag_cloud_content'] == 'all_or_current' and empty($page['items'])) ) { + $tags = get_available_tags(); + foreach ($tags as $tag) + { + $block->data[] = array_merge( + $tag, + array( + 'URL' => make_index_url( array( 'tags' => array($tag) ) ), + ) + ); + } + $template->assign( 'IS_RELATED', false); + } + //displays only the tags available from the current thumbnails displayed + else if ( !empty($page['items']) and ($conf['menubar_tag_cloud_content'] == 'current_only' or $conf['menubar_tag_cloud_content'] == 'all_or_current') ) + { $selection = array_slice( $page['items'], $page['start'], $page['nb_image_page'] ); $tags = add_level_to_tags( get_common_tags($selection, $conf['content_tag_cloud_items_number']) ); foreach ($tags as $tag) @@ -161,6 +178,7 @@ function initialize_menu() ) ); } + $template->assign( 'IS_RELATED', true); } if ( !empty($block->data) ) { diff --git a/themes/default/template/menubar_tags.tpl b/themes/default/template/menubar_tags.tpl index d1a672837..9216e94d6 100644 --- a/themes/default/template/menubar_tags.tpl +++ b/themes/default/template/menubar_tags.tpl @@ -1,4 +1,4 @@ -
{'Related tags'|@translate}
+
{if $IS_RELATED}{'Related tags'|@translate}{else}{'Tags'|@translate}{/if}