--- /dev/null
+package C4::Interface::CGI::Output;
+
+# $Id$
+
+#package to work around problems in HTTP headers
+# Note: This is just a utility module; it should not be instantiated.
+
+
+# Copyright 2003 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
+use strict;
+require Exporter;
+
+use vars qw($VERSION @ISA @EXPORT);
+
+# set the version for version checking
+$VERSION = 0.01;
+
+=head1 NAME
+
+C4::CGI::Output - Convenience functions for handling outputting HTML pages
+
+=head1 SYNOPSIS
+
+ use C4::CGI::Output;
+
+ print $query->header(-type => C4::CGI::Output::gettype($output)), $output;
+
+=head1 DESCRIPTION
+
+The functions in this module peek into a piece of HTML and return strings
+related to the (guessed) charset.
+
+=head1 FUNCTIONS
+
+=over 2
+
+=cut
+
+@ISA = qw(Exporter);
+@EXPORT = qw(
+ &guesscharset
+ &guesstype
+ &output_html_with_http_headers
+ );
+
+=item guesscharset
+
+ &guesscharset($output)
+
+"Guesses" the charset from the some HTML that would be output.
+
+C<$output> is the HTML page to be output. If it contains a META tag
+with a Content-Type, the tag will be scanned for a language code.
+This code is returned if it is found; undef is returned otherwise.
+
+This function only does sloppy guessing; it will be confused by
+unexpected things like SGML comments. What it basically does is to
+grab something that looks like a META tag and scan it.
+
+=cut
+
+sub guesscharset ($) {
+ my($html) = @_;
+ my $charset = undef;
+ local($`, $&, $', $1, $2, $3);
+ # FIXME... These regular expressions will miss a lot of valid tags!
+ if ($html =~ /<meta\s+http-equiv=(["']?)Content-Type\1\s+content=(["'])text\/html\s*;\s*charset=([^\2\s\r\n]+)\2\s*(?:\/?)>/is) {
+ $charset = $3;
+ } elsif ($html =~ /<meta\s+content=(["'])text\/html\s*;\s*charset=([^\1\s\r\n]+)\1\s+http-equiv=(["']?)Content-Type\3\s*(?:\/?)>/is) {
+ $charset = $2;
+ }
+ return $charset;
+} # guess
+
+sub guesstype ($) {
+ my($html) = @_;
+ my $charset = guesscharset($html);
+ return defined $charset? "text/html; charset=$charset": "text/html";
+}
+
+=item output_html_with_http_headers
+
+ &output_html_with_http_headers($query, $cookie, $html)
+
+Outputs the HTML page $html with the appropriate HTTP headers,
+with the authentication cookie $cookie and a Content-Type that
+corresponds to the HTML page $html.
+
+=cut
+
+sub output_html_with_http_headers ($$$) {
+ my($query, $cookie, $html) = @_;
+ print $query->header(
+ -type => guesstype($html),
+ -cookie => $cookie,
+ ), $html;
+}
+
+#---------------------------------
+
+END { } # module clean-up code here (global destructor)
+
+1;
+__END__
+
+=back
+
+=head1 AUTHOR
+
+Koha Developement team <info@koha.org>
+
+=cut
--- /dev/null
+package C4::Interface::CGI::Template;
+
+# $Id$
+
+# convenience package for HTML templating
+# Note: This is just a utility module; it should not be instantiated.
+
+
+# Copyright 2003 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
+use strict;
+require Exporter;
+
+use vars qw($VERSION @ISA @EXPORT);
+
+# set the version for version checking
+$VERSION = 0.01;
+
+=head1 NAME
+
+C4::Members - Convenience functions for using HTML::Template
+
+=head1 SYNOPSIS
+
+ use C4::Interface::HTML::Template;
+
+=head1 DESCRIPTION
+
+The functions in this module peek into a piece of HTML and return strings
+related to the (guessed) charset.
+
+=head1 FUNCTIONS
+
+=over 2
+
+=cut
+
+@ISA = qw(Exporter);
+@EXPORT = qw(
+ &expand_sex_into_predicate
+ );
+
+=item expand_sex_into_predicate
+
+ $data{&expand_sex_into_predicate($data{sex})} = 1;
+
+Converts a single 'M' or 'F' into 'sex_M_p' or 'sex_F_p'
+respectively.
+
+In some languages, 'M' and 'F' are not appropriate. However,
+with HTML::Template, there is no way to localize 'M' or 'F'
+unless these are converted into variables that TMPL_IF can
+understand. This function provides this conversion.
+
+=cut
+
+sub expand_sex_into_predicate ($) {
+ my($sex) = @_;
+ return "sex_${sex}_p";
+} # expand_sex_into_predicate
+
+#---------------------------------
+
+END { } # module clean-up code here (global destructor)
+
+1;
+__END__
+
+=back
+
+=head1 AUTHOR
+
+Koha Developement team <info@koha.org>
+
+=cut
use C4::Auth;
use C4::Context;
use C4::Output;
+use C4::Interface::CGI::Output;
use CGI;
use C4::Search;
use MARC::Record;
item_header_loop => \@header_value_loop,
biblionumber => $biblionumber,
bibid => $bibid);
-print $query->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-),$template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
use CGI;
use C4::Auth;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use C4::Biblio;
use C4::Context;
use HTML::Template;
oldbiblioitemnumtagsubfield => $oldbiblioitemnumtagsubfield,
oldbiblioitemnumber => $oldbiblioitemnumber);
}
-print $input->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-),$template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
use C4::Catalogue;
use C4::Biblio;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use HTML::Template;
my $query = new CGI;
flagsrequired => {catalogue => 1},
debug => 1,
});
-print $query->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-),$template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
use strict;
use C4::Auth;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use C4::Biblio;
use C4::Context;
use HTML::Template;
itemtagsubfield =>$itemtagsubfield,
op => $nextop,
opisadd => ($nextop eq "saveitem")?0:1);
-print $input->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-),$template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
use C4::Biblio;
use C4::Search;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use HTML::Template;
my $input = new CGI;
# Koha modules used
use C4::Context;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use C4::Input;
use C4::Biblio;
use MARC::File::USMARC;
}
-print $input->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-),$template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
my $menu;
my $file;
#---------------
# log cleared, as marcimport is (almost) rewritten from scratch.
# $Log$
+# Revision 1.30 2003/02/02 07:18:38 acli
+# Moved C4/Charset.pm to C4/Interface/CGI/Output.pm
+#
+# Create output_html_with_http_headers function to contain the "print $query
+# ->header(-type => guesstype...),..." call. This is in preparation for
+# non-HTML output (e.g., text/xml) and charset conversion before output in
+# the future.
+#
+# Created C4/Interface/CGI/Template.pm to hold convenience functions specific
+# to the CGI interface using HTML::Template
+#
+# Modified moremembers.pl to make the "sex" field localizable for languages
+# where M and F doesn't make sense
+#
# Revision 1.29 2003/01/28 15:28:31 tipaul
# removing use MARC::Charset
# Was a buggy test
use C4::Biblio;
use HTML::Template;
use C4::Auth;
-use C4::Charset;
+use C4::Interface::CGI::Output;
my $env;
my $input = new CGI;
loopsearch =>\@loopsearch,
loopresult =>\@loopresult);
-print $input->header(
--type => guesstype($template->output),
--cookie => $cookie
-),$template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
use CGI;
use C4::Auth;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use C4::Database;
use HTML::Template;
});
$template->param(loggeninuser => $loggedinuser);
-print $query->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-),$template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
use C4::Auth;
use C4::Context;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use C4::Search;
use HTML::Template;
$template->param(bookfund => \@loop_data);
} #---- END $OP eq DEFAULT
-print $input->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-), $template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
use C4::Auth;
use C4::Context;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use C4::Search;
use HTML::Template;
$template->param(budget => \@loop_data);
} #---- END $OP eq DEFAULT
-print $input->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-), $template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
use C4::Auth;
use C4::Context;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use C4::Search;
use HTML::Template;
use C4::Context;
}
} #---- END $OP eq DEFAULT
-print $input->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-), $template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
use C4::Auth;
use C4::Context;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use HTML::Template;
# Fixed variables
return $message;
}
-print $input->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-), $template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
use strict;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use C4::Auth;
use CGI;
use C4::Search;
}
$template->param(total => $total);
-print $input->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-), $template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
use strict;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use C4::Auth;
use CGI;
use C4::Search;
);
} #---- END $OP eq DEFAULT
-print $input->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-), $template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
use strict;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use C4::Auth;
use CGI;
use C4::Search;
}
} #---- END $OP eq DEFAULT
-print $input->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-), $template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
use C4::Auth;
use C4::Context;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use C4::Search;
use C4::Context;
use HTML::Template;
} #---- END $OP eq DEFAULT
$template->param(loggeninuser => $loggedinuser);
-print $input->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-), $template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
use C4::Auth;
use C4::Context;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use C4::Search;
use HTML::Template;
use C4::Context;
}
} #---- END $OP eq DEFAULT
-print $input->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-), $template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
use strict;
use CGI;
use C4::Auth;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use C4::Context;
use C4::Output;
use C4::Search;
}
} #---- END $OP eq DEFAULT
-print $input->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-), $template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
use strict;
use C4::Auth;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use CGI;
use C4::Search;
use HTML::Template;
total => $total,
accounts => \@accountrows );
-print $input->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-),$template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
use CGI;
use C4::Auth;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use C4::Database;
use HTML::Template;
classlist => $classlist,
type => 'intranet',);
-print $query->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-), $template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
branchoptionloop => \@branchoptionloop,
errmsgloop => \@errmsgloop
);
-print $query->header(-cookie=>$sessioncookie), $template->output;
+output_html_with_http_headers $query, $sessioncookie, $template->output;
sub name {
$template->param(WEB_RESULTS => $webarray);
$template->param(SITE_RESULTS => $sitearray);
$template->param(loggedinuser => $loggedinuser);
-print $query->header(-cookie => $cookie), $template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
titleloop => \@titledata,
cmemloop => \@cmemdata );
-print $input->header(-cookie => $cookie),$template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
±Ú¸Ç¡G<TMPL_VAR NAME="ethnicity">, <TMPL_VAR NAME="ethnotes"><br>
</TMPL_IF>
¥X¥Í¤é´Á¡G<TMPL_VAR NAME="dateofbirth"><BR>
- ©m§O¡G<TMPL_VAR NAME="sex"><P>
+ ©m§O¡G<TMPL_IF NAME="sex_M_p">¨k<TMPL_ELSE><TMPL_IF NAME="sex_F_p">¤k<TMPL_ELSE><TMPL_VAR NAME="sex"></TMPL_IF></TMPL_IF>
+ <P>
Alternative Contact: <TMPL_VAR NAME="contactname"><BR>
Phone: <TMPL_VAR NAME="altphone"><BR>
Relationship: <TMPL_VAR NAME="altrelationship"><BR>
require Exporter;
use C4::Database;
use C4::Output; # contains gettemplate
-use C4::Charset;
+use C4::Interface::CGI::Output;
use CGI;
use C4::Auth;
debug => 1,
});
-print $query->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-), $template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
use strict;
use C4::Auth;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use CGI;
use HTML::Template;
use C4::Search;
use strict;
use C4::Auth;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use CGI;
use C4::Search;
use C4::Accounts2;
use strict;
use C4::Auth;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use CGI;
use C4::Search;
use HTML::Template;
member => $member,
resultsloop => \@resultsdata );
-print $input->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-),$template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
use C4::Auth;
use C4::Context;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use CGI;
use C4::Search;
use C4::Koha;
cardnumber => $cardnumber,
dateofbirth => $data->{'dateofbirth'});
-print $input->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-),$template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
}
use CGI;
use C4::Auth;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use C4::Context;
use HTML::Template;
debug => 1,
});
-print $query->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-),$template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
use C4::Auth;
use C4::Context;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
+use C4::Interface::CGI::Template;
use CGI;
use C4::Search;
use Date::Manip;
$data->{'ethnicity'} = fixEthnicity($data->{'ethnicity'});
+$data->{&expand_sex_into_predicate($data->{'sex'})} = 1;
+
if ($data->{'categorycode'} eq 'C'){
my $data2=borrdata('',$data->{'guarantor'});
$data->{'streetaddress'}=$data2->{'streetaddress'};
issueloop => \@issuedata,
reserveloop => \@reservedata);
-print $input->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-),$template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
use strict;
use C4::Auth;
use C4::Input;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use CGI;
use Date::Manip;
use HTML::Template;
;
}
-print $input->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-), $template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
$template->param( total => $total );
#$template->param(loggeninuser => $loggedinuser);
-print $query->header(-cookie => $cookie), $template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
use CGI;
use C4::Search;
use C4::Auth;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use HTML::Template;
my $query=new CGI;
$template->param(WEB_RESULTS => $webarray);
$template->param(SITE_RESULTS => $sitearray);
-print $query->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-), $template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
use HTML::Template;
use C4::Auth; # get_template_and_user
-use C4::Charset;
+use C4::Interface::CGI::Output;
my $query = new CGI;
flagsrequired => {borrow => 1},
});
-print $query->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-), $template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
flagsrequired => {borrow => 1},
});
-print $query->header(-cookie => $cookie), $template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
$template->param(READING_RECORD => $issues);
-print $query->header(-cookie => $cookie), $template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
$template->param(BIBLIOITEMS => \@data);
-print $query->header(-cookie => $cookie), $template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
require Exporter;
use C4::Auth;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use C4::Context;
use CGI;
use C4::Database;
$template->param(classlist => $classlist);
-print $query->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-), $template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
use CGI;
use C4::Search;
use C4::Auth;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use HTML::Template;
my $query=new CGI;
$template->param(numbers => $numbers);
-print $query->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-), $template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
my $self_url = $query->url(-absolute => 1);
$template->param(url => $self_url);
-print $query->header(-cookie => $cookie), $template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
# $template->param(WAITING => \@waiting);
$template->param(waiting_count => $wcount);
-print $query->header(-cookie => $cookie), $template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
$template->param($borr);
-print $query->header(-cookie => $cookie), $template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
$template->param(BORROWER_INFO => \@bordat);
-print $query->header(-cookie => $cookie), $template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
use strict;
use C4::Auth;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use CGI;
use C4::Search;
use HTML::Template;
bornum => $bornum,
limit => $limit,
loop_reading => \@loop_reading);
-print $input->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-),$template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
use CGI;
use C4::Auth;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use C4::Context;
use HTML::Template;
flagsrequired => {permissions => 1},
debug => 1,
});
-print $query->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-),$template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
use C4::Search;
use C4::Auth;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use C4::Biblio;
use C4::SearchMarc;
$template->param("marclist" => $marclist);
}
# Print the page
-print $query->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-), $template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
use C4::Search;
use C4::Auth;
use C4::Output;
-use C4::Charset;
+use C4::Interface::CGI::Output;
my $query=new CGI;
my $type=$query->param('type');
}
# Print the page
-print $query->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-), $template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
$template->param(shelvesloop => \@shelvesloop);
}
-print $query->header(-cookie => $cookie), $template->output;
+output_html_with_http_headers $query, $cookie, $template->output;
sub shelves {
#
# $Log$
+# Revision 1.10 2003/02/02 07:18:37 acli
+# Moved C4/Charset.pm to C4/Interface/CGI/Output.pm
+#
+# Create output_html_with_http_headers function to contain the "print $query
+# ->header(-type => guesstype...),..." call. This is in preparation for
+# non-HTML output (e.g., text/xml) and charset conversion before output in
+# the future.
+#
+# Created C4/Interface/CGI/Template.pm to hold convenience functions specific
+# to the CGI interface using HTML::Template
+#
+# Modified moremembers.pl to make the "sex" field localizable for languages
+# where M and F doesn't make sense
+#
# Revision 1.9 2002/12/19 18:55:40 hdl
# Templating reservereport et shelves.
#
use strict;
-use C4::Charset;
+use C4::Interface::CGI::Output;
use vars qw( @tests );
use vars qw( $loaded );
@tests = (
[
'Normal HTML without meta tag',
- sub { C4::Charset::guesscharset($_[0]) },
+ sub { guesscharset($_[0]) },
undef,
<<EOF
<title>control case</title>
EOF
], [
'Result of guesscharset with normal HTML with irrelevant meta tag',
- sub { C4::Charset::guesscharset($_[0]) },
+ sub { guesscharset($_[0]) },
undef,
<<EOF
<meta http-equiv="Content-Language" content="zh-TW">
EOF
], [
- 'Result of guesscharset with normal HTML with irrelevant meta tag',
- sub { C4::Charset::guesstype($_[0]) },
- undef,
+ 'Result of guesstype with normal HTML with irrelevant meta tag',
+ sub { guesstype($_[0]) },
+ 'text/html',
<<EOF
<meta http-equiv="Content-Language" content="zh-TW">
EOF
], [
'Result of guesscharset with normal HTML with relevant meta tag',
- sub { C4::Charset::guesscharset($_[0]) },
+ sub { guesscharset($_[0]) },
'big5',
<<EOF
<meta http-equiv="Content-Type" content="text/html; charset=big5">
EOF
], [
'Result of guesstype with normal HTML with relevant meta tag',
- sub { C4::Charset::guesstype($_[0]) },
+ sub { guesstype($_[0]) },
'text/html; charset=big5',
<<EOF
<meta http-equiv="Content-Type" content="text/html; charset=big5">
EOF
], [
'Variant 1 using single quotes',
- sub { C4::Charset::guesstype($_[0]) },
+ sub { guesstype($_[0]) },
'text/html; charset=iso-2022-jp',
<<EOF
<meta http-equiv="Content-Type" content='text/html; charset=iso-2022-jp'>
EOF
], [
'Variant 2 using single quotes',
- sub { C4::Charset::guesstype($_[0]) },
+ sub { guesstype($_[0]) },
'text/html; charset=utf-8',
<<EOF
<meta http-equiv='Content-Type' content="text/html; charset=utf-8">
EOF
], [
'Unquoted Content-Type',
- sub { C4::Charset::guesstype($_[0]) },
+ sub { guesstype($_[0]) },
'text/html; charset=big5',
<<EOF
<meta http-equiv=Content-Type content="text/html; charset=big5">
EOF
], [
'XML syntax',
- sub { C4::Charset::guesstype($_[0]) },
+ sub { guesstype($_[0]) },
'text/html; charset=iso-8859-2',
<<EOF
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-2" />
EOF
], [
'Expected attributes in reverse order',
- sub { C4::Charset::guesstype($_[0]) },
+ sub { guesstype($_[0]) },
'text/html; charset=big5',
<<EOF
<meta content="text/html; charset=big5" http-equiv="Content-Type">
EOF
], [
'Extra whitespace at end',
- sub { C4::Charset::guesstype($_[0]) },
+ sub { guesstype($_[0]) },
'text/html; charset=big5',
<<EOF
<meta http-equiv="Content-Type" content="text/html; charset=big5" >
EOF
], [
'Multiple lines',
- sub { C4::Charset::guesstype($_[0]) },
+ sub { guesstype($_[0]) },
'text/html; charset=big5',
<<EOF
<meta
>
EOF
], [
+ # FIXME - THIS IS NOT A WELL-WRITTEN TEST CASE!!!
'With surrounding HTML',
- sub { C4::Charset::guesstype($_[0]) },
+ sub { guesstype($_[0]) },
'text/html; charset=us-ascii',
<<EOF
<html>
(!defined $output && !defined $expected)
|| (defined $output && defined $expected && $output eq $expected)
) {
- print "ok $i ($title)\n";
+ print "ok $i - $title\n";
} else {
- print "not ok $i ($title: got ",
+ print "not ok $i - $title: got ",
(defined $output? "\"$output\"": 'undef'),
', expected ',
(defined $expected? "\"$expected\"": 'undef'),
- ")\n";
+ "\n";
}
}
category => $category,
index => $index
);
-print $input->header(-cookie => $cookie),$template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
warn "userloggedin : $loggedinuser (".$query->param('userid')." et ".$query->param('password');
-print $query->header(-cookie => $cookie), $template->output;
+output_html_with_http_headers $query, $cookie, $template->output;