[Koha-cvs] CVS: koha/C4 Search.pm,1.67,1.68
Steve Tonnesen
tonnesen at users.sourceforge.net
Wed Jun 11 20:48:10 CEST 2003
Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1:/tmp/cvs-serv20129
Modified Files:
Search.pm
Log Message:
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).
Index: Search.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Search.pm,v
retrieving revision 1.67
retrieving revision 1.68
diff -C2 -r1.67 -r1.68
*** Search.pm 5 Jun 2003 17:03:32 -0000 1.67
--- Search.pm 11 Jun 2003 18:48:07 -0000 1.68
***************
*** 63,67 ****
&addauthor &bibitems &barcodes &findguarantees &allissues
&findguarantor &getwebsites &getwebbiblioitems &catalogsearch &itemcount2
! &isbnsearch &breedingsearch);
# make all your functions, whether exported or not;
--- 63,67 ----
&addauthor &bibitems &barcodes &findguarantees &allissues
&findguarantor &getwebsites &getwebbiblioitems &catalogsearch &itemcount2
! &isbnsearch &breedingsearch &getallthemes &getalllanguages);
# make all your functions, whether exported or not;
***************
*** 2425,2428 ****
--- 2425,2542 ----
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
More information about the Koha-cvs
mailing list