Class Template
Template
- public class Template
Template
The template itself contains all the zones, blocks and elements needed to compose
a HTML template of the interface to display. When the display method is called,
all the various items are parsed and composed to create the final HTML result.
Some thought has been made that we should either merge Template and Theme, or
possibly extract the various element types into their own classes.
Field Summary |
private unknown |
$b_order
This array is a index of blocks by ID within each zone. |
private unknown |
$blockAppend
A flag which indicates if the Dynamic block add should append the current
parsed data or create a new entry for the block ID. |
private unknown |
$blockID
For dynamic blocks, we wish to only add a copy of the block which is
calling itself into the zone. |
private unknown |
$blocks
An array of the block content for the Template. |
private unknown |
$content
The raw content of the template. |
private unknown |
$data
The physical dynamic data used placed into the <[data]> tags of the web page. |
private unknown |
$debug
A debugging flag. |
private unknown |
$elements
An array of all elements used in the Template. |
private unknown |
$id
The theme passes its own ID as the ID for the template. |
private unknown |
$name
The internal name of the theme as generated during template initialzation. |
private unknown |
$parsed_text
The fully parsed text of the template. |
private unknown |
$zoneID
This holding variable allows the dynamically added block to know what zone it
apply itself to. |
private unknown |
$zones
An array of the zones in the Template as indexed by their name and ID. |
Constructor Summary |
Template(var $id)
Template Constructor
Using the ID from the theme, the template will construct a new object. |
Method Summary |
unknown |
addParsedBlock()
Add Parsed Block
This method can be used by an interface method on its own theme object to
add an additional entry for the same block within a zone. |
unknown |
assign(var $name,
var $value)
Assign Template Data
Assigns data to the template using either single items or arrays. |
unknown |
buildForm(var $formName)
Build Dynamic Form
Dynamic form generation is handled by reading parameters from the dynamic form
and form element tables to compose data into the form as needed. |
unknown |
buildTable(var $formName)
Build Dynamic Table
When a <[table]> tag is inserted in an element or block, this method is called
to parse the table into the content. |
unknown |
getBlocks(var $zones)
Get Blocks
Loads the blocks based on a list of zones provided by the getZones method. |
unknown |
getElements()
Get Elements
We load the elements before any other portions of the template are loaded. |
unknown |
getparse()
Get Parsed Text
Pulls the parsed text of the template and returns it as a string. |
unknown |
getTemplate()
Get Template
Pulls the name and content from the database theme table and returns
an array containing the theme name and raw content information. |
unknown |
getZones()
Get Zones
Loads the zones for the theme based on how the zones are defined in the
database. |
unknown |
initTemplate()
Initialize Template
Initialization of the template first removes any data from the current zone, block
and element arrays. |
VOID |
parse()
Parse Template Content
The template parsing procedure starts with the element parsing and then moves
outward through the blocks, zones and finally core template to render the fully
parsed HTML. |
unknown |
parseBlocks(var $block)
Parse Blocks
Unlike elements, blocks are not parsed recursively. |
unknown |
parseElements(var $element,
var $reparse)
Parse Elements
Element parsing is done one element at a time. |
unknown |
parseZones(var $zone)
Parse Zones
Zones differ in how they are parsed from the blocks and elements. |
$elements
private unknown $elements
- An array of all elements used in the Template. Elements are indexed by their
element name and ID. Elements are generally small code snippets which are placed
into the blocks at their tag locations. Blocks should not contain code, but
have the ability to be parsed as code. Block code evaluation may be deprecated
in future releases.
$blocks
private unknown $blocks
- An array of the block content for the Template. Blocks are indexed by ID only,
though the b_order array allows the blocks to be sorted inside each zone. Blocks
should generally only contain static information with element tags for dynamic
or coded content. Block is generally a layout structure, with minimal content. This
allows the element to become the key structure for ensuring language specific and
dynamic code content. This is not universal yet, but should be implemented before
final production release.
$b_order
private unknown $b_order
- This array is a index of blocks by ID within each zone. The block array contains
the proper order of the blocks as they should be displayed within the zone as
extracted from the order in the database. This ensures proper block placement
in the interfaces.
$zones
private unknown $zones
- An array of the zones in the Template as indexed by their name and ID. Zones are
strictly a layout mechanism that allows blocks of data (as defined by the block
definition) to be placed in specific areas of the interface view.
$data
private unknown $data
- The physical dynamic data used placed into the <[data]> tags of the web page.
Data can be a single variable element or a single dimensioned array.
$id
private unknown $id
- The theme passes its own ID as the ID for the template. This is used to load
the data from the various element tables.
$zoneID
private unknown $zoneID
- This holding variable allows the dynamically added block to know what zone it
apply itself to. Without this ID, the dynamic block addition will not work.
$blockID
private unknown $blockID
- For dynamic blocks, we wish to only add a copy of the block which is
calling itself into the zone. Otherwise, all the blocks for that zone might
be added.
$blockAppend
private unknown $blockAppend
- A flag which indicates if the Dynamic block add should append the current
parsed data or create a new entry for the block ID.
$name
private unknown $name
- The internal name of the theme as generated during template initialzation.
$content
private unknown $content
- The raw content of the template. This is a massive string used to compose the
unparsed content of the template.
$parsed_text
private unknown $parsed_text
- The fully parsed text of the template.
$debug
private unknown $debug
- A debugging flag. This variable should be deprecated.
Template
public Template(var $id)
- Template Constructor
Using the ID from the theme, the template will construct a new object. This is
done by adding the global configuration to the object data array and then loading
the template through the initialization method.
- Parameters:
integer
- $id The ID number of the theme.- See Also:
initTemplate
initTemplate
public unknown initTemplate()
- Initialize Template
Initialization of the template first removes any data from the current zone, block
and element arrays. The template core content is then loaded and the Elements and
Zones are loaded. Elements are loaded first to ensure that any recursion issues are
met before the blocks might be dynamically loaded.
- Returns:
- VOID
- See Also:
getTemplate
public unknown getTemplate()
- Get Template
Pulls the name and content from the database theme table and returns
an array containing the theme name and raw content information. This raw
content should only contain basic HTML elements and the zone layout using
<[zone]> tags.
- Returns:
- Array The database result set of the theme information.
getZones
public unknown getZones()
- Get Zones
Loads the zones for the theme based on how the zones are defined in the
database. This operation is independent of the zone definition in the theme
content. After the zones are loaded, all blocks are then loaded into the blocks
array. In previous versions, multiple database calls were made for each zone.
Now all blocks are loaded in a single call.
- Returns:
- VOID
- See Also:
getBlocks
getBlocks
public unknown getBlocks(var $zones)
- Get Blocks
Loads the blocks based on a list of zones provided by the getZones method. This
method loads blocks on two levels. It first will load all the blocks needed to
build the interface using its operation. It will then load any user specific
blocks which were configured in the user's preferences.
Note that there are several "default" block types which need to be consolidated.
global block types should be universal in type of interface and operation. This
universal type should also be added to the block editors.
- Parameters:
Array
- $zones Contains all information needed to build the zone list for loading the blocks.- Returns:
- VOID
- See Also:
getZones
getElements
public unknown getElements()
- Get Elements
We load the elements before any other portions of the template are loaded.
This step is important, as it allows us to ensure that no other elements are
required (recursively) and that the elements can be added to a dynamic block
which is parsed on the fly rather than at display time.
- Returns:
- VOID
parse
public VOID parse()
- Parse Template Content
The template parsing procedure starts with the element parsing and then moves
outward through the blocks, zones and finally core template to render the fully
parsed HTML. Each content type has its own template specific tag which is used
to indicate the location and content to be placed in the theme.
Once the basic elements of the template are parsed individually, the parse engine
makes secondary passes over the entire contents to ensure that any items which
may be nested are caught in the parsing. The engine also makes checks for circular
nested items to ensure that infinate parsing loops do not occur.
Two special parsing tags for forms and tables of data are also parsed in the method.
This allows the dynamic creation of form data to be more easily handled instead of
creating custom form elements for each operation used in the interfaces.
- See Also:
parseElements
public unknown parseElements(var $element,
var $reparse)
- Parse Elements
Element parsing is done one element at a time. This ensures that if other element
dependencies are found during parsing, they are recursively parsed as needed. Recursion
is flagged on each element, so that if a successive parse call on the element is
made, an error is raised and the recursion is stopped. This prevents a element from
calling on itself or a circular parsing relationship from occuring. During
the parsing, if a element is flagged as code, it is evaluated and the return output
is then parsed for data items.
- Parameters:
ArrayRef
- $element A reference array of the element item to be parsed. Elements are parsed individually from the parse engine.boolean
- $reparse If set false, the method will not parse the element if its parsed text has already been set.$reparse
- Default Value: true- Returns:
- String Contains the parsed text of the element.** @param $element is passed by reference
parseBlocks
public unknown parseBlocks(var $block)
- Parse Blocks
Unlike elements, blocks are not parsed recursively. However, blocks may be
dynamically added to the template repetitively from within the interface zone
specific methods. We do currently allow blocks to be evaluated as code if the
block is flagged properly.
- Parameters:
ArrayRef
- $block Contains the block definition to parse.- Returns:
- String The parsed block content of the block.** @param $block is passed by reference
parseZones
public unknown parseZones(var $zone)
- Parse Zones
Zones differ in how they are parsed from the blocks and elements. A zone
contains two content definitions. The content area defines the overall layout
of the zone within the page and is a container for one or more blocks which
will be placed inside the zone. However, it also contains a common block
content definition which defines how each block will be formated within that
zone. Some zones contain a very specific layout which strictly conforms the
blocks to a specific look and feel, while other zones may provide only a basic
container, forcing the block itself to better define its content.
- Parameters:
ArrayRef
- $zone The zone definition containing the content and block definition.- Returns:
- String The parsed zone content.** @param $zone is passed by reference
addParsedBlock
public unknown addParsedBlock()
- Add Parsed Block
This method can be used by an interface method on its own theme object to
add an additional entry for the same block within a zone. This is useful for
adding a list of similar blocks, using different content for each block (see
the article list on the main index page for an example).
It should be noted that the block is actually parsed as it is added. As such,
the block must be appended to the list of current blocks and then all elements
for the block must be parsed and added.
- Returns:
- VOID
- See Also:
buildTable
public unknown buildTable(var $formName)
- Build Dynamic Table
When a <[table]> tag is inserted in an element or block, this method is called
to parse the table into the content. Tables are built from the dynamic form system
using all dynamic form elements which are defined for the plugin, interface, and
operation defined in the current interface instance. The table will pull all its
dynamic data from the interface internal data array. Field types of hidden and
password are not displayed. Select fields lookup their proper ID's to ensure that
the proper item names are displayed instead of cryptic ID's.
IN future releases, the HTML elements which create the table should be placed in
a secondary template in the database rather than be in the template class itself.
- Parameters:
String
- $formName- Returns:
- String The parsed content which will composed the table.
buildForm
public unknown buildForm(var $formName)
- Build Dynamic Form
Dynamic form generation is handled by reading parameters from the dynamic form
and form element tables to compose data into the form as needed. The data is
pre-entered into the form when the proper data is loaded into the interface data
array. This class handles the generation and population of all basic HTML form elements.
IN future releases, the HTML elements which create the table should be placed in
a secondary template in the database rather than be in the template class itself.
- Parameters:
String
- $formName- Returns:
- String The parsed content which will composed the table.
getparse
public unknown getparse()
- Get Parsed Text
Pulls the parsed text of the template and returns it as a string.
- Returns:
- String The parsed content of the entire template.
assign
public unknown assign(var $name,
var $value)
- Assign Template Data
Assigns data to the template using either single items or arrays. The
method does not properly handle an array of multi-dimensional data.
- Parameters:
String
- $name The name of <[data]> element to assign the data to.Multi
- $value Either a single or arrayed set of data to assign to the template.- Returns:
- VOID