From 399c681d03a85d9bc879c1a6ea23a80c2a901c0e Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 23 Jul 2013 09:21:07 -0400 Subject: [PATCH] Bug 10626 - Remove doubled up TT plugins - Merge KohaAuthorisedValues and AuthorisedValues Looking at the TT plugin directory I notice we have some plugins that seem to do the same thing: KohaAuthorisedValues.pm AuthorisedValues.pm Test Plan: 1) Apply this patch 2) View the pages that this patch has modified, make sure the branch name is still visible Signed-off-by: Chris Cormack --- Koha/Template/Plugin/AuthorisedValues.pm | 12 ++++++ Koha/Template/Plugin/KohaAuthorisedValues.pm | 50 ---------------------- .../prog/en/modules/circ/circulation.tt | 18 ++++---- .../prog/en/modules/suggestion/suggestion.tt | 8 ++-- .../opac-tmpl/prog/en/includes/item-status.inc | 6 +-- .../opac-tmpl/prog/en/modules/opac-suggestions.tt | 4 +- 6 files changed, 30 insertions(+), 68 deletions(-) delete mode 100644 Koha/Template/Plugin/KohaAuthorisedValues.pm diff --git a/Koha/Template/Plugin/AuthorisedValues.pm b/Koha/Template/Plugin/AuthorisedValues.pm index 683a0ff..0a19be2 100644 --- a/Koha/Template/Plugin/AuthorisedValues.pm +++ b/Koha/Template/Plugin/AuthorisedValues.pm @@ -26,6 +26,18 @@ use Encode qw{encode decode}; use C4::Koha; +=pod + +To use, first, include the line '[% USE AuthorisedValues %]' at the top +of the template to enable the plugin. + +Now, in a template, you can get the description for an authorised value with +the following TT code: [% AuthorisedValues.GetByCode( 'CATEGORY', 'AUTHORISED_VALUE_CODE', 'IS_OPAC' ) %] + +The parameters are identical to those used by the subroutine C4::Koha::GetAuthorisedValueByCode. + +=cut + sub GetByCode { my ( $self, $category, $code, $opac ) = @_; return encode( 'UTF-8', GetAuthorisedValueByCode( $category, $code, $opac ) ); diff --git a/Koha/Template/Plugin/KohaAuthorisedValues.pm b/Koha/Template/Plugin/KohaAuthorisedValues.pm deleted file mode 100644 index 68b1347..0000000 --- a/Koha/Template/Plugin/KohaAuthorisedValues.pm +++ /dev/null @@ -1,50 +0,0 @@ -package Koha::Template::Plugin::KohaAuthorisedValues; - -# Copyright ByWater Solutions 2012 - -# 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 Modern::Perl; - -use Template::Plugin; -use base qw( Template::Plugin ); - -use C4::Koha; - -=pod - -This plugin allows one to get the description for an authorised value -from within a template. - -First, include the line '[% USE KohaAuthorisedValues %]' at the top -of the template to enable the plugin. - -To use, call KohaAuthorisedValues.GetByCode with the category -of the authorised value, the code to look up, and optionally, -the OPAC flag ( if set, it will return the OPAC description rather -than the Intranet description ). - -For example: [% KohaAuthorisedValues.GetByCode( 'LOST', item.itemlost, 1 ) %] -will print the OPAC description for the LOST value stored in item.itemlost. - -=cut - -sub GetByCode { - my ( $self, $category, $code, $opac ) = @_; - return GetAuthorisedValueByCode( $category, $code, $opac ); -} - -1; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index f93ae74..a7bb45b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -2,7 +2,7 @@ [% IF ( export_remove_fields OR export_with_csv_profile ) %] [% SET exports_enabled = 1 %] [% END %] -[% USE KohaAuthorisedValues %] +[% USE AuthorisedValues %] [% INCLUDE 'doc-head-open.inc' %] [% SET destination = "circ" %] Koha › Circulation @@ -370,7 +370,7 @@ function validate1(date) { [% IF ( itemtype_notforloan ) %] Item type is normally not for loan. [% ELSIF ( item_notforloan ) %] - [% item_notforloan_lib = KohaAuthorisedValues.GetByCode( authvalcode_notforloan, item_notforloan, 0 ) %] + [% item_notforloan_lib = AuthorisedValues.GetByCode( authvalcode_notforloan, item_notforloan, 0 ) %] Item is normally not for loan [% IF (item_notforloan_lib) %]([% item_notforloan_lib %])[% END %]. [% END %] Check out anyway? @@ -503,7 +503,7 @@ function validate1(date) { [% IF ( itemtype_notforloan ) %] Item type not for loan. [% ELSIF ( item_notforloan ) %] - [% item_notforloan_lib = KohaAuthorisedValues.GetByCode( authvalcode_notforloan, item_notforloan, 0 ) %] + [% item_notforloan_lib = AuthorisedValues.GetByCode( authvalcode_notforloan, item_notforloan, 0 ) %] Item not for loan [% IF (item_notforloan_lib) %]([% item_notforloan_lib %])[% END %]. [% END %] </li> @@ -846,10 +846,10 @@ No patron matched <span class="ex">[% message %]</span> <span title="[% todayissue.dd_sort %]">[% todayissue.dd %]</span> [% IF ( todayissue.itemlost ) %] - <span class="lost">[% KohaAuthorisedValues.GetByCode( 'LOST', todayissue.itemlost ) %]</span> + <span class="lost">[% AuthorisedValues.GetByCode( 'LOST', todayissue.itemlost ) %]</span> [% END %] [% IF ( todayissue.damaged ) %] - <span class="dmg">[% KohaAuthorisedValues.GetByCode( 'DAMAGED', todayissue.damaged ) %]</span> + <span class="dmg">[% AuthorisedValues.GetByCode( 'DAMAGED', todayissue.damaged ) %]</span> [% END %] </td> <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% todayissue.biblionumber %]&type=intra"><strong>[% todayissue.title |html %][% FOREACH subtitl IN todayissue.subtitle %] [% subtitl.subfield %][% END %]</strong></a>[% IF ( todayissue.author ) %], by [% todayissue.author %][% END %][% IF ( todayissue.itemnotes ) %]- <span class="circ-hlt">[% todayissue.itemnotes %]</span>[% END %] <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% todayissue.biblionumber %]&itemnumber=[% todayissue.itemnumber %]#item[% todayissue.itemnumber %]">[% todayissue.barcode %]</a></td> @@ -933,10 +933,10 @@ No patron matched <span class="ex">[% message %]</span> <span title="[% previssue.dd_sort %]">[% previssue.dd %]</span> [% IF ( previssue.itemlost ) %] - <span class="lost">[% KohaAuthorisedValues.GetByCode( 'LOST', previssue.itemlost ) %]</span> + <span class="lost">[% AuthorisedValues.GetByCode( 'LOST', previssue.itemlost ) %]</span> [% END %] [% IF ( previssue.damaged ) %] - <span class="dmg">[% KohaAuthorisedValues.GetByCode( 'DAMAGED', previssue.damaged ) %]</span> + <span class="dmg">[% AuthorisedValues.GetByCode( 'DAMAGED', previssue.damaged ) %]</span> [% END %] </td> <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% previssue.biblionumber %]&type=intra"><strong>[% previssue.title |html %][% FOREACH subtitl IN previssue.subtitle %] [% subtitl.subfield %][% END %]</strong></a>[% IF ( previssue.author ) %], by [% previssue.author %][% END %] [% IF ( previssue.itemnotes ) %]- [% previssue.itemnotes %][% END %] <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% previssue.biblionumber %]&itemnumber=[% previssue.itemnumber %]#item[% previssue.itemnumber %]">[% previssue.barcode %]</a></td> @@ -1071,10 +1071,10 @@ No patron matched <span class="ex">[% message %]</span> <span title="[% relissue.dd_sort %]">[% relissue.dd %]</span></td> [% IF ( relissue.itemlost ) %] - <span class="lost">[% KohaAuthorisedValues.GetByCode( 'LOST', relissue.itemlost ) %]</span> + <span class="lost">[% AuthorisedValues.GetByCode( 'LOST', relissue.itemlost ) %]</span> [% END %] [% IF ( relissue.damaged ) %] - <span class="dmg">[% KohaAuthorisedValues.GetByCode( 'DAMAGED', relissue.damaged ) %]</span> + <span class="dmg">[% AuthorisedValues.GetByCode( 'DAMAGED', relissue.damaged ) %]</span> [% END %] </td> <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% relissue.biblionumber %]&type=intra"><strong>[% relissue.title |html %][% FOREACH subtitl IN relissue.subtitle %] [% subtitl.subfield %][% END %]</strong></a>[% IF ( relissue.author ) %], by [% relissue.author %][% END %][% IF ( relissue.itemnotes ) %]- <span class="circ-hlt">[% relissue.itemnotes %]</span>[% END %] <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% relissue.biblionumber %]&itemnumber=[% relissue.itemnumber %]#item[% relissue.itemnumber %]">[% relissue.barcode %]</a></td> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt index 0b4a4ab..0b559fb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt @@ -1,4 +1,4 @@ -[% USE KohaAuthorisedValues %] +[% USE AuthorisedValues %] [% USE KohaBranchName %] [% INCLUDE 'doc-head-open.inc' %] <title>Koha › Acquisitions › @@ -431,7 +431,7 @@ $(document).ready(function() { calcNewsuggTotal(); }); [% ELSE %][% suggestion.suggestiontypelabel %][% END %] [% ELSE %] [% IF ( suggestion.suggestiontype ) %] - [% KohaAuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestion.suggestiontype ) %] + [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestion.suggestiontype ) %] [% ELSE %] No name [% END %] @@ -498,8 +498,8 @@ $(document).ready(function() { calcNewsuggTotal(); }); Rejected [% ELSIF ( suggestions_loo.CHECKED ) %] Checked - [% ELSIF KohaAuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS ) %] - [% KohaAuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS ) %] + [% ELSIF AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS ) %] + [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS ) %] [% END %] [% IF ( suggestions_loo.reason ) %] diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/item-status.inc b/koha-tmpl/opac-tmpl/prog/en/includes/item-status.inc index 98fdb38..68e8a7d 100644 --- a/koha-tmpl/opac-tmpl/prog/en/includes/item-status.inc +++ b/koha-tmpl/opac-tmpl/prog/en/includes/item-status.inc @@ -1,4 +1,4 @@ -[% USE KohaAuthorisedValues %] +[% USE AuthorisedValues %] [% IF ( item.datedue ) %] [% IF ( OPACShowCheckoutName ) %] @@ -14,7 +14,7 @@ [% ELSIF ( item.wthdrawn ) %] Item withdrawn [% ELSIF ( item.itemlost ) %] - [% av_lib_include = KohaAuthorisedValues.GetByCode( 'LOST', item.itemlost, 1 ) %] + [% av_lib_include = AuthorisedValues.GetByCode( 'LOST', item.itemlost, 1 ) %] [% IF ( av_lib_include ) %] [% av_lib_include %] [% ELSE %] @@ -33,7 +33,7 @@ [% ELSIF ( item.notforloan_per_itemtype ) %] Not for loan [% IF ( item.restrictedopac ) %]<span class="restricted">([% item.restrictedopac %])</span>[% END %] [% ELSIF ( item.damaged ) %] - [% av_lib_include = KohaAuthorisedValues.GetByCode( 'DAMAGED', item.damaged, 1 ) %] + [% av_lib_include = AuthorisedValues.GetByCode( 'DAMAGED', item.damaged, 1 ) %] [% IF av_lib_include %] [% av_lib_include %] [% ELSE %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tt index a17372f..35e1bdc 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tt @@ -1,5 +1,5 @@ [% USE Koha %] -[% USE KohaAuthorisedValues %] +[% USE AuthorisedValues %] [% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › [% IF ( op_add ) %]Enter a new purchase suggestion[% END %] [% IF ( op_else ) %]Purchase Suggestions[% END %] @@ -224,7 +224,7 @@ $.tablesorter.addParser({ [% ELSIF ( suggestions_loo.ORDERED ) %]Ordered by the library [% ELSIF ( suggestions_loo.REJECTED ) %]Suggestion declined [% ELSIF ( suggestions_loo.AVAILABLE ) %]Available in the library - [% ELSE %] [% KohaAuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS, 1 ) %] [% END %] + [% ELSE %] [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS, 1 ) %] [% END %] [% IF ( suggestions_loo.reason ) %]([% suggestions_loo.reason %])[% END %] </td> -- 1.8.1.2