Class DocumentElement

Description

Extends base template class adding buffering capability and some utility methods

Located in /core/template/DocumentElement.class.php (line 43)

PHP2Go
   |
   --Component
      |
      --Template
         |
         --DocumentElement
Variable Summary
Method Summary
static DocumentElement &factory (string $src, [int $type = T_BYFILE])
bool assignFromQuery (string $variable, mixed $sqlStmt, [string $connectionId = NULL])
void generateFromDataSet (DataSet $DataSet, string $containerBlock, string $emptyBlock, string $repeaterBlock)
void generateFromQuery (string $blockName, mixed $sqlStmt, [string $connectionId = NULL])
string getContentBuffer ()
void parse ()
void put (string $content, [int $contentType = T_BYVAR])
Variables
Methods
static method factory (line 71)

Factory method. Builds an instance of the class based on 2 arguments: $src and $type

static DocumentElement &factory (string $src, [int $type = T_BYFILE])
  • string $src: Element string content or file path
  • int $type: T_BYVAR or T_BYFILE
Constructor DocumentElement (line 58)

Class constructor

DocumentElement DocumentElement ()
assignFromQuery (line 133)

Populates a template variable based on the first cell of the results of a database query or statement

bool assignFromQuery (string $variable, mixed $sqlStmt, [string $connectionId = NULL])
  • string $variable: Variable name
  • mixed $sqlStmt: Query or statement
  • string $connectionId: DB connection ID
generateFromDataSet (line 210)

Apply the contents of a data set in the template

This method expects 3 names of dynamic blocks. The first is the container block, which will be created if the data set is not empty. The second is the empty block, which will be created for empty data sets. The third and last block will be repeated for all records of the data set.

Example:

  1.  /* in your template */
  2.  <!-- start block container_block -->
  3.  Field1Field2
  4.  <!-- start block repeater_block -->
  5.  {$field1}{$field2}
  6.  <!-- end block repeater_block -->
  7.  <!-- end block container_block -->
  8.  <!-- start block empty_block -->
  9.  put here a message stating that the data set is empty )
  10.  <!-- end block empty_block -->
  11.  
  12.  /* in your PHP file */
  13.  $element new DocumentElement();
  14.  $element->put('mytemplate.tpl'T_BYFILE);
  15.  $dataset =DataSet::factory('db');
  16.  $dataset->load('select field1, field2 from my_table');
  17.  $element->generateFromDataSet($dataset'container_block''empty_block''repeater_block');

void generateFromDataSet (DataSet $DataSet, string $containerBlock, string $emptyBlock, string $repeaterBlock)
  • DataSet $DataSet: Data set
  • string $containerBlock: Container block
  • string $emptyBlock: Empty block
  • string $repeaterBlock: Repeater block
generateFromQuery (line 155)

Generates instances of a dynamic block based on the results of a database query or statement

Each row in the result set will represent a block instance, and its fields will be assigned as local variables of the block.

void generateFromQuery (string $blockName, mixed $sqlStmt, [string $connectionId = NULL])
  • string $blockName: Block name
  • mixed $sqlStmt: Query or statement
  • string $connectionId: DB connection ID
getContentBuffer (line 83)

Get current content buffer

string getContentBuffer ()
parse (line 117)

Overrides parent class implementation to run the parser with the contents of the buffer

void parse ()

Redefinition of:
Template::parse()
Triggers the compilation of the template
put (line 97)

Adds content or a file in the element's buffer

You can fill the element's buffer until parse() is called. After the template is parsed, no content can be added anymore.

void put (string $content, [int $contentType = T_BYVAR])
  • string $content: Content or file path
  • int $contentType: Content type (T_BYVAR or T_BYFILE)

Inherited Methods

Inherited From Template

Template::Template()
Template::addModifier()
Template::assign()
Template::assignByRef()
Template::createAndAssign()
Template::createBlock()
Template::display()
Template::getContent()
Template::getCurrentBlockName()
Template::getDefinedBlocks()
Template::getDefinedVariables()
Template::getValue()
Template::globalAssign()
Template::includeAssign()
Template::isBlockDefined()
Template::isPrepared()
Template::isVariableDefined()
Template::onPreRender()
Template::parse()
Template::resetTemplate()
Template::setCacheProperties()
Template::setCurrentBlock()
Template::setTagDelimiter()
Template::_assign()
Template::_getFullPath()
Template::_getLastInstance()
Template::_getLoopItem()
Template::_getLoopTotal()
Template::_globalAssign()
Template::_initializeContent()
Template::_loadConfigVars()
Template::_loadGlobalSettings()
Template::_popStack()
Template::_pushStack()

Inherited From Component

Component::Component()
Component::display()
Component::getAttribute()
Component::getContent()
Component::hasAttribute()
Component::onPreRender()
Component::setAttribute()
Component::__destruct()
Component::__toString()

Inherited From PHP2Go

PHP2Go::PHP2Go()
PHP2Go::equals()
PHP2Go::generateUniqueId()
PHP2Go::getClassName()
PHP2Go::getConfigVal()
PHP2Go::getLangVal()
PHP2Go::getObjectName()
PHP2Go::getParentName()
PHP2Go::hasDestructor()
PHP2Go::hashCode()
PHP2Go::isA()
PHP2Go::isSubclassOf()
PHP2Go::logError()
PHP2Go::raiseError()
PHP2Go::registerDestructor()
PHP2Go::registerShutdownFunc()
PHP2Go::retrieve()
PHP2Go::store()
PHP2Go::__toString()

Documentation generated on Sun, 07 Oct 2007 19:23:26 -0300 by phpDocumentor 1.3.2