[Koha-patches] [PATCH] Bug 7642 - OpacShowTagCloudWeight system preference

Robin Sheat robin at catalyst.net.nz
Sat May 26 03:43:53 CEST 2012


This system preference allows the mouseover text on the tag cloud to be
turned off. The text consists of the weight for the tag, but users are
more likely to confuse it with the number of items that have this tag.
---
 installer/data/mysql/sysprefs.sql                  |    1 +
 installer/data/mysql/updatedatabase.pl             |    8 ++++++++
 .../prog/en/modules/admin/preferences/opac.pref    |    6 ++++++
 koha-tmpl/opac-tmpl/prog/en/modules/opac-tags.tt   |    7 ++++++-
 opac/opac-tags.pl                                  |    7 +++++--
 5 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql
index cc3a9e2..2c276c6 100644
--- a/installer/data/mysql/sysprefs.sql
+++ b/installer/data/mysql/sysprefs.sql
@@ -364,3 +364,4 @@ INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES (
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacStarRatings','all',NULL,'disable|all|details','Choice');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacBrowseResults','1','Disable/enable browsing and paging search results from the OPAC detail page.',NULL,'YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SvcMaxReportRows','10','Maximum number of rows to return via the report web service.',NULL,'Integer');
+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowTagCloudWeight','1','Whether to show the weight of a tag when you hover over its name in the tag cloud',NULL,'YesNo');
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index ca5fb30..f45c657 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -5284,6 +5284,14 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
     SetVersion($DBversion);
 }
 
+$DBversion = "XXX";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+    $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowTagCloudWeight','1','Whether to show the weight of a tag when you hover over its name in the tag cloud',NULL,'YesNo')");
+    print "Upgrade to $DBversion done (Add the 'OpacShowTagCloudWeight' system preference)\n";
+    SetVersion($DBversion);
+}
+
+
 =head1 FUNCTIONS
 
 =head2 TableExists($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 e4ea15b..63ab78b 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
@@ -223,6 +223,12 @@ OPAC:
             - '<br />Note: Available options are: BIBTEX (<code>bibtex</code>), Dublin Core (<code>dc</code>),'
             - 'MARCXML (<code>marcxml</code>), MARC-8 encoded MARC (<code>marc8</code>), Unicode/UTF-8 encoded MARC (<code>utf8</code>),'
             - 'Unicode/UTF-8 encoded MARC without local use -9xx, x9x, xx9- fields and subfields (<code>marcstd</code>), MODS (<code>mods</code>), RIS (<code>ris</code>)'
+        -
+            - pref: OpacShowTagCloudWeight
+              choices:
+                  yes: Show
+                  no: "Don't show"
+            - 'the numerical weight of a tag when you hover over its name in the tag cloud.'
     Features:
         -
             - pref: opacuserlogin
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-tags.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-tags.tt
index 1c291c9..b67d4e9 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-tags.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-tags.tt
@@ -90,7 +90,12 @@
 	[% IF ( TAGLOOP ) %]
 	<div id="tagcloud">
 	[% FOREACH TAGLOO IN TAGLOOP %]
-	<span class="tag" id="tag[% loop.count %]" title="[% TAGLOO.cloudweight %]">
+	    [% IF (showweight) %]
+                <span class="tag" id="tag[% loop.count %]" title="[% TAGLOO.cloudweight %]">
+	    [% ELSE %]
+                <span class="tag" id="tag[% loop.count %]" >
+	    [% END %]
+
 		<a href="/cgi-bin/koha/opac-search.pl?tag=[% TAGLOO.term |url %]&amp;q=[% TAGLOO.term |url %]">
 		[% TAGLOO.term |html %]</a>
 			<span class="tagweight">[% TAGLOO.weight_total %]</span>
diff --git a/opac/opac-tags.pl b/opac/opac-tags.pl
index 36bc096..cab0e43 100755
--- a/opac/opac-tags.pl
+++ b/opac/opac-tags.pl
@@ -234,8 +234,11 @@ if ($loggedinuser) {
 	}
 }
 
-$template->param(tagsview => 1,
-dateformat => C4::Context->preference("dateformat"));
+$template->param(
+    tagsview   => 1,
+    dateformat => C4::Context->preference("dateformat"),
+    showweight => C4::Context->preference("OpacShowTagCloudWeight")
+);
 
 if ($add_op) {
 	my $adds = 0;
-- 
1.7.5.4



More information about the Koha-patches mailing list