From 47a606ebc39e5c71c04adf034415c87d78c03e85 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 8 Jan 2016 11:19:50 -0300 Subject: [PATCH] Bug 15527: (followup) Allow using custom stylesheets This patch introduces a syspref to let users choose their own XSLT stylesheets for the OAI-PMH front end. Regards Sponsored-by: Universidad Empresarial Siglo 21 --- Koha/OAI/Server/Repository.pm | 8 +++++++- .../data/mysql/atomicupdate/bug_15527_oai_stylesheets.sql | 12 ++++++++++++ installer/data/mysql/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/web_services.pref | 4 ++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_15527_oai_stylesheets.sql diff --git a/Koha/OAI/Server/Repository.pm b/Koha/OAI/Server/Repository.pm index 374ce29..ff2fc8e 100644 --- a/Koha/OAI/Server/Repository.pm +++ b/Koha/OAI/Server/Repository.pm @@ -136,7 +136,13 @@ sub new { } $response->set_handler( XML::SAX::Writer->new( Output => *STDOUT ) ); - $response->xslt( "/opac-tmpl/xslt/OAI.xslt" ); + + my $stylesheet = C4::Context->preference('OAI-PMH:CustomStylesheet'); + if ( !$stylesheet ) { + # fallback to shipped xslt + $stylesheet = '/opac-tmpl/xslt/OAI.xslt'; + } + $response->xslt( $stylesheet ); $response->generate; bless $self, $class; diff --git a/installer/data/mysql/atomicupdate/bug_15527_oai_stylesheets.sql b/installer/data/mysql/atomicupdate/bug_15527_oai_stylesheets.sql new file mode 100644 index 0000000..5945cc0 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_15527_oai_stylesheets.sql @@ -0,0 +1,12 @@ +INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) +VALUES('OAI-PMH:CustomStylesheet',NULL,'Use a custom stylesheet instead of the default stylesheet for the OAI-PMH server. Leave the field blank to use the default.',NULL,'free'); + +-- $DBversion = "3.23.00.XXX"; +-- if(CheckVersion($DBversion)) { +-- $dbh->do(q{ +-- INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) +-- VALUES('OAI-PMH:CustomStylesheet',NULL,'Use a custom stylesheet instead of the default stylesheet for the OAI-PMH server. Leave the field blank to use the default.',NULL,'free') +-- }); +-- print "Upgrade to $DBversion done (Bug 15527: Add a stylesheet for OAI-PMH to aid usability)\n"; +-- SetVersion($DBversion); +-- } \ No newline at end of file diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index aa53139..7e38861 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -255,6 +255,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OAI-PMH:ConfFile','',NULL,'If empty, Koha OAI Server operates in normal mode, otherwise it operates in extended mode.','File'), ('OAI-PMH:DeletedRecord','persistent','Koha\'s deletedbiblio table will never be deleted (persistent), might be deleted (transient), or will never have any data in it (no)','transient|persistent|no','Choice'), ('OAI-PMH:MaxCount','50',NULL,'OAI-PMH maximum number of records by answer to ListRecords and ListIdentifiers queries','Integer'), +('OAI-PMH:CustomStylesheet',NULL,NULL,'Use a custom stylesheet instead of the default stylesheet for the OAI-PMH server. Leave the field blank to use the default.','free'), ('OCLCAffiliateID','','','Use with FRBRizeEditions and XISBN. You can sign up for an AffiliateID here: http://www.worldcat.org/wcpa/do/AffiliateUserServices?method=initSelfRegister','free'), ('OPACAcquisitionDetails','0','','Show the acquisition details at the OPAC','YesNo'), ('OpacAddMastheadLibraryPulldown','0','','Adds a pulldown menu to select the library to search on the opac masthead.','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref index ee65980..5e14635 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref @@ -28,6 +28,10 @@ Web services: no: Disable - automatic update of OAI-PMH sets when a bibliographic record is created or updated - + - Use + - pref: "OAI-PMH:CustomStylesheet" + - instead of the default stylesheet for the OAI-PMH server. Leave the field blank to use the default. + - - Koha's deletedbiblio table - pref: "OAI-PMH:DeletedRecord" choices: -- 2.7.0