fixes #2414 change related tags display

Add conf to display or not the related tag options by default
Add templates and css for new display
This commit is contained in:
HWFord
2025-10-03 15:43:29 +02:00
committed by GitHub
parent f930b6b524
commit b682fd0cd3
13 changed files with 332 additions and 109 deletions

View File

@@ -411,42 +411,25 @@ function get_tags_content_title()
for ($i=0; $i<count($page['tags']); $i++)
{
$title.= $i>0 ? ' + ' : '';
$title.=
'<a href="'
.make_index_url(
array(
'tags' => array( $page['tags'][$i] )
)
)
.'" title="'
.l10n('display photos linked to this tag')
.'">'
.trigger_change('render_tag_name', $page['tags'][$i]['name'], $page['tags'][$i])
.'</a>';
if (count($page['tags']) > 1)
if (1 == count($page['tags']))
{
$other_tags = $page['tags'];
unset($other_tags[$i]);
$remove_url = make_index_url(
array(
'tags' => $other_tags
)
);
$title.=
'<a id="TagsGroupRemoveTag" href="'.$remove_url.'" style="border:none;" title="'
.l10n('remove this tag from the list')
.'"><img src="'
.get_root_url().get_themeconf('icon_dir').'/remove_s.png'
.'" alt="x" style="vertical-align:bottom;" >'
.'<span class="pwg-icon pwg-icon-close" ></span>'
.'<i class="fas fa-plus" aria-hidden="true"></i>'
'<a href="'
.make_index_url(
array(
'tags' => array( $page['tags'][$i] )
)
)
.'" title="'
.l10n('display photos linked to this tag')
.'">'
.trigger_change('render_tag_name', $page['tags'][$i]['name'], $page['tags'][$i])
.'</a>';
}
}
return $title;
}
@@ -557,7 +540,7 @@ function register_default_menubar_blocks($menu_ref_arr)
return;
$menu->register_block( new RegisteredBlock( 'mbLinks', 'Links', 'piwigo'));
$menu->register_block( new RegisteredBlock( 'mbCategories', 'Albums', 'piwigo'));
$menu->register_block( new RegisteredBlock( 'mbTags', 'Related tags', 'piwigo'));
$menu->register_block( new RegisteredBlock( 'mbTags', 'Tags', 'piwigo'));
$menu->register_block( new RegisteredBlock( 'mbSpecials', 'Specials', 'piwigo'));
$menu->register_block( new RegisteredBlock( 'mbMenu', 'Menu', 'piwigo'));
$menu->register_block( new RegisteredBlock( 'mbRelatedCategories', 'Related albums', 'piwigo') );

View File

@@ -143,68 +143,19 @@ function initialize_menu()
$block = $menu->get_block('mbTags');
if ( $block!=null and 'picture' != script_basename() )
{
if ('tags'==@$page['section'])
$tags = get_available_tags();
usort($tags, 'tags_counter_compare');
$tags = array_slice($tags, 0, $conf['menubar_tag_cloud_items_number']);
foreach ($tags as $tag)
{
$tags = get_common_tags(
$page['items'],
$conf['menubar_tag_cloud_items_number'],
$page['tag_ids']
);
$tags = add_level_to_tags($tags);
$block->data[] = array_merge(
$tag,
array(
'URL' => make_index_url( array( 'tags' => array($tag) ) ),
)
);
}
foreach ($tags as $tag)
{
$block->data[] = array_merge(
$tag,
array(
'U_ADD' => make_index_url(
array(
'tags' => array_merge(
$page['tags'],
array($tag)
)
)
),
'URL' => make_index_url( array( 'tags' => array($tag) )
),
)
);
}
$template->assign( 'IS_RELATED', false);
}
//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();
usort($tags, 'tags_counter_compare');
$tags = array_slice($tags, 0, $conf['menubar_tag_cloud_items_number']);
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)
{
$block->data[] =
array_merge( $tag,
array(
'URL' => make_index_url( array( 'tags' => array($tag) ) ),
)
);
}
$template->assign( 'IS_RELATED', true);
}
if ( !empty($block->data) )
{
$block->template = 'menubar_tags.tpl';

View File

@@ -0,0 +1,45 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
global $page;
$selected_related_tags_info = array();
if (count($page['tags']) > 1)
{
foreach ($page['tags'] as $key=>$tag)
{
$other_tags = $page['tags'];
unset($other_tags[$key]);
$selected_related_tags_info[$key] =
array(
'tag_name' => trigger_change('render_tag_name', $page['tags'][$key]['name'], $page['tags'][$key]),
'item_count' => '',
'index_url' => make_index_url(
array(
'tags' => array( $page['tags'][$key] )
)
),
'remove_url' => make_index_url(
array(
'tags' => $other_tags
)
)
);
}
}
$template->assign(
array(
'SELECT_RELATED_TAGS' => $selected_related_tags_info,
)
);
$template->set_filename('selected_tags', 'include/selected_tags.inc.tpl');
$template->assign_var_from_handle('SELECTED_TAGS_TEMPLATE', 'selected_tags');