From 28718d254db996189bdd3bc987b1a076ac1742ce Mon Sep 17 00:00:00 2001 From: Paul Poulain Date: Tue, 21 Apr 2009 18:52:51 +0200 Subject: [PATCH] bugfix for ??? Tag cloud fixes : * ordering cloud by tag name, not by weight * improve behaviour : either display everyone cloud or my cloud only. When clicquing on "Tag cloud" on the top, will display by default everyone cloud. when clicquing on "My tag" (left tab when logged in), the page will display only my tags and my tags only --- C4/Tags.pm | 5 +++-- koha-tmpl/opac-tmpl/prog/en/includes/usermenu.inc | 2 +- koha-tmpl/opac-tmpl/prog/en/modules/opac-tags.tmpl | 1 - opac/opac-tags.pl | 12 +++++++----- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/C4/Tags.pm b/C4/Tags.pm index 5f2ff6988a..ecd9758b30 100644 --- a/C4/Tags.pm +++ b/C4/Tags.pm @@ -261,7 +261,7 @@ sub get_tags (;$) { # i.e., from tags_index sub get_approval_rows (;$) { # i.e., from tags_approval my $hash = shift || {}; - my @ok_fields = qw(term approved date_approved approved_by weight_total limit sort); + my @ok_fields = qw(term approved date_approved approved_by weight_total limit sort borrowernumber); my $wheres; my $limit = ""; my $order = ""; @@ -279,7 +279,7 @@ sub get_approval_rows (;$) { # i.e., from tags_approval if ($key eq 'limit') { my $val = $hash->{$key}; unless ($val =~ /^(\d+,)?\d+$/) { - carp "Non-nuerical limit value '$val' ignored!"; + carp "Non-numerical limit value '$val' ignored!"; next; } $limit = " LIMIT $val\n"; @@ -288,6 +288,7 @@ sub get_approval_rows (;$) { # i.e., from tags_approval unless ( $by =~ /^([-+])?(term)/ or $by =~ /^([-+])?(biblionumber)/ or + $by =~ /^([-+])?(borrowernumber)/ or $by =~ /^([-+])?(weight_total)/ or $by =~ /^([-+])?(approved(_by)?)/ or $by =~ /^([-+])?(date_approved)/ diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/usermenu.inc b/koha-tmpl/opac-tmpl/prog/en/includes/usermenu.inc index a8fc320fcd..1e0071a363 100644 --- a/koha-tmpl/opac-tmpl/prog/en/includes/usermenu.inc +++ b/koha-tmpl/opac-tmpl/prog/en/includes/usermenu.inc @@ -9,7 +9,7 @@
  • my personal details
  • -
  • my tags
  • +
  • my tags
  • change my password
  • diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-tags.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-tags.tmpl index 2f4aa9ecf8..8681a8aa12 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-tags.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-tags.tmpl @@ -134,7 +134,6 @@ - diff --git a/opac/opac-tags.pl b/opac/opac-tags.pl index 296fa07341..dc229fdbd8 100755 --- a/opac/opac-tags.pl +++ b/opac/opac-tags.pl @@ -219,7 +219,7 @@ if ($is_ajax) { my $results = []; my $my_tags = []; -if ($loggedinuser and not $query->param('hidemytags')) { +if ($loggedinuser) { $my_tags = get_tag_rows({borrowernumber=>$loggedinuser}); foreach (@$my_tags) { my $biblio = GetBiblioData($_->{biblionumber}); @@ -244,12 +244,14 @@ if ($add_op) { deleted_count => $dels, ); } else { - my ($arg,$limit); + my ($arg,$limit,$mine); my $hardmax = 100; # you might disagree what this value should be, but there definitely should be a max $limit = $query->param('limit') || $hardmax; + $mine = $query->param('mine') || 0; # set if the patron want to see only his own tags. ($limit =~ /^\d+$/ and $limit <= $hardmax) or $limit = $hardmax; $template->param(limit => $limit); my $arghash = {approved=>1, limit=>$limit, 'sort'=>'-weight_total'}; + $arghash->{'borrowernumber'} = $loggedinuser if $mine; # ($openadds) or $arghash->{approved} = 1; if ($arg = $query->param('tag')) { $arghash->{term} = $arg; @@ -259,7 +261,7 @@ if ($add_op) { $results = get_approval_rows($arghash); my $count = scalar @$results; - $template->param(TAGLOOP_COUNT => $count); + $template->param(TAGLOOP_COUNT => $count, mine => $mine); # Here we make a halfhearted attempt to separate the tags into "strata" based on weight_total # FIXME: code4lib probably has a better algorithm, iirc # FIXME: when we get a better algorithm, move to C4 @@ -286,9 +288,9 @@ if ($add_op) { $previous = $current; } } -$query->param('hidemytags') and $template->param(hidemytags => 1); (scalar @errors ) and $template->param(ERRORS => \@errors); -(scalar @$results) and $template->param(TAGLOOP => $results); +my @orderedresult = sort { $a->{'term'} cmp $b->{'term'} } @$results; +(scalar @$results) and $template->param(TAGLOOP => \@orderedresult ); (scalar @$my_tags) and $template->param(MY_TAGS => $my_tags); output_html_with_http_headers $query, $cookie, $template->output; -- 2.39.5