[Koha-patches] [PATCH] Adds system preferences and template code to support LibraryThing for Libraries.

Chris Catalfo ccatalfo at gmail.com
Fri Mar 27 14:26:11 CET 2009


Changes made:
Two new system preferences are added: LibraryThingForLibrariesEnabled (yes/no) and LibraryThingForLibrariesID (account id).
sysprefs.sql is updated to insert these.
Search results template is modified so that if enabled, LibraryThing reviews are inserted below each search result.
Bib detail template is updated so that if enabled, LibraryThing editions, related items, tags and reviews are shown under the item metadata.
COiNS span is also updated on bib detail to include subtitle in rft.title field as this improves LibraryThing review results.
---
 admin/systempreferences.pl                         |    2 ++
 installer/data/mysql/en/mandatory/sysprefs.sql     |    2 ++
 .../opac-tmpl/prog/en/modules/opac-detail.tmpl     |   19 ++++++++++++++-----
 .../opac-tmpl/prog/en/modules/opac-results.tmpl    |    5 ++++-
 opac/opac-detail.pl                                |    4 ++++
 opac/opac-search.pl                                |    4 +++-
 6 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/admin/systempreferences.pl b/admin/systempreferences.pl
index 806afc3..67ad3be 100755
--- a/admin/systempreferences.pl
+++ b/admin/systempreferences.pl
@@ -224,6 +224,8 @@ $tabsysprefs{AmazonAssocTag}         = "EnhancedContent";
 $tabsysprefs{AmazonSimilarItems}     = "EnhancedContent";
 $tabsysprefs{OPACAmazonContent}      = "EnhancedContent";
 $tabsysprefs{OPACAmazonSimilarItems} = "EnhancedContent";
+$tabsysprefs{LibraryThingforLibrariesId} = "EnhancedContent";
+$tabsysprefs{LibraryThingforLibrariesEnabled} = "EnhancedContent";
 
 # Baker & Taylor
 $tabsysprefs{BakerTaylorBookstoreURL} = 'EnhancedContent';
diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql
index c79a727..cbdd5da 100644
--- a/installer/data/mysql/en/mandatory/sysprefs.sql
+++ b/installer/data/mysql/en/mandatory/sysprefs.sql
@@ -215,3 +215,5 @@ INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES
 INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` ) VALUES ( 'UseBranchTransferLimits', '0', '', 'If ON, Koha will will use the rules defined in branch_transfer_limits to decide if an item transfer should be allowed.', 'YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowHoldPolicyOverride', '0', 'Allow staff to override hold policies when placing holds',NULL,'YesNo');
 INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` ) VALUES ( 'BranchTransferLimitsType', 'ccode', 'itemtype|ccode', 'When using branch transfer limits, choose whether to limit by itemtype or collection code.', 'Choice');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('LibraryThingForLibrariesID','','See: http://librarything.com/forlibraries/','','free');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('LibraryThingForLibrariesEnabled','0','','Enable or disable all Baker & Taylor features.','YesNo');
\ No newline at end of file
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
index 73fdeca..87ce8fb 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
@@ -112,7 +112,7 @@
     <!-- TMPL_IF NAME="pages" --><span class="results_summary"><span class="label">Physical details:</span> <!-- TMPL_VAR NAME="pages" --> <!-- TMPL_VAR NAME="illus" --> <!-- TMPL_VAR NAME="size" --></span><!-- /TMPL_IF -->
     <!-- COinS / OpenURL -->
     <!-- TMPL_IF NAME="ocoins_format" -->
-    <span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3A<!-- TMPL_VAR NAME="ocoins_format" -->&amp;rft.au=<!-- TMPL_VAR NAME="author" -->&amp;rft.btitle=<!-- TMPL_VAR NAME="title" -->&amp;rft.date=<!-- TMPL_VAR NAME="publicationyear" -->&amp;rft.pages=<!-- TMPL_VAR NAME="pages" -->&amp;rft.isbn=<!-- TMPL_VAR NAME=amazonisbn -->&amp;rft.aucorp=&amp;rft.place=<!-- TMPL_VAR NAME="place" -->&amp;rft.pub=<!-- TMPL_VAR NAME="publishercode" -->&amp;rft.edition=<!-- TMPL_VAR NAME="edition" -->&amp;rft.series=<!-- TMPL_VAR NAME="series" -->&amp;rft.genre="></span><!-- /TMPL_IF -->
+    <span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3A<!-- TMPL_VAR NAME="ocoins_format" -->&amp;rft.au=<!-- TMPL_VAR NAME="author" -->&amp;rft.btitle=<!-- TMPL_VAR NAME="title" --> <!-- TMPL_VAR NAME="subtitle" -->&amp;rft.date=<!-- TMPL_VAR NAME="publicationyear" -->&amp;rft.pages=<!-- TMPL_VAR NAME="pages" -->&amp;rft.isbn=<!-- TMPL_VAR NAME=amazonisbn -->&amp;rft.aucorp=&amp;rft.place=<!-- TMPL_VAR NAME="place" -->&amp;rft.pub=<!-- TMPL_VAR NAME="publishercode" -->&amp;rft.edition=<!-- TMPL_VAR NAME="edition" -->&amp;rft.series=<!-- TMPL_VAR NAME="series" -->&amp;rft.genre="></span><!-- /TMPL_IF -->
     <!-- TMPL_IF name="isbn" -->
     <!-- unAPI <abbr/> tag -->
     <span class="results_summary"><span class="label">ISBN: </span><abbr class="unapi-id" title="koha:isbn:<!-- TMPL_VAR NAME="isbn" -->"><!-- TMPL_VAR NAME="isbn" --></abbr></span><!-- /TMPL_IF -->
@@ -183,15 +183,21 @@
         </div>
         <!-- /TMPL_IF -->
         <!-- /TMPL_IF -->
-
+<!-- TMPL_IF NAME="LibraryThingForLibrariesID">
+<!-- ltfl content -->
+<span class="results_summary"><div id="ltfl_related" class="ltfl"></div></span>
+<span class="results_summary"><div id="ltfl_similars" class="ltfl"></div></span>
+<span class="results_summary"><div id="ltfl_tagbrowse" class="ltfl"></div></span>
+<span class="results_summary"><span class="label">Reviews from LibraryThing.com:</span><div class="ltfl_reviews"></div></span>
+<!-- /TMPL_IF -->
     <!-- TMPL_IF NAME="TagsShowOnDetail" -->
         <div class="results_summary">
         <!-- TMPL_IF NAME="TagLoop" -->
-        <span class="label">Tags:</span>
+        <span class="label">Tags from this library:</span>
             <ul><!-- TMPL_LOOP NAME="TagLoop" -->
             <li><a href="/cgi-bin/koha/opac-search.pl?tag=<!-- TMPL_VAR NAME="term" ESCAPE="URL" -->&amp;q=<!-- TMPL_VAR NAME="term" ESCAPE="URL" -->"><!-- TMPL_VAR NAME="term" ESCAPE="HTML" --></a> <span class="weight">(<!-- TMPL_VAR NAME="weight_total" -->)</span></li>
             <!-- /TMPL_LOOP -->
-            </ul><!-- TMPL_ELSE -->No tags for this title. 
+            </ul><!-- TMPL_ELSE --><span class="label">Tags from this library: </span><div>No tags from this library for this title.</div>
         <!-- /TMPL_IF -->
         <!-- TMPL_IF NAME="TagsInputOnDetail" -->
             <!-- TMPL_IF NAME="loggedinusername" -->
@@ -503,7 +509,7 @@
         <!-- /TMPL_LOOP -->
         <!-- TMPL_ELSE -->
 
-    <p> Sorry, there are no reviews available for this title. <!-- TMPL_IF NAME="isbn" --><!-- TMPL_IF NAME="OPACURLOpenInNewWindow" --><a href="http://www.amazon.com/gp/customer-reviews/write-a-review.html/002-2970817-7876066?%5Fencoding=UTF8&amp;asin=<!-- TMPL_VAR NAME="amazonisbn" -->&amp;store=books" target="_blank">Add your own review</a><!-- TMPL_ELSE --><a href="http://www.amazon.com/gp/customer-reviews/write-a-review.html/002-2970817-7876066?%5Fencoding=UTF8&amp;asin=<!-- TMPL_VAR NAME="amazonisbn" -->&amp;store=books">Add your own review</a><!-- /TMPL_IF --><!-- /TMPL_IF --></p>
+    <p> Sorry, there are no reviews from this library available for this title. <!-- TMPL_IF NAME="isbn" --><!-- TMPL_IF NAME="OPACURLOpenInNewWindow" --><a href="http://www.amazon.com/gp/customer-reviews/write-a-review.html/002-2970817-7876066?%5Fencoding=UTF8&amp;asin=<!-- TMPL_VAR NAME="amazonisbn" -->&amp;store=books" target="_blank">Add your own review</a><!-- TMPL_ELSE --><a href="http://www.amazon.com/gp/customer-reviews/write-a-review.html/002-2970817-7876066?%5Fencoding=UTF8&amp;asin=<!-- TMPL_VAR NAME="amazonisbn" -->&amp;store=books">Add your own review</a><!-- /TMPL_IF --><!-- /TMPL_IF --></p>
 
         <!-- /TMPL_IF -->
 </div>
@@ -592,4 +598,7 @@
     </div>
 <!-- /TMPL_IF -->
 </div>
+<!-- TMPL_IF NAME="LibraryThingForLibrariesID" -->
+<script src="http://ltfl.librarything.com/forlibraries/widget.js?systype=koha&id=<!-- TMPL_VAR NAME="LibraryThingForLibrariesID" -->" type="text/javascript"></script><noscript>This page contains enriched content visible when JavaScript is enabled or by clicking <a href="http://www.librarything.com/forlibraries/noscript.php?id=326-4221977395&accessibility=1">here</a>.</noscript>
+<!-- /TMPL_IF -->
 <!-- TMPL_INCLUDE NAME="opac-bottom.inc" -->
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl
index 6faefd0..8cf63ed 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl
@@ -292,6 +292,7 @@ $(document).ready(function(){
 
 				<!-- /TMPL_IF -->
 				
+	<!-- TMPL_IF NAME="LibraryThingForLibrariesID" --><div class="ltfl_reviews"></div><!-- /TMPL_IF -->
 				<!-- TMPL_IF NAME="TagsEnabled" -->
                 <!-- TMPL_IF NAME="TagsShowOnList" -->
                 <!-- TMPL_IF NAME="TagLoop" -->
@@ -363,5 +364,7 @@ $(document).ready(function(){
 </div></div>
         <!-- /TMPL_IF -->
 </div>
-
+<!-- TMPL_IF NAME="LibraryThingForLibrariesID" -->
+<script src="http://ltfl.librarything.com/forlibraries/widget.js?id=<!-- TMPL_VAR NAME="LibraryThingForLibrariesID" -->&systype=koha" type="text/javascript"></script>
+<!-- /TMPL_IF -->
 <!-- TMPL_INCLUDE NAME="opac-bottom.inc" -->
diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl
index 24f59b0..e22ce7d 100755
--- a/opac/opac-detail.pl
+++ b/opac/opac-detail.pl
@@ -289,6 +289,10 @@ if ( C4::Context->preference("OPACAmazonContent") == 1 ) {
     $template->param( AMAZON_SIMILAR_PRODUCTS => \@similar_products );
     $template->param( AMAZON_EDITORIAL_REVIEWS    => $editorial_reviews );
 }
+# LibraryThingForLibraries
+if( C4::Context->preference('LibraryThingForLibrariesEnabled') ) {
+    $template->param(LibraryThingForLibrariesID => C4::Context->preference('LibraryThingForLibrariesID') );
+}
 # Shelf Browser Stuff
 if (C4::Context->preference("OPACShelfBrowser")) {
     # pick the first itemnumber unless one was selected by the user
diff --git a/opac/opac-search.pl b/opac/opac-search.pl
index f9d51f9..3b297f5 100755
--- a/opac/opac-search.pl
+++ b/opac/opac-search.pl
@@ -89,7 +89,9 @@ if (C4::Context->preference('TagsEnabled')) {
 		C4::Context->preference($_) and $template->param($_ => 1);
 	}
 }
-
+if( C4::Context->preference('LibraryThingForLibrariesEnabled')) {
+    $template->param(LibraryThingForLibrariesID => C4::Context->preference('LibraryThingForLibrariesID'));
+}
 ## URI Re-Writing
 # Deprecated, but preserved because it's interesting :-)
 # The same thing can be accomplished with mod_rewrite in
-- 
1.5.4.3




More information about the Koha-patches mailing list