Big Sister Web Application Framework
List of all members
BigSWAF::DispEngine Class Reference

Implements the template mechanism. More...

Public Class Methods

 new (BigSWAF::AppHandler application)
 Create one DispEngine.

Public Object Methods

 init (BigSWAF::AppHandler application)
BigSWAF::AppHandler application (BigSWAF::AppHandler application)
 Get/set the application this display engine is related to.
hashref globalvars (scalar name, scalar value)
 Set the value of a "global" variable.
retval setglobal (scalar name, scalar value)
 Similiar to globalvars().
retval clone ()
 Returns an identical copy of the DispEngine object.
retval language (scalar language)
 Get/set the language to be used when filling in language specific text into a template.
retval replace_vars_file (scalar skin, scalar vars, scalar template, scalar file, scalar replacer)
 Run replace_vars() and write the results to a file.
retval replace_vars (scalar skin, scalar vars, scalar template)
 Fill in a template and return the result as a text string.
retval get_var (scalar name, scalar skin, scalar vars, scalar localvars)
retval get_skin (scalar skin, scalar what)
retval find_skin (scalar name)
retval bypass_skincache (scalar bypass)
hashref read_skin (scalar name, hashref skinbase)
 Given the name of a skin, slurps the files out of the corresponding skin directory into an in-memory object (hash) and returns this object.
hashref skin (scalar skinnames)
 If called without an argument skin() returns the skin of a former skin() invocation.
retval cache_skin (scalar name, scalar skin)
retval encode (scalar text)
retval encode_args (scalar args)
retval encode_formargs (scalar args)
retval encode_tagtext (scalar arg)
retval encode_text (scalar text)
retval softbreak (scalar text, scalar maxchunksize)
 Insert "soft break" positions in a string.
retval persistent (scalar attrs, scalar value)
retval formargs (scalar args)

Public Functions

retval logmsg (scalar prio, scalar msg)

Protected Object Methods

protected retval _replace_vars (scalar skin, scalar vars, scalar template, scalar depth, scalar localvars)
protected retval _one_var (scalar skin, scalar vars, scalar var, scalar depth, scalar localvars, scalar template)
protected retval _loop (scalar skin, scalar vars, scalar localvars, scalar template)

Detailed Description

Implements the template mechanism.

This class uses the skins in the skin directory as templates the applications can manipulate with various methods.

Member Function Documentation

protected retval BigSWAF::DispEngine::_loop ( scalar  skin,
scalar  vars,
scalar  localvars,
scalar  template 
)
protected retval BigSWAF::DispEngine::_one_var ( scalar  skin,
scalar  vars,
scalar  var,
scalar  depth,
scalar  localvars,
scalar  template 
)
protected retval BigSWAF::DispEngine::_replace_vars ( scalar  skin,
scalar  vars,
scalar  template,
scalar  depth,
scalar  localvars 
)
BigSWAF::AppHandler BigSWAF::DispEngine::application ( BigSWAF::AppHandler  application)

Get/set the application this display engine is related to.

retval BigSWAF::DispEngine::bypass_skincache ( scalar  bypass)
retval BigSWAF::DispEngine::cache_skin ( scalar  name,
scalar  skin 
)
retval BigSWAF::DispEngine::clone ( )

Returns an identical copy of the DispEngine object.

retval BigSWAF::DispEngine::encode ( scalar  text)
retval BigSWAF::DispEngine::encode_args ( scalar  args)
retval BigSWAF::DispEngine::encode_formargs ( scalar  args)
retval BigSWAF::DispEngine::encode_tagtext ( scalar  arg)
retval BigSWAF::DispEngine::encode_text ( scalar  text)
retval BigSWAF::DispEngine::find_skin ( scalar  name)
retval BigSWAF::DispEngine::formargs ( scalar  args)
retval BigSWAF::DispEngine::get_skin ( scalar  skin,
scalar  what 
)
retval BigSWAF::DispEngine::get_var ( scalar  name,
scalar  skin,
scalar  vars,
scalar  localvars 
)
hashref BigSWAF::DispEngine::globalvars ( scalar  name,
scalar  value 
)

Set the value of a "global" variable.

The global variables are remembered during multiple replace_vars() calls and are complementing the variables directly passed to the replace methods.

Returns
a reference to a hash containing current global vars
BigSWAF::DispEngine::init ( BigSWAF::AppHandler  application)
retval BigSWAF::DispEngine::language ( scalar  language)

Get/set the language to be used when filling in language specific text into a template.

The language specific texts are extracted from the respective .lang file within the skin, therefore the language set should correspond to one of the .lang files of the application.

retval BigSWAF::DispEngine::logmsg ( scalar  prio,
scalar  msg 
)
BigSWAF::DispEngine::new ( BigSWAF::AppHandler  application)

Create one DispEngine.

The default display engine for an application is automatically set up by BigSWAF::Application and is available via its BigSWAF::Application::display() method.

retval BigSWAF::DispEngine::persistent ( scalar  attrs,
scalar  value 
)
hashref BigSWAF::DispEngine::read_skin ( scalar  name,
hashref  skinbase 
)

Given the name of a skin, slurps the files out of the corresponding skin directory into an in-memory object (hash) and returns this object.

Since skin reading is an I/O-intense operation the results are cached.

If in the optional skinbase argument a former result of read_skin() is passed, then the new skin is added to this skin.

Parameters
namename of the skin to read
skinbase(optional) former result of a read_skin() run
Returns
a hashref
retval BigSWAF::DispEngine::replace_vars ( scalar  skin,
scalar  vars,
scalar  template 
)

Fill in a template and return the result as a text string.

The skin argument is expected to be a hash ref as returned by skin(name) - if undefined replace_vars() uses the default skin (as returned by the skin() method). The vars argument is a reference to a hash containing variable names (keys) and values that should be filled into the template. The template argument must either be a template itself (e.g. skin()->{"sometemplate.proto"}) or a string containing the name of a template. In the latter case the name must be preceded by an equal sign (e.g. "=sometemplate.proto").

The vars hash is complemented by the global vars as accessible via globalvars() and setglobalvar().

Parameters
skin(optional) The skin to be used
varsa hash containing variable/value pairs to be filled into the template
templatea template to be expanded or alternatively the name of a template prefixed with an equal sign
retval BigSWAF::DispEngine::replace_vars_file ( scalar  skin,
scalar  vars,
scalar  template,
scalar  file,
scalar  replacer 
)

Run replace_vars() and write the results to a file.

retval BigSWAF::DispEngine::setglobal ( scalar  name,
scalar  value 
)

Similiar to globalvars().

Does not return the global variable hash.

hashref BigSWAF::DispEngine::skin ( scalar  skinnames)

If called without an argument skin() returns the skin of a former skin() invocation.

Otherwise the skinnames argument is expected to be a comma-separated list of skin names. This list is preceded by some default skins that are always read-in like "common", "default" and followed by "interface_(interface)" (where the (interface) name depends on the method BigSWAF was called - usually it is "html").

This means that the resulting skinset bases on the common and default skinsets, any additional skin names passed via skinnames complement or override settings of these skins and finally the respective interface_* skin overrides/complements the result.

retval BigSWAF::DispEngine::softbreak ( scalar  text,
scalar  maxchunksize 
)

Insert "soft break" positions in a string.


The documentation for this class was generated from the following file: