Bug 22445: Add new prefs *CustomCoverImages*
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 1 Mar 2019 11:00:02 +0000 (08:00 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 22 Oct 2019 14:02:47 +0000 (15:02 +0100)
This patch set adds a new method to display cover images for
bibliographic records.
The idea is to provide a flexible way allowing several use cases:
- local path
- remote url
- webservice
which would follow a given pattern.

So far only the following patterns are available:
- {isbn} will be replaced byt the isbn of the record
- {issn}
- using MARC subfields:
  {024$a} to replace with the value in 024$a
(Note that the selector has been changed from %% to {} in a coming
patch)

For example
- /your/local/images/{isbn}.png
- https://covers.openlibrary.org/b/isbn/{isbn}-M.jpb
- etc.

There are 3 new sysprefs:
CustomCoverImagesURL
=> Define the path/url
CustomCoverImages
=> Turn on/off the display of the custom cover image in the staff client
OPACCustomCoverImages
=> Turn on/off the display of the custom cover image at the OPAC

Sponsored-by: Orex Digital
Signed-off-by: Hayley Mapley <hayleymapley@catalyst.net.nz>
Signed-off-by: Hugo Agud <hagud@orex.es>
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Michal Denar <black23@gmail.com>
Signed-off-by: Kyle Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

installer/data/mysql/atomicupdate/bug_xxxxx.perl [new file with mode: 0644]
installer/data/mysql/sysprefs.sql
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref

diff --git a/installer/data/mysql/atomicupdate/bug_xxxxx.perl b/installer/data/mysql/atomicupdate/bug_xxxxx.perl
new file mode 100644 (file)
index 0000000..4cf30e8
--- /dev/null
@@ -0,0 +1,14 @@
+$DBversion = 'XXX'; # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+    $dbh->do(q{
+        INSERT IGNORE INTO systempreferences
+            ( variable, value, options, explanation, type )
+        VALUES
+            ('CustomCoverImages','0',NULL,'If enabled, the custom cover images will be displayed in the staff client. CustomCoverImagesURL must be defined.','YesNo'),
+            ('OPACCustomCoverImages','0',NULL,'If enabled, the custom cover images will be displayed at the OPAC. CustomCoverImagesURL must be defined.','YesNo'),
+            ('CustomCoverImagesURL','',NULL,'Define an URL serving book cover images, using the following patterns: %issn%, %isbn%, FIXME ADD MORE (use it with CustomCoverImages and/or OPACCustomCoverImages)','free')
+    });
+
+    SetVersion( $DBversion );
+    print "Upgrade to $DBversion done (Bug XXXXX - Add new pref *CustomCoverImages*)\n";
+}
index 75b04e2..11aa53d 100644 (file)
@@ -128,6 +128,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('CronjobLog','0',NULL,'If ON, log information from cron jobs.','YesNo'),
 ('CumulativeRestrictionPeriods',0,NULL,'Cumulate the restriction periods instead of keeping the highest','YesNo'),
 ('CurrencyFormat','US','US|FR|CH','Determines the display format of currencies. eg: \'36000\' is displayed as \'360 000,00\'  in \'FR\' or \'360,000.00\'  in \'US\'.','Choice'),
+('CustomCoverImages','0',NULL,'If enabled, the custom cover images will be displayed in the staff client. CustomCoverImagesURL must be defined.','YesNo'),
+('CustomCoverImagesURL','',NULL,'Define an URL serving book cover images, using the following patterns: %issn%, %isbn%, FIXME ADD MORE (use it with CustomCoverImages and/or OPACCustomCoverImages)','free'),
 ('dateformat','us','metric|us|iso|dmydot','Define global date format (us mm/dd/yyyy, metric dd/mm/yyy, ISO yyyy-mm-dd, dmydot dd.mm.yyyy)','Choice'),
 ('DebugLevel','2','0|1|2','Define the level of debugging information sent to the browser when errors are encountered (set to 0 in production). 0=none, 1=some, 2=most','Choice'),
 ('decreaseLoanHighHolds',NULL,'','Decreases the loan period for items with number of holds above the threshold specified in decreaseLoanHighHoldsValue','YesNo'),
@@ -361,6 +363,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('OpacCloud','0',NULL,'If ON, enables subject cloud on OPAC','YesNo'),
 ('OpacAdditionalStylesheet','','','Define an auxiliary stylesheet for OPAC use, to override specified settings from the primary opac.css 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).','free'),
 ('OpacCoce','0', NULL, 'If on, enables cover retrieval from the configured Coce server in the OPAC', 'YesNo'),
+('OPACCustomCoverImages','0',NULL,'If enabled, the custom cover images will be displayed at the OPAC. CustomCoverImagesURL must be defined.','YesNo'),
 ('OpacCustomSearch','','70|10','Replace the search box on the OPAC with the provided HTML','Textarea'),
 ('opaccredits','','70|10','Define HTML Credits at the bottom of the OPAC page','Textarea'),
 ('OPACdefaultSortField','relevance','relevance|popularity|call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'),
index 7d1cdfc..1315dd9 100644 (file)
@@ -313,7 +313,7 @@ Enhanced Content:
             - pref: TagsExternalDictionary
               class: file
             - on the server to be approved without moderation.
-    Local Cover Images:
+    Local or remote cover images:
         -
             - pref: LocalCoverImages
               choices:
@@ -332,6 +332,21 @@ Enhanced Content:
                   yes: Allow
                   no: "Don't allow"
             - multiple images to be attached to each bibliographic record.
+        -
+            - pref: CustomCoverImages
+              choices:
+                  yes: Display
+                  no: "Don't display"
+            - "custom remote url images in the staff client.<br/>"
+            - pref: OPACCustomCoverImages
+              choices:
+                  yes: Display
+                  no: "Don't display"
+            - "custom remote url images at the OPAC.<br/>"
+            - "Using the following URL:"
+            - pref: CustomCoverImagesURL
+              class: url
+            - "You can defined it using the following patterns: %isbn%, %issn%."
     HTML5 Media:
         -
             - Show a tab with a HTML5 media player for files catalogued in field 856