Skip to content

Commit

Permalink
functions that were in C4::Interface::CGI::Output are now in C4::Output.
Browse files Browse the repository at this point in the history
So this implies quite a change for files.
Sorry about conflicts which will be caused.
directory Interface::CGI should now be dropped.
I noticed that many scripts (reports ones, but also some circ/stats.pl or opac-topissues) still use Date::Manip.
  • Loading branch information
hdl committed Apr 24, 2007
1 parent 4dea4d2 commit 100e6a9
Show file tree
Hide file tree
Showing 199 changed files with 213 additions and 302 deletions.
1 change: 0 additions & 1 deletion C4/Auth.pm
Expand Up @@ -26,7 +26,6 @@ use Digest::MD5 qw(md5_base64);
require Exporter;
use C4::Context;
use C4::Output; # to get the template
use C4::Interface::CGI::Output;
use C4::Members;
use C4::Koha;
use C4::Branch; # GetBranches
Expand Down
64 changes: 63 additions & 1 deletion C4/Output.pm
Expand Up @@ -48,10 +48,18 @@ C4::Output - Functions for managing templates
=cut

@ISA = qw(Exporter);
@EXPORT = qw(
push @EXPORT, qw(
&themelanguage &gettemplate setlanguagecookie pagination_bar
);

#Output
push @EXPORT, qw(
&guesscharset
&guesstype
&output_html_with_http_headers
);


#FIXME: this is a quick fix to stop rc1 installing broken
#Still trying to figure out the correct fix.
my $path = C4::Context->config('intrahtdocs') . "/default/en/includes/";
Expand Down Expand Up @@ -307,6 +315,60 @@ sub pagination_bar {
return $pagination_bar;
}


=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;
Expand Down
1 change: 0 additions & 1 deletion about.pl
Expand Up @@ -20,7 +20,6 @@
require Exporter;

use C4::Output; # contains gettemplate
use C4::Interface::CGI::Output;
use C4::Auth;
use C4::Context;
use CGI;
Expand Down
1 change: 0 additions & 1 deletion acqui/acqui-home.pl
Expand Up @@ -44,7 +44,6 @@ =head1 CGI PARAMETERS
use CGI;
use C4::Auth;
use C4::Output;
use C4::Interface::CGI::Output;

use C4::Suggestions;

Expand Down
2 changes: 0 additions & 2 deletions acqui/addorder.pl
Expand Up @@ -115,12 +115,10 @@ =head1 CGI PARAMETERS
use strict;
use CGI;
use C4::Auth;
use C4::Output;
use C4::Acquisition;
use C4::Suggestions;
use C4::Biblio;
use C4::Output;
use C4::Interface::CGI::Output;



Expand Down
1 change: 0 additions & 1 deletion acqui/basket.pl
Expand Up @@ -27,7 +27,6 @@
use C4::Koha;
use C4::Output;
use CGI;
use C4::Interface::CGI::Output;


use C4::Acquisition;
Expand Down
2 changes: 1 addition & 1 deletion acqui/bookfund.pl
Expand Up @@ -21,7 +21,7 @@
use strict;
use CGI;
use C4::Auth;
use C4::Interface::CGI::Output;
use C4::Output;

my $dbh = C4::Context->dbh;
my $input = new CGI;
Expand Down
1 change: 0 additions & 1 deletion acqui/booksellers.pl
Expand Up @@ -58,7 +58,6 @@ =head1 CGI PARAMETERS
use C4::Biblio;
use C4::Output;
use CGI;
use C4::Interface::CGI::Output;


use C4::Acquisition;
Expand Down
2 changes: 1 addition & 1 deletion acqui/histsearch.pl
Expand Up @@ -52,7 +52,7 @@ =head1 CGI PARAMETERS
require Exporter;
use CGI;
use C4::Auth; # get_template_and_user
use C4::Interface::CGI::Output;
use C4::Output;
use C4::Acquisition;

my $input = new CGI;
Expand Down
1 change: 0 additions & 1 deletion acqui/lateorders.pl
Expand Up @@ -49,7 +49,6 @@ =head1 CGI PARAMETERS
use C4::Auth;
use C4::Koha;
use C4::Output;
use C4::Interface::CGI::Output;
use C4::Context;
use C4::Acquisition;
use C4::Letters;
Expand Down
3 changes: 1 addition & 2 deletions acqui/neworderbiblio.pl
Expand Up @@ -57,12 +57,11 @@ =head1 CGI PARAMETERS
use strict;
use C4::Search;
use CGI;
use C4::Output;
use C4::Bookseller;
use C4::Biblio;

use C4::Auth;
use C4::Interface::CGI::Output;
use C4::Output;
use C4::Koha;

my $input = new CGI;
Expand Down
1 change: 0 additions & 1 deletion acqui/neworderempty.pl
Expand Up @@ -76,7 +76,6 @@ =head1 CGI PARAMETERS
use C4::Output;
use C4::Input;
use C4::Koha;
use C4::Interface::CGI::Output;
use C4::Branch; # GetBranches
use C4::Members;

Expand Down
2 changes: 1 addition & 1 deletion acqui/newordersuggestion.pl
Expand Up @@ -91,7 +91,7 @@ =head1 CGI PARAMETERS
require Exporter;
use CGI;
use C4::Auth; # get_template_and_user
use C4::Interface::CGI::Output;
use C4::Output;
use C4::Suggestions;
use C4::Biblio;

Expand Down
2 changes: 1 addition & 1 deletion acqui/orderreceive.pl
Expand Up @@ -63,7 +63,7 @@ =head1 CGI PARAMETERS
use C4::Koha; # GetKohaAuthorisedValues GetItemTypes
use C4::Acquisition;
use C4::Auth;
use C4::Interface::CGI::Output;
use C4::Output;
use C4::Date;
use C4::Bookseller;
use C4::Members;
Expand Down
3 changes: 1 addition & 2 deletions acqui/parcel.pl
Expand Up @@ -59,9 +59,8 @@ =head1 CGI PARAMETERS
use C4::Acquisition;
use C4::Bookseller;
use C4::Biblio;
use C4::Output;
use CGI;
use C4::Interface::CGI::Output;
use C4::Output;
use C4::Date;

use strict;
Expand Down
1 change: 0 additions & 1 deletion acqui/parcels.pl
Expand Up @@ -65,7 +65,6 @@ =head1 CGI PARAMETERS
use CGI;
use C4::Auth;
use C4::Output;
use C4::Interface::CGI::Output;

use C4::Date;

Expand Down
2 changes: 1 addition & 1 deletion acqui/spent.pl
Expand Up @@ -6,7 +6,7 @@

use C4::Context;
use C4::Auth;
use C4::Interface::CGI::Output;
use C4::Output;
use strict;
use CGI;

Expand Down
1 change: 0 additions & 1 deletion acqui/supplier.pl
Expand Up @@ -47,7 +47,6 @@ =head1 CGI PARAMETERS
use C4::Biblio;
use C4::Output;
use CGI;
use C4::Interface::CGI::Output;


use C4::Bookseller;
Expand Down
1 change: 0 additions & 1 deletion admin/admin-home.pl
Expand Up @@ -19,7 +19,6 @@
use CGI;
use C4::Auth;
use C4::Output;
use C4::Interface::CGI::Output;



Expand Down
1 change: 0 additions & 1 deletion admin/aqbookfund.pl
Expand Up @@ -59,7 +59,6 @@ =head1 CGI PARAMETERS
use C4::Context;
use C4::Bookfund;
use C4::Output;
use C4::Interface::CGI::Output;
use C4::Date;

my $dbh = C4::Context->dbh;
Expand Down
1 change: 0 additions & 1 deletion admin/aqbudget.pl
Expand Up @@ -47,7 +47,6 @@
use C4::Acquisition;
use C4::Context;
use C4::Output;
use C4::Interface::CGI::Output;
use C4::Koha;

my $input = new CGI;
Expand Down
1 change: 0 additions & 1 deletion admin/auth_subfields_structure.pl
Expand Up @@ -20,7 +20,6 @@

use strict;
use C4::Output;
use C4::Interface::CGI::Output;
use C4::Auth;
use CGI;
use C4::Context;
Expand Down
1 change: 0 additions & 1 deletion admin/auth_tag_structure.pl
Expand Up @@ -24,7 +24,6 @@
use C4::Koha;
use C4::Context;
use C4::Output;
use C4::Interface::CGI::Output;
use C4::Context;


Expand Down
1 change: 0 additions & 1 deletion admin/authorised_values.pl
Expand Up @@ -22,7 +22,6 @@
use C4::Auth;
use C4::Context;
use C4::Output;
use C4::Interface::CGI::Output;

use C4::Context;

Expand Down
3 changes: 1 addition & 2 deletions admin/authtypes.pl
Expand Up @@ -24,9 +24,8 @@
use strict;
use CGI;
use C4::Context;
use C4::Output;
use C4::Auth;
use C4::Interface::CGI::Output;
use C4::Output;


sub StringSearch {
Expand Down
3 changes: 1 addition & 2 deletions admin/biblio_framework.pl
Expand Up @@ -24,9 +24,8 @@
use strict;
use CGI;
use C4::Context;
use C4::Output;
use C4::Auth;
use C4::Interface::CGI::Output;
use C4::Output;


sub StringSearch {
Expand Down
1 change: 0 additions & 1 deletion admin/branches.pl
Expand Up @@ -48,7 +48,6 @@ =head1 branches.pl
use C4::Auth;
use C4::Context;
use C4::Output;
use C4::Interface::CGI::Output;
use C4::Koha;
use C4::Branch;

Expand Down
4 changes: 1 addition & 3 deletions admin/categorie.pl
Expand Up @@ -39,10 +39,8 @@
use strict;
use CGI;
use C4::Context;
use C4::Output;

use C4::Auth;
use C4::Interface::CGI::Output;
use C4::Output;

sub StringSearch {
my ($searchstring,$type)=@_;
Expand Down
4 changes: 1 addition & 3 deletions admin/categoryitem.pl
Expand Up @@ -40,10 +40,8 @@
use strict;
use CGI;
use C4::Context;
use C4::Output;

use C4::Auth;
use C4::Interface::CGI::Output;
use C4::Output;

sub StringSearch {
my ($searchstring,$type)=@_;
Expand Down
1 change: 0 additions & 1 deletion admin/checkmarc.pl
Expand Up @@ -20,7 +20,6 @@

use strict;
use C4::Output;
use C4::Interface::CGI::Output;
use C4::Auth;
use CGI;
use C4::Context;
Expand Down
4 changes: 1 addition & 3 deletions admin/cities.pl
Expand Up @@ -20,10 +20,8 @@
use strict;
use CGI;
use C4::Context;
use C4::Output;

use C4::Auth;
use C4::Interface::CGI::Output;
use C4::Output;

sub StringSearch {
my ($searchstring,$type)=@_;
Expand Down
4 changes: 1 addition & 3 deletions admin/currency.pl
Expand Up @@ -40,10 +40,8 @@
use strict;
use CGI;
use C4::Context;
use C4::Output;

use C4::Auth;
use C4::Interface::CGI::Output;
use C4::Output;

sub StringSearch {
my ($searchstring,$type)=@_;
Expand Down
4 changes: 1 addition & 3 deletions admin/finesrules.pl
Expand Up @@ -20,12 +20,10 @@
use strict;
use CGI;
use C4::Context;
use C4::Output;

use C4::Auth;
use C4::Output;

use C4::Koha;
use C4::Interface::CGI::Output;
use C4::Branch; # GetBranches

my $input = new CGI;
Expand Down
3 changes: 0 additions & 3 deletions admin/issuingrules.pl
Expand Up @@ -21,11 +21,8 @@
use CGI;
use C4::Context;
use C4::Output;

use C4::Auth;
use C4::Output;
use C4::Koha;
use C4::Interface::CGI::Output;
use C4::Branch; # GetBranches

my $input = new CGI;
Expand Down

0 comments on commit 100e6a9

Please sign in to comment.