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

(-)a/C4/Languages.pm (-7 / +23 lines)
Lines 168-174 sub getTranslatedLanguages { Link Here
168
168
169
Returns a reference to an array of hashes:
169
Returns a reference to an array of hashes:
170
170
171
 my $alllanguages = getAllLanguages();
171
 my $alllanguages = getAllLanguages()
172
 print "Available translated languages:\n";
172
 print "Available translated languages:\n";
173
 for my $language(@$alllanguages) {
173
 for my $language(@$alllanguages) {
174
    print "$language->{language_code}\n";
174
    print "$language->{language_code}\n";
Lines 179-197 Returns a reference to an array of hashes: Link Here
179
=cut
179
=cut
180
180
181
sub getAllLanguages {
181
sub getAllLanguages {
182
    my $lang = shift;
183
# if no parameter is passed to the function, it returns english languages names
184
# if a $lang parameter conforming to RFC4646 syntax is passed, the function returns languages names translated in $lang
185
# if a language name is not translated in $lang in database, the function returns english language name
182
    my @languages_loop;
186
    my @languages_loop;
183
    my $dbh=C4::Context->dbh;
187
    my $dbh=C4::Context->dbh;
184
    my $current_language = shift || 'en';
188
    my $default_language = 'en';
189
    my $current_language = $default_language;
190
    if ($lang) {
191
        $current_language = regex_lang_subtags($lang)->{'language'};
192
    }
185
    my $sth = $dbh->prepare('SELECT * FROM language_subtag_registry WHERE type=\'language\'');
193
    my $sth = $dbh->prepare('SELECT * FROM language_subtag_registry WHERE type=\'language\'');
186
    $sth->execute();
194
    $sth->execute();
187
    while (my $language_subtag_registry = $sth->fetchrow_hashref) {
195
    while (my $language_subtag_registry = $sth->fetchrow_hashref) {
188
196
        my $desc; 
189
        # pull out all the script descriptions for each language
197
        # check if language name is stored in current language
198
        my $sth4= $dbh->prepare("SELECT description FROM language_descriptions WHERE type='language' AND subtag =? AND lang = ?");
199
        $sth4->execute($language_subtag_registry->{subtag},$current_language);
200
        while (my $language_desc = $sth4->fetchrow_hashref) {
201
             $desc=$language_desc->{description};
202
        }
190
        my $sth2= $dbh->prepare("SELECT * FROM language_descriptions LEFT JOIN language_rfc4646_to_iso639 on language_rfc4646_to_iso639.rfc4646_subtag = language_descriptions.subtag WHERE type='language' AND subtag =? AND language_descriptions.lang = ?");
203
        my $sth2= $dbh->prepare("SELECT * FROM language_descriptions LEFT JOIN language_rfc4646_to_iso639 on language_rfc4646_to_iso639.rfc4646_subtag = language_descriptions.subtag WHERE type='language' AND subtag =? AND language_descriptions.lang = ?");
191
        $sth2->execute($language_subtag_registry->{subtag},$current_language);
204
        if ($desc) {
192
205
            $sth2->execute($language_subtag_registry->{subtag},$current_language);
206
        }
207
        else { 
208
            $sth2->execute($language_subtag_registry->{subtag},$default_language);
209
        }
193
        my $sth3 = $dbh->prepare("SELECT description FROM language_descriptions WHERE type='language' AND subtag=? AND lang=?");
210
        my $sth3 = $dbh->prepare("SELECT description FROM language_descriptions WHERE type='language' AND subtag=? AND lang=?");
194
195
        # add the correct description info
211
        # add the correct description info
196
        while (my $language_descriptions = $sth2->fetchrow_hashref) {
212
        while (my $language_descriptions = $sth2->fetchrow_hashref) {
197
            $sth3->execute($language_subtag_registry->{subtag},$language_subtag_registry->{subtag});
213
            $sth3->execute($language_subtag_registry->{subtag},$language_subtag_registry->{subtag});
(-)a/catalogue/search.pl (-3 / +2 lines)
Lines 158-164 use CGI qw('-no_undef_params'); Link Here
158
my $cgi = new CGI;
158
my $cgi = new CGI;
159
159
160
my ($template,$borrowernumber,$cookie);
160
my ($template,$borrowernumber,$cookie);
161
161
my $lang = C4::Templates::getlanguage($cgi, 'intranet');
162
# decide which template to use
162
# decide which template to use
163
my $template_name;
163
my $template_name;
164
my $template_type;
164
my $template_type;
Lines 334-340 if ( $template_type eq 'advsearch' ) { Link Here
334
                      search_boxes_loop => \@search_boxes_array);
334
                      search_boxes_loop => \@search_boxes_array);
335
335
336
    # load the language limits (for search)
336
    # load the language limits (for search)
337
    my $languages_limit_loop = getAllLanguages();
337
    my $languages_limit_loop = getAllLanguages($lang);
338
    $template->param(search_languages_loop => $languages_limit_loop,);
338
    $template->param(search_languages_loop => $languages_limit_loop,);
339
339
340
    # Expanded search options in advanced search:
340
    # Expanded search options in advanced search:
Lines 472-478 my ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit Link Here
472
my @results;
472
my @results;
473
473
474
## I. BUILD THE QUERY
474
## I. BUILD THE QUERY
475
my $lang = C4::Templates::getlanguage($cgi, 'intranet');
476
( $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);
477
476
478
## 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/opac/opac-search.pl (-4 / +2 lines)
Lines 71-77 BEGIN { Link Here
71
}
71
}
72
72
73
my ($template,$borrowernumber,$cookie);
73
my ($template,$borrowernumber,$cookie);
74
74
my $lang = C4::Templates::getlanguage($cgi, 'opac');
75
# decide which template to use
75
# decide which template to use
76
my $template_name;
76
my $template_name;
77
my $template_type = 'basic';
77
my $template_type = 'basic';
Lines 178-184 $template->param( Link Here
178
);
178
);
179
179
180
# load the language limits (for search)
180
# load the language limits (for search)
181
my $languages_limit_loop = getAllLanguages();
181
my $languages_limit_loop = getAllLanguages($lang);
182
$template->param(search_languages_loop => $languages_limit_loop,);
182
$template->param(search_languages_loop => $languages_limit_loop,);
183
183
184
# load the Type stuff
184
# load the Type stuff
Lines 418-424 my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_ Link Here
418
my @results;
418
my @results;
419
419
420
## I. BUILD THE QUERY
420
## I. BUILD THE QUERY
421
my $lang = C4::Templates::getlanguage($cgi, 'opac');
422
( $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);
421
( $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);
423
422
424
sub _input_cgi_parse {
423
sub _input_cgi_parse {
425
- 

Return to bug 8954