From b2d3fe1ccb34e31d9d1c3dd0c0e66000e6ccc051 Mon Sep 17 00:00:00 2001 From: tipaul Date: Mon, 16 Aug 2004 12:49:42 +0000 Subject: [PATCH] moving language chooser to the main page. moving the getalltemplates and getalllanguages subs out from Search.pm (that will be deprecated soon) to Koha.pm moving changelanguage.pl to OPAC scope --- C4/Koha.pm | 112 +++++++++++++++++++++++++++++++++++++++++ C4/Search.pm | 112 +---------------------------------------- opac/changelanguage.pl | 10 ++++ 3 files changed, 123 insertions(+), 111 deletions(-) create mode 100755 opac/changelanguage.pl diff --git a/C4/Koha.pm b/C4/Koha.pm index 61a3d554d6..e8fc481a1d 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -60,6 +60,7 @@ Koha.pm provides many functions for Koha scripts. &getitemtypes &getitemtypeinfo &getframeworks &getframeworkinfo &getauthtypes &getauthtype + &getallthemes &getalllanguages $DEBUG); use vars qw(); @@ -459,6 +460,117 @@ sub getprinter ($$) { return $printer; } +=item getalllanguages + + (@languages) = &getalllanguages($type); + (@languages) = &getalllanguages($type,$theme); + +Returns an array of all available languages. + +=cut + +sub getalllanguages { + my $type=shift; + my $theme=shift; + my $htdocs; + my @languages; + if ($type eq 'opac') { + $htdocs=C4::Context->config('opachtdocs'); + if ($theme and -d "$htdocs/$theme") { + opendir D, "$htdocs/$theme"; + foreach my $language (readdir D) { + next if $language=~/^\./; + next if $language eq 'all'; + push @languages, $language; + } + return sort @languages; + } else { + my $lang; + foreach my $theme (getallthemes('opac')) { + opendir D, "$htdocs/$theme"; + foreach my $language (readdir D) { + next if $language=~/^\./; + next if $language eq 'all'; + $lang->{$language}=1; + } + } + @languages=keys %$lang; + return sort @languages; + } + } elsif ($type eq 'intranet') { + $htdocs=C4::Context->config('intrahtdocs'); + if ($theme and -d "$htdocs/$theme") { + opendir D, "$htdocs/$theme"; + foreach my $language (readdir D) { + next if $language=~/^\./; + next if $language eq 'all'; + push @languages, $language; + } + return sort @languages; + } else { + my $lang; + foreach my $theme (getallthemes('opac')) { + opendir D, "$htdocs/$theme"; + foreach my $language (readdir D) { + next if $language=~/^\./; + next if $language eq 'all'; + $lang->{$language}=1; + } + } + @languages=keys %$lang; + return sort @languages; + } + } else { + my $lang; + my $htdocs=C4::Context->config('intrahtdocs'); + foreach my $theme (getallthemes('intranet')) { + opendir D, "$htdocs/$theme"; + foreach my $language (readdir D) { + next if $language=~/^\./; + next if $language eq 'all'; + $lang->{$language}=1; + } + } + my $htdocs=C4::Context->config('opachtdocs'); + foreach my $theme (getallthemes('opac')) { + opendir D, "$htdocs/$theme"; + foreach my $language (readdir D) { + next if $language=~/^\./; + next if $language eq 'all'; + $lang->{$language}=1; + } + } + @languages=keys %$lang; + return sort @languages; + } +} + +=item getallthemes + + (@themes) = &getallthemes('opac'); + (@themes) = &getallthemes('intranet'); + +Returns an array of all available themes. + +=cut + +sub getallthemes { + my $type=shift; + my $htdocs; + my @themes; + if ($type eq 'intranet') { + $htdocs=C4::Context->config('intrahtdocs'); + } else { + $htdocs=C4::Context->config('opachtdocs'); + } + opendir D, "$htdocs"; + my @dirlist=readdir D; + foreach my $directory (@dirlist) { + -d "$htdocs/$directory/en" and push @themes, $directory; + } + return @themes; +} + 1; __END__ diff --git a/C4/Search.pm b/C4/Search.pm index 0d11b0ee39..63bb48ad64 100755 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -64,7 +64,7 @@ on what is passed to it, it calls the appropriate search function. &getboracctrecord &ItemType &itemissues &subject &subtitle &addauthor &bibitems &barcodes &findguarantees &allissues &findguarantor &getwebsites &getwebbiblioitems &catalogsearch &itemcount2 -&isbnsearch &breedingsearch &getallthemes &getalllanguages &getbranchname &getborrowercategory); +&isbnsearch &breedingsearch &getbranchname &getborrowercategory); # make all your functions, whether exported or not; @@ -2568,116 +2568,6 @@ sub breedingsearch { } # sub breedingsearch -=item getalllanguages - - (@languages) = &getalllanguages($type); - (@languages) = &getalllanguages($type,$theme); - -Returns an array of all available languages. - -=cut - -sub getalllanguages { - my $type=shift; - my $theme=shift; - my $htdocs; - my @languages; - if ($type eq 'opac') { - $htdocs=C4::Context->config('opachtdocs'); - if ($theme and -d "$htdocs/$theme") { - opendir D, "$htdocs/$theme"; - foreach my $language (readdir D) { - next if $language=~/^\./; - next if $language eq 'all'; - push @languages, $language; - } - return sort @languages; - } else { - my $lang; - foreach my $theme (getallthemes('opac')) { - opendir D, "$htdocs/$theme"; - foreach my $language (readdir D) { - next if $language=~/^\./; - next if $language eq 'all'; - $lang->{$language}=1; - } - } - @languages=keys %$lang; - return sort @languages; - } - } elsif ($type eq 'intranet') { - $htdocs=C4::Context->config('intrahtdocs'); - if ($theme and -d "$htdocs/$theme") { - opendir D, "$htdocs/$theme"; - foreach my $language (readdir D) { - next if $language=~/^\./; - next if $language eq 'all'; - push @languages, $language; - } - return sort @languages; - } else { - my $lang; - foreach my $theme (getallthemes('opac')) { - opendir D, "$htdocs/$theme"; - foreach my $language (readdir D) { - next if $language=~/^\./; - next if $language eq 'all'; - $lang->{$language}=1; - } - } - @languages=keys %$lang; - return sort @languages; - } - } else { - my $lang; - my $htdocs=C4::Context->config('intrahtdocs'); - foreach my $theme (getallthemes('intranet')) { - opendir D, "$htdocs/$theme"; - foreach my $language (readdir D) { - next if $language=~/^\./; - next if $language eq 'all'; - $lang->{$language}=1; - } - } - my $htdocs=C4::Context->config('opachtdocs'); - foreach my $theme (getallthemes('opac')) { - opendir D, "$htdocs/$theme"; - foreach my $language (readdir D) { - next if $language=~/^\./; - next if $language eq 'all'; - $lang->{$language}=1; - } - } - @languages=keys %$lang; - return sort @languages; - } -} - -=item getallthemes - - (@themes) = &getallthemes('opac'); - (@themes) = &getallthemes('intranet'); - -Returns an array of all available themes. - -=cut - -sub getallthemes { - my $type=shift; - my $htdocs; - my @themes; - if ($type eq 'intranet') { - $htdocs=C4::Context->config('intrahtdocs'); - } else { - $htdocs=C4::Context->config('opachtdocs'); - } - opendir D, "$htdocs"; - my @dirlist=readdir D; - foreach my $directory (@dirlist) { - -d "$htdocs/$directory/en" and push @themes, $directory; - } - return @themes; -} diff --git a/opac/changelanguage.pl b/opac/changelanguage.pl new file mode 100755 index 0000000000..ad616a71b7 --- /dev/null +++ b/opac/changelanguage.pl @@ -0,0 +1,10 @@ +#!/usr/bin/perl + +use C4::Output; +use CGI; + +my $query=new CGI; +my $language=$query->param('language'); +my $url=$query->referer(); + +setlanguagecookie($query,$language,$url); -- 2.39.5