Docs For Class StringParser_Node

## StringParser_Node

Description

Generic string parser node class

This is an abstract class for any type of node that is used within the string parser. General warning: This class contains code regarding references that is very tricky. Please do not touch this code unless you exactly know what you are doing. Incorrect handling of references may cause PHP to crash with a segmentation fault! You have been warned.

Located in /stringparser.class.php (line 838)

Direct descendents

Class | Description
--- | ---
StringParser_Node_Root | String parser root node class
StringParser_Node_Text | String parser text node class
StringParser_BBCode_Node_Paragraph | BBCode String parser paragraph node class
StringParser_BBCode_Node_Element | BBCode String parser element node class

Variable Summary
int $occurredAt
array $_children
int $_id
mixed $_parent
int $_type
Method Summary
static bool destroyNode ( &$node, object $node)
StringParser_Node StringParser_Node ([int $occurredAt = -1])
bool appendChild ( &$node, object $node)
bool appendToLastTextChild (string $text)
string dump ([string $prefix = " "], [string $linesep = "\n"], [int $level = 0])
bool equals ( &$node, mixed $node)
mixed &firstChild ()
int getNodeCountByCriterium (string $criterium, mixed $value)
array &getNodesByCriterium (string $criterium, mixed $value)
bool insertChildAfter ( &$node, &$reference, object $node, object $reference)
bool insertChildBefore ( &$node, &$reference, object $node, object $reference)
mixed &lastChild ()
bool matchesCriterium (string $criterium, mixed $value)
bool prependChild ( &$node, object $node)
bool removeChild ( &$child, [bool $destroy = false], mixed $child)
int type ()
bool _destroy ()
string _dumpToString ()
mixed _findChild ( &$child, mixed $child)
Variables
int $occurredAt = -1 (line 900)

Occured at

This defines the position in the parsed text where this node occurred at. If -1, this value was not possible to be determined.

- access: public

array $_children = array () (line 889)

The children of this node.

It contains an array of references to all the children nodes of this node.

- see: StringParser_Node::_parent
- access: protected

int $_id = -1 (line 866)

The node ID

This ID uniquely identifies this node. This is needed when searching for a specific node in the children array. Please note that this is only an internal variable and should never be used - not even in subclasses and especially not in external data structures. This ID has nothing to do with any type of ID in HTML oder XML.

- see: StringParser_Node::_children
- access: protected

mixed $_parent = null (line 877)

The parent of this node.

It is either null (root node) or a reference to the parent object.

- see: StringParser_Node::_children
- access: protected

int $_type = STRINGPARSER_NODE_UNKNOWN (line 851)

The type of this node.

There are three standard node types: root node, text node and unknown node. All node types are integer constants. Any node type of a subclass must be at least 32 to allow future developements.

- see: STRINGPARSER_NODE_UNKNOWN
- see: STRINGPARSER_NODE_ROOT, STRINGPARSER_NODE_TEXT
- access: protected

Redefined in descendants as:

- StringParser_Node_Root::$_type : The type of this node.
- StringParser_Node_Text::$_type : The type of this node.
- StringParser_BBCode_Node_Paragraph::$_type : The type of this node.
- StringParser_BBCode_Node_Element::$_type : The type of this node.

Methods
static destroyNode (line 1251)

Destroy a node

- return: True on success, else false.
- access: public

bool destroyNode ( &$node, object $node)

- object $node: The node to destroy
- &$node

Constructor StringParser_Node (line 913)

Constructor

Currently, the constructor only allocates a new ID for the node and assigns it.

- global: __STRINGPARSER_NODE_ID 0:
- access: public

StringParser_Node StringParser_Node ([int $occurredAt = -1])

- int $occurredAt: The position in the text where this node occurred at. If not determinable, it is -1.

appendChild (line 1001)

Append a node to the children

This function appends a node to the children array(). It automatically sets the StrinParser_Node::_parent property of the node that is to be appended.

- return: On success, the function returns true, else false.
- access: public

bool appendChild ( &$node, object $node)

- object $node: The node that is to be appended.
- &$node

appendToLastTextChild (line 979)

Append text to last text child

- return: On success, the function returns true, else false
- access: public

bool appendToLastTextChild (string $text)

- string $text: The text to append

dump (line 1408)

Dump nodes

This dumps a tree of nodes

- access: public

string dump ([string $prefix = " "], [string $linesep = "\n"], [int $level = 0])

- string $prefix: The prefix that is to be used for indentation
- string $linesep: The line separator
- int $level: The initial level of indentation

equals (line 1329)

Checks equality of this node and another node

- return: True if the other node equals to this node, else false.
- access: public

bool equals ( &$node, mixed $node)

- mixed $node: The node to be compared with
- &$node

firstChild (line 1220)

Get the first child of this node

- access: public

mixed &firstChild ()
getNodeCountByCriterium (line 1385)

Search for nodes with a certain criterium and return the count

Similar to getNodesByCriterium

- return: The number of subnodes that match this criterium
- access: public

int getNodeCountByCriterium (string $criterium, mixed $value)

- string $criterium: The criterium that is to be checked
- mixed $value: The value that is to be compared

getNodesByCriterium (line 1355)

Search for nodes with a certain criterium

This may be used to implement getElementsByTagName etc.

- return: All subnodes that match this criterium
- access: public

array &getNodesByCriterium (string $criterium, mixed $value)

- string $criterium: The criterium that is to be checked
- mixed $value: The value that is to be compared

insertChildAfter (line 1089)

Insert a node after another node

- return: On success, the function returns true, else false.
- access: public

bool insertChildAfter ( &$node, &$reference, object $node, object $reference)

- object $node: The node to be inserted.
- object $reference: The reference node where the new node is to be inserted after.
- &$node
- &$reference

insertChildBefore (line 1037)

Insert a node before another node

- return: On success, the function returns true, else false.
- access: public

bool insertChildBefore ( &$node, &$reference, object $node, object $reference)

- object $node: The node to be inserted.
- object $reference: The reference node where the new node is to be inserted before.
- &$node
- &$reference

lastChild (line 1234)

Get the last child of this node

- access: public

mixed &lastChild ()
matchesCriterium (line 1341)

Determines whether a criterium matches this node

- return: True if this node matches that criterium
- access: public

bool matchesCriterium (string $criterium, mixed $value)

- string $criterium: The criterium that is to be checked
- mixed $value: The value that is to be compared

Redefined in descendants as:

- StringParser_BBCode_Node_Paragraph::matchesCriterium() : Determines whether a criterium matches this node
- StringParser_BBCode_Node_Element::matchesCriterium() : Determines whether a criterium matches this node

prependChild (line 937)

Prepend a node

- return: On success, the function returns true, else false.
- access: public

bool prependChild ( &$node, object $node)

- object $node: The node to be prepended.
- &$node

removeChild (line 1147)

Remove a child node

This function removes a child from the children array. A parameter tells the function whether to destroy the child afterwards or not. If the specified node is not a child of this node, the function will return false.

- return: On success, the function returns true, else false.
- access: public

bool removeChild ( &$child, [bool $destroy = false], mixed $child)

- mixed $child: The child to destroy; either an integer specifying the index of the child or a reference to the child itself.
- bool $destroy: Destroy the child afterwards.
- &$child

type (line 926)

Type of the node

This function returns the type of the node

- access: public

int type ()
_destroy (line 1292)

Destroy this node

- return: True on success, else false.
- access: protected

bool _destroy ()
_dumpToString (line 1422)

Dump this node to a string

- access: protected

string _dumpToString ()

Redefined in descendants as:

- StringParser_Node_Text::_dumpToString() : Dump this node to a string
- StringParser_BBCode_Node_Element::_dumpToString() : Dump this node to a string

_findChild (line 1307)

Find a child node

This function searches for a node in the own children and returns the index of the node or false if the node is not a child of this node.

- return: The index of the child node on success, else false.
- access: protected

mixed _findChild ( &$child, mixed $child)

- mixed $child: The node to look for.
- &$child

Documentation generated on Mon, 10 Dec 2007 13:29:39 +0100 by phpDocumentor 1.4.0