Added two new routines for getting a list of available themes/languages (used

by new systempreferences.pl script to present a list of available themes or
languages).
This commit is contained in:
tonnesen 2003-06-11 18:48:07 +00:00
parent 53084f1a8c
commit 66bf985d0a

View file

@ -62,7 +62,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);
&isbnsearch &breedingsearch &getallthemes &getalllanguages);
# make all your functions, whether exported or not;
=item findguarantees
@ -2425,6 +2425,120 @@ sub breedingsearch {
return($count, @results);
} # sub breedingsearch
=item getalllanguages
(@languages) = &getalllanguages();
(@languages) = &getalllanguages($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;
}
=item isbnsearch
($count, @results) = &isbnsearch($isbn,$title);