Fragment Class
+ + + + +Represents a set of HTML tags without a wrapper.
+Do not initiate this class directly, use the html()
function:
$div = html('fragment');
+
+Constructor
+ + +-
+
- Index + + +
- Methods + + +
- Properties + + + +
Item Index
+ + +Methods
+ +-
+
+
- + __get + + + + + +
- + __isset + + + + + +
- + __set + + + + + +
- + __toString + + + + + +
- + addChild + + + + + +
- + addChildAt + + + + + +
- + appendTo + + + + + +
- + getAttribute + + + + + +
- + getChildAt + + + + + +
- + getChildren + + + + + +
- + getData + + + + + +
- + getParent + + + + + +
- + isEmpty + + + + + +
- + prepareChild + + + + + +
- + prependTo + + + + + +
- + removeChild + + + + + +
- + removeChildAt + + + + + +
- + removeChildren + + + + + +
- + setAttribute + + + + + +
- + setAttributes + + + + + +
- + setParent + + + + + +
- + writeClose + + + + + +
- + writeOpen + + + + + +
Properties
+ +-
+
+
- + _attributes + + + + + +
- + _children + + + + + +
- + _parent + + + + + +
- + _tag + + + + + +
- + _validAttrs + + + + + +
Methods
+ + +__get
+
+
+ -
+
+
-
+
+
name
+ +
+
+
General purpose getter to get attribute values
+ +Parameters:
+ +-
+
+
-
+
+
name
+ String + + + + +++ + +The name of the property to set
+ +
+
+
__isset
+
+
+ -
+
+
-
+
+
name
+ +
+
+
See if a property exists
+ +Parameters:
+ +-
+
+
-
+
+
name
+ String + + + + +++ + +The name of the attribute
+ +
+
+
__set
+
+
+ -
+
+
-
+
+
name
+ +
+
+ -
+
+
value
+ +
+
+
General purpose setter to set attribute values
+ +__toString
+
+
+ ()
+
+
+
+
+ String
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Write to HTML
+ +Returns:
+ +The string representation of this HTML node
+ + +addChild
+
+
+ -
+
+
-
+
+
childNode
+ +
+
+
Add's a child to this NodeContainer. The child to add cannot be null.
+ +Parameters:
+ + +Returns:
+ +The instance of this container
+ + +addChildAt
+
+
+ -
+
+
-
+
+
childNode
+ +
+
+ -
+
+
index
+ +
+
+
Add a child at a specific index
+ +Parameters:
+ + +Returns:
+ +The instance of this container
+ + +appendTo
+
+
+ -
+
+
-
+
+
container
+ +
+
+
Add this child to a node container at the end
+ +Parameters:
+ +-
+
+
-
+
+
container
+ NodeContainer + + + + +++ + +The 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 + optional + + + + +++ + +The name of the attribute to fetch
+ +
+
+
Returns:
+ +The attribute's value, if any or null
+ + +getChildAt
+
+
+ -
+
+
-
+
+
[index=0]
+ +
+
+
Gets a child of this Node container at given +index. If no index is passed in, getChild() +will return the child at index zero (0).
+ +Parameters:
+ +-
+
+
-
+
+
[index=0]
+ Int + optional + + + + +++ + +The index to fetch child Node at
+ +
+
+
Returns:
+ +The child Node
+ + +getChildren
+
+
+ ()
+
+
+
+
+ Array
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns an array of all children attached to this Node container.
+ +Returns:
+ +The collection of Node objects
+ + +getData
+
+
+ -
+
+
-
+
+
name
+ +
+
+
Get the data-* HTML5 attribute value, if set
+ +Parameters:
+ +-
+
+
-
+
+
name
+ String + + + + +++ + +The 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
+ Mixed + + + + +++ + +The variable to check for empty on
+ +
+
+
prepareChild
+
+
+ -
+
+
-
+
+
childNode
+ +
+
+
Before adding a child, we should do some checking for basic types +and convert it into a more useable Node object.
+ +Parameters:
+ + +Returns:
+ +The child node
+ + +prependTo
+
+
+ -
+
+
-
+
+
container
+ +
+
+
Add this child to the beginning of a node container
+ +Parameters:
+ +-
+
+
-
+
+
container
+ NodeContainer + + + + +++ + +The node container to prepend to to
+ +
+
+
Returns:
+ +The instance of this Node
+ + +removeChild
+
+
+ -
+
+
-
+
+
[childNode=null]
+ +
+
+
Removes the first instance of child from this.
Once the first instance of the child
+is removed, this function will return. It returns
+true if a child was removed and false if no child
+was removed.
Parameters:
+ +-
+
+
-
+
+
[childNode=null]
+ Node + optional + + + + +++ + +The node to remove
+ +
+
+
Returns:
+ +If successfully removed
+ + +removeChildAt
+
+
+ -
+
+
-
+
+
index
+ +
+
+
Remove a child as a specific index
+ +Parameters:
+ +-
+
+
-
+
+
index
+ Int + + + + +++ + +The index to remove child at
+ +
+
+
Returns:
+ +The instance of the node container
+ + +removeChildren
+
+
+ ()
+
+
+
+
+ NodeContainer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Removes all children attached to this Node container
+ +Returns:
+ +The instance of the node container
+ + +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
+ Dictionary + + + + +++ + +An 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 + optional + + + + +++ + +The parent container node
+ +
+
+
writeClose
+
+
+ ()
+
+
+
+
+ String
+
+
+
+
+
+
+ protected
+
+
+
+
+
+
+
+
+
+
+
+
+ Close the writing of this container as HTML
+ +Returns:
+ +The closing HTML tag element
+ + +writeOpen
+
+
+ -
+
+
-
+
+
[selfClose=true]
+ +
+
+
Start the writing the tag
+ +Parameters:
+ +-
+
+
-
+
+
[selfClose=true]
+ Boolean + optional + + + + +++ + +If the tag is a self closing tag (e.g., br, img, hr)
+ +
+
+
Returns:
+ +The buffer of HTML
+ + +Properties
+ + +_attributes
+ Array
+
+
+
+
+ protected
+
+
+
+
+
+
+
+
+ The collection of Attributes objects
+ +_children
+ Array
+
+
+
+
+ private
+
+
+
+
+
+
+
+
+ The collection of children nodes
+ +_parent
+ NodeContainer
+
+
+
+
+ protected
+
+
+
+
+
+
+
+
+ The parent node, if any
+ +_tag
+ String
+
+
+
+
+ protected
+
+
+
+
+
+
+
+
+ The string name of the tag
+ +_validAttrs
+ Array
+
+
+
+
+ protected
+
+
+
+
+
+
+
+
+ The collection of valid attributes names for given tag
+ +