Bug 12424 - ddc sorting of call numbers truncates long Cutter parts
[koha.git] / C4 / Templates.pm
index 8d13a49..6a9d48b 100644 (file)
@@ -109,7 +109,6 @@ sub output {
     $vars->{theme} = $self->theme;
     $vars->{opaccolorstylesheet} =
         C4::Context->preference('opaccolorstylesheet');
-    $vars->{opacsmallimage} = C4::Context->preference('opacsmallimage');
     $vars->{opaclayoutstylesheet} =
         C4::Context->preference('opaclayoutstylesheet');
 
@@ -163,20 +162,6 @@ sub utf8_hashref {
         utf8::encode($hashref->{$key}) if utf8::is_utf8($hashref->{$key});
     }
 }
-        
-        
-# FIXME - this is a horrible hack to cache
-# the current known-good language, temporarily
-# put in place to resolve bug 4403.  It is
-# used only by C4::XSLT::XSLTParse4Display;
-# the language is set via the usual call
-# to themelanguage.
-my $_current_language = 'en';
-
-sub _current_language {
-    return $_current_language;
-}
-
 
 # wrapper method to allow easier transition from HTML template pro to Template Toolkit
 sub param {
@@ -231,28 +216,11 @@ sub gettemplate {
     my ( $tmplbase, $interface, $query, $is_plugin ) = @_;
     ($query) or warn "no query in gettemplate";
     my $path = C4::Context->preference('intranet_includes') || 'includes';
-    $tmplbase =~ s/\.tmpl$/.tt/;
     my ($htdocs, $theme, $lang, $filename)
        =  _get_template_file($tmplbase, $interface, $query);
     $filename = $tmplbase if ( $is_plugin );
     my $template = C4::Templates->new($interface, $filename, $tmplbase, $query);
 
-# NOTE: Commenting these out rather than deleting them so that those who need
-# to know how we previously shimmed these directories will be able to understand.
-#    my $is_intranet = $interface eq 'intranet';
-#    my $themelang =
-#        ($is_intranet ? '/intranet-tmpl' : '/opac-tmpl') .
-#        "/$theme/$lang";
-#    $template->param(
-#        themelang => $themelang,
-#        yuipath   => C4::Context->preference("yuipath") eq "local"
-#                     ? "$themelang/lib/yui"
-#                     : C4::Context->preference("yuipath"),
-#        interface => $is_intranet ? '/intranet-tmpl' : '/opac-tmpl',
-#        theme     => $theme,
-#        lang      => $lang
-#    );
-
     # Bidirectionality, must be sent even if is the only language
     my $current_lang = regex_lang_subtags($lang);
     my $bidi;
@@ -296,7 +264,6 @@ sub themelanguage {
     # Try to find first theme for the selected language
     for my $theme (@themes) {
         if ( -e "$htdocs/$theme/$lang/modules/$tmpl" ) {
-            $_current_language = $lang;
             return ($theme, $lang, \@themes)
         }
     }
@@ -340,4 +307,51 @@ sub getlanguagecookie {
     return $cookie;
 }
 
+=head2 GetColumnDefs
+
+    my $columns = GetColumnDefs( $cgi )
+
+It is passed a CGI object and returns a hash of hashes containing
+the column names and descriptions for each table defined in the
+columns.def file corresponding to the CGI object.
+
+=cut
+
+sub GetColumnDefs {
+
+    my $query = shift;
+
+    my $columns = {};
+
+    my $htdocs = C4::Context->config('intrahtdocs');
+    my $columns_file = 'columns.def';
+
+    # Get theme and language to build the path to columns.def
+    my ($theme, $lang, $availablethemes) =
+        themelanguage($htdocs, 'about.tt', 'intranet', $query);
+    # Build columns.def path
+    my $path = "$htdocs/$theme/$lang/$columns_file";
+    my $fh;
+    if ( ! open ( $fh, q{<}, $path ) )  {
+        carp "Error opening $path. Check your templates.";
+        return;
+    }
+    # Loop through the columns.def file
+    while ( my $input = <$fh> ){
+        chomp $input;
+        if ( $input =~ m|<field name="(.*)">(.*)</field>| ) {
+            my ( $table, $column ) =  split( '\.', $1);
+            my $description        = $2;
+            # Initialize the table array if needed.
+            @{$columns->{ $table }} = () if ! defined $columns->{ $table };
+            # Push field and description
+            push @{$columns->{ $table }},
+                { field => $column, description => $description };
+        }
+    }
+    close $fh;
+
+    return $columns;
+}
+
 1;