package C4::Output;
+# $Id$
+
#package to deal with marking up output
#You will need to edit parts of this pm
#set the value of path to be where your html lives
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
+# NOTE: I'm pretty sure this module is deprecated in favor of
+# templates.
+
use strict;
require Exporter;
use C4::Context;
use C4::Database;
+use HTML::Template;
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+use vars qw($VERSION @ISA @EXPORT);
# set the version for version checking
$VERSION = 0.01;
&pathtotemplate
&themelanguage &gettemplate
);
-%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
-
-# your exported package globals go here,
-# as well as any optionally exported functions
-
-@EXPORT_OK = qw($Var1 %Hashit); # FIXME - These are never used
-
-
-# non-exported package globals go here
-use vars qw(@more $stuff); # FIXME - These are never used
-
-# initalize package globals, first exported ones
-
-# FIXME - These are never used
-my $Var1 = '';
-my %Hashit = ();
-
-
-# then the others (which are still accessible as $Some::Module::stuff)
-# FIXME - These are never used
-my $stuff = '';
-my @more = ();
-
-# all file-scoped lexicals must be created before
-# the functions below that use them.
my $path = C4::Context->config('includes') ||
"/usr/local/www/hdl/htdocs/includes";
#---------------------------------------------------------------------------------------------------------
# FIXME - POD
sub gettemplate {
- my ($tmplbase, $opac) = @_;
+ my ($tmplbase, $opac) = @_;
- my $htdocs;
- if ($opac) {
- $htdocs = C4::Context->config('opachtdocs');
- } else {
- $htdocs = C4::Context->config('intrahtdocs');
- }
+ my $htdocs;
+ if ($opac ne "intranet") {
+ $htdocs = C4::Context->config('opachtdocs');
+ } else {
+ $htdocs = C4::Context->config('intrahtdocs');
+ }
- my ($theme, $lang) = themelanguage($htdocs, $tmplbase);
+ my ($theme, $lang) = themelanguage($htdocs, $tmplbase, $opac);
- my $template = HTML::Template->new(filename => "$htdocs/$theme/$lang/$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;
+ # XXX temporary patch for Bug 182 for themelang
+ $template->param(themelang => ($opac ne 'intranet'? '/opac-tmpl': '/intranet-tmpl') . "/$theme/$lang",
+ interface => ($opac ne 'intranet'? '/opac-tmpl': '/intranet-tmpl'),
+ theme => $theme,
+ lang => $lang);
+ return $template;
}
#---------------------------------------------------------------------------------------------------------
# FIXME - POD
sub themelanguage {
- my ($htdocs, $tmpl) = @_;
+ my ($htdocs, $tmpl, $section) = @_;
my $dbh = C4::Context->dbh;
- my @languages = split " ", C4::Context->preference("opaclanguages");
- # language preference
- my @themes = split " ", C4::Context->preference("opacthemes");
- # theme preferences
+ my @languages;
+ my @themes;
+ if ( $section eq "intranet")
+ {
+ @languages = split " ", C4::Context->preference("opaclanguages");
+ @themes = split " ", C4::Context->preference("template");
+ }
+ else
+ {
+ @languages = split " ", C4::Context->preference("opaclanguages");
+ @themes = split " ", C4::Context->preference("opacthemes");
+ }
my ($theme, $lang);
# searches through the themes and languages. First template it find it returns.
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;
# edit the paths in here
my ($type)=shift;
if ($type eq 'issue') {
- open (FILE,"$path/issues-top.inc") || die;
+ open (FILE,"$path/issues-top.inc") || die "could not find : $path/issues-top.inc";
} elsif ($type eq 'opac') {
- open (FILE,"$path/opac-top.inc") || die;
+ open (FILE,"$path/opac-top.inc") || die "could not find : $path/opac-top.inc";
} elsif ($type eq 'member') {
- open (FILE,"$path/members-top.inc") || die;
+ open (FILE,"$path/members-top.inc") || die "could not find : $path/members-top.inc";
} elsif ($type eq 'acquisitions'){
- open (FILE,"$path/acquisitions-top.inc") || die;
+ open (FILE,"$path/acquisitions-top.inc") || die "could not find : $path/acquisition-top.inc";
} elsif ($type eq 'report'){
- open (FILE,"$path/reports-top.inc") || die;
+ open (FILE,"$path/reports-top.inc") || die "could not find : $path/reports-top.inc";
} elsif ($type eq 'circulation') {
- open (FILE,"$path/circulation-top.inc") || die;
+ open (FILE,"$path/circulation-top.inc") || die "could not find : $path/circulation-top.inc";
+ } elsif ($type eq 'admin') {
+ open (FILE,"$path/parameters-top.inc") || die "could not find : $path/parameters-top.inc";
} else {
- open (FILE,"$path/cat-top.inc") || die;
+ open (FILE,"$path/cat-top.inc") || die "could not find : $path/cat-top.inc";
}
my @string=<FILE>;
close FILE;
# FIXME - It's bad form to die in a CGI script. It's even worse form
# to die without issuing an error message.
if ($type eq 'issue') {
- open (FILE,"$path/issues-bottom.inc") || die;
+ open (FILE,"<$path/issues-bottom.inc") || die;
} elsif ($type eq 'opac') {
- open (FILE,"$path/opac-bottom.inc") || die;
+ open (FILE,"<$path/opac-bottom.inc") || die;
} elsif ($type eq 'member') {
- open (FILE,"$path/members-bottom.inc") || die;
+ open (FILE,"<$path/members-bottom.inc") || die;
} elsif ($type eq 'acquisitions') {
- open (FILE,"$path/acquisitions-bottom.inc") || die;
+ open (FILE,"<$path/acquisitions-bottom.inc") || die;
} elsif ($type eq 'report') {
- open (FILE,"$path/reports-bottom.inc") || die;
+ open (FILE,"<$path/reports-bottom.inc") || die;
} elsif ($type eq 'circulation') {
- open (FILE,"$path/circulation-bottom.inc") || die;
+ open (FILE,"<$path/circulation-bottom.inc") || die;
+ } elsif ($type eq 'admin') {
+ open (FILE,"<$path/parameters-bottom.inc") || die;
} else {
- open (FILE,"$path/cat-bottom.inc") || die;
+ open (FILE,"<$path/cat-bottom.inc") || die;
}
my @string=<FILE>;
close FILE;
}
$i++;
}
- $string=$string."</tr>\n"; # FIXME - .=
+ $string .= "</tr>\n";
return($string);
}
sub mkform{
my ($action,%inputs)=@_;
my $string="<form action=$action method=post>\n";
- $string=$string.mktablehdr(); # FIXME - .=
+ $string .= mktablehdr();
my $key;
my @keys=sort keys %inputs;
my @data=split('\t',$value);
#my $posn = shift(@data);
if ($data[0] eq 'hidden'){
- $string=$string."<input type=hidden name=$keys[$i2] value=\"$data[1]\">\n";
- # FIXME - .=
+ $string .= "<input type=hidden name=$keys[$i2] value=\"$data[1]\">\n";
} else {
my $text;
if ($data[0] eq 'radio') {
my $i=1;
while ($data[$i] ne "") {
my $val = $data[$i+1];
- $text = $text."<option value=$data[$i]>$val"; # FIXME - .=
- $i = $i+2; # FIXME - +=
+ $text .= "<option value=$data[$i]>$val";
+ $i += 2;
}
- $text=$text."</select>";
- # FIXME - .=
+ $text .= "</select>";
}
- $string=$string.mktablerow(2,'white',$keys[$i2],$text); # FIXME - .=
+ $string .= mktablerow(2,'white',$keys[$i2],$text);
#@order[$posn] =mktablerow(2,'white',$keys[$i2],$text);
}
$i2++;
}
#$string=$string.join("\n",@order);
- $string=$string.mktablerow(2,'white','<input type=submit>','<input type=reset>');
- # FIXME - .=
- $string=$string.mktableft; # FIXME - .=
- $string=$string."</form>"; # FIXME - .=
+ $string .= mktablerow(2,'white','<input type=submit>','<input type=reset>');
+ $string .= mktableft;
+ $string .= "</form>";
}
=item mkform3
my $i=1;
while ($data[$i] ne "") {
my $val = $data[$i+1];
- $text = $text."<option value=$data[$i]>$val"; # FIXME - .=
- $i = $i+2; # FIXME - Use $i += 2.
+ $text .= "<option value=$data[$i]>$val";
+ $i += 2;
}
- $text=$text."</select>"; # FIXME - .=
+ $text .= "</select>";
}
# $string=$string.mktablerow(2,'white',$keys[$i2],$text);
$order[$posn]=mktablerow(2,'white',$keys[$i2],$text);
$i2++;
}
my $temp=join("\n",@order);
- $string=$string.$temp; # FIXME - .=
- $string=$string.mktablerow(1,'white','<input type=submit>'); # FIXME - .=
- $string=$string.mktableft; # FIXME - .=
- $string=$string."</form>"; # FIXME - .=
+ $string .= $temp;
+ $string .= mktablerow(1,'white','<input type=submit>');
+ $string .= mktableft;
+ $string .= "</form>";
# FIXME - A return statement, while not strictly necessary, would be nice.
}
my $count=@inputs;
for (my $i=0; $i<$count; $i++){
if ($inputs[$i][0] eq 'hidden'){
- $string=$string."<input type=hidden name=$inputs[$i][1] value=\"$inputs[$i][2]\">\n";
- # FIXME - .=
+ $string .= "<input type=hidden name=$inputs[$i][1] value=\"$inputs[$i][2]\">\n";
}
if ($inputs[$i][0] eq 'radio') {
- $string.="<input type=radio name=$inputs[1] value=$inputs[$i][2]>$inputs[$i][2]";
- # FIXME - .=
+ $string .= "<input type=radio name=$inputs[1] value=$inputs[$i][2]>$inputs[$i][2]";
}
if ($inputs[$i][0] eq 'text') {
- $string.="<input type=$inputs[$i][0] name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
- # FIXME - .=
+ $string .= "<input type=$inputs[$i][0] name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
}
if ($inputs[$i][0] eq 'textarea') {
- $string.="<textarea name=$inputs[$i][1] wrap=physical cols=40 rows=4>$inputs[$i][2]</textarea>";
- # FIXME - .=
+ $string .= "<textarea name=$inputs[$i][1] wrap=physical cols=40 rows=4>$inputs[$i][2]</textarea>";
}
if ($inputs[$i][0] eq 'reset'){
- $string.="<input type=reset name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
- # FIXME - .=
+ $string .= "<input type=reset name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
}
if ($inputs[$i][0] eq 'submit'){
- $string.="<input type=submit name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
- # FIXME - .=
+ $string .= "<input type=submit name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
}
}
- $string=$string."</form>"; # FIXME - .=
+ $string .= "</form>";
}
=item mkform2
# functions
my ($action,%inputs)=@_;
my $string="<form action=$action method=post>\n";
- $string=$string.mktablehdr(); # FIXME - .=
+ $string .= mktablehdr();
my $key;
my @order;
while ( my ($key, $value) = each %inputs) {
my $reqd = shift(@data);
my $ltext = shift(@data);
if ($data[0] eq 'hidden'){
- $string=$string."<input type=hidden name=$key value=\"$data[1]\">\n";
- # FIXME - .=
+ $string .= "<input type=hidden name=$key value=\"$data[1]\">\n";
} else {
my $text;
if ($data[0] eq 'radio') {
my $i=2;
while ($data[$i] ne "") {
my $val = $data[$i+1];
- $text = $text."<option value=\"$data[$i]\""; # FIXME - .=
+ $text .= "<option value=\"$data[$i]\"";
if ($data[$i] eq $sel) {
- $text = $text." selected"; # FIXME - .=
+ $text .= " selected";
}
- $text = $text.">$val"; # FIXME - .=
- $i = $i+2; # FIXME - +=
+ $text .= ">$val";
+ $i += 2;
}
- $text=$text."</select>"; # FIXME - .=
+ $text .= "</select>";
}
if ($reqd eq "R") {
- $ltext = $ltext." (Req)"; # FIXME - .=
+ $ltext .= " (Req)";
}
$order[$posn] =mktablerow(2,'white',$ltext,$text);
}
}
- $string=$string.join("\n",@order); # FIXME - .=
- $string=$string.mktablerow(2,'white','<input type=submit>','<input type=reset>');
- # FIXME - .=
- $string=$string.mktableft; # FIXME - .=
- $string=$string."</form>"; # FIXME - .=
+ $string .= join("\n",@order);
+ $string .= mktablerow(2,'white','<input type=submit>','<input type=reset>');
+ $string .= mktableft;
+ $string .= "</form>";
}
=item endpage