Skip to content

Commit

Permalink
Feature #759, choose to display all Tags and/or current ones
Browse files Browse the repository at this point in the history
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
  • Loading branch information
flop25 committed Sep 5, 2017
1 parent 06952b2 commit 06a50ca
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
8 changes: 8 additions & 0 deletions include/config_default.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,14 @@
// 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
Expand Down
22 changes: 20 additions & 2 deletions include/menubar.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
{
Expand Down Expand Up @@ -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)
Expand All @@ -161,6 +178,7 @@ function initialize_menu()
)
);
}
$template->assign( 'IS_RELATED', true);
}
if ( !empty($block->data) )
{
Expand Down
2 changes: 1 addition & 1 deletion themes/default/template/menubar_tags.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<dt>{'Related tags'|@translate}</dt>
<dt>{if $IS_RELATED}{'Related tags'|@translate}{else}{'Tags'|@translate}{/if}</dt>
<dd>
<div id="menuTagCloud">
{foreach from=$block->data item=tag}
Expand Down

0 comments on commit 06a50ca

Please sign in to comment.