[Koha-patches] [PATCH] Bug-5621 Adding Google Transliteration on opac search page.
Amit Gupta
amit.gupta at osslabs.biz
Tue Jan 18 04:36:54 CET 2011
---
C4/Auth.pm | 1 +
installer/data/mysql/en/mandatory/sysprefs.sql | 1 +
installer/data/mysql/updatedatabase.pl | 8 ++++-
.../prog/en/modules/admin/preferences/opac.pref | 7 +++++
.../opac-tmpl/prog/en/includes/doc-head-close.inc | 4 +-
.../opac-tmpl/prog/en/js/googletransliteration.js | 29 ++++++++++++++++++++
kohaversion.pl | 2 +-
opac/opac-main.pl | 5 ---
opac/opac-search.pl | 5 ---
9 files changed, 47 insertions(+), 15 deletions(-)
create mode 100644 koha-tmpl/opac-tmpl/prog/en/js/googletransliteration.js
diff --git a/C4/Auth.pm b/C4/Auth.pm
index 2f13b86..e045ffc 100644
--- a/C4/Auth.pm
+++ b/C4/Auth.pm
@@ -438,6 +438,7 @@ sub get_template_and_user {
reviewson => C4::Context->preference("reviewson"),
suggestion => "" . C4::Context->preference("suggestion"),
virtualshelves => "" . C4::Context->preference("virtualshelves"),
+ GoogleTransliteration => C4::Context->preference("GoogleTransliteration"),
OPACSerialIssueDisplayCount => C4::Context->preference("OPACSerialIssueDisplayCount"),
OpacAddMastheadLibraryPulldown => C4::Context->preference("OpacAddMastheadLibraryPulldown"),
OPACXSLTDetailsDisplay => C4::Context->preference("OPACXSLTDetailsDisplay"),
diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql
index 3e16fd5..de2f24b 100644
--- a/installer/data/mysql/en/mandatory/sysprefs.sql
+++ b/installer/data/mysql/en/mandatory/sysprefs.sql
@@ -279,3 +279,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ILS-DI:AuthorizedIPs','','.','Restricts usage of ILS-DI to some IPs','Free');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OverduesBlockCirc','noblock','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','noblock|confirmation|block','Choice');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('DisplayMultiPlaceHold','1','Display the ability to place multiple holds or not','','YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('GoogleTransliteration','0','Show GoogleTransliteration on the OPAC Masthead.', '','YesNo');
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index cb88827..a1fdbce 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -3922,20 +3922,24 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
print "Upgrade to $DBversion done (Fix misspelled 034r subfield in MARC21 Frameworks)\n";
SetVersion ($DBversion);
}
-
$DBversion = "3.03.00.011";
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
$dbh->do("UPDATE aqbooksellers SET gstrate=NULL WHERE gstrate=0.0");
print "Upgrade to $DBversion done (Bug 5186: allow GST rate to be set to 0)\n";
SetVersion ($DBversion);
}
-
$DBversion = "3.03.00.012";
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
$dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('maxItemsInSearchResults',20,'Specify the maximum number of items to display for each result on a page of results',NULL,'free')");
print "Upgrade to $DBversion done (Bug 2142: maxItemsInSearchResults syspref resurrected)\n";
SetVersion ($DBversion);
}
+$DBversion = '3.03.00.013';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('GoogleTransliteration','0','Show GoogleTransliteration on the OPAC Masthead.', '','YesNo')");
+ print "Upgrade to $DBversion done (Add GoogleTransliteration on opac page)\n";
+ SetVersion ($DBversion);
+}
=head1 FUNCTIONS
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 acab30a..faef009 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
@@ -1,4 +1,11 @@
OPAC:
+ GoogleTransliteration:
+ -
+ - pref: GoogleTransliteration
+ choices:
+ yes: Show
+ no: "Don't show"
+ - Show GoogleTransliteration on the OPAC Masthead.
Appearance:
-
- Use the
diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc b/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc
index beda270..b2a4e91 100644
--- a/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc
+++ b/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc
@@ -79,8 +79,8 @@
//]]>
</script><!-- /TMPL_IF -->
<link rel="unapi-server" type="application/xml" title="unAPI" href="<!-- TMPL_VAR NAME="OPACBaseURL" -->/cgi-bin/koha/unapi" />
-<!-- TMPL_IF NAME="GoogleIndicTransliteration" -->
+<!-- TMPL_IF NAME="GoogleTransliteration" -->
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
- <script type="text/javascript" language="javascript" src="<!-- TMPL_VAR NAME="themelang" -->/js/googleindictransliteration.js"></script>
+ <script type="text/javascript" language="javascript" src="<!-- TMPL_VAR NAME="themelang" -->/js/googletransliteration.js"></script>
<!-- /TMPL_IF -->
diff --git a/koha-tmpl/opac-tmpl/prog/en/js/googletransliteration.js b/koha-tmpl/opac-tmpl/prog/en/js/googletransliteration.js
new file mode 100644
index 0000000..5672d43
--- /dev/null
+++ b/koha-tmpl/opac-tmpl/prog/en/js/googletransliteration.js
@@ -0,0 +1,29 @@
+ // Load the Google Transliteration API
+ google.load("elements", "1", {
+ packages: "transliteration"
+ });
+
+ function onLoad() {
+ var options = {
+ sourceLanguage: 'en',
+ destinationLanguage: ['hi','kn','ml','ta','te','ar','ur','pa','fa','bn'],
+ shortcutKey: 'ctrl+g',
+ transliterationEnabled: false
+ };
+
+ // Create an instance on TransliterationControl with the required
+ // options.
+ var control =
+ new google.elements.transliteration.TransliterationControl(options);
+
+ // Enable transliteration in the textfields with the given ids.
+ var ids = [ "transl1" ];
+ control.makeTransliteratable(ids);
+
+ // Show the transliteration control which can be used to toggle between
+ // English and Hindi and also choose other destination language.
+ control.showControl('translControl');
+ }
+ google.setOnLoadCallback(onLoad);
+
+
diff --git a/kohaversion.pl b/kohaversion.pl
index fc595a0..270e2d0 100644
--- a/kohaversion.pl
+++ b/kohaversion.pl
@@ -16,7 +16,7 @@ the kohaversion is divided in 4 parts :
use strict;
sub kohaversion {
- our $VERSION = '3.03.00.012';
+ our $VERSION = '3.03.00.013';
# version needs to be set this way
# so that it can be picked up by Makefile.PL
# during install
diff --git a/opac/opac-main.pl b/opac/opac-main.pl
index e0a65a9..6f1b949 100755
--- a/opac/opac-main.pl
+++ b/opac/opac-main.pl
@@ -90,9 +90,4 @@ $template->param(
koha_news_count => $koha_news_count
);
-# If GoogleIndicTransliteration system preference is On Set paramter to load Google's javascript in OPAC search screens
-if (C4::Context->preference('GoogleIndicTransliteration')) {
- $template->param('GoogleIndicTransliteration' => 1);
-}
-
output_html_with_http_headers $input, $cookie, $template->output;
diff --git a/opac/opac-search.pl b/opac/opac-search.pl
index 45cb766..3c1785c 100755
--- a/opac/opac-search.pl
+++ b/opac/opac-search.pl
@@ -659,9 +659,4 @@ if (defined $barshelves) {
my $content_type = ($format eq 'rss' or $format eq 'atom') ? $format : 'html';
-# If GoogleIndicTransliteration system preference is On Set paramter to load Google's javascript in OPAC search screens
-if (C4::Context->preference('GoogleIndicTransliteration')) {
- $template->param('GoogleIndicTransliteration' => 1);
-}
-
output_with_http_headers $cgi, $cookie, $template->output, $content_type;
--
1.6.4.2
More information about the Koha-patches
mailing list