use Modern::Perl;
-use URI::Escape;
+use HTML::Entities;
use Scalar::Util qw( looks_like_number );
+use URI::Escape;
-use C4::Auth qw(get_template_and_user);
+use C4::Auth qw( get_template_and_user );
use C4::Context;
use C4::Templates;
-use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+our (@ISA, @EXPORT_OK);
BEGIN {
require Exporter;
- @ISA = qw(Exporter);
- @EXPORT_OK = qw(&is_ajax ajax_fail); # More stuff should go here instead
- %EXPORT_TAGS = ( all =>[qw(setlanguagecookie pagination_bar parametrized_url
- &output_with_http_headers &output_ajax_with_http_headers &output_html_with_http_headers)],
- ajax =>[qw(&output_with_http_headers &output_ajax_with_http_headers is_ajax)],
- html =>[qw(&output_with_http_headers &output_html_with_http_headers)]
- );
- push @EXPORT, qw(
+ @ISA = qw(Exporter);
+ @EXPORT_OK = qw(
+ is_ajax
+ ajax_fail
setlanguagecookie getlanguagecookie pagination_bar parametrized_url
+ output_html_with_http_headers output_ajax_with_http_headers output_with_http_headers
+ output_and_exit_if_error output_and_exit output_error
);
- push @EXPORT, qw(
- &output_html_with_http_headers &output_ajax_with_http_headers &output_with_http_headers
- &output_and_exit_if_error &output_and_exit &output_error
- );
-
}
=head1 NAME
my $startfrom_name = (@_) ? shift : 'page';
my $additional_parameters = shift || {};
+ $base_url = HTML::Entities::encode($base_url);
+
$current_page = looks_like_number($current_page) ? $current_page : undef;
$nb_pages = looks_like_number($nb_pages) ? $nb_pages : undef;
$base_url =~ s/$delim*\b$startfrom_name=(\d+)//g; # remove previous pagination var
unless (defined $current_page and $current_page > 0 and $current_page <= $nb_pages) {
$current_page = ($1) ? $1 : 1; # pull current page from param in URL, else default to 1
- # $debug and # FIXME: use C4::Debug;
- # warn "with QUERY_STRING:" .$ENV{QUERY_STRING}. "\ncurrent_page:$current_page\n1:$1 2:$2 3:$3";
}
$base_url =~ s/($delim)+/$1/g; # compress duplicate delims
$base_url =~ s/$delim;//g; # remove empties
$base_url =~ s/$delim$//; # remove trailing delim
my $url = $base_url . (($base_url =~ m/$delim/ or $base_url =~ m/\?/) ? '&' : '?' ) . $startfrom_name . '=';
- my $url_suffix;
+ my $url_suffix = '';
while ( my ( $k, $v ) = each %$additional_parameters ) {
$url_suffix .= '&' . URI::Escape::uri_escape_utf8($k) . '=' . URI::Escape::uri_escape_utf8($v);
}
If applicable, $cookie can be undef, and it will not be sent.
-$content_type is one of the following: 'html', 'js', 'json', 'xml', 'rss', or 'atom'.
+$content_type is one of the following: 'html', 'js', 'json', 'opensearchdescription', 'xml', 'rss', or 'atom'.
$status is an HTTP status message, like '403 Authentication Required'. It defaults to '200 OK'.
# NOTE: not using application/atom+xml or application/rss+xml because of
# Internet Explorer 6; see bug 2078.
'rss' => 'text/xml',
- 'atom' => 'text/xml'
+ 'atom' => 'text/xml',
+ 'opensearchdescription' => 'application/opensearchdescription+xml',
);
die "Unknown content type '$content_type'" if ( !defined( $content_type_map{$content_type} ) );