[Koha-cvs] CVS: koha/C4 Output.pm,1.18.2.1,1.18.2.2

Andrew Arensburger arensb at users.sourceforge.net
Sat Oct 5 09:19:36 CEST 2002


Update of /cvsroot/koha/koha/C4
In directory usw-pr-cvs1:/tmp/cvs-serv18915

Modified Files:
      Tag: arensb-context
	Output.pm 
Log Message:
Merged in changes from main branch.


Index: Output.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Output.pm,v
retrieving revision 1.18.2.1
retrieving revision 1.18.2.2
diff -C2 -r1.18.2.1 -r1.18.2.2
*** Output.pm	4 Oct 2002 02:52:33 -0000	1.18.2.1
--- Output.pm	5 Oct 2002 07:19:34 -0000	1.18.2.2
***************
*** 66,70 ****
  	     &getkeytableselectoptions
  	     &pathtotemplate
! 	     &picktemplate);
  %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
  
--- 66,71 ----
  	     &getkeytableselectoptions
  	     &pathtotemplate
! 		&themelanguage &gettemplate
! 	     );
  %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
  
***************
*** 96,146 ****
  	"/usr/local/www/hdl/htdocs/includes";
  
! # make all your functions, whether exported or not;
  
! =item picktemplate
  
!   $template = &picktemplate($includes, $base);
  
! Returns the preferred template for a given page. C<$base> is the
! basename of the script that will generate the page (with the C<.pl>
! extension stripped off), and C<$includes> is the directory in which
! HTML include files are located.
! 
! The preferred template is given by the C<template> entry in the
! C<systempreferences> table in the Koha database. If
! C<$includes>F</templates/preferred-template/>C<$base.tmpl> exists,
! C<&picktemplate> returns the preferred template; otherwise, it returns
! the string C<default>.
! 
! =cut
! #'
! sub picktemplate {
!   my ($includes, $base) = @_;
!   my $dbh = C4::Context->dbh;
!   my $templates;
!   # FIXME - Instead of generating the list of possible templates, and
!   # then querying the database to see if, by chance, one of them has
!   # been selected, wouldn't it be better to query the database first,
!   # and then see whether the selected template file exists?
!   opendir (D, "$includes/templates");
!   my @dirlist=readdir D;
!   foreach (@dirlist) {
!     (next) if (/^\./);
!     #(next) unless (/\.tmpl$/);
!     (next) unless (-e "$includes/templates/$_/$base");
!     $templates->{$_}=1;
!   }
!   my $sth=$dbh->prepare("select value from systempreferences where
!   variable='template'");
    $sth->execute;
!   my ($preftemplate) = $sth->fetchrow;
    $sth->finish;
!   if ($templates->{$preftemplate}) {
!     return $preftemplate;
    } else {
!     return 'default';
    }
- 
  }
  
  =item pathtotemplate
--- 97,164 ----
  	"/usr/local/www/hdl/htdocs/includes";
  
! #---------------------------------------------------------------------------------------------------------
! sub gettemplate {
!     my ($tmplbase, $opac) = @_;
! 
!     my $htdocs;
!     if ($opac) {
! 	$htdocs = $configfile->{'opachtdocs'};
!     } else {
! 	$htdocs = $configfile->{'intrahtdocs'};
!     }
! 
!     my ($theme, $lang) = themelanguage($htdocs, $tmplbase);
! 
!     my $template = HTML::Template->new(filename      => "$htdocs/$theme/$lang/$tmplbase",
! 				   die_on_bad_params => 0,
! 				   global_vars       => 1,
! 				   path              => ["$htdocs/$theme/$lang/includes"]);
  
!     $template->param(themelang => "/$theme/$lang");
!     return $template;
! }
  
! #---------------------------------------------------------------------------------------------------------
! sub themelanguage {
!   my ($htdocs, $tmpl) = @_;
! 
! # language preferences....
!   my $dbh=C4Connect;
!   my $sth=$dbh->prepare("SELECT value FROM systempreferences WHERE variable='opaclanguages'");
!   $sth->execute;
!   my ($lang) = $sth->fetchrow;
!   $sth->finish;
!   my @languages = split " ", $lang;
  
! # theme preferences....
!   my $sth=$dbh->prepare("SELECT value FROM systempreferences WHERE variable='opacthemes'");
    $sth->execute;
!   my ($theme) = $sth->fetchrow;
    $sth->finish;
!   my @themes = split " ", $theme;
! 
!   $dbh->disconnect;
! 
!   my ($theme, $lang);
! # searches through the themes and languages. First template it find it returns.
! # Priority is for getting the theme right.
!   THEME:
!   foreach my $th (@themes) {
!     foreach my $la (@languages) {
! 	warn "File = $htdocs/$th/$la/$tmpl\n";
! 	if (-e "$htdocs/$th/$la/$tmpl") {
! 	    $theme = $th;
! 	    $lang = $la;
! 	    last THEME;
! 	}
!     }
!   }
!   if ($theme and $lang) {
!     return ($theme, $lang);
    } else {
!     return ('default', 'en');
    }
  }
+ 
  
  =item pathtotemplate





More information about the Koha-cvs mailing list