Bugzilla – Attachment 140406 Details for
Bug 30036
Add XSLT for authority results view in OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30036: Allow XSLT for authority results view in OPAC
Bug-30036-Allow-XSLT-for-authority-results-view-in.patch (text/plain), 7.26 KB, created by
David Nind
on 2022-09-11 18:00:48 UTC
(
hide
)
Description:
Bug 30036: Allow XSLT for authority results view in OPAC
Filename:
MIME Type:
Creator:
David Nind
Created:
2022-09-11 18:00:48 UTC
Size:
7.26 KB
patch
obsolete
>From c54404f5dba28a82d087ff1cd9667b30a39428b7 Mon Sep 17 00:00:00 2001 >From: jeremy breuillard <jeremy.breuillard@biblibre.com> >Date: Mon, 7 Feb 2022 12:34:52 +0100 >Subject: [PATCH] Bug 30036: Allow XSLT for authority results view in OPAC > >This patch adds a syspref to allow customizing the authority results >view at OPAC with XSLT > >Test plan: >1. For testing make sure to have at least one or more authorities > defined >2. OPAC: Home > Authority search(Submit) > Authority search results > Notice the normal view of results >3. Apply patch >4. INTRA: Home > Administration > System preferences ->find > "AuthorityXSLTOpacResultsDisplay" >5. Write the path where your file is. You can use the one for intranet: > .../koha/koha-tmpl/intranet-tmpl/prog/en/XSLT/UNIMARCauthResults.xsl >6. Save changes >7. Repeat step 2 and notice the xslt view of results > >Signed-off-by: David Nind <david@davidnind.com> >--- > .../data/mysql/atomicupdate/bug-30036.pl | 15 ++++++++++++ > installer/data/mysql/mandatory/sysprefs.sql | 1 + > .../admin/preferences/staff_interface.pref | 5 ++++ > .../opac-authoritiessearchresultlist.tt | 8 ++++++- > opac/opac-authorities-home.pl | 23 +++++++++++++++++++ > 5 files changed, 51 insertions(+), 1 deletion(-) > create mode 100644 installer/data/mysql/atomicupdate/bug-30036.pl > >diff --git a/installer/data/mysql/atomicupdate/bug-30036.pl b/installer/data/mysql/atomicupdate/bug-30036.pl >new file mode 100644 >index 0000000000..13a97986e3 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug-30036.pl >@@ -0,0 +1,15 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => '30036', >+ description => 'Add syspref AuthorityXSLTOpacResultsDisplay', >+ up => sub { >+ my ($args) = @_; >+ my ($dbh, $out) = @$args{qw(dbh out)}; >+ >+ $dbh->do(q{ >+ INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) >+ VALUES ('AuthorityXSLTOpacResultsDisplay','','','Enable XSL stylesheet control over authority results page display on opac','Free') >+ }); >+ }, >+}; >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index 3ee50c6d93..2b0f3ab327 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -70,6 +70,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'), >+('AuthorityXSLTOpacResultsDisplay','','','Enable XSL stylesheet control over authority results page display on opac','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'), >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 32473520c4..f035012f88 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 opac interface using XSLT stylesheet at: ' >+ - pref: AuthorityXSLTOpacResultsDisplay >+ 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 authority results in the staff interface using XSLT stylesheet at: ' > - pref: AuthorityXSLTResultsDisplay >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-authoritiessearchresultlist.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-authoritiessearchresultlist.tt >index 27e000e504..1f9dd8debb 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-authoritiessearchresultlist.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-authoritiessearchresultlist.tt >@@ -106,7 +106,13 @@ > <tbody> > [% FOREACH resul IN result %] > <tr> >- <td>[% PROCESS authresult summary=resul.summary %]</td> >+ <td> >+ [% IF resul.html %] >+ [% resul.html | $raw %] >+ [% ELSE %] >+ [% PROCESS authresult summary=resul.summary authid=resul.authid %] >+ [% END %] >+ </td> > <td><a href="/cgi-bin/koha/opac-authoritiesdetail.pl?authid=[% resul.authid | uri %]">Details</a> > <td>[% resul.authtype | html %]</td> > [% UNLESS ( resul.isEDITORS ) %] >diff --git a/opac/opac-authorities-home.pl b/opac/opac-authorities-home.pl >index eb795f4ed3..0c0f2180ff 100755 >--- a/opac/opac-authorities-home.pl >+++ b/opac/opac-authorities-home.pl >@@ -28,6 +28,8 @@ use C4::Context; > use C4::Output qw( pagination_bar output_html_with_http_headers ); > use C4::Koha; > use C4::Search::History; >+use C4::Languages; >+use Koha::XSLT::Base; > > use Koha::Authority::Types; > use Koha::SearchEngine::Search; >@@ -100,6 +102,27 @@ if ( $op eq "do_search" ) { > $to = $startfrom * $resultsperpage; > } > >+ my $AuthorityXSLTOpacResultsDisplay = C4::Context->preference('AuthorityXSLTOpacResultsDisplay'); >+ if ($results && $AuthorityXSLTOpacResultsDisplay) { >+ 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 = $AuthorityXSLTOpacResultsDisplay; >+ >+ $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; > > $template->param( >-- >2.30.2
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 30036
:
130223
|
130232
|
140002
|
140332
|
140406
|
140407
|
141493
|
141494
|
141495
|
142721
|
142722