Text Class
Special Node representing plain text. Do not initiate this class directly, it is created whenever a text is passed into a container tag:
echo html('p', 'Some Text Here');
Constructor
Item Index
Methods
Properties
Methods
__get
-
name
General purpose getter to get attribute values
Parameters:
-
name
StringThe name of the property to set
__set
-
name
-
value
General purpose setter to set attribute values
appendTo
-
container
Add this child to a node container at the end
Parameters:
-
container
NodeContainerThe node container to add to
Returns:
The instance of this Node
getAttribute
-
[name=null]
Fetch and attribute by name from this Node. The attribute name cannot be null; if so, this function will throw an Exception.
Parameters:
-
[name=null]
String optionalThe name of the attribute to fetch
Returns:
The attribute's value, if any or null
getData
-
name
Get the data-* HTML5 attribute value, if set
Parameters:
-
name
StringThe name of the data attribute
Returns:
The value of the data
getParent
()
NodeContainer
private
Returns the parent node of this node, if a parent exists. If no parent exists, this function returns null.
Returns:
The parent node object
isEmpty
-
var
Checks if a variable is really "empty". Code borrowed from PHP.net at http://us3.php.net/manual/en/function.empty.php#90767 because we were previously using empty() to see if a variable is empty or not. But empty() dosen't work for attributes that have a value of "0", so we need something more robust here.
- an unset variable -> empty
- null -> empty
- 0 -> NOT empty
- "0" -> NOT empty
- false -> empty
- true -> NOT empty
- 'string value' -> NOT empty
- " "(white space) -> empty
- array()(empty array) -> empty
Parameters:
-
var
MixedThe variable to check for empty on
prependTo
-
container
Add this child to the beginning of a node container
Parameters:
-
container
NodeContainerThe node container to prepend to to
Returns:
The instance of this Node
setAttribute
-
[name=null]
-
[value=null]
-
The
Given a name and value pair, sets an attribute on this Node. The name and value cannot be empty; if so, this function will throw an Exception. Note if the attribute already exists and the caller wants to set an attribute of the same name, this function will not create a new Attribute, but rather update the value of the existing named attribute.
setAttributes
-
values
Set the list of all attributes.
Parameters:
-
values
DictionaryAn attributes array(name=>value, name=>value)
Returns:
The instance of this Node
setParent
-
[parent=null]
Sets the parent of this Node. Note that this function is protected and can only be called by classes that extend Node. The parent cannot be null; this function will throw an Exception if the parent node is empty.
Parameters:
-
[parent=null]
NodeContainer optionalThe parent container node