ePages 6.10 - DE_EPAGES/TLE/API/Processor.pm

Package DE_EPAGES::TLE::API::Processor

This class module includes a basic tle processor. This processor can replace simple scalar tle values and provides the possibility to add handler for different opportunities, see new or registerHandler to add more functionalities on a processor.
Hint: The DE_EPAGES::TLE::API::BaseProcessor is a tle processor with the most used functions (LOOP,JOIN,...).

Functions

callFormatHandler
existsTLE
formatTLE
getContext
getTLE
new
registerHandler
replaceTLEs
setContext
tle

callFormatHandler

Calls the apropriate format handler for the given format string and returns the formatted value.

Syntax
$Value = $TLEProcessor->callFormatHandler( $Value, $FormatString, $Name, $aFormatParameter );
Input
$Value (string)
tle value (unformatted)
$FormatString (string)
format name, e.g. 'datetime'
$Name (string)
name for debugging
$aFormatParameter (ref.array)
list of additional parameters
Return
$Value (string)
tle value (formatted)

existsTLE

Returns true if the TLE variable exists.

Syntax
$Exists = $TLEProcessor->existsTLE( $Name );
Input
$Name (string)
the name of the TLE variable
Return
$Exists (boolean)
1/0, flag to indicate the existence

formatTLE

The value will be formatted according to the format parameters.

Syntax
$Value = $TLEProcessor->formatTLE( $Name, $Format, $Value );
Input
$Name (string)
the name of the TLE variable
$Format (string)
format information (comma separated formatstrings)
$Value (string)
tle value (unformatted)
Return
$Value (string)
tle value (formatted)

getContext

Return copy of context. The entries of context can be set via functions new or setContext.

Syntax
$hContext = $TLEProcessor->getContext();
Input
$hContext (ref.hash)
context data

getTLE

Returns the value of a TLE variable. This procedure takes care about the current context. The value will NOT be formatted according to the format parameters. If the value read by form error then the formatting will be replaced by the default formatting. This function needs a previous run of existsTLE to find the value at stack. $rFormat will be set with default formatter in case the value is set via form error.

Syntax
$Value = $TLEProcessor->getTLE( $Name, $rFormat );
Input
$Name (string)
the name of the TLE variable
$rFormat (ref.string)
format information (comma separated formatstrings)
Return
$Value (printable scalar)
the value, if it can be retrieved. undef in the
other case.

new

This method is used to create a new tle processor. The initial context defined by $hContext can be overwritten by setContext.

Syntax
$TLEProcessor = new DE_EPAGES::TLE::API::Processor($hContext);
Input
$hContext (hash reference)
special context for this processor
  • Encoding - not used yet (but possible for xml/html encoding)
  • AccessParentVars - are variables from outer loops accessable from inside - bool
  • * - current process information (templateclass, templatename, filenames, ...) - *
Return
$TLEProcessor (blessed reference)
the tle processor

registerHandler

Register handler to add more functionality to the tle processor, you can add four different types:

Syntax
$ReturnValue = $TLEProcessor->registerHandler( $HandlerType, $Handler, $Name);
Example
my $PriceHandler = new ProductPriceHandler;
$TLEProcessor->registerHandler('VariableHandler', $PriceHandler, 'MyPrice');
$TLEProcessor->registerHandler('FormatHandler', DE_EPAGES::TLE::API::SpaceFormatter->new);
my $LoopHandler = new DE_EPAGES::TLE::API::LoopHandler;
$TLEProcessor->registerHandler('FunctionHandler', $LoopHandler, 'JOIN');
$TLEProcessor->registerHandler('FunctionHandler', $LoopHandler, 'LOOP');
Input
$HandlerType (string)
name of handler
$Handler (ref.*)
the handler object
$Name (string)
name of tle or function

replaceTLEs

Replaces placeholder in template with dynamic variables. The rVars can be used from template. The existing variables will be saved on stack. Note: the block function which is registered with registerHandler also gets the byte code as parameter, see DE_EPAGES::TLE::API::LoopHandler::LOOP.

Syntax
$Content = $TLEProcessor->replaceTLEs( $aByteCode, $hVars);
Example
sub WITH {
    my $self = shift;
    my ($Processor, $raParams, $cTemplate) = @_;
    my $Parameter = $raParams->[0];
    return join('', @{$Processor->replaceTLEs($cTemplate, $Parameter)});
}
Input
$aByteCode (ref.code)
name of object
$rVars (ref.*)
dynamic data
Return
$Content (string)
replaced content

setContext

Adds data to the processor to save process information. If a value of this hash isn't defined then the entry will be deleted.

Syntax
$TLEProcessor->setContext( $hContext );
Example
$TLEProcessor->setContext( { 'FileName'=>$FileName });
Input
$hContext (ref.hash)
new context data

tle

Returns the value of a TLE variable. This procedure takes care about the current context. The value will be formatted according to the format parameters.

Syntax
$Value = $TLEProcessor->tle( $Name, $Format );
Input
$Name (string)
the name of the TLE variable
$Format (string)
format information (comma separated formatstrings)
Return
$Value (printable scalar)
the value, if it can be retrieved. undef in the
other case.