Switching Languages.pm to EXPORT_OK -- don't export
[koha.git] / C4 / Output.pm
index b92d712..c588e14 100644 (file)
@@ -21,7 +21,6 @@ package C4::Output;
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id$
 
 # NOTE: I'm pretty sure this module is deprecated in favor of
 # templates.
@@ -30,12 +29,13 @@ use strict;
 require Exporter;
 
 use C4::Context;
-use HTML::Template::Pro;
+use C4::Languages qw(getTranslatedLanguages);
 
+use HTML::Template::Pro;
 use vars qw($VERSION @ISA @EXPORT);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision$' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = 3.00;
 
 =head1 NAME
 
@@ -54,23 +54,23 @@ push @EXPORT, qw(
 
 #Output
 push @EXPORT, qw(
-                &output_html_with_http_headers
-                );
+    &output_html_with_http_headers
+);
 
 
 #FIXME: this is a quick fix to stop rc1 installing broken
 #Still trying to figure out the correct fix.
-my $path = C4::Context->config('intrahtdocs') . "/default/en/includes/";
+my $path = C4::Context->config('intrahtdocs') . "/prog/en/includes/";
 
 #---------------------------------------------------------------------------------------------------------
 # FIXME - POD
 sub gettemplate {
-    my ( $tmplbase, $opac, $query ) = @_;
+    my ( $tmplbase, $interface, $query ) = @_;
     if ( !$query ) {
         warn "no query in gettemplate";
     }
     my $htdocs;
-    if ( $opac ne "intranet" ) {
+    if ( $interface ne "intranet" ) {
         $htdocs = C4::Context->config('opachtdocs');
     }
     else {
@@ -79,10 +79,10 @@ sub gettemplate {
     my $path = C4::Context->preference('intranet_includes') || 'includes';
 
     #    warn "PATH : $path";
-    my ( $theme, $lang ) = themelanguage( $htdocs, $tmplbase, $opac, $query );
+    my ( $theme, $lang ) = themelanguage( $htdocs, $tmplbase, $interface, $query );
     my $opacstylesheet = C4::Context->preference('opacstylesheet');
     my $template       = HTML::Template::Pro->new(
-        filename          => "$htdocs/$theme/$lang/$tmplbase",
+        filename          => "$htdocs/$theme/$lang/modules/$tmplbase",
         die_on_bad_params => 1,
         global_vars       => 1,
         case_sensitive    => 1,
@@ -90,9 +90,9 @@ sub gettemplate {
     );
 
     $template->param(
-        themelang => ( $opac ne 'intranet' ? '/opac-tmpl' : '/intranet-tmpl' )
+        themelang => ( $interface ne 'intranet' ? '/opac-tmpl' : '/intranet-tmpl' )
           . "/$theme/$lang",
-        interface => ( $opac ne 'intranet' ? '/opac-tmpl' : '/intranet-tmpl' ),
+        interface => ( $interface ne 'intranet' ? '/opac-tmpl' : '/intranet-tmpl' ),
         theme => $theme,
         opacstylesheet      => $opacstylesheet,
         opaccolorstylesheet => C4::Context->preference('opaccolorstylesheet'),
@@ -100,6 +100,9 @@ sub gettemplate {
         lang                => $lang
     );
 
+       # load the languages ( for switching from one template to another )
+       $template->param(languages_loop => getTranslatedLanguages($interface,$theme));
+
     return $template;
 }
 
@@ -144,7 +147,7 @@ sub themelanguage {
         foreach my $la (@languages) {
             for ( my $pass = 1 ; $pass <= 2 ; $pass += 1 ) {
                 $la =~ s/([-_])/ $1 eq '-'? '_': '-' /eg if $pass == 2;
-                if ( -e "$htdocs/$th/$la/$tmpl" ) {
+                if ( -e "$htdocs/$th/$la/modules/$tmpl" ) {
                     $theme = $th;
                     $lang  = $la;
                     last THEME;
@@ -326,8 +329,11 @@ corresponds to the HTML page $html.
 sub output_html_with_http_headers ($$$) {
     my($query, $cookie, $html) = @_;
     print $query->header(
-       -type   => 'text/html; charset=utf-8',
-       -cookie => $cookie,
+        -type    => 'text/html',
+        -charset => 'UTF-8',
+        -cookie  => $cookie,
+               -Pragma => 'no-cache',
+               -'Cache-Control' => 'no-cache',
     ), $html;
 }