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
This commit is contained in:
flop25 2017-09-05 14:47:27 +02:00
parent 06952b2d5a
commit 06a50ca8b0
3 changed files with 29 additions and 3 deletions

View file

@ -635,6 +635,14 @@ $conf['full_tag_cloud_items_number'] = 200;
// cloud in the menubar. Only the most represented tags will be shown // cloud in the menubar. Only the most represented tags will be shown
$conf['menubar_tag_cloud_items_number'] = 20; $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 // 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 // cloud on the content page, when the current section is not a set of
// tags. Only the most represented tags will be shown // tags. Only the most represented tags will be shown

View file

@ -118,7 +118,7 @@ function initialize_menu()
//------------------------------------------------------------------------ tags //------------------------------------------------------------------------ tags
$block = $menu->get_block('mbTags'); $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']) 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'] ); $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']) ); $tags = add_level_to_tags( get_common_tags($selection, $conf['content_tag_cloud_items_number']) );
foreach ($tags as $tag) foreach ($tags as $tag)
@ -161,6 +178,7 @@ function initialize_menu()
) )
); );
} }
$template->assign( 'IS_RELATED', true);
} }
if ( !empty($block->data) ) if ( !empty($block->data) )
{ {

View file

@ -1,4 +1,4 @@
<dt>{'Related tags'|@translate}</dt> <dt>{if $IS_RELATED}{'Related tags'|@translate}{else}{'Tags'|@translate}{/if}</dt>
<dd> <dd>
<div id="menuTagCloud"> <div id="menuTagCloud">
{foreach from=$block->data item=tag} {foreach from=$block->data item=tag}