[Koha-patches] [PATCH] Improvement in GoogleTransliteration including system preferences

amit gupta amit.gupta at osslabs.biz
Mon Aug 9 06:07:31 CEST 2010


---
 C4/Auth.pm                                         |    1 +
 installer/data/mysql/updatedatabase.pl             |   10 +++++++
 .../prog/en/modules/admin/preferences/opac.pref    |    8 +++++
 .../opac-tmpl/prog/en/js/googletransliteration.js  |   29
++++++++++++++++++++
 kohaversion.pl                                     |    2 +-
 opac/opac-main.pl                                  |    6 ++--
 opac/opac-search.pl                                |    6 ++--
 7 files changed, 55 insertions(+), 7 deletions(-)
 create mode 100644 koha-tmpl/opac-tmpl/prog/en/js/googletransliteration.js

diff --git a/C4/Auth.pm b/C4/Auth.pm
index 593f36e..d0927c7 100644
--- a/C4/Auth.pm
+++ b/C4/Auth.pm
@@ -439,6 +439,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/updatedatabase.pl b/installer/data/mysql/
updatedatabase.pl
index a0b5c4a..9f4ab90 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -3701,6 +3701,16 @@ if (C4::Context->preference("Version") <
TransformToNum($DBversion)) {
    SetVersion ($DBversion);
 }

+$DBversion = '3.01.00.146';
+if (C4::Context->preference("GoogleTransliteration") <
TransformToNum($DBversion)) {
+    $dbh->do(q{
+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
Masthead)\n";
+    SetVersion ($DBversion);
+}
+
+
 =item DropAllForeignKeys($table)

  Drop all foreign keys of the table $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 e919dd1..74a2783 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
@@ -2,6 +2,14 @@
 # Broken, omitted: OPACDisplayExtendedSubInfo, OPACSubscriptionDisplay

 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/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 63b6d31..ffd2e69 100644
--- a/kohaversion.pl
+++ b/kohaversion.pl
@@ -11,7 +11,7 @@ use strict;

 sub kohaversion {

-    our $VERSION = '3.01.00.145';
+    our $VERSION = '3.01.00.146';

    # version needs to be set this way
    # so that it can be picked up by Makefile.PL
diff --git a/opac/opac-main.pl b/opac/opac-main.pl
index e0a65a9..39b8bfa 100755
--- a/opac/opac-main.pl
+++ b/opac/opac-main.pl
@@ -90,9 +90,9 @@ $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);
+# If GoogleTransliteration system preference is On Set paramter to load
Google's javascript in OPAC search screens
+if (C4::Context->preference('GoogleTransliteration')) {
+        $template->param('GoogleTransliteration' => 1);
 }

 output_html_with_http_headers $input, $cookie, $template->output;
diff --git a/opac/opac-search.pl b/opac/opac-search.pl
index 30bc34a..26154ef 100755
--- a/opac/opac-search.pl
+++ b/opac/opac-search.pl
@@ -650,9 +650,9 @@ 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);
+# If GoogleTransliteration system preference is On Set paramter to load
Google's javascript in OPAC search screens
+if (C4::Context->preference('GoogleTransliteration')) {
+        $template->param('GoogleTransliteration' => 1);
 }

 output_with_http_headers $cgi, $cookie, $template->output, $content_type;
--
1.5.4.5
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/koha-patches/attachments/20100809/3dcc1190/attachment-0001.htm>


More information about the Koha-patches mailing list