Wouldn't this be better to put in a .pm rather than a .pl so that it can be called from other places too?
On Fri, Mar 6, 2009 at 5:37 AM, <[email protected]> wrote: > From: Nahuel Angelinetti <[email protected]> > > Signed-off-by: Henri-Damien LAURENT <[email protected]> > --- > opac/opac-main.pl | 24 +++++++++++++++++++++++- > 1 files changed, 23 insertions(+), 1 deletions(-) > > diff --git a/opac/opac-main.pl b/opac/opac-main.pl > index 1062109..704dc75 100755 > --- a/opac/opac-main.pl > +++ b/opac/opac-main.pl > @@ -25,6 +25,7 @@ use C4::Branch; # GetBranches > use C4::Members; # GetMember > use C4::NewsChannels; # get_opac_news > use C4::Acquisition; # GetRecentAcqui > +use C4::Languages qw(getTranslatedLanguages); > > my $input = new CGI; > my $dbh = C4::Context->dbh; > @@ -46,7 +47,28 @@ $template->param( > > # display news > # use cookie setting for language, bug default to syspref if it's not set > -my $news_lang = $input->cookie('KohaOpacLanguage') || 'en'; > +(my $theme) = > themelanguage(C4::Context->config('opachtdocs'),'opac-main.tmpl','opac',$input); > + > +my $translations = getTranslatedLanguages('opac',$theme); > +my @languages = (); > +foreach my $trans (@$translations) > +{ > + push(@languages, $trans->{rfc4646_subtag}); > +} > + > +my $news_lang; > +if($input->cookie('KohaOpacLanguage')){ > + $news_lang = $input->cookie('KohaOpacLanguage'); > +}else{ > + while( !$news_lang && ( $ENV{HTTP_ACCEPT_LANGUAGE} =~ > m/([a-zA-Z]{2,}-?[a-zA-Z]*)(;|,)?/g ) ){ > + if( my @lang = grep { /^$1$/i } @languages ) { > + $news_lang = $lang[0]; > + } > + } > +} > + > +$news_lang = $news_lang ? $news_lang : 'en' ; > + > my $all_koha_news = &GetNewsToDisplay($news_lang); > my $koha_news_count = scalar @$all_koha_news; > > -- > 1.5.6.3 > > _______________________________________________ > Koha-patches mailing list > [email protected] > http://lists.koha.org/mailman/listinfo/koha-patches > -- Joshua Ferraro SUPPORT FOR OPEN-SOURCE SOFTWARE CEO migration, training, maintenance, support LibLime Featuring Koha Open-Source ILS [email protected] |Full Demos at http://liblime.com/koha |1(888)KohaILS _______________________________________________ Koha-patches mailing list [email protected] http://lists.koha.org/mailman/listinfo/koha-patches
