Apache-iNcom
view release on metacpan or search on metacpan
lib/Apache/iNcom/Request.pm view on Meta::CPAN
};
}
=pod
=head1 APACHE::INCOM PAGE FUNCTIONS
Here is list of the helper functions that are defined in the context
of the executing page and that can be used.
=head2 Localize ( ... )
This acts as a wrapper around $Locale->maketext. It should be used
to format messages in a localized format for the user.
=cut
sub Localize {
return $Locale->maketext( @_ );
}
=pod
=head2 Currency ( ... )
This acts as a wrapper around $Locale->currency. It should be used to
format amount of money for display.
=cut
sub Currency {
return $Locale->currency( @_ );
}
=pod
=head2 Include ( $file_or_param_ref )
This is a function which is like HTML::Embperl::Execute in that it
includes another page in the current one. The difference is that this
included page will be executed in the name space of the current so
that all global variables remains accessible. Also, this functions checks
for the presence of a localized version of the file and checks in the
C<INCOM_TEMPLATE_PATH> if the path is not absolute.
=cut
sub Include {
my ($file,$params) ;
my $r = $Request->{req_rec};
# Check if we are called with a file or hash param
if ( ref $_[0] ) {
# We hope the caller knows what he was doing when
# he setup the parameter hash.
$params = shift;
$file = $params->{inputfile};
} else {
$file = shift;
# Create default params
# Since Include file can contain fragment,
my $debug = $r->dir_config( "EMBPERL_DEBUG" ) ||
$ENV{EMBPERL_DEBUG} || 0;
# Default = optRawInput + optDisableTableScan
# disable Table scan by default
my $options = $r->dir_config( "EMBPERL_OPTIONS" ) ||
$ENV{EMBPERL_OPTIONS} || 16 | 2048;
# optDisableFormData
$options |= 256 ;
$params = {
param => \@_,
options => $options,
debug => $debug,
};
}
# Search for template in TEMPLATE_PATH
my $path = $r->pnotes( "INCOM_TEMPLATE_PATH" );
unless ( $path ) {
# Memoize template path
$path = [];
foreach my $p ( split /:/, $r->dir_config( "INCOM_TEMPLATE_PATH" ) ) {
push @$path, $r->server_root_relative( $p );
}
$r->pnotes( "INCOM_TEMPLATE_PATH", $path );
}
unless ( substr( $file, 0, 1) eq "/" || -e $file ) {
foreach my $p ( @$path ) {
if ( -e $p . "/" . $file ) {
$file = $p . "/" . $file;
last;
}
}
}
# Localize the template
my $localizer = $r->pnotes( "INCOM_LOCALIZER" );
$file = $localizer->find_localized_file( $file );
# Set the localized and normalized file
$params->{inputfile} = $file;
# Set the package in which to execute the template
$params->{package} = $package;
HTML::Embperl::Execute( $params );
}
=pod
=head2 TextInclude ( file )
This is a function is like C<Include> except that it is not interpreted
for embedded perl.
=cut
sub TextInclude {
my $file = shift;
( run in 3.054 seconds using v1.01-cache-2.11-cpan-b16cb0d3907 )