View | Details | Raw Unified | Return to bug 6755
Collapse All | Expand All

(-)a/C4/Auth.pm (-3 / +3 lines)
Lines 26-32 use CGI::Session; Link Here
26
26
27
require Exporter;
27
require Exporter;
28
use C4::Context;
28
use C4::Context;
29
use C4::Output;    # to get the template
29
use C4::Templates;    # to get the template
30
use C4::Members;
30
use C4::Members;
31
use C4::Koha;
31
use C4::Koha;
32
use C4::Branch; # GetBranches
32
use C4::Branch; # GetBranches
Lines 136-142 EOQ Link Here
136
sub get_template_and_user {
136
sub get_template_and_user {
137
    my $in       = shift;
137
    my $in       = shift;
138
    my $template =
138
    my $template =
139
      gettemplate( $in->{'template_name'}, $in->{'type'}, $in->{'query'} );
139
      C4::Templates::gettemplate( $in->{'template_name'}, $in->{'type'}, $in->{'query'} );
140
    my ( $user, $cookie, $sessionID, $flags );
140
    my ( $user, $cookie, $sessionID, $flags );
141
    if ( $in->{'template_name'} !~m/maintenance/ ) {
141
    if ( $in->{'template_name'} !~m/maintenance/ ) {
142
        ( $user, $cookie, $sessionID, $flags ) = checkauth(
142
        ( $user, $cookie, $sessionID, $flags ) = checkauth(
Lines 936-942 sub checkauth { Link Here
936
    }
936
    }
937
937
938
    my $template_name = ( $type eq 'opac' ) ? 'opac-auth.tmpl' : 'auth.tmpl';
938
    my $template_name = ( $type eq 'opac' ) ? 'opac-auth.tmpl' : 'auth.tmpl';
939
    my $template = gettemplate( $template_name, $type, $query );
939
    my $template = C4::Templates::gettemplate( $template_name, $type, $query );
940
    $template->param(branchloop => \@branch_loop,);
940
    $template->param(branchloop => \@branch_loop,);
941
    my $checkstyle = C4::Context->preference("opaccolorstylesheet");
941
    my $checkstyle = C4::Context->preference("opaccolorstylesheet");
942
    if ($checkstyle =~ /\//)
942
    if ($checkstyle =~ /\//)
(-)a/C4/Output.pm (-180 / +3 lines)
Lines 29-35 use strict; Link Here
29
#use warnings; FIXME - Bug 2505
29
#use warnings; FIXME - Bug 2505
30
30
31
use C4::Context;
31
use C4::Context;
32
use C4::Languages qw(getTranslatedLanguages get_bidi regex_lang_subtags language_get_description accept_language );
33
use C4::Dates qw(format_date);
32
use C4::Dates qw(format_date);
34
use C4::Budgets qw(GetCurrency);
33
use C4::Budgets qw(GetCurrency);
35
use C4::Templates;
34
use C4::Templates;
Lines 43-234 BEGIN { Link Here
43
    require Exporter;
42
    require Exporter;
44
    @ISA    = qw(Exporter);
43
    @ISA    = qw(Exporter);
45
	@EXPORT_OK = qw(&is_ajax ajax_fail); # More stuff should go here instead
44
	@EXPORT_OK = qw(&is_ajax ajax_fail); # More stuff should go here instead
46
	%EXPORT_TAGS = ( all =>[qw(&themelanguage &gettemplate setlanguagecookie pagination_bar
45
	%EXPORT_TAGS = ( all =>[qw(&pagination_bar
47
								&output_with_http_headers &output_html_with_http_headers)],
46
							   &output_with_http_headers &output_html_with_http_headers)],
48
					ajax =>[qw(&output_with_http_headers is_ajax)],
47
					ajax =>[qw(&output_with_http_headers is_ajax)],
49
					html =>[qw(&output_with_http_headers &output_html_with_http_headers)]
48
					html =>[qw(&output_with_http_headers &output_html_with_http_headers)]
50
				);
49
				);
51
    push @EXPORT, qw(
50
    push @EXPORT, qw(
52
        &themelanguage &gettemplate setlanguagecookie getlanguagecookie pagination_bar
51
        &output_html_with_http_headers &output_with_http_headers FormatData FormatNumber pagination_bar
53
    );
54
    push @EXPORT, qw(
55
        &output_html_with_http_headers &output_with_http_headers FormatData FormatNumber
56
    );
57
}
58
59
=head1 NAME
60
61
C4::Output - Functions for managing templates
62
63
=head1 FUNCTIONS
64
65
=over 2
66
67
=cut
68
69
#FIXME: this is a quick fix to stop rc1 installing broken
70
#Still trying to figure out the correct fix.
71
my $path = C4::Context->config('intrahtdocs') . "/prog/en/includes/";
72
73
#---------------------------------------------------------------------------------------------------------
74
# FIXME - POD
75
76
sub _get_template_file {
77
    my ( $tmplbase, $interface, $query ) = @_;
78
    my $htdocs = C4::Context->config( $interface ne 'intranet' ? 'opachtdocs' : 'intrahtdocs' );
79
    my ( $theme, $lang ) = themelanguage( $htdocs, $tmplbase, $interface, $query );
80
    my $opacstylesheet = C4::Context->preference('opacstylesheet');
81
82
    # if the template doesn't exist, load the English one as a last resort
83
    my $filename = "$htdocs/$theme/$lang/modules/$tmplbase";
84
    unless (-f $filename) {
85
        $lang = 'en';
86
        $filename = "$htdocs/$theme/$lang/modules/$tmplbase";
87
    }
88
89
    return ( $htdocs, $theme, $lang, $filename );
90
}
91
92
sub gettemplate {
93
    my ( $tmplbase, $interface, $query ) = @_;
94
    ($query) or warn "no query in gettemplate";
95
    my $path = C4::Context->preference('intranet_includes') || 'includes';
96
    my $opacstylesheet = C4::Context->preference('opacstylesheet');
97
    $tmplbase =~ s/\.tmpl$/.tt/;
98
    my ( $htdocs, $theme, $lang, $filename ) = _get_template_file( $tmplbase, $interface, $query );
99
    my $template = C4::Templates->new( $interface, $filename, $tmplbase);
100
    my $themelang=( $interface ne 'intranet' ? '/opac-tmpl' : '/intranet-tmpl' )
101
          . "/$theme/$lang";
102
    $template->param(
103
        themelang => $themelang,
104
        yuipath   => (C4::Context->preference("yuipath") eq "local"?"$themelang/lib/yui":C4::Context->preference("yuipath")),
105
        interface => ( $interface ne 'intranet' ? '/opac-tmpl' : '/intranet-tmpl' ),
106
        theme     => $theme,
107
        lang      => $lang
108
    );
109
110
    # Bidirectionality
111
    my $current_lang = regex_lang_subtags($lang);
112
    my $bidi;
113
    $bidi = get_bidi($current_lang->{script}) if $current_lang->{script};
114
    # Languages
115
    my $languages_loop = getTranslatedLanguages($interface,$theme,$lang);
116
    my $num_languages_enabled = 0;
117
    foreach my $lang (@$languages_loop) {
118
        foreach my $sublang (@{ $lang->{'sublanguages_loop'} }) {
119
            $num_languages_enabled++ if $sublang->{enabled};
120
         }
121
    }
122
    $template->param(
123
            languages_loop       => $languages_loop,
124
            bidi                 => $bidi,
125
            one_language_enabled => ($num_languages_enabled <= 1) ? 1 : 0, # deal with zero enabled langs as well
126
    ) unless @$languages_loop<2;
127
128
    return $template;
129
}
130
131
# FIXME - this is a horrible hack to cache
132
# the current known-good language, temporarily
133
# put in place to resolve bug 4403.  It is
134
# used only by C4::XSLT::XSLTParse4Display;
135
# the language is set via the usual call
136
# to themelanguage.
137
my $_current_language = 'en';
138
sub _current_language {
139
    return $_current_language;
140
}
141
142
#---------------------------------------------------------------------------------------------------------
143
# FIXME - POD
144
sub themelanguage {
145
    my ( $htdocs, $tmpl, $interface, $query ) = @_;
146
    ($query) or warn "no query in themelanguage";
147
148
    # Set some defaults for language and theme
149
    # First, check the user's preferences
150
    my $lang;
151
    my $http_accept_language = $ENV{ HTTP_ACCEPT_LANGUAGE };
152
    $lang = accept_language( $http_accept_language, 
153
              getTranslatedLanguages($interface,'prog') )
154
      if $http_accept_language;
155
    # But, if there's a cookie set, obey it
156
    $lang = $query->cookie('KohaOpacLanguage') if (defined $query and $query->cookie('KohaOpacLanguage'));
157
    # Fall back to English
158
    my @languages;
159
    if ($interface eq 'intranet') {
160
        @languages = split ",", C4::Context->preference("language");
161
    } else {
162
        @languages = split ",", C4::Context->preference("opaclanguages");
163
    }
164
    if ($lang){  
165
        @languages=($lang,@languages);
166
    } else {
167
        $lang = $languages[0];
168
    }      
169
    my $theme = 'prog';	# in the event of theme failure default to 'prog' -fbcit
170
    my $dbh = C4::Context->dbh;
171
    my @themes;
172
    if ( $interface eq "intranet" ) {
173
        @themes    = split " ", C4::Context->preference("template");
174
    }
175
    else {
176
      # we are in the opac here, what im trying to do is let the individual user
177
      # set the theme they want to use.
178
      # and perhaps the them as well.
179
        #my $lang = $query->cookie('KohaOpacLanguage');
180
        @themes = split " ", C4::Context->preference("opacthemes");
181
    }
182
183
 # searches through the themes and languages. First template it find it returns.
184
 # Priority is for getting the theme right.
185
    THEME:
186
    foreach my $th (@themes) {
187
        foreach my $la (@languages) {
188
            #for ( my $pass = 1 ; $pass <= 2 ; $pass += 1 ) {
189
                # warn "$htdocs/$th/$la/modules/$interface-"."tmpl";
190
                #$la =~ s/([-_])/ $1 eq '-'? '_': '-' /eg if $pass == 2;
191
				if ( -e "$htdocs/$th/$la/modules/$tmpl") {
192
                #".($interface eq 'intranet'?"modules":"")."/$tmpl" ) {
193
                    $theme = $th;
194
                    $lang  = $la;
195
                    last THEME;
196
                }
197
                last unless $la =~ /[-_]/;
198
            #}
199
        }
200
    }
201
202
    $_current_language = $lang; # FIXME part of bad hack to paper over bug 4403
203
    return ( $theme, $lang );
204
}
205
206
sub setlanguagecookie {
207
    my ( $query, $language, $uri ) = @_;
208
    my $cookie = $query->cookie(
209
        -name    => 'KohaOpacLanguage',
210
        -value   => $language,
211
        -expires => ''
212
    );
213
    print $query->redirect(
214
        -uri    => $uri,
215
        -cookie => $cookie
216
    );
52
    );
217
}
53
}
218
54
219
sub getlanguagecookie {
220
    my ($query) = @_;
221
    my $lang;
222
    if ($query->cookie('KohaOpacLanguage')){
223
        $lang = $query->cookie('KohaOpacLanguage') ;
224
    }else{
225
        $lang = $ENV{HTTP_ACCEPT_LANGUAGE};
226
        
227
    }
228
    $lang = substr($lang, 0, 2);
229
230
    return $lang;
231
}
232
55
233
=item FormatNumber
56
=item FormatNumber
234
=cut
57
=cut
(-)a/C4/Templates.pm (-2 / +171 lines)
Lines 31-46 use CGI; Link Here
31
use base qw(Class::Accessor);
31
use base qw(Class::Accessor);
32
use Template;
32
use Template;
33
use Template::Constants qw( :debug );
33
use Template::Constants qw( :debug );
34
use C4::Languages qw(getTranslatedLanguages get_bidi regex_lang_subtags language_get_description accept_language );
34
35
35
use C4::Context;
36
use C4::Context;
36
37
37
__PACKAGE__->mk_accessors(qw( theme lang filename htdocs interface vars));
38
__PACKAGE__->mk_accessors(qw( theme lang filename htdocs interface vars));
38
39
40
41
39
sub new {
42
sub new {
40
    my $class     = shift;
43
    my $class     = shift;
41
    my $interface = shift;
44
    my $interface = shift;
42
    my $filename  = shift;
45
    my $filename  = shift;
43
    my $tmplbase  = shift;
46
    my $tmplbase  = shift;
47
    my $query     = @_? shift: undef;
44
    my $htdocs;
48
    my $htdocs;
45
    if ( $interface ne "intranet" ) {
49
    if ( $interface ne "intranet" ) {
46
        $htdocs = C4::Context->config('opachtdocs');
50
        $htdocs = C4::Context->config('opachtdocs');
Lines 49-55 sub new { Link Here
49
        $htdocs = C4::Context->config('intrahtdocs');
53
        $htdocs = C4::Context->config('intrahtdocs');
50
    }
54
    }
51
55
52
    my ( $theme, $lang ) = themelanguage( $htdocs, $tmplbase, $interface );
56
    my ($theme, $lang)= themelanguage( $htdocs, $tmplbase, $interface, $query);
53
    my $template = Template->new(
57
    my $template = Template->new(
54
        {
58
        {
55
            EVAL_PERL    => 1,
59
            EVAL_PERL    => 1,
Lines 164-170 sub _current_language { Link Here
164
    return $_current_language;
168
    return $_current_language;
165
}
169
}
166
170
167
sub themelanguage {
171
sub themelanguage_lite {
168
    my ( $htdocs, $tmpl, $interface ) = @_;
172
    my ( $htdocs, $tmpl, $interface ) = @_;
169
    my $query = new CGI;
173
    my $query = new CGI;
170
174
Lines 228-232 sub param { Link Here
228
    }
232
    }
229
}
233
}
230
234
235
236
=head1 NAME
237
238
C4::Templates - Functions for managing templates
239
240
=head1 FUNCTIONS
241
242
=over 2
243
244
=cut
245
246
#FIXME: this is a quick fix to stop rc1 installing broken
247
#Still trying to figure out the correct fix.
248
my $path = C4::Context->config('intrahtdocs') . "/prog/en/includes/";
249
250
#---------------------------------------------------------------------------------------------------------
251
# FIXME - POD
252
253
sub _get_template_file {
254
    my ( $tmplbase, $interface, $query ) = @_;
255
    my $htdocs = C4::Context->config( $interface ne 'intranet' ? 'opachtdocs' : 'intrahtdocs' );
256
    my ( $theme, $lang ) = themelanguage( $htdocs, $tmplbase, $interface, $query );
257
    my $opacstylesheet = C4::Context->preference('opacstylesheet');
258
259
    # if the template doesn't exist, load the English one as a last resort
260
    my $filename = "$htdocs/$theme/$lang/modules/$tmplbase";
261
    unless (-f $filename) {
262
        $lang = 'en';
263
        $filename = "$htdocs/$theme/$lang/modules/$tmplbase";
264
    }
265
266
    return ( $htdocs, $theme, $lang, $filename );
267
}
268
269
sub gettemplate {
270
    my ( $tmplbase, $interface, $query ) = @_;
271
    ($query) or warn "no query in gettemplate";
272
    my $path = C4::Context->preference('intranet_includes') || 'includes';
273
    my $opacstylesheet = C4::Context->preference('opacstylesheet');
274
    $tmplbase =~ s/\.tmpl$/.tt/;
275
    my ( $htdocs, $theme, $lang, $filename ) = _get_template_file( $tmplbase, $interface, $query );
276
    my $template = C4::Templates->new($interface, $filename, $tmplbase, $query);
277
    my $themelang=( $interface ne 'intranet' ? '/opac-tmpl' : '/intranet-tmpl' )
278
          . "/$theme/$lang";
279
    $template->param(
280
        themelang => $themelang,
281
        yuipath   => (C4::Context->preference("yuipath") eq "local"?"$themelang/lib/yui":C4::Context->preference("yuipath")),
282
        interface => ( $interface ne 'intranet' ? '/opac-tmpl' : '/intranet-tmpl' ),
283
        theme     => $theme,
284
        lang      => $lang
285
    );
286
287
    # Bidirectionality
288
    my $current_lang = regex_lang_subtags($lang);
289
    my $bidi;
290
    $bidi = get_bidi($current_lang->{script}) if $current_lang->{script};
291
    # Languages
292
    my $languages_loop = getTranslatedLanguages($interface,$theme,$lang);
293
    my $num_languages_enabled = 0;
294
    foreach my $lang (@$languages_loop) {
295
        foreach my $sublang (@{ $lang->{'sublanguages_loop'} }) {
296
            $num_languages_enabled++ if $sublang->{enabled};
297
         }
298
    }
299
    $template->param(
300
            languages_loop       => $languages_loop,
301
            bidi                 => $bidi,
302
            one_language_enabled => ($num_languages_enabled <= 1) ? 1 : 0, # deal with zero enabled langs as well
303
    ) unless @$languages_loop<2;
304
305
    return $template;
306
}
307
308
309
#---------------------------------------------------------------------------------------------------------
310
# FIXME - POD
311
sub themelanguage {
312
    my ( $htdocs, $tmpl, $interface, $query ) = @_;
313
    ($query) or warn "no query in themelanguage";
314
315
    # Set some defaults for language and theme
316
    # First, check the user's preferences
317
    my $lang;
318
    my $http_accept_language = $ENV{ HTTP_ACCEPT_LANGUAGE };
319
    $lang = accept_language( $http_accept_language, 
320
              getTranslatedLanguages($interface,'prog') )
321
      if $http_accept_language;
322
    # But, if there's a cookie set, obey it
323
    $lang = $query->cookie('KohaOpacLanguage') if (defined $query and $query->cookie('KohaOpacLanguage'));
324
    # Fall back to English
325
    my @languages;
326
    if ($interface eq 'intranet') {
327
        @languages = split ",", C4::Context->preference("language");
328
    } else {
329
        @languages = split ",", C4::Context->preference("opaclanguages");
330
    }
331
    if ($lang){  
332
        @languages=($lang,@languages);
333
    } else {
334
        $lang = $languages[0];
335
    }      
336
    my $theme = 'prog';	# in the event of theme failure default to 'prog' -fbcit
337
    my $dbh = C4::Context->dbh;
338
    my @themes;
339
    if ( $interface eq "intranet" ) {
340
        @themes    = split " ", C4::Context->preference("template");
341
    }
342
    else {
343
      # we are in the opac here, what im trying to do is let the individual user
344
      # set the theme they want to use.
345
      # and perhaps the them as well.
346
        #my $lang = $query->cookie('KohaOpacLanguage');
347
        @themes = split " ", C4::Context->preference("opacthemes");
348
    }
349
350
 # searches through the themes and languages. First template it find it returns.
351
 # Priority is for getting the theme right.
352
    THEME:
353
    foreach my $th (@themes) {
354
        foreach my $la (@languages) {
355
            #for ( my $pass = 1 ; $pass <= 2 ; $pass += 1 ) {
356
                # warn "$htdocs/$th/$la/modules/$interface-"."tmpl";
357
                #$la =~ s/([-_])/ $1 eq '-'? '_': '-' /eg if $pass == 2;
358
				if ( -e "$htdocs/$th/$la/modules/$tmpl") {
359
                #".($interface eq 'intranet'?"modules":"")."/$tmpl" ) {
360
                    $theme = $th;
361
                    $lang  = $la;
362
                    last THEME;
363
                }
364
                last unless $la =~ /[-_]/;
365
            #}
366
        }
367
    }
368
369
    $_current_language = $lang; # FIXME part of bad hack to paper over bug 4403
370
    return ( $theme, $lang );
371
}
372
373
sub setlanguagecookie {
374
    my ( $query, $language, $uri ) = @_;
375
    my $cookie = $query->cookie(
376
        -name    => 'KohaOpacLanguage',
377
        -value   => $language,
378
        -expires => ''
379
    );
380
    print $query->redirect(
381
        -uri    => $uri,
382
        -cookie => $cookie
383
    );
384
}
385
386
sub getlanguagecookie {
387
    my ($query) = @_;
388
    my $lang;
389
    if ($query->cookie('KohaOpacLanguage')){
390
        $lang = $query->cookie('KohaOpacLanguage') ;
391
    }else{
392
        $lang = $ENV{HTTP_ACCEPT_LANGUAGE};
393
        
394
    }
395
    $lang = substr($lang, 0, 2);
396
397
    return $lang;
398
}
399
231
1;
400
1;
232
401
(-)a/C4/XSLT.pm (-3 / +2 lines)
Lines 29-35 use C4::Koha; Link Here
29
use C4::Biblio;
29
use C4::Biblio;
30
use C4::Circulation;
30
use C4::Circulation;
31
use C4::Reserves;
31
use C4::Reserves;
32
use C4::Output qw//;
33
use Encode;
32
use Encode;
34
use XML::LibXML;
33
use XML::LibXML;
35
use XML::LibXSLT;
34
use XML::LibXSLT;
Lines 160-173 sub XSLTParse4Display { Link Here
160
        if ($interface eq 'intranet') {
159
        if ($interface eq 'intranet') {
161
            $xslfile = C4::Context->config('intrahtdocs') . 
160
            $xslfile = C4::Context->config('intrahtdocs') . 
162
                      '/' . C4::Context->preference("template") . 
161
                      '/' . C4::Context->preference("template") . 
163
                      '/' . C4::Output::_current_language() .
162
                      '/' . C4::Templates::_current_language() .
164
                      '/xslt/' .
163
                      '/xslt/' .
165
                      C4::Context->preference('marcflavour') .
164
                      C4::Context->preference('marcflavour') .
166
                      "slim2intranet$xsl_suffix.xsl";
165
                      "slim2intranet$xsl_suffix.xsl";
167
        } else {
166
        } else {
168
            $xslfile = C4::Context->config('opachtdocs') . 
167
            $xslfile = C4::Context->config('opachtdocs') . 
169
                      '/' . C4::Context->preference("opacthemes") . 
168
                      '/' . C4::Context->preference("opacthemes") . 
170
                      '/' . C4::Output::_current_language() .
169
                      '/' . C4::Templates::_current_language() .
171
                      '/xslt/' .
170
                      '/xslt/' .
172
                      C4::Context->preference('marcflavour') .
171
                      C4::Context->preference('marcflavour') .
173
                      "slim2OPAC$xsl_suffix.xsl";
172
                      "slim2OPAC$xsl_suffix.xsl";
(-)a/about.pl (-1 / +1 lines)
Lines 28-34 use LWP::Simple; Link Here
28
use XML::Simple;
28
use XML::Simple;
29
use Config;
29
use Config;
30
30
31
use C4::Output;    # contains gettemplate
31
use C4::Output;
32
use C4::Auth;
32
use C4::Auth;
33
use C4::Context;
33
use C4::Context;
34
use C4::Installer;
34
use C4::Installer;
(-)a/admin/preferences.pl (-1 / +2 lines)
Lines 28-33 use C4::Languages qw(getTranslatedLanguages); Link Here
28
use C4::ClassSource;
28
use C4::ClassSource;
29
use C4::Log;
29
use C4::Log;
30
use C4::Output;
30
use C4::Output;
31
use C4::Templates;
31
use C4::Budgets qw(GetCurrency);
32
use C4::Budgets qw(GetCurrency);
32
use File::Spec;
33
use File::Spec;
33
use IO::File;
34
use IO::File;
Lines 41-47 our $lang; Link Here
41
sub GetTab {
42
sub GetTab {
42
    my ( $input, $tab ) = @_;
43
    my ( $input, $tab ) = @_;
43
44
44
    my $tab_template = C4::Output::gettemplate( 'admin/preferences/' . $tab . '.pref', 'intranet', $input );
45
    my $tab_template = C4::Templates::gettemplate( 'admin/preferences/' . $tab . '.pref', 'intranet', $input );
45
46
46
    my $active_currency = GetCurrency();
47
    my $active_currency = GetCurrency();
47
    my $local_currency;
48
    my $local_currency;
(-)a/catalogue/moredetail.pl (-1 / +1 lines)
Lines 27-33 use C4::Biblio; Link Here
27
use C4::Items;
27
use C4::Items;
28
use C4::Branch;
28
use C4::Branch;
29
use C4::Acquisition;
29
use C4::Acquisition;
30
use C4::Output;             # contains gettemplate
30
use C4::Output;
31
use C4::Auth;
31
use C4::Auth;
32
use C4::Serials;
32
use C4::Serials;
33
use C4::Dates qw/format_date/;
33
use C4::Dates qw/format_date/;
(-)a/catalogue/search.pl (-1 / +1 lines)
Lines 471-477 my ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit Link Here
471
my @results;
471
my @results;
472
472
473
## I. BUILD THE QUERY
473
## I. BUILD THE QUERY
474
my $lang = C4::Output::getlanguagecookie($cgi);
474
my $lang = C4::Templates::getlanguagecookie($cgi);
475
( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type) = buildQuery(\@operators,\@operands,\@indexes,\@limits,\@sort_by,$scan,$lang);
475
( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type) = buildQuery(\@operators,\@operands,\@indexes,\@limits,\@sort_by,$scan,$lang);
476
476
477
## parse the query_cgi string and put it into a form suitable for <input>s
477
## parse the query_cgi string and put it into a form suitable for <input>s
(-)a/changelanguage.pl (-2 / +2 lines)
Lines 18-24 Link Here
18
use strict;
18
use strict;
19
use warnings;
19
use warnings;
20
20
21
use C4::Output qw(setlanguagecookie);
21
use C4::Templates;
22
use CGI;
22
use CGI;
23
23
24
my $query    = new CGI;
24
my $query    = new CGI;
Lines 26-29 my $language = $query->param('language'); Link Here
26
my $url      = $query->referer();
26
my $url      = $query->referer();
27
27
28
#warn "Language : $query // $language // $url";
28
#warn "Language : $query // $language // $url";
29
setlanguagecookie( $query, $language, $url );
29
C4::Templates::setlanguagecookie( $query, $language, $url );
(-)a/installer/InstallAuth.pm (-1 / +1 lines)
Lines 103-109 InstallAuth - Authenticates Koha users for Install process Link Here
103
    authenticated page.
103
    authenticated page.
104
104
105
    More information on the C<gettemplate> sub can be found in the
105
    More information on the C<gettemplate> sub can be found in the
106
    Output.pm module.
106
    Templates.pm module.
107
107
108
=cut
108
=cut
109
109
(-)a/misc/cronjobs/gather_print_notices.pl (-3 / +3 lines)
Lines 28-39 BEGIN { Link Here
28
    eval { require "$FindBin::Bin/../kohalib.pl" };
28
    eval { require "$FindBin::Bin/../kohalib.pl" };
29
}
29
}
30
30
31
use CGI; # NOT a CGI script, this is just to keep C4::Output::gettemplate happy
31
use CGI; # NOT a CGI script, this is just to keep C4::Templates::gettemplate happy
32
use C4::Context;
32
use C4::Context;
33
use C4::Dates;
33
use C4::Dates;
34
use C4::Debug;
34
use C4::Debug;
35
use C4::Letters;
35
use C4::Letters;
36
use C4::Output;
36
use C4::Templates;
37
use File::Spec;
37
use File::Spec;
38
use Getopt::Long;
38
use Getopt::Long;
39
39
Lines 70-76 exit unless( @messages ); Link Here
70
70
71
open OUTPUT, '>', File::Spec->catdir( $output_directory, "holdnotices-" . $today->output( 'iso' ) . ".html" );
71
open OUTPUT, '>', File::Spec->catdir( $output_directory, "holdnotices-" . $today->output( 'iso' ) . ".html" );
72
72
73
my $template = C4::Output::gettemplate( 'batch/print-notices.tmpl', 'intranet', new CGI );
73
my $template = C4::Templates::gettemplate( 'batch/print-notices.tmpl', 'intranet', new CGI );
74
my $stylesheet_contents = '';
74
my $stylesheet_contents = '';
75
75
76
if ($stylesheet) {
76
if ($stylesheet) {
(-)a/misc/exportauth.pl (-1 lines)
Lines 13-19 BEGIN { Link Here
13
}
13
}
14
14
15
use C4::Context;
15
use C4::Context;
16
use C4::Output;  # contains gettemplate
17
use C4::Biblio;
16
use C4::Biblio;
18
use C4::Auth;
17
use C4::Auth;
19
my $outfile = $ARGV[0];
18
my $outfile = $ARGV[0];
(-)a/opac/opac-changelanguage.pl (-2 / +2 lines)
Lines 17-23 Link Here
17
17
18
use strict;
18
use strict;
19
use warnings;
19
use warnings;
20
use C4::Output qw(setlanguagecookie);
20
use C4::Templates;
21
use CGI;
21
use CGI;
22
22
23
my $query    = new CGI;
23
my $query    = new CGI;
Lines 25-28 my $language = $query->param('language'); Link Here
25
my $url      = $query->referer();
25
my $url      = $query->referer();
26
26
27
# warn "Language : $query // $language // $url";
27
# warn "Language : $query // $language // $url";
28
setlanguagecookie( $query, $language, $url );
28
C4::Templates::setlanguagecookie( $query, $language, $url );
(-)a/opac/opac-main.pl (-27 / +1 lines)
Lines 54-86 $template->param( Link Here
54
54
55
# display news
55
# display news
56
# use cookie setting for language, bug default to syspref if it's not set
56
# use cookie setting for language, bug default to syspref if it's not set
57
(my $theme) = themelanguage(C4::Context->config('opachtdocs'),'opac-main.tmpl','opac',$input);
57
my ($theme, $news_lang) = C4::Templates::themelanguage(C4::Context->config('opachtdocs'),'opac-main.tt','opac',$input);
58
59
my $translations = getTranslatedLanguages('opac',$theme);
60
my @languages = ();
61
foreach my $trans (@$translations)
62
{
63
    push(@languages, $trans->{rfc4646_subtag});
64
}
65
66
my $news_lang;
67
if($input->cookie('KohaOpacLanguage')){
68
    $news_lang = $input->cookie('KohaOpacLanguage');
69
}else{
70
    if ($ENV{HTTP_ACCEPT_LANGUAGE}) {
71
        while( !$news_lang && ( $ENV{HTTP_ACCEPT_LANGUAGE} =~ m/([a-zA-Z]{2,}-?[a-zA-Z]*)(;|,)?/g ) ){
72
            if( my @lang = grep { /^$1$/i } @languages ) {
73
                $news_lang = $lang[0];
74
            }
75
        }
76
    }
77
    if (not $news_lang) {
78
        my @languages = split ",", C4::Context->preference("opaclanguages");
79
        $news_lang = $languages[0];
80
    }
81
}
82
83
$news_lang = $news_lang ? $news_lang : 'en' ;
84
58
85
my $all_koha_news   = &GetNewsToDisplay($news_lang);
59
my $all_koha_news   = &GetNewsToDisplay($news_lang);
86
my $koha_news_count = scalar @$all_koha_news;
60
my $koha_news_count = scalar @$all_koha_news;
(-)a/opac/opac-search.pl (-1 / +1 lines)
Lines 373-379 my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_ Link Here
373
my @results;
373
my @results;
374
374
375
## I. BUILD THE QUERY
375
## I. BUILD THE QUERY
376
my $lang = C4::Output::getlanguagecookie($cgi);
376
my $lang = C4::Templates::getlanguagecookie($cgi);
377
( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type) = buildQuery(\@operators,\@operands,\@indexes,\@limits,\@sort_by, 0, $lang);
377
( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type) = buildQuery(\@operators,\@operands,\@indexes,\@limits,\@sort_by, 0, $lang);
378
378
379
sub _input_cgi_parse ($) { 
379
sub _input_cgi_parse ($) { 
(-)a/tools/export.pl (-2 / +1 lines)
Lines 20-26 Link Here
20
use strict;
20
use strict;
21
use warnings;
21
use warnings;
22
use C4::Auth;
22
use C4::Auth;
23
use C4::Output;  # contains gettemplate
23
use C4::Output;
24
use C4::Biblio;  # GetMarcBiblio GetXmlBiblio
24
use C4::Biblio;  # GetMarcBiblio GetXmlBiblio
25
use CGI;
25
use CGI;
26
use C4::Koha;    # GetItemTypes
26
use C4::Koha;    # GetItemTypes
27
- 

Return to bug 6755