Bugzilla – Attachment 10912 Details for
Bug 5079
Make display of shelving location and call number in XSLT results controlled by sysprefs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 5079 - Make display of shelving location and call number in XSLT results controlled by sysprefs
Bug-5079---Make-display-of-shelving-location-and-c.patch (text/plain), 16.32 KB, created by
Jared Camins-Esakov
on 2012-07-17 18:59:36 UTC
(
hide
)
Description:
Bug 5079 - Make display of shelving location and call number in XSLT results controlled by sysprefs
Filename:
MIME Type:
Creator:
Jared Camins-Esakov
Created:
2012-07-17 18:59:36 UTC
Size:
16.32 KB
patch
obsolete
>From dc3512bf872581f9a43bca8f481ed1e635f61871 Mon Sep 17 00:00:00 2001 >From: Elliott Davis <tdavis@uttyler.edu> >Date: Thu, 19 Jan 2012 14:52:37 -0500 >Subject: [PATCH] Bug 5079 - Make display of shelving location and call number in XSLT results controlled by sysprefs >Content-Type: text/plain; charset="UTF-8" > >* Don't show the Location line if there are no copies available, since it > will inevitably be blank > >* Also, don't show locations for Checked Out, Lost, Damaged, Withdrawn, > On Hold or In transit items; it doesn't really make sense, since the > items aren't actually there, and it results in repetitive listing of > the shelving location > >* Added system preference to display shelving location of an item on opac > results. The system preference is called OpacItemLocation. I also moved > the call number to a new line called Location along with the shelving > location if it is enabled. > >To Test: > 1) Run database update script to add syspref. > 2) Set OpacItemLocation to show locations or collection codes on the > opac-search page. > > If it is working you should see the shelving location of the item > before the call number. Multiple home branch shelving locations > are seperated by a pipe character ( i.e. '|' ). > >Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com> >Rebased on latest master, removed the reformatting, and changed the >syspref to be a choice between showing the call number only, the >location, and the collection code. >--- > C4/XSLT.pm | 22 +++- > installer/data/mysql/sysprefs.sql | 1 + > installer/data/mysql/updatedatabase.pl | 7 ++ > .../prog/en/modules/admin/preferences/opac.pref | 8 ++ > .../prog/en/xslt/MARC21slim2OPACResults.xsl | 111 +++++++++++++------- > 5 files changed, 105 insertions(+), 44 deletions(-) > >diff --git a/C4/XSLT.pm b/C4/XSLT.pm >index cbe1ff0..3888ff2 100644 >--- a/C4/XSLT.pm >+++ b/C4/XSLT.pm >@@ -187,7 +187,7 @@ sub XSLTParse4Display { > OPACBaseURL TraceCompleteSubfields UseICU > UseAuthoritiesForTracings TraceSubjectSubdivisions > Display856uAsImage OPACDisplay856uAsImage >- UseControlNumber >+ UseControlNumber OPACItemLocation > AlternateHoldingsField AlternateHoldingsSeparator / ) > { > my $sp = C4::Context->preference( $syspref ); >@@ -227,12 +227,19 @@ sub buildKohaItemsNamespace { > my ($biblionumber, $hidden_items) = @_; > > my @items = C4::Items::GetItemsInfo($biblionumber); >+ > if ($hidden_items && @$hidden_items) { > my %hi = map {$_ => 1} @$hidden_items; > @items = grep { !$hi{$_->{itemnumber}} } @items; > } >+ >+ my $shelflocations = GetKohaAuthorisedValues('items.location',GetFrameworkCode($biblionumber), 'opac'); >+ my $ccodes = GetKohaAuthorisedValues('items.ccode',GetFrameworkCode($biblionumber), 'opac'); >+ > my $branches = GetBranches(); > my $itemtypes = GetItemTypes(); >+ my $location = ""; >+ my $ccode = ""; > my $xml = ''; > for my $item (@items) { > my $status; >@@ -271,11 +278,16 @@ sub buildKohaItemsNamespace { > $status = "available"; > } > my $homebranch = $item->{homebranch}? xml_escape($branches->{$item->{homebranch}}->{'branchname'}):''; >- my $itemcallnumber = xml_escape($item->{itemcallnumber}); >+ $location = xml_escape($shelflocations->{$item->{location}}); >+ $ccode = xml_escape($ccodes->{$item->{ccode}}); >+ >+ my $itemcallnumber = xml_escape($item->{itemcallnumber}); > $xml.= "<item><homebranch>$homebranch</homebranch>". >- "<status>$status</status>". >- "<itemcallnumber>".$itemcallnumber."</itemcallnumber>" >- . "</item>"; >+ "<location>$location</location>". >+ "<ccode>$ccode</ccode>". >+ "<status>$status</status>". >+ "<itemcallnumber>".$itemcallnumber."</itemcallnumber>". >+ "</item>"; > > } > $xml = "<items xmlns=\"http://www.koha-community.org/items\">".$xml."</items>"; >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 7009155..0419a94 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -375,3 +375,4 @@ INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ( > INSERT INTO systempreferences (variable,value,explanation,type) VALUES('EnableBorrowerFiles','0','If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UpdateTotalIssuesOnCirc','0','Whether to update the totalissues field in the biblio on each circ.',NULL,'YesNo'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('IntranetSlipPrinterJS','','Use this JavaScript for printing slips. Define at least function printThenClose(). For use e.g. with Firefox PlugIn jsPrintSetup, see http://jsprintsetup.mozdev.org/','','Free'); >+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacItemLocation','callnum','Show the shelving location of items in the opac','callnum|ccode|location','Choice'); >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index bb96644..cfd8e51 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -5536,6 +5536,13 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.09.00.XXX"; >+if (C4::Context->preference("Version") < TransformToNum($DBversion)) { >+ $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacItemLocation','callnum','Show the shelving location of items in the opac','callnum|ccode|location','Choice');"); >+ print "Upgrade to $DBversion done (Add OpacItemLocation syspref)\n"; >+ SetVersion ($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index 4a4d4de..40ed3d3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -249,6 +249,14 @@ OPAC: > no: "Don't allow" > - patrons to log in to their accounts on the OPAC. > - >+ - Show >+ - pref: OpacItemLocation >+ choices: >+ location: location >+ ccode: "collection code" >+ callnum: "call number only" >+ - for items on the OPAC search results. >+ - > - pref: OpacPasswordChange > choices: > yes: Allow >diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl >index 2b5aacc..bdee24d 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl >+++ b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl >@@ -27,6 +27,7 @@ > <xsl:variable name="AlternateHoldingsField" select="substring(marc:sysprefs/marc:syspref[@name='AlternateHoldingsField'], 1, 3)"/> > <xsl:variable name="AlternateHoldingsSubfields" select="substring(marc:sysprefs/marc:syspref[@name='AlternateHoldingsField'], 4)"/> > <xsl:variable name="AlternateHoldingsSeparator" select="marc:sysprefs/marc:syspref[@name='AlternateHoldingsSeparator']"/> >+ <xsl:variable name="OPACItemLocation" select="marc:sysprefs/marc:syspref[@name='OPACItemLocation']"/> > <xsl:variable name="leader" select="marc:leader"/> > <xsl:variable name="leader6" select="substring($leader,7,1)"/> > <xsl:variable name="leader7" select="substring($leader,8,1)"/> >@@ -1020,46 +1021,43 @@ > <xsl:otherwise>No copies available </xsl:otherwise> > </xsl:choose> > </xsl:when> >- <xsl:when test="count(key('item-by-status', 'available'))>0"> >- <span class="available"> >- <b><xsl:text>Copies available for loan: </xsl:text></b> >- <xsl:variable name="available_items" >- select="key('item-by-status', 'available')"/> >- <xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch))[1])]"> >- <xsl:value-of select="items:homebranch"/> >- <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> [<xsl:value-of select="items:itemcallnumber"/>]</xsl:if> >- <xsl:text> (</xsl:text> >- <xsl:value-of select="count(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch)))"/> >- <xsl:text>)</xsl:text> >-<xsl:choose><xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose> >- </xsl:for-each> >- </span> >- </xsl:when> >- </xsl:choose> >+ <xsl:when test="count(key('item-by-status', 'available'))>0"> >+ <span class="available"> >+ <b> >+ <xsl:value-of select="count(key('item-by-status', 'available'))"/> >+ <xsl:choose><xsl:when test="count(key('item-by-status', 'available')) = 1"><xsl:text> copy available for loan at </xsl:text></xsl:when> >+ <xsl:otherwise><xsl:text> copies available for loan at </xsl:text></xsl:otherwise></xsl:choose> >+ </b> >+ <xsl:variable name="available_items" >+ select="key('item-by-status', 'available')"/> >+ <xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch))[1])]"> >+ <xsl:value-of select="items:homebranch"/> >+ <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber and $OPACItemLocation='callnum'"> [<xsl:value-of select="items:itemcallnumber"/>]</xsl:if> >+ <xsl:choose><xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose> >+ </xsl:for-each> >+ </span> >+ </xsl:when> >+ </xsl:choose> > >- <xsl:choose> <xsl:when test="count(key('item-by-status', 'available'))>0"> >- <xsl:choose><xsl:when test="count(key('item-by-status', 'reference'))>0"> >- <br/> >- </xsl:when></xsl:choose> >- </xsl:when> </xsl:choose> >+ <xsl:choose> >+ <xsl:when test="count(key('item-by-status', 'reference'))>0"> >+ <span class="available"> >+ <b> >+ <xsl:value-of select="count(key('item-by-status', 'reference'))"/> >+ <xsl:choose><xsl:when test="count(key('item-by-status', 'reference')) = 1"><xsl:text> copy available for reference at </xsl:text></xsl:when> >+ <xsl:otherwise><xsl:text> copies available for reference at </xsl:text></xsl:otherwise></xsl:choose> >+ </b> >+ <xsl:variable name="reference_items" >+ select="key('item-by-status', 'reference')"/> >+ <xsl:for-each select="$reference_items[generate-id() = generate-id(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch))[1])]"> >+ <xsl:value-of select="items:homebranch"/> >+ <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber and $OPACItemLocation='callnum'"> [<xsl:value-of select="items:itemcallnumber"/>]</xsl:if> >+ <xsl:choose><xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose> >+ </xsl:for-each> >+ </span> >+ </xsl:when> >+ </xsl:choose> > >- <xsl:choose> >- <xsl:when test="count(key('item-by-status', 'reference'))>0"> >- <span class="available"> >- <b><xsl:text>Copies available for reference: </xsl:text></b> >- <xsl:variable name="reference_items" >- select="key('item-by-status', 'reference')"/> >- <xsl:for-each select="$reference_items[generate-id() = generate-id(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch))[1])]"> >- <xsl:value-of select="items:homebranch"/> >- <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> [<xsl:value-of select="items:itemcallnumber"/>]</xsl:if> >- <xsl:text> (</xsl:text> >- <xsl:value-of select="count(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch)))"/> >- <xsl:text>)</xsl:text> >- <xsl:choose><xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose> >- </xsl:for-each> >- </span> >- </xsl:when> >- </xsl:choose> > > <xsl:if test="count(key('item-by-status', 'Checked out'))>0"> > <span class="unavailable"> >@@ -1105,7 +1103,42 @@ > <xsl:text>). </xsl:text> </span> > </xsl:if> > </span> >- </xsl:template> >+ <xsl:choose> >+ <xsl:when test="($OPACItemLocation='location' or $OPACItemLocation='ccode') and (count(key('item-by-status', 'available'))!=0 or count(key('item-by-status', 'reference'))!=0)"> >+ <span class="results_summary" id="location"> >+ <span class="label">Location(s): </span> >+ <xsl:choose> >+ <xsl:when test="count(key('item-by-status', 'available'))>0"> >+ <span class="available"> >+ <xsl:variable name="available_items" select="key('item-by-status', 'available')"/> >+ <xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch))[1])]"> >+ <xsl:choose> >+ <xsl:when test="$OPACItemLocation='location'"><b><xsl:value-of select="concat(items:location,' ')"/></b></xsl:when> >+ <xsl:when test="$OPACItemLocation='ccode'"><b><xsl:value-of select="concat(items:ccode,' ')"/></b></xsl:when> >+ </xsl:choose> >+ <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> <xsl:value-of select="items:itemcallnumber"/></xsl:if> >+ <xsl:choose><xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose> >+ </xsl:for-each> >+ </span> >+ </xsl:when> >+ <xsl:when test="count(key('item-by-status', 'reference'))>0"> >+ <span class="available"> >+ <xsl:variable name="reference_items" select="key('item-by-status', 'reference')"/> >+ <xsl:for-each select="$reference_items[generate-id() = generate-id(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch))[1])]"> >+ <xsl:choose> >+ <xsl:when test="$OPACItemLocation='location'"><b><xsl:value-of select="concat(items:location,' ')"/></b></xsl:when> >+ <xsl:when test="$OPACItemLocation='ccode'"><b><xsl:value-of select="concat(items:ccode,' ')"/></b></xsl:when> >+ </xsl:choose> >+ <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> <xsl:value-of select="items:itemcallnumber"/></xsl:if> >+ <xsl:choose><xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose> >+ </xsl:for-each> >+ </span> >+ </xsl:when> >+ </xsl:choose> >+ </span> >+ </xsl:when> >+ </xsl:choose> >+ </xsl:template> > > <xsl:template name="nameABCDQ"> > <xsl:call-template name="chopPunctuation"> >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 5079
:
4523
|
4534
|
4543
|
4544
|
4545
|
4547
|
9296
|
9297
|
9298
|
9299
|
10912
|
10913
|
10929
|
12317
|
14355
|
14605