Acquisition minor improvements
[koha_gimpoz] / C4 / Output.pm
index b9279e1..d809c3b 100644 (file)
@@ -54,25 +54,23 @@ push @EXPORT, qw(
 
 #Output
 push @EXPORT, qw(
-               &guesscharset
-               &guesstype
-               &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 {
@@ -81,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/".($interface eq 'intranet'?"modules":"")."/$tmplbase",
         die_on_bad_params => 1,
         global_vars       => 1,
         case_sensitive    => 1,
@@ -92,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'),
@@ -146,7 +144,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/".($section eq 'intranet'?"modules":"")."/$tmpl" ) {
                     $theme = $th;
                     $lang  = $la;
                     last THEME;
@@ -315,42 +313,6 @@ sub pagination_bar {
     return $pagination_bar;
 }
 
-
-=item guesscharset
-
-   &guesscharset($output)
-
-"Guesses" the charset from the some HTML that would be output.
-
-C<$output> is the HTML page to be output. If it contains a META tag
-with a Content-Type, the tag will be scanned for a language code.
-This code is returned if it is found; undef is returned otherwise.
-
-This function only does sloppy guessing; it will be confused by
-unexpected things like SGML comments. What it basically does is to
-grab something that looks like a META tag and scan it.
-
-=cut
-
-sub guesscharset ($) {
-    my($html) = @_;
-    my $charset = undef;
-    local($`, $&, $', $1, $2, $3);
-    # FIXME... These regular expressions will miss a lot of valid tags!
-    if ($html =~ /<meta\s+http-equiv=(["']?)Content-Type\1\s+content=(["'])text\/html\s*;\s*charset=([^\2\s\r\n]+)\2\s*(?:\/?)>/is) {
-        $charset = $3;
-    } elsif ($html =~ /<meta\s+content=(["'])text\/html\s*;\s*charset=([^\1\s\r\n]+)\1\s+http-equiv=(["']?)Content-Type\3\s*(?:\/?)>/is) {
-        $charset = $2;
-    }
-    return $charset;
-} # guess
-
-sub guesstype ($) {
-    my($html) = @_;
-    my $charset = guesscharset($html);
-    return defined $charset? "text/html; charset=$charset": "text/html";
-}
-
 =item output_html_with_http_headers
 
    &output_html_with_http_headers($query, $cookie, $html)
@@ -364,8 +326,9 @@ corresponds to the HTML page $html.
 sub output_html_with_http_headers ($$$) {
     my($query, $cookie, $html) = @_;
     print $query->header(
-       -type   => guesstype($html),
-       -cookie => $cookie,
+        -type    => 'text/html',
+        -charset => 'UTF-8',
+        -cookie  => $cookie,
     ), $html;
 }