CIPP
view release on metacpan or search on metacpan
lib/CIPP/Runtime/Request.pm view on Meta::CPAN
$formatted .= "o" x int($time / $profile->{scale_unit});
return $formatted;
}
sub eval_perl_code {
# do the eval in this mini subroutine, so NO lexicals
# are in the scope of it.
# checking of $@ has to be done by the caller
eval ${$_[0]};
}
sub print_http_header {
my $self = shift;
my %par = @_;
my ($custom_http_header_file) = @par{'custom_http_header_file'};
# evtl. execute custom http header subroutine
$self->call_include_subroutine (
file => $custom_http_header_file,
input => {},
output => {},
) if $custom_http_header_file;
# print HTTP Header
my ($k, $v);
my $content_type;
while ( ($k, $v) = each %{$self->get_http_header} ) {
# $k =~ s/\b([a-z])/uc($1)/eg;
print "$k: $v\n";
$content_type = $v if $k =~ /^content-type$/i;
}
print "\n";
$self->set_http_header_printed (1);
if ( $content_type =~ m!text/html! && !$self->get_xhtml ) {
my $runtime = $self->get_project_handle->get_cipp_runtime_version;
my $compiler = $self->get_project_handle->get_cipp_compiler_version;
print "<!-- CIPP $compiler / $CIPP::Runtime::Request::VERSION | $runtime - Copyright (c) dimedis GmbH, All Rights Reserved -->\n\n";
}
1;
}
sub load_module {
my $self = shift;
my %par = @_;
my ($name) = @par{'name'};
$name =~ s!::!/!og;
$name .= ".pm";
require $name;
1;
}
sub set_locale_messages_lang {
my $self = shift;
my ($lang) = @_;
POSIX::setlocale(POSIX::LC_MESSAGES(), $lang);
POSIX::setlocale(POSIX::LC_TIME(), $lang);
1;
}
sub gettext {
my $self = shift;
my ($message, $data_href) = @_;
return $message if not $data_href;
my $re = join '|', map { quotemeta $_ } keys %{$data_href};
$message =~
s/\{($re)\}/defined $data_href->{$1} ?
$data_href->{$1} : "{$1}"/ge;
return $message;
}
sub dgettext {
my $self = shift;
my ($domain, $message, $data_href) = @_;
my $trans = Locale::Messages::dgettext($domain, $message);
return $trans if not $data_href;
my $re = join '|', map { quotemeta $_ } keys %{$data_href};
$trans =~
s/\{($re)\}/defined $data_href->{$1} ?
$data_href->{$1} : "{$1}"/ge;
return $trans;
}
1;
__END__
=head1 NAME
CIPP::Request - CIPP runtime environment interface
=head1 SYNOPSIS
use CIPP::Request;
# The request object is always accessed through this class method
# (Object creation is done magically by the runtime
# environment: new.spirit, Apache or whatever...)
$request = CIPP->request;
# Get the current CGI object for this request
$cgi_object = CIPP->request->get_cgi_object;
# Several static configuation information is accessable
# through this object
$cgi_url = CIPP->request->get_cgi_url;
$doc_url = CIPP->request->get_doc_url;
$prod_dir = CIPP->request->get_prod_dir;
$config_dir = CIPP->request->get_config_dir;
( run in 1.875 second using v1.01-cache-2.11-cpan-ceb78f64989 )