Bugzilla – Attachment 158772 Details for
Bug 35305
Add XSLT for authority details page in staff interface
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35305: Add XSLT for authority details page in staff interface
Bug-35305-Add-XSLT-for-authority-details-page-in-s.patch (text/plain), 7.83 KB, created by
Fridolin Somers
on 2023-11-09 21:29:49 UTC
(
hide
)
Description:
Bug 35305: Add XSLT for authority details page in staff interface
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2023-11-09 21:29:49 UTC
Size:
7.83 KB
patch
obsolete
>From 1ab7dfd1aff44a12f4e22ad811f3c3877278a213 Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Thu, 9 Nov 2023 11:20:43 -1000 >Subject: [PATCH] Bug 35305: Add XSLT for authority details page in staff > interface > >This adds a new system preference 'AuthorityXSLTDetailsDisplay'. >If set, authority MARCXML will be transformed using the XSLT >at the given filename or URL. >The HTML output will be displayed in place of tabs in details page. > >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) Search for an authority type GEOGR_NAME and view details page >3) Verify that display is not affected yet >4) Create an XSLT file (for example in /home/koha/xslt/en/GEOGR_NAME.xsl) >5) Set 'AuthorityXSLTDetailsDisplay' syspref value to : > /home/koha/xslt/{langcode}/{authtypecode}.xsl >6) Refresh details page >7) Verify that display matches what you expect from your XSLT >8) Go to an authority of another type >9) Verify that the default display is used > >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/detail.pl | 28 ++++++++++++++++--- > .../data/mysql/atomicupdate/bug_35305.pl | 15 ++++++++++ > installer/data/mysql/mandatory/sysprefs.sql | 1 + > .../admin/preferences/staff_interface.pref | 5 ++++ > .../prog/en/modules/authorities/detail.tt | 5 ++++ > 5 files changed, 50 insertions(+), 4 deletions(-) > create mode 100755 installer/data/mysql/atomicupdate/bug_35305.pl > >diff --git a/authorities/detail.pl b/authorities/detail.pl >index a95460958b..9127b8c3f6 100755 >--- a/authorities/detail.pl >+++ b/authorities/detail.pl >@@ -38,16 +38,19 @@ parameters tables. > > use Modern::Perl; > >+use CGI qw ( -utf8 ); >+ > use C4::Auth qw( get_template_and_user ); > use C4::AuthoritiesMarc qw( GetAuthority GenerateHierarchy GetTagsLabels ); > use C4::Context; >-use C4::Output qw( output_html_with_http_headers ); >-use CGI qw ( -utf8 ); > use C4::Koha; >-use Koha::Authorities; >+use C4::Languages; >+use C4::Output qw( output_html_with_http_headers ); > >+use Koha::Authorities; > use Koha::Authority::Types; > use Koha::Token; >+use Koha::XSLT::Base; > use Koha::Z3950Servers; > > our ($tagslib); >@@ -213,7 +216,24 @@ while (my ($tagfield) = $sth->fetchrow) { > } > chop $biblio_fields if $biblio_fields; > >-build_tabs ($template, $record, $dbh,"",$query); >+my $AuthorityXSLTDetailsDisplay = C4::Context->preference('AuthorityXSLTDetailsDisplay'); >+if ( $AuthorityXSLTDetailsDisplay ) { >+ my $xsl = $AuthorityXSLTDetailsDisplay; >+ my $lang = C4::Languages::getlanguage(); >+ $xsl =~ s/\{langcode\}/$lang/g; >+ $xsl =~ s/\{authtypecode\}/$authtypecode/g; >+ >+ my $xslt_engine = Koha::XSLT::Base->new; >+ my $output = $xslt_engine->transform({ xml => $authobj->marcxml, file => $xsl }); >+ if ($xslt_engine->err) { >+ warn "XSL transformation failed ($xsl): " . $xslt_engine->err; >+ next; >+ } >+ >+ $template->param( html => $output ); >+} else { >+ build_tabs ($template, $record, $dbh,"",$query); >+} > > my $servers = Koha::Z3950Servers->search( > { >diff --git a/installer/data/mysql/atomicupdate/bug_35305.pl b/installer/data/mysql/atomicupdate/bug_35305.pl >new file mode 100755 >index 0000000000..f5d1c64cd3 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_35305.pl >@@ -0,0 +1,15 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "35305", >+ description => "Add XSLT for authority details display in staff interface", >+ up => sub { >+ my ($args) = @_; >+ my ( $dbh, $out ) = @$args{qw(dbh out)}; >+ $dbh->do(q{ >+ INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) >+ VALUES ('AuthorityXSLTDetailsDisplay','','','Enable XSL stylesheet control over authority details page display on intranet','Free') >+ }); >+ say $out "Added new system preference 'AuthorityXSLTDetailsDisplay'"; >+ }, >+}; >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index 3e6715120d..4b35edeb9a 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -76,6 +76,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('AuthoritySeparator','--','10','Used to separate a list of authorities in a display. Usually --','free'), > ('AuthorityXSLTOpacDetailsDisplay','','','Enable XSL stylesheet control over authority details page in the OPAC','Free'), > ('AuthorityXSLTOpacResultsDisplay','','','Enable XSL stylesheet control over authority results page in the OPAC','Free'), >+('AuthorityXSLTDetailsDisplay','','','Enable XSL stylesheet control over authority details page display on intranet','Free'), > ('AuthorityXSLTResultsDisplay','','','Enable XSL stylesheet control over authority results page display on intranet','Free'), > ('AuthorLinkSortBy','default','call_number|pubdate|acqdate|title','Specify the default field used for sorting when click author links','Choice'), > ('AuthorLinkSortOrder','asc','asc|dsc|az|za','Specify the default sort order for author links','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 62dca5a673..b17828d8b1 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 >@@ -5,6 +5,11 @@ Staff interface: > - 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 authority details in the staff interface using XSLT stylesheet at: ' >+ - pref: AuthorityXSLTDetailsDisplay >+ 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/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/detail.tt >index 74ab0c56ee..4862ab16d8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/detail.tt >@@ -70,6 +70,10 @@ > [% END %] > </div> > >+ [% IF html %] >+ [% html | $raw %] >+ [% ELSE %] >+ > [% WRAPPER tabs id= "authoritiestabs" %] > [% WRAPPER tabs_nav %] > [% FOREACH BIG_LOO IN BIG_LOOP %] >@@ -123,6 +127,7 @@ > [% END # /FOREACH BIG_LOO %] > [% END # /WRAPPER tab_panels %] > [% END # /WRAPPER tabs %] >+ [% END # /IF html %] > > [% END # /IF ( unknownauthid ) %] > </div> <!-- /.col-md-8 col-md-offset-2 --> >-- >2.42.0
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 35305
:
158772
|
158775
|
158781
|
167302
|
167303
|
167304
|
167305
|
167362
|
167363
|
167364
|
173439
|
173440
|
173441