Skip to content
Permalink
Browse files

fixes #1102 limit the number of tags shown in the menubar

  • Loading branch information...
plegall committed Oct 15, 2019
1 parent c4142c2 commit 41b4230b39e4bf2b02b6fd38fdba1e1d2903bf73
Showing with 17 additions and 20 deletions.
  1. +14 −0 include/functions_tag.inc.php
  2. +2 −0 include/menubar.inc.php
  3. +1 −20 tags.php
@@ -308,4 +308,18 @@ function find_tags($ids=array(), $url_names=array(), $names=array() )
return query2array($query);
}
function tags_id_compare($a, $b)
{
return ($a['id'] < $b['id']) ? -1 : 1;
}
function tags_counter_compare($a, $b)
{
if ($a['counter'] == $b['counter'])
{
return tags_id_compare($a, $b);
}
return ($a['counter'] < $b['counter']) ? +1 : -1;
}
?>
@@ -138,6 +138,8 @@ function initialize_menu()
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(
@@ -6,25 +6,6 @@
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
// +-----------------------------------------------------------------------+
// | functions |
// +-----------------------------------------------------------------------+
function counter_compare($a, $b)
{
if ($a['counter'] == $b['counter'])
{
return id_compare($a, $b);
}
return ($a['counter'] < $b['counter']) ? +1 : -1;
}
function id_compare($a, $b)
{
return ($a['id'] < $b['id']) ? -1 : 1;
}
// +-----------------------------------------------------------------------+
// | initialization |
// +-----------------------------------------------------------------------+
@@ -145,7 +126,7 @@ function id_compare($a, $b)
// we want only the first most represented tags, so we sort them by counter
// and take the first tags
usort($tags, 'counter_compare');
usort($tags, 'tags_counter_compare');
$tags = array_slice($tags, 0, $conf['full_tag_cloud_items_number']);
// depending on its counter and the other tags counter, each tag has a level

0 comments on commit 41b4230

Please sign in to comment.
You can’t perform that action at this time.