From 0ce66160fb97eeddbc04a874ed52a0ffa7e4dd58 Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Mon, 1 Oct 2012 10:58:06 +1300 Subject: [PATCH] Bug 8732: Allowing biblio level itemtypes to display instead of MARC ones This patchset adds a new syspref: BiblioItemtypeImages If you set BiblioItemtypeImage to Koha, you will see the Koha itemtypes, if it is Control you will get the ones generated from the MARC control fields. The control field images are formed in XSLT and use label 'Material type' When switching to 'Koha' the images are added in the tmeplate and labeled 'Item type' if labelled TODO: Image size cleanup - adjust UNIMARC xslt To test: 1 - Apply patch 2 - Update database 3 - Do an opac search and view results 4 - Switch pref to 'Koha' and refresh 5 - Note itemtypes appear and material types dissappear 6 - Click in to a record details 7 - Note you see itemtype and icon 8 - Switch the pref 9 - Note you now see material type and icon 10 - Repeat in staff interface Signed-off-by: Andrew Fuerste-Henry --- C4/XSLT.pm | 2 +- catalogue/detail.pl | 2 +- ..._add_BiblioItemtypeImage_system_preference.perl | 7 +++++ installer/data/mysql/sysprefs.sql | 1 + .../en/modules/admin/preferences/searching.pref | 6 ++++ .../prog/en/modules/catalogue/detail.tt | 12 ++++++++ .../prog/en/modules/catalogue/results.tt | 2 +- .../prog/en/xslt/MARC21slim2intranetDetail.xsl | 7 +++-- .../prog/en/xslt/MARC21slim2intranetResults.xsl | 7 +++-- .../opac-tmpl/bootstrap/en/modules/opac-detail.tt | 36 ++++++++-------------- .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 3 +- .../bootstrap/en/xslt/MARC21slim2OPACDetail.xsl | 3 ++ .../bootstrap/en/xslt/MARC21slim2OPACResults.xsl | 9 ++++-- opac/opac-detail.pl | 1 + opac/opac-search.pl | 2 ++ 15 files changed, 66 insertions(+), 34 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_8732_add_BiblioItemtypeImage_system_preference.perl diff --git a/C4/XSLT.pm b/C4/XSLT.pm index 648bab28ab..c2e68e079f 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -173,7 +173,7 @@ sub get_xslt_sysprefs { TrackClicks opacthemes IdRef OpacSuppression OPACResultsLibrary OPACShowOpenURL OpenURLResolverURL OpenURLImageLocation - OpenURLText / ) + OpenURLText BiblioItemtypeImage / ) { my $sp = C4::Context->preference( $syspref ); next unless defined($sp); diff --git a/catalogue/detail.pl b/catalogue/detail.pl index b4d9bae646..1e979a329c 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -477,7 +477,6 @@ if ( (C4::Context->preference("HTML5MediaEnabled") eq 'both') or (C4::Context->p } # Displaying tags - my $tag_quantity; if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnDetail')) { $template->param( @@ -541,5 +540,6 @@ $template->param (countdeletedorders => $count_deletedorders_using_biblio); $template->param (basketsorders => \@baskets_orders); $template->param (basketsdeletedorders => \@baskets_deletedorders); +$template->{VARS}->{'BiblioItemtypeImage'} = C4::Context->preference('BiblioItemtypeImage'); output_html_with_http_headers $query, $cookie, $template->output; diff --git a/installer/data/mysql/atomicupdate/bug_8732_add_BiblioItemtypeImage_system_preference.perl b/installer/data/mysql/atomicupdate/bug_8732_add_BiblioItemtypeImage_system_preference.perl new file mode 100644 index 0000000000..d47a6eeb35 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_8732_add_BiblioItemtypeImage_system_preference.perl @@ -0,0 +1,7 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + $dbh->do( "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('BiblioItemtypeImage', 'Control','Control what biblio level itemtype image displays','Control|Koha','Choice')" ); + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 8732: Add new BiblioItemtypeImage to system preferences)\n"; +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 82a8402a36..abf4f016ca 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -90,6 +90,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('BatchCheckoutsValidCategories','',NULL,'Patron categories allowed to checkout in a batch','Free'), ('BiblioAddsAuthorities','0',NULL,'If ON, adding a new biblio will check for an existing authority record and create one on the fly if one doesn\'t exist','YesNo'), ('BiblioDefaultView','normal','normal|marc|isbd','Choose the default detail view in the catalog; choose between normal, marc or isbd','Choice'), +('BiblioItemtypeImage','Control','Control which itemtype info displays for biblio level itemtypes','Control|Koha','Choice'), ('BibtexExportAdditionalFields', '', NULL , 'Define additional BibTex tags to export from MARC records in YAML format as an associative array with either a marc tag/subfield combination as the value, or a list of tag/subfield combinations.', 'textarea'), ('BlockExpiredPatronOpacActions','1',NULL,'Set whether an expired patron can perform opac actions such as placing holds or renew books, can be overridden on a per patron-type basis','YesNo'), ('BlockReturnOfLostItems','0','0','If enabled, items that are marked as lost cannot be returned.','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref index f1b87d89c9..8f11fce76f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref @@ -253,3 +253,9 @@ Searching: - LIBRIS base URL - pref: LibrisURL - "Please only change this if you are sure it needs changing." + - + - "Display " + - pref: BiblioItemtypeImage + choices: + Control: "Itemtype information from the MARC control fields" + Koha: "Itemtype information from the Koha biblio level itemtype" 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 3819628274..64f067115e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -98,6 +98,18 @@ [% END %] MARC Preview: Show + [% IF !item_level_itypes || BiblioItemtypeImage == 'Koha' %] + Itemtype: + [% IF ( imageurl ) %] + + [% END %] + [% IF ( description ) %] + [% description %] + [% ELSE %] + [% itemtype %] + [% END %] + + [% END %] [% IF ( holdcount ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt index c8af35f986..7170365598 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -403,7 +403,7 @@ - [% UNLESS ( item_level_itypes ) %] + [% IF ( !item_level_itypes ) || Koha.Preference('BiblioItemtypeImage') == 'Koha' %]
[% IF !noItemTypeImages && SEARCH_RESULT.imageurl %] [%  SEARCH_RESULT.description | html %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl index 515e96618f..3722720c8e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl +++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl @@ -29,6 +29,7 @@ + { @@ -171,16 +172,18 @@ - + + Material type: materialtype mt_icon_/intranet-tmpl/prog/img/famfamfam/.png - + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl index 2ba9c1ff5f..5ea71ab5dc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl +++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl @@ -30,6 +30,7 @@ + @@ -486,6 +487,7 @@ + Material type: @@ -510,12 +512,13 @@ sound Sound music Music - + ; + - ; Format: + Format: diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index 8afe1b76a5..c4b8a52578 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -115,16 +115,6 @@

[% INCLUDE 'biblio-title.inc' %]

[% IF ( author ) %]
by [% author | html %]
[% END %] - [% UNLESS ( item_level_itypes ) %] - [ - [% IF ( description ) %] - [% description | html %] - [% ELSE %] - [% itemtype | html %] - [% END %] - ] [% END %] - [% IF ( unititle ) %], [% unititle | html %][% END %] - [% IF ( MARCAUTHORS ) %]
@@ -317,19 +307,6 @@ Year: [% copyrightdate | html %] [% END %] - [% UNLESS ( item_level_itypes ) %] - [% IF ( imgeurl ) %] - - [% END %] - Item type: - [% IF ( description ) %] - [% description | html %] - [% ELSE %] - [% itemtype | html %] - [% END %] - - [% END %] - [% IF ( MARCURLS ) %]
Online resources:
    @@ -364,6 +341,19 @@ [% END # / IF MARCURLS %] [% END # / IF OPACXSLTDetailsDisplay %] + [% IF ( !item_level_itypes ) || Koha.Preference('BiblioItemtypeImage') == 'Koha' %] + Item type: + [% IF ( imageurl ) %] + + [% END %] + [% IF ( description ) %] + [% description | html %] + [% ELSE %] + [% itemtype | html %] + [% END %] + + [% END %] + [% IF ( LibraryThingForLibrariesID ) %] [% UNLESS ( LibraryThingForLibrariesTabbedView ) %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt index 12c9a2d1c6..2d5fbfe90f 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt @@ -233,8 +233,7 @@ [% SEARCH_RESULT.result_number | html %]. [% END %] - - [% IF ( !item_level_itypes && !noItemTypeImages ) %] + [% IF ( !item_level_itypes && !noItemTypeImages ) || Koha.Preference('BiblioItemtypeImage') == 'Koha' %] [% # Cell 3: Show item type image %] [% IF ( SEARCH_RESULT.imageurl ) %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl index 391c9cda8c..bd85e9ec25 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl +++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl @@ -32,6 +32,7 @@ + { @@ -188,6 +189,7 @@ + Material type: @@ -198,6 +200,7 @@ + diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl index 6aaa329870..8a1ad8607b 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl +++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl @@ -18,8 +18,8 @@ - - + + @@ -34,6 +34,7 @@ + @@ -658,6 +659,9 @@ + + + Material type: @@ -1017,6 +1021,7 @@ + diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index e55ecb6a39..c11c41e4f8 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -1191,6 +1191,7 @@ my $defaulttab = @serialcollections > 0 ? 'serialcollection' : 'subscriptions'; $template->param('defaulttab' => $defaulttab); +$template->{VARS}->{'BiblioItemtypeImage'} = C4::Context->preference('BiblioItemtypeImage'); if (C4::Context->preference('OPACLocalCoverImages') == 1) { my @images = ListImagesForBiblio($biblionumber); diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 27d1f2ce5c..df1b2da87a 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -3,6 +3,7 @@ # Copyright 2008 Garry Collum and the Koha Development team # Copyright 2010 BibLibre # Copyright 2011 KohaAloha, NZ +# Copyright 2012 Catalyst IT, NZ # # This file is part of Koha. # @@ -1021,6 +1022,7 @@ $template->{VARS}->{DidYouMean} = $template->{VARS}->{IDreamBooksReviews} = C4::Context->preference('IDreamBooksReviews'); $template->{VARS}->{IDreamBooksReadometer} = C4::Context->preference('IDreamBooksReadometer'); $template->{VARS}->{IDreamBooksResults} = C4::Context->preference('IDreamBooksResults'); +$template->{VARS}->{'BiblioItemtypeImage'} = C4::Context->preference('BiblioItemtypeImage'); if ($offset == 0) { $template->param(firstPage => 1); -- 2.11.0