Bugzilla – Attachment 121537 Details for
Bug 11083
Authority search result display in staff interface should be XSLT driven
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11083: Add ability to generate authority summary using XSLT
Bug-11083-Add-ability-to-generate-authority-summar.patch (text/plain), 7.62 KB, created by
Julian Maurice
on 2021-06-02 12:59:27 UTC
(
hide
)
Description:
Bug 11083: Add ability to generate authority summary using XSLT
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2021-06-02 12:59:27 UTC
Size:
7.62 KB
patch
obsolete
>From 579d5baab583f09376e883e4af48c1479bd2306d Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Wed, 2 Jun 2021 14:20:34 +0200 >Subject: [PATCH] Bug 11083: Add ability to generate authority summary using > XSLT > >This patch only affects authority search results in the staff interface. >It adds a new system preference AuthorityXSLTResultsDisplay. If set, >each authority search result MARCXML will be transformed using the XSLT >at the given filename or URL. The output will be displayed in place of >the default summary. >If errors occur, the XSLT is ignored and the default summary is >displayed. > >The syspref value can contain {langcode} and {authtypecode} which will >be replaced by the appropriate value (resp. current language and >authority type code) > >Test plan: >1. Apply patch and run updatedatabase >2. Verify that authority search results are not affected yet. >3. Create an XSLT file (for instance in >/home/koha/xslt/en/GEOGR_NAME.xsl) >4. Set AuthorityXSLTResultsDisplay syspref value to >/home/koha/xslt/{langcode}/{authtypecode}.xsl >5. Do an authority search that returns GEOGR_NAME results. Verify that >the summary matches what you expect from your XSLT >6. Do an authority search that returns authorities of other types. >Verify that the default summary is displayed. > >Example of a minimal XSLT: > ><?xml version='1.0' encoding="UTF-8"?> ><xsl:stylesheet version="1.0" > xmlns:marc="http://www.loc.gov/MARC21/slim" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:output omit-xml-declaration="yes"/> > <xsl:template match="marc:record"> > <xsl:element name="div"> > <xsl:attribute name="class"> > <xsl:text>authority-summary</xsl:text> > </xsl:attribute> > <xsl:value-of > select="marc:datafield[@tag='151']/marc:subfield[@code='a']"/> > </xsl:element> > </xsl:template> ></xsl:stylesheet> >--- > authorities/authorities-home.pl | 25 +++++++++++++++++++ > ...d-syspref-AuthorityXSLTResultsDisplay.perl | 9 +++++++ > installer/data/mysql/mandatory/sysprefs.sql | 1 + > .../admin/preferences/staff_interface.pref | 5 ++++ > .../modules/authorities/searchresultlist.tt | 8 +++++- > 5 files changed, 47 insertions(+), 1 deletion(-) > create mode 100644 installer/data/mysql/atomicupdate/add-syspref-AuthorityXSLTResultsDisplay.perl > >diff --git a/authorities/authorities-home.pl b/authorities/authorities-home.pl >index 66083d3285..886701c942 100755 >--- a/authorities/authorities-home.pl >+++ b/authorities/authorities-home.pl >@@ -31,11 +31,13 @@ use C4::Acquisition; > use C4::Koha; > use C4::Biblio; > use C4::Search::History; >+use C4::Languages; > > use Koha::Authority::Types; > use Koha::SearchEngine::Search; > use Koha::SearchEngine::QueryBuilder; > use Koha::Token; >+use Koha::XSLT::Base; > use Koha::Z3950Servers; > > my $query = CGI->new; >@@ -178,6 +180,29 @@ if ( $op eq "do_search" ) { > $to = $startfrom * $resultsperpage; > } > >+ my $AuthorityXSLTResultsDisplay = C4::Context->preference('AuthorityXSLTResultsDisplay'); >+ if ($results && $AuthorityXSLTResultsDisplay) { >+ my $lang = C4::Languages::getlanguage(); >+ foreach my $result (@$results) { >+ my $authority = Koha::Authorities->find($result->{authid}); >+ next unless $authority; >+ >+ my $authtypecode = $authority->authtypecode; >+ my $xsl = $AuthorityXSLTResultsDisplay; >+ $xsl =~ s/\{langcode\}/$lang/g; >+ $xsl =~ s/\{authtypecode\}/$authtypecode/g; >+ >+ my $xslt_engine = Koha::XSLT::Base->new; >+ my $output = $xslt_engine->transform({ xml => $authority->marcxml, file => $xsl }); >+ if ($xslt_engine->err) { >+ warn "XSL transformation failed ($xsl): " . $xslt_engine->err; >+ next; >+ } >+ >+ $result->{html} = $output; >+ } >+ } >+ > $template->param( result => $results ) if $results; > > my $max_result_window = $searcher->max_result_window; >diff --git a/installer/data/mysql/atomicupdate/add-syspref-AuthorityXSLTResultsDisplay.perl b/installer/data/mysql/atomicupdate/add-syspref-AuthorityXSLTResultsDisplay.perl >new file mode 100644 >index 0000000000..728aee12af >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/add-syspref-AuthorityXSLTResultsDisplay.perl >@@ -0,0 +1,9 @@ >+$DBversion = 'XXX'; >+if (CheckVersion($DBversion)) { >+ $dbh->do(q{ >+ INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES >+ ('AuthorityXSLTResultsDisplay','','','Enable XSL stylesheet control over authority results page display on intranet','Free') >+ }); >+ >+ NewVersion($DBversion, '11083', 'Add syspref AuthorityXSLTResultsDisplay'); >+} >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index 0a86168ee0..78625a0222 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -68,6 +68,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('AuthorityMergeLimit','50',NULL,'Maximum number of biblio records updated immediately when an authority record has been modified.','integer'), > ('AuthorityMergeMode','loose','loose|strict','Authority merge mode','Choice'), > ('AuthoritySeparator','--','10','Used to separate a list of authorities in a display. Usually --','free'), >+('AuthorityXSLTResultsDisplay','','','Enable XSL stylesheet control over authority results page display on intranet','Free'), > ('AuthSuccessLog','0',NULL,'If enabled, log successful authentications','YesNo'), > ('autoBarcode','OFF','incremental|annual|hbyymmincr|EAN13|OFF','Used to autogenerate a barcode: incremental will be of the form 1, 2, 3; annual of the form 2007-0001, 2007-0002; hbyymmincr of the form HB08010001 where HB=Home Branch','Choice'), > ('AutoCreateAuthorities','0',NULL,'Automatically create authorities that do not exist when cataloging records.','YesNo'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref >index a2b25e5168..2c9fb74a0a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref >@@ -1,5 +1,10 @@ > Staff interface: > Appearance: >+ - >+ - 'Display authority results in the staff interface using XSLT stylesheet at: ' >+ - pref: AuthorityXSLTResultsDisplay >+ class: file >+ - '<br />Options:<ul><li>Put a path to define a xslt file</li><li>Put an URL for an external specific stylesheet.</li></ul>{langcode} will be replaced with current interface language and {authtypecode} will be replaced by the authority type code' > - > - "Display language selector on " > - pref: StaffLangSelectorMode >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt >index 3baec6db23..60092cff9d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt >@@ -55,7 +55,13 @@ > </tr> > [% FOREACH resul IN result %] > <tr data-authid="[% resul.authid | html %]"> >- <td>[% PROCESS authresult summary=resul.summary authid=resul.authid %]</td> >+ <td> >+ [% IF resul.html %] >+ [% resul.html | $raw %] >+ [% ELSE %] >+ [% PROCESS authresult summary=resul.summary authid=resul.authid %] >+ [% END %] >+ </td> > <td>[% resul.authtype | html %]</td> > [% UNLESS ( resul.isEDITORS ) %] > <td> >-- >2.20.1
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 11083
:
121537
|
128913
|
130051
|
130052
|
132269
|
132270