From 4409bbcda5f2b395e8c52350a1b8d0d67501330e Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Sat, 31 Dec 2011 17:28:34 +0100 Subject: [PATCH] Bug 7392: Add system preference to define export options in OPAC Content-Type: text/plain; charset="utf-8" NOTE: Patch depends on changes made for bug 7345 for the "marcstd" option. It adds a new system preference 'OpacExportOptions': The new system preference allows to give a list of | separated values to define, which download options are offered in OPAC. Possible options are listed in the system preference editor and include the new export option 'marcstd' from bug 7345. The sequence of the download options in the system preference will be the sequence in the OPAC pull down. If left empty, the export option will be hidden from OPAC. This patch creates a new include file for the OPAC with all the code that is common to the three detail views (regular, MARC, and ISBD). As a side effect of creating this include file, some inconsistencies in OpacSearchForTitleIn were fixed. {BIBLIONUMBER} and {CONTROLNUMBER} were broken for ISBD and MARC view before and should now be replaced with the correct values in all tabs. Signed-off-by: Jared Camins-Esakov Signed-off-by: Marcel de Rooy Resolved merge conflicts on sysprefs.sql and updatedatabase.pl. Feb 13, 2012: Rebased it again. --- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 8 +++ .../prog/en/modules/admin/preferences/opac.pref | 9 +++- .../prog/en/includes/opac-detail-sidebar.inc | 63 ++++++++++++++++++++ .../opac-tmpl/prog/en/modules/opac-ISBDdetail.tt | 56 +----------------- .../opac-tmpl/prog/en/modules/opac-MARCdetail.tt | 55 +----------------- koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 55 +----------------- opac/opac-ISBDdetail.pl | 9 +++ opac/opac-MARCdetail.pl | 22 +++++-- opac/opac-detail.pl | 5 ++ 10 files changed, 114 insertions(+), 169 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/prog/en/includes/opac-detail-sidebar.inc diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index ba79327..0cc79b2 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -335,3 +335,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowMultipleCovers','0','Allow multiple cover images to be attached to each bibliographic record.','1','YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('BorrowerRenewalPeriodBase', 'now', 'Set whether the borrower renewal date should be counted from the dateexpiry or from the current date ','dateexpiry|now','Choice'); INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('AllowItemsOnHoldCheckout',0,'Do not generate RESERVE_WAITING and RESERVED warning when checking out items reserved to someone else. This allows self checkouts for those items.','','YesNo'); +INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacExportOptions','bibtex|dc|marcxml|marc8|utf8|marcstd|mods|ris','Define export options available on OPAC detail page.','','free'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index d4ac31d..7f850f8 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -4671,6 +4671,14 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.07.99.XXX"; #FIXME +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacExportOptions','bibtex|dc|marcxml|marc8|utf8|marcstd|mods|ris','Define available export options on OPAC detail page.','','free');"); + print "Upgrade to $DBversion done (Bug 7345: Add system preference OpacExportOptions.)\n"; + SetVersion($DBversion); +} + + =head1 FUNCTIONS =head2 DropAllForeignKeys($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 d6ae2b2..1872b6e 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 @@ -132,7 +132,7 @@ OPAC: class: file - to override specified settings from the default stylesheet. Enter the filename (if the file is in the server's css directory) or a complete URL beginning with http:// (if the file lives on a remote server). Leave blank to disable. - - - Use the CSS stylesheet /css/ + - Use the CSS stylesheet [% opacthemelang %]/css/ - pref: opaclayoutstylesheet class: file - on all pages in the OPAC, instead of the default (leave blank to disable). @@ -208,6 +208,13 @@ OPAC: Results: "Results page only" Both: "Both Details and Results pages" - 'Note: The corresponding OPACXSLT option must be turned on.' + - + - 'List export options that should be available from OPAC detail page separated by |:' + - pref: OpacExportOptions + class: multi + - '
Note: Available options are: BIBTEX (bibtex), Dublin Core (dc),' + - 'MARCXML (marcxml), MARC-8 encoded MARC (marc8), Unicode/UTF-8 encoded MARC (utf8),' + - 'Unicode/UTF-8 encoded MARC without local use (9xx, x9x, xx9) fields and subfields (marcstd), MODS (mods), RIS (ris)' Features: - - pref: opacuserlogin diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/opac-detail-sidebar.inc b/koha-tmpl/opac-tmpl/prog/en/includes/opac-detail-sidebar.inc new file mode 100644 index 0000000..bbcd54d --- /dev/null +++ b/koha-tmpl/opac-tmpl/prog/en/includes/opac-detail-sidebar.inc @@ -0,0 +1,63 @@ +
    + [% UNLESS ( norequests ) %] + [% IF ( opacuserlogin ) %] + [% IF ( RequestOnOpac ) %] + [% IF ( AllowOnShelfHolds ) %] +
  • Place Hold
  • + [% ELSE %] + [% IF ( ItemsIssued ) %] +
  • Place Hold
  • + [% END %] + [% END %] + [% END %] + [% END %] + [% END %] +
  • Print
  • + [% IF ( virtualshelves ) %] + [% IF ( opacuserlogin ) %][% IF ( loggedinusername ) %] +
  • + Save to Your Lists +
  • + [% END %][% END %] + [% END %] + [% IF ( opacbookbag ) %] +
  • Add to Your Cart
  • + [% END %] +
  • More searches
  • +
+ +[% IF ( OPACSearchForTitleIn ) %] +
+
+

Search for this title in:

+
    + [% OPACSearchForTitleIn %] +
+
+
+[% END %] + +[% IF ( export_options.size ) %] +
+
+ + + + +
+
+[% END %] \ No newline at end of file diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-ISBDdetail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-ISBDdetail.tt index f9984a7..97b64ad 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-ISBDdetail.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-ISBDdetail.tt @@ -46,63 +46,9 @@
-
    -[% UNLESS ( norequests ) %] - [% IF ( opacuserlogin ) %] - [% IF ( RequestOnOpac ) %] - [% IF ( AllowOnShelfHolds ) %] -
  • Place Hold
  • - [% ELSE %] - [% IF ( ItemsIssued ) %] -
  • Place Hold
  • - [% END %] - [% END %] +[% INCLUDE 'opac-detail-sidebar.inc' %] - [% END %] - [% END %] -[% END %] -
  • Print
  • -[% IF ( virtualshelves ) %] - [% IF ( opacuserlogin ) %] [% IF ( loggedinusername ) %] -
  • - Save to Your Lists -
  • - [% END %][% END %] -[% END %] - [% IF ( opacbookbag ) %]
  • - Add to Your Cart -
  • [% END %] -
  • More searches
  • -
- -[% IF ( OPACSearchForTitleIn ) %] -
-
-

Search for this title in:

-
    - -[% OPACSearchForTitleIn %] - -
-
-
-[% END %] - -
-
- - -
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-MARCdetail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-MARCdetail.tt index 284154e..f3d2c91 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-MARCdetail.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-MARCdetail.tt @@ -201,62 +201,9 @@ $(document).ready(function(){
-
    -[% UNLESS ( norequests ) %] - [% IF ( opacuserlogin ) %] - [% IF ( RequestOnOpac ) %] - [% IF ( AllowOnShelfHolds ) %] -
  • Place Hold
  • - [% ELSE %] - [% IF ( ItemsIssued ) %] -
  • Place Hold
  • - [% END %] - [% END %] - - [% END %] - [% END %] -[% END %] -
  • - Print -
  • -[% IF ( virtualshelves ) %] - [% IF ( opacuserlogin ) %] [% IF ( loggedinusername ) %] -
  • - Save to Your Lists -
  • - [% END %][% END %] -[% END %] - [% IF ( opacbookbag ) %]
  • - Add to Your Cart -
  • [% END %] -
  • More searches
  • -
- -[% IF ( OPACSearchForTitleIn ) %] -
-
-

Search for this title in:

-
    - -[% OPACSearchForTitleIn %] - -
-
-
-[% END %] +[% INCLUDE 'opac-detail-sidebar.inc' %] -
-
- - -
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt index dd1c33f..5a2dc09 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt @@ -1035,61 +1035,8 @@ YAHOO.util.Event.onContentReady("furtherm", function () { [% END %] [% END %] -
    - -[% UNLESS ( norequests ) %] - [% IF ( opacuserlogin ) %] - [% IF ( RequestOnOpac ) %] - [% IF ( AllowOnShelfHolds ) %] -
  • Place Hold
  • - [% ELSE %] - [% IF ( ItemsIssued ) %] -
  • Place Hold
  • - [% END %] - [% END %] - [% END %] - [% END %] -[% END %] -
  • Print
  • -[% IF ( virtualshelves ) %] - [% IF ( opacuserlogin ) %][% IF ( loggedinusername ) %] -
  • - Save to Your Lists -
  • - [% END %][% END %] -[% END %] - [% IF ( opacbookbag ) %]
  • Add to Your Cart
  • [% END %] -
  • More searches
  • -
- -[% IF ( OPACSearchForTitleIn ) %] -
-
-

Search for this title in:

-
    - -[% OPACSearchForTitleIn %] -
-
-
-[% END %] - -
-
- - -
-
+[% INCLUDE 'opac-detail-sidebar.inc' %] [% IF ( NovelistSelectProfile ) %] [% IF ( NovelistSelectView == 'right') %]
diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl index c80d41c..3373787 100755 --- a/opac/opac-ISBDdetail.pl +++ b/opac/opac-ISBDdetail.pl @@ -159,13 +159,22 @@ $template->param( reviews => $reviews, ); +#Export options +my $OpacExportOptions=C4::Context->preference("OpacExportOptions"); +my @export_options = split(/\|/,$OpacExportOptions); +$template->{VARS}->{'export_options'} = \@export_options; + #Search for title in links +my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour); + if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){ $dat->{author} ? $search_for_title =~ s/{AUTHOR}/$dat->{author}/g : $search_for_title =~ s/{AUTHOR}//g; $dat->{title} =~ s/\/+$//; # remove trailing slash $dat->{title} =~ s/\s+$//; # remove trailing space $dat->{title} ? $search_for_title =~ s/{TITLE}/$dat->{title}/g : $search_for_title =~ s/{TITLE}//g; $isbn ? $search_for_title =~ s/{ISBN}/$isbn/g : $search_for_title =~ s/{ISBN}//g; + $marccontrolnumber ? $search_for_title =~ s/{CONTROLNUMBER}/$marccontrolnumber/g : $search_for_title =~ s/{CONTROLNUMBER}//g; + $search_for_title =~ s/{BIBLIONUMBER}/$biblionumber/g; $template->param('OPACSearchForTitleIn' => $search_for_title); } diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl index f408cd2..519791c 100755 --- a/opac/opac-MARCdetail.pl +++ b/opac/opac-MARCdetail.pl @@ -270,13 +270,25 @@ if(C4::Context->preference("ISBD")) { $template->param(ISBD => 1); } +#Export options +my $OpacExportOptions=C4::Context->preference("OpacExportOptions"); +my @export_options = split(/\|/,$OpacExportOptions); +$template->{VARS}->{'export_options'} = \@export_options; + #Search for title in links +my $marcflavour = C4::Context->preference("marcflavour"); +my $dat = TransformMarcToKoha( $dbh, $record ); +my $isbn = GetNormalizedISBN(undef,$record,$marcflavour); +my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour); + if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){ - $biblio->{author} ? $search_for_title =~ s/{AUTHOR}/$biblio->{author}/g : $search_for_title =~ s/{AUTHOR}//g; - $biblio->{title} =~ s/\/+$//; # remove trailing slash - $biblio->{title} =~ s/\s+$//; # remove trailing space - $biblio->{title} ? $search_for_title =~ s/{TITLE}/$biblio->{title}/g : $search_for_title =~ s/{TITLE}//g; - $biblio->{isbn} ? $search_for_title =~ s/{ISBN}/$biblio->{isbn}/g : $search_for_title =~ s/{ISBN}//g; + $dat->{author} ? $search_for_title =~ s/{AUTHOR}/$dat->{author}/g : $search_for_title =~ s/{AUTHOR}//g; + $dat->{title} =~ s/\/+$//; # remove trailing slash + $dat->{title} =~ s/\s+$//; # remove trailing space + $dat->{title} ? $search_for_title =~ s/{TITLE}/$dat->{title}/g : $search_for_title =~ s/{TITLE}//g; + $isbn ? $search_for_title =~ s/{ISBN}/$isbn/g : $search_for_title =~ s/{ISBN}//g; + $marccontrolnumber ? $search_for_title =~ s/{CONTROLNUMBER}/$marccontrolnumber/g : $search_for_title =~ s/{CONTROLNUMBER}//g; + $search_for_title =~ s/{BIBLIONUMBER}/$biblionumber/g; $template->param('OPACSearchForTitleIn' => $search_for_title); } diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index c4d8218..dd41bbb 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -891,6 +891,11 @@ if (C4::Context->preference("OPACURLOpenInNewWindow")) { $template->param(covernewwindow => 'false'); } +#Export options +my $OpacExportOptions=C4::Context->preference("OpacExportOptions"); +my @export_options = split(/\|/,$OpacExportOptions); +$template->{VARS}->{'export_options'} = \@export_options; + #Search for title in links my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour); -- 1.6.0.6