adding bi-directional support to the OPAC based on the language
authorJoshua Ferraro <jmf@liblime.com>
Sat, 10 Nov 2007 14:51:40 +0000 (08:51 -0600)
committerJoshua Ferraro <jmf@liblime.com>
Sat, 5 Jan 2008 08:58:46 +0000 (02:58 -0600)
selected (Hebrew and Arabic currently set)

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/Output.pm
koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-open.inc

index c588e14..df71d65 100644 (file)
@@ -99,9 +99,24 @@ sub gettemplate {
         opacsmallimage      => C4::Context->preference('opacsmallimage'),
         lang                => $lang
     );
-
+       warn "LANG: $lang";
+       # Languages and Locale
+       my $bidi;
+       my @template_languages;
+       my $languages_loop = getTranslatedLanguages($interface,$theme);
+       for my $language_hashref (@$languages_loop) {
+               if ($language_hashref->{language_code} eq $lang) {
+                       $language_hashref->{current}++;
+                       if ($language_hashref->{bidi}) {
+                               $bidi = $language_hashref->{bidi};
+                       }
+               }
+               push @template_languages, $language_hashref;
+       }
        # load the languages ( for switching from one template to another )
-       $template->param(languages_loop => getTranslatedLanguages($interface,$theme));
+       $template->param(       languages_loop => \@template_languages,
+                                               bidi => $bidi
+       );
 
     return $template;
 }
@@ -114,19 +129,26 @@ sub themelanguage {
     #   if (!$query) {
     #     warn "no query";
     #   }
+
+       # set some defaults for language and theme
+       my $lang = $query->cookie('KohaOpacLanguage');
+       $lang = 'en' unless $lang;
+       my $theme = 'prog';
+
     my $dbh = C4::Context->dbh;
     my @languages;
     my @themes;
     if ( $section eq "intranet" ) {
         @languages = split " ", C4::Context->preference("opaclanguages");
         @themes    = split " ", C4::Context->preference("template");
+        pop @languages, $lang if $lang;
     }
     else {
 
       # we are in the opac here, what im trying to do is let the individual user
       # set the theme they want to use.
       # and perhaps the them as well.
-        my $lang = $query->cookie('KohaOpacLanguage');
+        #my $lang = $query->cookie('KohaOpacLanguage');
         if ($lang) {
 
             push @languages, $lang;
@@ -138,8 +160,6 @@ sub themelanguage {
         }
     }
 
-    my ( $theme, $lang );
-
  # searches through the themes and languages. First template it find it returns.
  # Priority is for getting the theme right.
   THEME:
@@ -156,12 +176,7 @@ sub themelanguage {
             }
         }
     }
-    if ( $theme and $lang ) {
-        return ( $theme, $lang );
-    }
-    else {
-        return ( 'prog', 'en' );
-    }
+    return ( $theme, $lang );
 }
 
 sub setlanguagecookie {
index 018d6e1..1c28a75 100644 (file)
@@ -1,4 +1,4 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html <!-- TMPL_IF NAME="bidi" -->dir="<!-- TMPL_VAR NAME="bidi" -->"<!-- /TMPL_IF --> xmlns="http://www.w3.org/1999/xhtml">
 <head>