From a526f2936e0f412b570e7a06f0134fafa8641432 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 28 Sep 2011 12:44:26 -0400 Subject: [PATCH] Bug 6933 [REVISED] Add a view of titles with a particular tag to the staff client - Adds a new page to the tags moderation section for viewing all the titles tagged with a particular term. - Adds display of approved tags to the catalog detail page matching the opac view. Adding tags from the detail view not implemented. Follow-up adds tags display to XSLT detail view Areas for improvement: - I think it would be better to show "Also tagged with:" and exclude the current tag from the list of titles tagged with a particular tag. - It would be nice to be able to show unapproved tags (and some idication of their status) along with approved tags on the detail page if the user had TagsModeration permission. Signed-off-by: Nicole C. Engard Signed-off-by: Paul Poulain --- catalogue/detail.pl | 13 +++ .../prog/en/modules/catalogue/detail.tt | 27 +++++ .../prog/en/modules/tags/list.tt | 103 ++++++++++++++++++ .../prog/en/modules/tags/review.tt | 2 +- tags/list.pl | 81 ++++++++++++++ 5 files changed, 225 insertions(+), 1 deletion(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/tags/list.tt create mode 100755 tags/list.pl diff --git a/catalogue/detail.pl b/catalogue/detail.pl index fcf1f2b57a..db38551fde 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -35,6 +35,7 @@ use C4::Serials; use C4::XISBN qw(get_xisbns get_biblionumber_from_isbn); use C4::External::Amazon; use C4::Search; # enabled_staff_search_views +use C4::Tags qw(get_tags); use C4::VirtualShelves; use C4::XSLT; use C4::Images; @@ -395,4 +396,16 @@ if (C4::Context->preference('OPACBaseURL')){ $template->param( OpacUrl => C4::Context->preference('OPACBaseURL') ); } +# Displaying tags + +my $tag_quantity; +if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnDetail')) { + $template->param( + TagsEnabled => 1, + TagsShowOnDetail => $tag_quantity + ); + $template->param(TagLoop => get_tags({biblionumber=>$biblionumber, approved=>1, + 'sort'=>'-weight', limit=>$tag_quantity})); +} + output_html_with_http_headers $query, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 38a26c9528..80e04a976d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -102,6 +102,18 @@ function verify_images() { [% END %] [% END %] + [% IF ( TagsEnabled && TagsShowOnDetail && TagLoop ) %] + Tags: + [% FOREACH TagLoo IN TagLoop %] + [% IF ( CAN_user_tools_moderate_tags ) %] + [% TagLoo.term |html %] + [% ELSE %] + [% TagLoo.term |html %] + [% END %] + ([% TagLoo.weight_total %])[% IF ( loop.last ) %][% ELSE %], [% END %] + [% END %] + + [% END %] [% IF ( holdcount ) %]Holds: [% holdcount %][% ELSE %][% END %] [% IF ( AmazonEnabled ) %][% IF ( AmazonCoverImages ) %]
@@ -219,10 +231,25 @@ function verify_images() { [% END %] + [% END %] + [% IF ( TagsEnabled && TagsShowOnDetail && TagLoop ) %] +
  • Tags: +
      + [% FOREACH TagLoo IN TagLoop %] +
    • + [% IF ( CAN_user_tools_moderate_tags ) %] + [% TagLoo.term |html %] + [% ELSE %] + [% TagLoo.term |html %] + [% END %] + ([% TagLoo.weight_total %])[% IF ( loop.last ) %][% ELSE %], [% END %]
    • + [% END %] +
  • [% END %] [% IF ( holdcount ) %]
  • Holds: [% holdcount %]
  • [% ELSE %][% END %] [% END %] +
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tags/list.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tags/list.tt new file mode 100644 index 0000000000..05fd45288b --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tags/list.tt @@ -0,0 +1,103 @@ +[% INCLUDE 'doc-head-open.inc' %] +Koha › Tools › Tags › [% IF ( do_it ) %]Review › [% ELSE %]Review Tags[% END %] +[% INCLUDE 'doc-head-close.inc' %] + + + + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'cat-search.inc' %] + + + +
    +
    +
    +
    +[% IF ( titles ) %] +

    Titles tagged with the term [% tag %]

    + + + + + + + + [% FOREACH title IN titles %] + [% IF ( title.even ) %] + + [% ELSE %] + + [% END %] + + + + + [% END %] +
    TitleLocation 
    [% INCLUDE 'biblio-default-view.inc' biblionumber = title.biblionumber %][% title.title |html %][% FOREACH subtitl IN title.subtitle %] [% subtitl.subfield %][% END %] + [% title.author %] +

    [% IF ( title.publishercode ) %]- [% title.publishercode|html %] + [% IF ( title.place ) %] [% title.place %][% END %][% END %] + [% IF ( title.pages ) %] - [% title.pages %][% IF ( title.size ) %] [% title.size %] + [% END %] + [% END %]

    + [% IF ( title.notes ) %] +

    [% title.notes |html%]

    [% END %] + [% IF ( title.TagLoop ) %]

    Tagged with: [% FOREACH TagLoo IN title.TagLoop %] + [% TagLoo.term |html %] ([% TagLoo.weight_total %])[% IF ( loop.last ) %][% ELSE %], [% END %] + [% END %]

    + [% END %] +
    [% IF ( title.items ) %]
      [% FOREACH item IN title.items %] +
    • + [% item.branchname %] [% item.location_description %] + [% IF ( item.itemcallnumber ) %] + ([% item.itemcallnumber %]) + [% END %] +
    • + [% END %]
    [% ELSE %]This record has no items.[% END %] +
    +[% ELSE %] +
    There are no titles tagged with the term [% tag %]
    +[% END %] + +
    +
    + +
    +[% INCLUDE 'intranet-bottom.inc' %] \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt index 5d025af6d3..843f7cad70 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt @@ -217,7 +217,7 @@ td input,td input[type="submit"] { font-size: 85%; padding: 1px; } [% ELSE %] [% END %] - [% tagloo.term %] + [% tagloo.term %] [% tagloo.weight_total %] diff --git a/tags/list.pl b/tags/list.pl new file mode 100755 index 0000000000..7b16ce5052 --- /dev/null +++ b/tags/list.pl @@ -0,0 +1,81 @@ +#!/usr/bin/perl + +# Copyright 2011 Athens County Public Libraries +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use warnings; +use strict; +use CGI; + +use C4::Auth qw(:DEFAULT check_cookie_auth); +use C4::Biblio; +use C4::Context; +use C4::Dates qw(format_date); +use C4::Items; +use C4::Koha; +use C4::Tags 0.03 qw(get_tags remove_tag get_tag_rows); +use C4::Output; + +my $needed_flags = { tools => 'moderate_tags' }; # FIXME: replace when more specific permission is created. + +my $query = CGI->new; +my $op = $query->param('op') || ''; +my $biblionumber = $query->param('biblionumber'); +my $tag = $query->param('tag'); +my $tag_id = $query->param('tag_id'); + +my ($template, $borrowernumber, $cookie) = get_template_and_user({ + template_name => "tags/list.tmpl", + query => $query, + type => "intranet", + debug => 1, + authnotrequired => 0, + flagsrequired => $needed_flags, +}); + +if( $op eq "del" ){ + remove_tag($tag_id); + print $query->redirect("/cgi-bin/koha/tags/list.pl?tag=$tag"); +} else { + +my $marcflavour = C4::Context->preference('marcflavour'); +my @results; + +if ($tag) { + my $taglist = get_tag_rows({term=>$tag}); + for ( @{$taglist} ) { + my $dat = &GetBiblioData($_->{biblionumber}); + my $record = &GetMarcBiblio($_->{biblionumber}); + $dat->{'subtitle'} = GetRecordValue('subtitle', $record, GetFrameworkCode($_->{biblionumber})); + my @items = GetItemsInfo( $_->{biblionumber} ); + $dat->{biblionumber} = $_->{biblionumber}; + $dat->{tag_id} = $_->{tag_id}; + $dat->{items} = \@items; + $dat->{TagLoop} = get_tags({biblionumber=>$_->{biblionumber}, 'sort'=>'-weight',limit=>10 }); + push( @results, $dat ); + } + +my $resultsarray = \@results; + +$template->param( + tag => $tag, + titles => $resultsarray, +); +} +} + +output_html_with_http_headers $query, $cookie, $template->output; -- 2.39.5