WACT_TEMPLATE
[ class tree: WACT_TEMPLATE ] [ index: WACT_TEMPLATE ] [ all elements ]

Class: CompilerComponent

Source Location: /framework/template/compiler/compilercomponent.inc.php

http://wact.sourceforge.net/index.php/CompilerComponent

SourceFileParser

Class Overview


Base class for compile time components.

Variables

Methods


Child classes:

CompilerDirectiveTag
Compiler directive tags do not have a corresponding runtime server Component, but they do render their contents into the compiled template.
OutputExpression
Outputs the resultof an expression
ServerComponentTag
Server component tags have a corresponding server Component which represents an API which can be used to manipulate the marked up portion of the template.
SilentCompilerDirectiveTag
Silent compiler directive tags are instructions for the compiler and do not have a corresponding runtime Component, nor do they normally generate output into the compiled template.

Inherited Variables

Inherited Methods


Class Details

Base class for compile time components.

Compile time component methods are called by the template parser SourceFileParser.
Note this in the comments for this class, parent and child refer to the XML heirarchy in the template, as opposed to the PHP class tree.

abstract:  
access:  public
see:  http://wact.sourceforge.net/index.php/CompilerComponent
see:  SourceFileParser

Class Variables


$attributeNodes = array()

XML attributes of the tag
access:  private
Type:   array

$children = array()

Child compile-time components
var:  of compile time component objects
access:  private
Type:   array

$emptyClosedTag = FALSE

Whether the was empty and closed such as
access:  private
Type:   boolean

$hasClosingTag = TRUE

Defines whether the tag is allowed to have a closing tag
access:  private
Type:   boolean

$parent = NULL

Parent compile-time component
var:  of CompilerComponent
access:  private
Type:   subclass

$plainTagCount = 0

Counter for plain text tags matching the current tag component name. Used to prevent premature closing.

See bug 906138

access:  private
Type:   int

$properties = array()

A list of properties for this component
access:  private
Type:   array

$ServerId =

Stores the identifying component ID
var:  value of id attribute
access:  private
Type:   string

$SourceFile =

Used to identify the source template file, when generating compile time error messages.
var:  source template filename
access:  private
Type:   string

$StartingLineNo =

Used to indentify the line number where a compile time error occurred.
var:  line number
access:  private
Type:   int

$tag =

Name of the XML tag as it appears in the template.

This would include the namespace prefix, if applicable.

var:  tag name
access:  private
Type:   string

$TagInfo =

TagInfo metadata for this component
Type:   TagInfo

$WrappingComponents = array()

Instance of a CoreWrapTag
access:  private
see:  CoreWrapTag
Type:   CoreWrapTag

Class Methods


method addChild

Adds a child component, by reference, to the array of children

void addChild( object &$child)

API Tags:

access:  protected

Overridden in child classes as:

CoreGraftTag::addChild()
Adds a child component, by reference, to the array of children of the placeholder node (overrides parent class method)

Parameters:

object   &$child   instance of a compile time component

method addChildAttribute

Sets the XML attributes for this component (as extracted from the template)

void addChildAttribute( object &$child)

API Tags:

access:  protected

Parameters:

object   &$child   XML attributes

method CheckNestingLevel

Used to perform some error checking on the source template, such as examining the tag hierarchy and triggering an error if a tag is incorrectly nested.

Concrete implementation is in subclasses




method findChild

Returns a child component, given it's ServerID

mixed &findChild( string $ServerId)

API Tags:

return:  if child is found, returns a reference of false
access:  protected

Parameters:

string   $ServerId   server id

method findChildByClass

Returns a child component, given it's compile time component class

mixed &findChildByClass( string $class)

API Tags:

return:  if child is found, returns a reference of false
access:  protected

Parameters:

string   $class   PHP class name

method findChildrenByClass

Returns an array of child components, given it's compile time component class

array findChildrenByClass( string $class)

API Tags:

access:  protected

Parameters:

string   $class   PHP class name

method findImmediateChildByClass

Returns a child component, given it's compile time component class

mixed &findImmediateChildByClass( string $class)

API Tags:

return:  if child is found, returns a reference of false
access:  protected

Parameters:

string   $class   PHP class name

method findParentByClass

Returns a parent component, recursively searching parents by their compile time component class name

mixed &findParentByClass( string $class)

API Tags:

return:  if parent is found, returns a reference of void
access:  protected

Parameters:

string   $class   PHP class name

method findSelfOrParentByClass

Extends findParentByClass to begin search at the current component then moving on to its parent, if there's no match.

This is called from TagJudge to determine known children.



mixed &findSelfOrParentByClass( string $class)

API Tags:

return:  if parent is found, returns a reference of void
access:  protected

Parameters:

string   $class   class name

method generate

Calls the local preGenerate(), generateContents() and postGenerate() methods.

void generate( CodeWriter &$code)

API Tags:

access:  protected

Overridden in child classes as:

PHPNode::generate()
Writes the contents of the PHP node to the compiled template using the writePHP method
TextNode::generate()
Writes the contents of the text node to the compiled template using the writeHTML method
CoreWrapTag::generate()
By the time this is called we have already called generate on all of our children, so does nothing
OutputExpression::generate()
SilentCompilerDirectiveTag::generate()
Does nothing - SilentCompilerDirectiveTags do not generate during construction of the compiled template

Parameters:

CodeWriter   &$code  

method generateAttributeList



void generateAttributeList( mixed &$code, [mixed $suppress = array()])

method generateConstructor

Calls the generateConstructor() method of each child component


method generateContents

Calls the generate() method of each child component

void generateContents( CodeWriter &$code)

API Tags:

access:  protected

Overridden in child classes as:

CoreCommentTag::generateContents()
DevDataSpaceTag::generateContents()
EncodeJavascriptTag::generateContents()
ListItemTag::generateContents()
PageListTag::generateContents()
DataTableTag::generateContents()
InputAutoCompleteTag::generateContents()
SelectTag::generateContents()
Ignore the compiler time contents and generate the contents at run time.
SelectYearTag::generateContents()
SelectMonthTag::generateContents()
SelectDayTag::generateContents()
SelectHourTag::generateContents()
SelectMinuteTag::generateContents()
SelectSecondTag::generateContents()
TextAreaTag::generateContents()
Ignore the compiler time contents and generate the contents at run time.
CalendarMonthTag::generateContents()
CalendarDayHeaderStyleTag::generateContents()
SelectDateTag::generateContents()
SelectTimeTag::generateContents()
CoreCssTag::generateContents()
CoreScriptTag::generateContents()
DataDumpTag::generateContents()
HtmlBaseTag::generateContents()
HtmlAnchorTag::generateContents()
HtmlTableTag::generateContents()
HtmlTableCaptionTag::generateContents()
HtmlTableCellTag::generateContents()
CalendarTitleStyleTag::generateContents()
CalendarDayStyleTag::generateContents()
CalendarSelectedDayStyleTag::generateContents()
CalendarEmptyDayStyleTag::generateContents()
CalendarNextPrevStyleTag::generateContents()
HtmlTableRowTag::generateContents()
HtmlBBCodeTag::generateContents()
PageNumberTag::generateContents()

Parameters:

CodeWriter   &$code  

method generateDynamicAttributeList



void generateDynamicAttributeList( mixed &$code, [mixed $suppress = array()])

method getAttribute

Returns the value of an XML attribute (as extracted from template) or NULL if attribute not found

mixed getAttribute( string $attrib)

API Tags:

return:  string attribute value or null
access:  public

Parameters:

string   $attrib   attribute name

method getAttributesAsArray

Returns an array containing the attributes of this component that can be resolved at compile time.

array getAttributesAsArray( [mixed $suppress = array()])

API Tags:

return:  representation of attributes
access:  protected

method getBoolAttribute

Return the value of a boolean attribute as a boolean.

ATTRIBUTE=ANYTHING (true) ATTRIBUTE=(FALSE|N|NA|NO|NONE|0) (false) ATTRIBUTE (true) (attribute unspecified) (default)



boolean getBoolAttribute( string $attrib, [boolean $default = FALSE])

API Tags:

access:  public

Parameters:

string   $attrib   attribute name
boolean   $default   value to return if attribute is not found

method getClientId

Get the value of the XML id attribute

string getClientId( )

API Tags:

return:  value of id attribute
access:  protected

method getComponentRefCode

Gets the component reference code of the parent.

This is a PHP string which is used in the compiled template to reference the component in the hierarchy at runtime



string getComponentRefCode( )

API Tags:

access:  protected

Overridden in child classes as:

ComponentTree::getComponentRefCode()
Returns the base for building the PHP runtime component reference string
ServerComponentTag::getComponentRefCode()
Returns a string of PHP code identifying the component in the hierarchy.


method getDataSource

If a parent compile time component exists, returns the value of the parent's getDataSource() method, which will be a concrete implementation

mixed &getDataSource( )

API Tags:

return:  object compile time component if parent exists or void
access:  protected

Overridden in child classes as:

ComponentTree::getDataSource()
Returns this instance of ComponentTree
ServerDataComponentTag::getDataSource()
FormTag::getDataSource()


method getDataSourceRefCode

Gets the DataSource reference code of the parent

string getDataSourceRefCode( )

API Tags:

access:  protected

Overridden in child classes as:

ComponentTree::getDataSourceRefCode()
ServerDataComponentTag::getDataSourceRefCode()
FormTag::getDataSourceRefCode()


method getLastChild

Returns the last child added to a component

mixed &getLastChild( )

API Tags:

return:  last child instance or false if no children
access:  protected

method getParentDataSource

Gets the parent in the DataSource, if one exists

mixed &getParentDataSource( )

API Tags:

return:  object compile time data component if exists or void
access:  protected

method getProperty



CompilerProperty &getProperty( mixed $name)

API Tags:

return:  returns the named property or NULL if it doesn't exist
access:  public

method getRootDataSource

Gets a root DataSource

mixed &getRootDataSource( )

API Tags:

return:  object compile time data component if exists or void
access:  protected

method getServerId

Returns the identifying server ID.

It's value it determined in the following order;

  1. The XML id attribute in the template if it exists
  2. The value of $this->ServerId
  3. An ID generated by the getNewServerId() function



string getServerId( )

API Tags:

return:  value identifying this component
access:  protected
see:  getNewServerId()

Overridden in child classes as:

ControlTag::getServerId()
Returns the identifying server ID.
FormTag::getServerId()
Returns the identifying server ID.


method hasAttribute

Check to see whether a named attribute exists

boolean hasAttribute( string $attrib)

API Tags:

access:  public

Parameters:

string   $attrib   name of attribute

method isDataSource



Boolean isDataSource( )

API Tags:

return:  Indicating whether or not this component is a DataSource

Overridden in child classes as:

ComponentTree::isDataSource()
ServerDataComponentTag::isDataSource()
FormTag::isDataSource()


method postGenerate

Post generation method, calls the WrappingComponents generateWrapperPostfix() method if the component exists


method preGenerate

Pre generation method, calls the WrappingComponents generateWrapperPrefix() method if the component exists

void preGenerate( CodeWriter &$code)

API Tags:

access:  protected
see:  CoreWrapTag

Overridden in child classes as:

ComponentTree::preGenerate()
Calls the parent preGenerate() method then writes the prepare method to the compiled template.
CoreDefaultTag::preGenerate()
CoreOptionalTag::preGenerate()
CoreOutputTag::preGenerate()
DevSourceTag::preGenerate()
DevTreeTag::preGenerate()
EncodeJavascriptTag::preGenerate()
HtmlLinkTag::preGenerate()
PageFirstTag::preGenerate()
PageLastTag::preGenerate()
PageListTag::preGenerate()
PageNextTag::preGenerate()
PagePrevTag::preGenerate()
ServerDataComponentTag::preGenerate()
Calls the parent preGenerate() method then writes "$DataSpace->prepare();" to the compiled template.
DataTableTag::preGenerate()
ErrorSummaryTag::preGenerate()
ListListTag::preGenerate()
ServerTagComponentTag::preGenerate()
Calls the parent preGenerate() method then writes the XML tag name plus a PHP string which renders the attributes from the runtime component.
InputAutoCompleteTag::preGenerate()
SelectYearTag::preGenerate()
SelectMonthTag::preGenerate()
SelectDayTag::preGenerate()
SelectHourTag::preGenerate()
SelectMinuteTag::preGenerate()
SelectSecondTag::preGenerate()
FormTag::preGenerate()
CacheOutputCacheTag::preGenerate()
CoreBlockTag::preGenerate()
CalendarMonthTag::preGenerate()
DataDumpTag::preGenerate()
DataGroupTag::preGenerate()
DataColumnTag::preGenerate()
HtmlBaseTag::preGenerate()
HtmlAnchorTag::preGenerate()
HtmlTableTag::preGenerate()
HtmlTableCaptionTag::preGenerate()
HtmlTableCellTag::preGenerate()
HtmlTableHeaderTag::preGenerate()
HtmlTableRowTag::preGenerate()
HtmlBBCodeTag::preGenerate()
PageNavigatorTag::preGenerate()
DataCellTag::preGenerate()

Parameters:

CodeWriter   &$code  

method prepare

Calls the prepare method for each child component, which will override

this method it it's concrete implementation. In the subclasses, prepare will set up compile time variables. For example the CoreWrapTag uses the prepare method to assign itself as the wrapping component.



void prepare( )

API Tags:

access:  protected
see:  CoreWrapTag

Overridden in child classes as:

CoreDefaultTag::prepare()
CoreOptionalTag::prepare()
CoreOutputTag::prepare()
CoreWrapTag::prepare()
OutputExpression::prepare()
ControlTag::prepare()
InputTag::prepare()
Sets the runtimeComponentName property, depending on the type of Input tag
SelectTag::prepare()


method preParse

Provides instruction to the template parser, while parsing is in

progress, telling it how it should handle the tag. Subclasses of CompilerComponent will return different instructions.
Available instructions are;

  • PARSER_REQUIRE_PARSING - default in this class. Tag must be parsed
  • PARSER_FORBID_PARSING - Tag may not be parsed
  • PARSER_ALLOW_PARSING - Tag may can be parsed
In practice, the parser currently only pays attention to the PARSER_FORBID_PARSING instruction.
Also used to perform error checking on template related to the syntax of the concrete tag implementing this method.




method registerProperty

register a property with this component. Currently, this component must be a database to support properties.

This may change.



void registerProperty( mixed $name, mixed &$property)

API Tags:

access:  public

method registerWrapper

Set a wrapping component for this component

void registerWrapper( object &$wrapper)

API Tags:

access:  protected

Parameters:

object   &$wrapper  

method removeAttribute

Remove an attribute from the list

void removeAttribute( string $attrib)

API Tags:

access:  public

Parameters:

string   $attrib   name of attribute

method removeChild

Removes a child component, given it's ServerID

mixed &removeChild( string $ServerId)

API Tags:

return:  if child is found, returns a reference to it or void
access:  protected

Parameters:

string   $ServerId   server id

method setAttribute

Sets an attribute

void setAttribute( string $attrib, string $value)

API Tags:

access:  public

Parameters:

string   $attrib   name of attribute
string   $value   value of attribute
WACT: Copyright 2003 Procata, Inc. Released under the LGPL license (http://www.gnu.org/copyleft/lesser.html)
Documentation generated on Sun, 28 Nov 2004 19:44:40 -0800 by phpDocumentor 1.2.3