[Patches] [PATCH] Bug 6933 [REVISED] Add a view of titles with a particular tag to the staff client
koha-patchbot at kohaaloha.com
koha-patchbot at kohaaloha.com
Wed Dec 21 03:11:45 NZDT 2011
From: Owen Leonard <oleonard at myacpl.org>
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
Content-Type: text/plain; charset="utf-8"
- 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.
---
catalogue/detail.pl | 13 +++
.../prog/en/modules/catalogue/detail.tt | 27 +++++
.../intranet-tmpl/prog/en/modules/tags/list.tt | 103 ++++++++++++++++++++
.../intranet-tmpl/prog/en/modules/tags/review.tt | 2 +-
tags/list.pl | 81 +++++++++++++++
5 files changed, 225 insertions(+), 1 deletions(-)
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 580949d..c9b8321 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;
@@ -384,4 +385,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 019fa10..ad013f7 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
@@ -97,6 +97,18 @@ function verify_images() {
[% END %]
</span>
[% END %]
+ [% IF ( TagsEnabled && TagsShowOnDetail && TagLoop ) %]
+ <span class="results_summary"><span class="label">Tags:</span>
+ [% FOREACH TagLoo IN TagLoop %]
+ [% IF ( CAN_user_tools_moderate_tags ) %]
+ <a href="/cgi-bin/koha/tags/list.pl?tag=[% TagLoo.term |url %]">[% TagLoo.term |html %]</a>
+ [% ELSE %]
+ [% TagLoo.term |html %]
+ [% END %]
+ <span class="weight">([% TagLoo.weight_total %])</span>[% IF ( loop.last ) %][% ELSE %], [% END %]
+ [% END %]
+ </span>
+ [% END %]
[% IF ( holdcount ) %]<span class="results_summary"><span class="label">Holds:</span> <span class="holdcount"><a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% biblionumber %]">[% holdcount %]</a></span></span>[% ELSE %][% END %]
[% IF ( AmazonEnabled ) %][% IF ( AmazonCoverImages ) %]</div><div class="yui-u" id="bookcoverimg">
@@ -215,9 +227,24 @@ function verify_images() {
</ul>
</li>
[% END %]
+ [% IF ( TagsEnabled && TagsShowOnDetail && TagLoop ) %]
+ <li><strong>Tags:</strong>
+ <ul id="tagslist">
+ [% FOREACH TagLoo IN TagLoop %]
+ <li>
+ [% IF ( CAN_user_tools_moderate_tags ) %]
+ <a href="/cgi-bin/koha/tags/list.pl?tag=[% TagLoo.term |url %]">[% TagLoo.term |html %]</a>
+ [% ELSE %]
+ [% TagLoo.term |html %]
+ [% END %]
+ <span class="weight">([% TagLoo.weight_total %])</span>[% IF ( loop.last ) %][% ELSE %], [% END %]</li>
+ [% END %]
+ </ul></li>
+ [% END %]
[% IF ( holdcount ) %]<li><strong>Holds:</strong> <span class="holdcount"><a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% biblionumber %]">[% holdcount %]</a></span></li>[% ELSE %][% END %]
</ul>
[% END %]
+
</div>
</div>
<div id="bibliodetails" class="toptabs">
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 0000000..05fd452
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tags/list.tt
@@ -0,0 +1,103 @@
+[% INCLUDE 'doc-head-open.inc' %]
+<title>Koha › Tools › Tags › [% IF ( do_it ) %]Review › [% ELSE %]Review Tags[% END %]</title>
+[% INCLUDE 'doc-head-close.inc' %]
+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
+<script type="text/javascript">
+//<![CDATA[
+ $.tablesorter.addParser({
+ id: 'articles',
+ is: function(s) {return false; },
+ format: function(s) { return s.toLowerCase().replace(/^(the|an|a) /,''); },
+ type: 'text'
+ });
+ $(document).ready(function() {
+ $(".delete").click(function (event) {
+ $(this).parent().parent().parent().addClass("selected");
+ var answer = confirm(_("Are you sure you want to remove the tag from this title?"));
+ if (!answer){
+ $("tr").removeClass("selected");
+ event.preventDefault();
+ }
+ });
+ $("#itemst").tablesorter({
+ sortList: [[0,0]],
+ headers: { 0: { sorter: 'articles' },1: { sorter: false },2:{sorter:false}}
+ });
+ });
+//]]>
+</script>
+<style type="text/css">
+tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : transparent; }</style>
+</head>
+<body>
+[% INCLUDE 'header.inc' %]
+[% INCLUDE 'cat-search.inc' %]
+
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> › <a href="/cgi-bin/koha/tags/review.pl">Tags</a> › Results for tag <i>[% tag %]</i></div>
+
+<div id="doc3" class="yui-t2">
+ <div id="bd">
+ <div id="yui-main">
+ <div class="yui-b">
+[% IF ( titles ) %]
+<h3>Titles tagged with the term <i>[% tag %]</i></h3>
+<table id="itemst">
+ <thead><tr>
+ <th>Title</th>
+ <th>Location</th>
+ <th> </th>
+ </tr></thead>
+
+ [% FOREACH title IN titles %]
+ [% IF ( title.even ) %]
+ <tr class="highlight">
+ [% ELSE %]
+ <tr>
+ [% END %]
+ <td>[% INCLUDE 'biblio-default-view.inc' biblionumber = title.biblionumber %][% title.title |html %][% FOREACH subtitl IN title.subtitle %] [% subtitl.subfield %][% END %]</a>
+ [% title.author %]
+ <p>[% 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 %]</p>
+ [% IF ( title.notes ) %]
+ <p>[% title.notes |html%]</p>[% END %]
+ [% IF ( title.TagLoop ) %]<p style="font-size:90%"><strong>Tagged with:</strong> [% FOREACH TagLoo IN title.TagLoop %]
+ <a href="/cgi-bin/koha/tags/list.pl?tag=[% TagLoo.term %]">[% TagLoo.term |html %]</a> <span class="weight">([% TagLoo.weight_total %])</span>[% IF ( loop.last ) %][% ELSE %], [% END %]
+ [% END %]</p>
+ [% END %]
+ </td>
+ <td>[% IF ( title.items ) %]<ul style="font-size:80%">[% FOREACH item IN title.items %]
+ <li>
+ [% item.branchname %] [% item.location_description %]
+ [% IF ( item.itemcallnumber ) %]
+ ([% item.itemcallnumber %])
+ [% END %]
+ </li>
+ [% END %]</ul>[% ELSE %]This record has no items.[% END %]
+ </td>
+ <td><form method="post" action="/cgi-bin/koha/tags/list.pl"><input type="hidden" name="op" value="del" /><input type="hidden" name="tag" value="[% tag %]" /><input type="hidden" name="tag_id" value="[% title.tag_id %]" /><input type="submit" class="delete" value="Remove tag" /></form></td>
+ </tr>
+ [% END %]
+ </table>
+[% ELSE %]
+ <div class="dialog message">There are no titles tagged with the term <i>[% tag %]</i></div>
+[% END %]
+</form>
+ </div>
+ </div>
+ <div class="yui-b">
+ <ul>
+ <li><a href="/cgi-bin/koha/tags/review.pl?approved=1">Approved tags</a>
+ </li>
+ <li><a href="/cgi-bin/koha/tags/review.pl?approved=-1">Rejected tags</a>
+ </li>
+ <li><a href="/cgi-bin/koha/tags/review.pl?approved=0">Pending tags</a>
+ </li>
+ <li><a href="/cgi-bin/koha/tags/review.pl?approved=all">All tags</a>
+ </li>
+ </ul>
+ </div>
+</div>
+[% 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 5d025af..843f7ca 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 %]<td class="pending">
[% END %]
</td>
- <td>[% tagloo.term %]
+ <td><a href="/cgi-bin/koha/tags/list.pl?tag=[% tagloo.term %]">[% tagloo.term %]</a>
</td>
<td>[% tagloo.weight_total %]
</td>
diff --git a/tags/list.pl b/tags/list.pl
new file mode 100755
index 0000000..7b16ce5
--- /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;
--
1.7.3
More information about the Patches
mailing list