Class miTemplateParser

Description

Parses templates

Usage:

  1. create a template parser object
  2. add template parser section infos (optional step)
  3. use readTemplate() ot setContents()
  4. assign template variables
  5. parse the template

  • copyright: Copyright (c) 2003-2006 Mirchev Ideas Ltd. All rights reserved.

Located in /util/TemplateParser.php (line 143)


	
			
Class Constant Summary
Variable Summary
Method Summary
void assign (string $name, string $value)
void assignArray (array $pairs)
void assignList (array $keys, array $values)
mixed &get (string $name)
miTemplateParserSectionInfo|false getSectionInfo (string $sectionInfoName)
void parseSections ()
void parseSingleSection (int $lastTagEnd, int $startPos,  &$sections, array $sections)
void readTemplate (String $filename)
void setContents (string $contents)
void setSectionInfos (array $sectionInfos)
string templateParse ()
string templateParseSubsection (array $templateSections, array $sectionInfos, [int $subsectionIndex = 0])
void templateShow ()
Variables
mixed $_sectionInfos = array() (line 160)

Array with sections

  • access: protected
mixed $_templateFileContents = '' (line 183)

The contents of the template file

  • access: protected
mixed $_templateSections = array() (line 167)

Array with sections

  • access: protected
mixed $_templateVars = array() (line 175)

Associative array of template variables They will be used after all sections have been parsed

  • access: protected
Methods
addSectionInfo (line 452)

Add new section info.

If a previous section info with the same name exists it will be overwritten.

  • access: public
void addSectionInfo (miTemplateParserSectionInfo $sectionInfo)
assign (line 477)

Assigns a variable to be replaced

  • access: public
void assign (string $name, string $value)
  • string $name: variable name, usually %%VAR_NAME%%
  • string $value: the contents of the variable. usually escaped with htmlenities()
assignArray (line 488)

Assigns a array of variables to be replaced

  • access: public
void assignArray (array $pairs)
  • array $pairs: variable name is the key, the contents is the value
assignList (line 501)

Assigns a list of variables. Both array should have equal sizes, as counted by count() The first variable in the list is assigned the first value, the second variable, the seoncd value, and so on

  • access: public
void assignList (array $keys, array $values)
  • array $keys: the keys with the variable names
  • array $values: the values
get (line 517)

Retrieves an assigned variable value

  • return: the value of the variable
  • access: public
mixed &get (string $name)
  • string $name: the name of the variable
getSectionInfo (line 463)

Returns the section info with the requested name

  • return: the section info object, or false if not found
  • access: public
miTemplateParserSectionInfo|false getSectionInfo (string $sectionInfoName)
  • string $sectionInfoName
parseSections (line 335)

Parse the template file sections

  • access: protected
void parseSections ()
parseSingleSection (line 349)

Parse a template section recursive method

  • access: protected
void parseSingleSection (int $lastTagEnd, int $startPos,  &$sections, array $sections)
  • int $lastTagEnd
  • int $startPos
  • array $sections
  • &$sections
readTemplate (line 192)

Reads the template file

  • access: public
void readTemplate (String $filename)
  • String $filename
setContents (line 210)

Sets the contents of the template from string Alternative to reading it from file

  • access: public
void setContents (string $contents)
  • string $contents
setSectionInfos (line 438)

Set the section infos. Clears all previous section infos

  • access: public
void setSectionInfos (array $sectionInfos)
  • array $sectionInfos
templateParse (line 223)

Parses the template and returns the result

  • return: the parsed contents
  • access: public
string templateParse ()
templateParseSubsection (line 247)

Parses a subsection

  • return: the parsed string
  • access: protected
string templateParseSubsection (array $templateSections, array $sectionInfos, [int $subsectionIndex = 0])
  • array $templateSections
  • array $sectionInfos
  • int $subsectionIndex: (optional)
templateShow (line 234)

Shows the parsed template

  • access: public
void templateShow ()
Class Constants
TEMPLATE_PARSER_END_TAG = '</mi:section>' (line 148)
TEMPLATE_PARSER_END_TAG_LEN = '13' (line 149)
TEMPLATE_PARSER_PREPROCESS_AT_ITERATIONS = 5 (line 152)
TEMPLATE_PARSER_SECTION_TAG = 'mi:section' (line 150)
TEMPLATE_PARSER_START_TAG = '<mi:section name="' (line 144)
TEMPLATE_PARSER_START_TAG2 = '">' (line 146)
TEMPLATE_PARSER_START_TAG2_LEN = '2' (line 147)
TEMPLATE_PARSER_START_TAG_LEN = '18' (line 145)

Documentation generated on Thu, 08 May 2008 16:57:49 +0300 by phpDocumentor 1.4.1