WebFioriAPI ReferenceLearnDownloadContributeLearn{{result.parent_page}} > {{result.title}}{{result.title}}Classes{{result.class_name}}{{result.summary}}Methods{{result.name}}{{result.summary}}

namespace \webfiori\ui

class HTMLNode

Class Attributes Summary

const COMMENT_NODEA constant that indicates a node is of type comment.const DEFAULT_CODE_FORMATAn associative array of default formatting options for the code.const TEXT_NODEA constant that indicates a node is of type text.const VOID_TAGSAn array that contains all unpaired (or void) HTML tags.

Class Methods Summary

public function __construct(string$name, $attrsAn)Constructs a new instance of the class.public function __toString()Returns non-formatted HTML string that represents the node as a whole.public function addChild(HTMLNode|string$node, array|boolean$attrsOrChain, boolean$chainOnParent)Adds new child node to the body of the instance.public function addCommentNode(string$text)Adds a comment node as a child.public function addTextNode(string$text, boolean$escHtmlEntities)Adds a text node as a child.public function anchor(string|HTMLNode$body, array$attributes)Adds an anchor (<a>) tag to the body of the node.public function applyClass(string$cName, boolean$override)Sets the attribute 'class' for all child nodes.public function asCode(array$formattingOptions)Returns the node as readable HTML code wrapped inside 'pre' element.public function br()Adds a line break (<br/>) to the body of the node.public function build(array$arrOfChildren)Build the body of the node using an array.public function cell(string|HTMLNode$cellBody, string$cellType, array$attributes)Adds a cell (<td> or <th>) to the body of the node.public function children()Returns a linked list of all child nodes.public function childrenCount()Returns the number of child nodes attached to the node.public function close()Returns a string that represents the closing part of the node.public function codeSnippit(string$title, string$code, array$attributes)Adds an object of type 'CodeSnippit' as a child element.public function comment(string$txt)Adds a comment node as a child.public function component(string$path, array$slotsVals)Loads HTML-like component and make it a child of current node.public function count()Returns the number of child nodes attached to the node.public static function createComment(string$text)Creates new comment node.public static function createTextNode(string$nodeText, boolean$escHtmlEntities)Creates new text node.public function current()Returns the element that the iterator is currently is pointing to.public function div(array$attributes)Adds a <div> element to the body of the node.public function form(array$attributes)Adds a <form> element to the body of the node.public static function fromHTMLText(string$text, boolean$asHTMLDocObj)Creates HTMLNode object given a string of HTML code.public function getAttribute(string$attrName)Returns the value of an attribute.public function getAttributeValue(string$attrName)Returns the value of an attribute.public function getAttributes()Returns an associative array of all node attributes alongside the values.public function getChild(int$index)Returns a child node given its index.public function getChildByAttributeValue(string$attrName, string$attrVal)Returns a node based on its attribute value (Direct child).public function getChildByID(string$val)Returns a child node given its ID.public function getChildrenByTag(string$val)Returns a linked list that contains all child nodes which has the given tag name.public function getClassName()Returns the value of the attribute 'class' of the element.public function getComment()Returns the node as HTML comment.public function getID()Returns the value of the attribute 'id' of the element.public function getLastChild()Returns the last added child.public function getName()Returns the value of the attribute 'name' of the element.public function getNodeName()Returns the name of the node.public function getOriginalText()Returns the original text which was set in the body of the node.public function getParent()Returns the parent node.public function getStyle()Returns an array that contains in-line CSS declarations.public function getTabIndex()Returns the value of the attribute 'tabindex' of the element.public function getText()Returns the value of the text that this node represents.public function getTextUnescaped()Returns the value of the text that this node represents.public function getTitle()Returns the value of the attribute 'title' of the element.public function getWritingDir()Returns the value of the attribute 'dir' of the element.public function hasAttribute(string$attrName)Checks if the node has a given attribute or not.public function hasChild(HTMLNode$node)Checks if a given node is a direct child of the instance.public function hr()Adds a horizontal rule (<hr/>) to the body of the node.public static function htmlAsArray(string$text)Converts a string of HTML code to an array that looks like a tree of HTML elements.public function img(array$attributes)Adds an image element (<img>) to the body of the node.public function input(string$inputType, array$attributes)Adds new input (<input>, <select> or <textarea>) element as a child to the body of the node.public function insert(HTMLNode$el, int$position)Insert new HTML element at specific position.public function isComment()Checks if the given node represents a comment or not.public function isFormatted()Returns the value of the property $isFormatted.public function isQuotedAttribute()Checks if the node will rendere all attributes quoted or not.public function isTextNode()Checks if the node is a text node or not.public function isUseOriginalText()Returns the value of the property $useOriginalTxt.public function isVoidNode()Checks if the given node is a void node.public function key()Returns the current node in the iterator.public function label(string|array$body, array$attributes)Adds new label (<label>) element to the body of the node.public function li(HTMLNode|string$itemBody, array$attributes)Adds a list item element (<li>) to the body of the node.public static function loadComponent(string$htmlTemplatePath, array$slotsValsArr)Loads HTML-like component.public function next()Returns the next element in the iterator.public function ol(array$items, array$attributes)Adds a list (<ol>) to the body of the node.public function open()Returns a string that represents the opening part of the node.public function paragraph(string|HTMLNode$body, type$attributes, boolean$escEntities)Adds a paragraph (<p>) as a child element.public function removeAllChildNodes()Removes all child nodes.public function removeAttribute(string$name)Removes an attribute from the node given its name.public function removeAttributes()Removes all attributes from the node.public function removeChild(HTMLNode|string$nodeInstOrId)Removes a direct child node.public function removeLastChild()Removes the last child on the node.public function replaceChild(HTMLNode$oldNode, HTMLNode$replacement)Replace a direct child node with a new one.public function rewind()Return iterator pointer to the first element in the list.public function section(string|HTMLNode$title, int$headingLvl, array$attributes)Adds a section (<section>) as a child element.public function setAttribute(string$name, string|null$val)Sets a value for an attribute.public function setAttributes(array$attrsArr)Sets multiple attributes at once.public function setClassName(string$val, boolean$override)Sets the value of the attribute 'class' of the node.public function setID(string$idVal)Sets the value of the attribute 'id' of the node.public function setIsFormatted(boolean$bool)Sets the value of the property $isFormatted.public function setIsQuotedAttribute(boolean$bool)Sets the value of the property which is used to tell if all node attributes will be quoted or not.public function setIsVoidNode(boolean$bool)Make the node a void node or not.public function setName(string$val)Sets the value of the attribute 'name' of the node.public function setNodeName(string$name)Updates the name of the node.public function setStyle(array$cssStyles, boolean$override)Sets the value of the attribute 'style' of the node.public function setTabIndex(int$val)Sets the value of the attribute 'tabindex' of the node.public function setText(string$text, boolean$escHtmlEntities)Sets the value of the property $text.public function setTitle(string$val)Sets the value of the attribute 'title' of the node.public function setUseOriginal(boolean$boolean)Sets the value of the property $useOriginalTxt.public function setWritingDir(string$val)Sets the value of the attribute 'dir' of the node.public function table(array$attributes)Adds a table node (<table>) to the body of the node.public function text(string$txt, boolean$escEntities)Adds a text node as a child.public function toHTML(boolean$formatted, int$initTab)Returns HTML string that represents the node as a whole.public function tr(array$data, array$attributes, boolean$headerRow)Adds a row (<tr>) to the body of the node.public function ul(array$items, array$attributes)Adds a list (<ul>) to the body of the node.public function valid()Checks if the iterator has more elements or not.

Class Attributes Details

const COMMENT_NODEA constant that indicates a node is of type comment. const DEFAULT_CODE_FORMATAn associative array of default formatting options for the code. It is used when displaying the actual generated HTML code. The array has the following indices and values:
  • tab-spaces: Number of spaces in a tab. The value is 4.
  • initial-tab: Initial number of tabs. The value is 0.
  • with-colors: A boolean. The value is true.
  • use-pre: Use 'pre' or 'span' to add colors. The value is true.
  • colors: A sub-associative array of colors. The array has the following indices and values:
    • bg-color: Background color of code block. The value is 'rgb(21, 18, 33)'
    • text-color: Color of any text that appears inside any node. The value is 'gray'.
    • attribute-color: The color of attribute name. The value is 'rgb(0,124,0)'.
    • attribute-value-color: The color of attribute value. The value is 'rgb(170,85,137)'.
    • node-name-color: Color of HTML node name. The value is 'rgb(204,225,70)'.
    • lt-gt-color: The color of '<' and '>' signs (around node name). The value is 'rgb(204,225,70)'.
    • comment-color: The color of any HTML comment. The value is 'rgb(0,189,36)'.
    • operator-color: The color of equal operator for attribute value. The value is 'gray'.
    const TEXT_NODEA constant that indicates a node is of type text. const VOID_TAGSAn array that contains all unpaired (or void) HTML tags. An unpaired tag is a tag that does tot require closing tag. Its body is empty and does not contain any thing. This array has the following values:
    • br
    • hr
    • meta
    • img
    • input
    • wbr
    • embed
    • base
    • col
    • link
    • param
    • source
    • track
    • area

    Class Methods Details

    public function __construct(string$name, $attrsAn)Constructs a new instance of the class.

    Parameters:

    • string $name The name of the node (such as 'div'). If the developer would like to create a comment node, the name should be '#comment'. If the developer would like to create a text node, the name should be '#text'. If this parameter is not given, default value will be used which is 'div'. A valid node name must follow the following rules:
      • Must not be an empty string.
      • Must not start with a number.
      • Must not start with '-', '.' or ':'.
      • Can only have the following characters in its name: [A-Z], [a-z], [0-9], ':', '.' and '-'.
      • $attrs An optional array that contains node attributes.
      public function __toString()Returns non-formatted HTML string that represents the node as a whole. Returns: stringHTML string that represents the node as a whole.public function addChild(HTMLNode|string$node, array|boolean$attrsOrChain, boolean$chainOnParent)Adds new child node to the body of the instance.

      Parameters:

      • HTMLNode|string $node The node that will be added. It can be an instance of the class 'HTMLNode' or a string that represents the name of the node that will be added. The node can have child nodes only if 4 conditions are met:
        • If the node is not a text node.
        • The node is not a comment node.
        • The node is not a void node.
        • The node is not it self. (making a node as a child of it self)
      • array|boolean $attrsOrChain An optional array of attributes which will be set in the newly added child. Applicable only if the newly added node is not a text or a comment node. Also, this can be used as boolean value to act as last method parameter (the $chainOnParent)
      • boolean $chainOnParent If this parameter is set to true, the method will return the same instance at which the child node is added to. If set to false, the method will return the child which have been added. This can be useful if the developer would like to add a chain of elements to the body of the parent or child. Default value is false. It means the chaining will happen at child level.
      Returns: HTMLNodeIf the parameter $chainOnParent is set to true, the method will return the '$this' instance. If set to false, it will return the newly added child.
      public function addCommentNode(string$text)Adds a comment node as a child. The comment node will be added to the body of the node only if it is not a void node.

      Parameters:

      • string $text The text that will be in the node.
      Returns: HTMLNodeThe method will return the same instance at which the method is called on.
      public function addTextNode(string$text, boolean$escHtmlEntities)Adds a text node as a child. The text node will be added to the body of the node only if it is not a void node.

      Parameters:

      • string $text The text that will be in the node.
      • boolean $escHtmlEntities If set to true, the method will replace the characters '<', '>' and '&' with the following HTML entities: '&lt;', '&gt;' and '&amp;' in the given text. Default is true.
      Returns: HTMLNodeThe method will return the same instance.
      public function anchor(string|HTMLNode$body, array$attributes)Adds an anchor (<a>) tag to the body of the node.

      Parameters:

      • string|HTMLNode $body The body of the tag. This can be a simple text or an object of type 'HTMLNode'. Note that if text is given and the text contains HTML code, the method will not replace the code by HTML entities.
      • array $attributes An optional array that contains the attributes which will be set for the created node.
      Returns: HTMLNodeThe method will return the instance that this method is called on.
      public function applyClass(string$cName, boolean$override)Sets the attribute 'class' for all child nodes.

      Parameters:

      • string $cName The value of the attribute.
      • boolean $override If set to true and the child has already this attribute set, the given value will override the existing value. If set to false, the new value will be appended to the existing one. Default is true.
      Returns: HTMLNodeThe method will return the same instance.
      public function asCode(array$formattingOptions)Returns the node as readable HTML code wrapped inside 'pre' element.

      Parameters:

      • array $formattingOptions An associative array which contains an options for formatting the code. The available options are:
        • tab-spaces: The number of spaces in a tab. Usually 4.
        • with-colors: A boolean value. If set to true, the code will be highlighted with colors.
        • initial-tab: Number of initial tabs
        • colors: An associative array of highlight colors.
        The array 'colors' has the following options:
        • bg-color: The 'pre' block background color.
        • attribute-color: HTML attribute name color.
        • attribute-value-color: HTML attribute value color.
        • text-color: Normal text color.
        • comment-color: Comment color.
        • operator-color: Assignment operator color.
        • lt-gt-color: Less than and greater than color.
        • node-name-color: Node name color.
      Returns: stringThe node as readable HTML code wrapped inside 'pre' element.
      public function br()Adds a line break (<br/>) to the body of the node. Returns: HTMLNodeThe method will return the instance that this method is called on.public function build(array$arrOfChildren)Build the body of the node using an array.

      Parameters:

      • array $arrOfChildren The array can hold objects of type HTMLNode or can hold sub associative arrays. each array will hold one child information. Each array can have the following options:
        • name: The name of the child such as 'div'.
        • attributes: A sub associative array that holds the attributes of the child.
        • is-void: A boolean which can be set to true if the child represents a void node.
        • text: This index is used if node type is #TEXT or #COMMENT. It represents the text that will appear in the body of the node
        • children: An array that holds arrays that represents the children of the child. The arrays can have same structure.
      public function cell(string|HTMLNode$cellBody, string$cellType, array$attributes)Adds a cell (<td> or <th>) to the body of the node. The method will create the cell as an object of type 'TableCell'. Note that the cell will be added only if the node name is 'tr'.

      Parameters:

      • string|HTMLNode $cellBody The text of cell body. It can have HTML. Also, it can be an object of type 'HTMLNode'.
      • string $cellType The type of the cell. This attribute can have only one of two values, 'td' or 'th'. 'td' If the cell is in the body of the table and 'th' if the cell is in the header. If none of the two is given, 'td' will be used by default.
      • array $attributes An optional array of attributes to set for the cell.
      Returns: HTMLNodeThe method will return the instance that this method is called on.
      public function children()Returns a linked list of all child nodes. Returns: LinkedList|nullA linked list of all child nodes. if the given node is a text node, the method will return null.public function childrenCount()Returns the number of child nodes attached to the node. If the node is a text node, a comment node or a void node, the method will return 0.Returns: intThe number of child nodes attached to the node.public function close()Returns a string that represents the closing part of the node. Returns: stringA string that represents the closing part of the node. if the node is a text node, a comment node or a void node the returned value will be an empty string.public function codeSnippit(string$title, string$code, array$attributes)Adds an object of type 'CodeSnippit' as a child element.

      Parameters:

      • string $title The title of the code snippit such as 'PHP Code'.
      • string $code The code that will be displayed by the snippit. It is recommended that the code enclosed between double quotation marks.
      • array $attributes An optional array of attributes to set for the parent element in the object. Note that if the array has the attribute 'class' or the attribute 'style', they will be ignored.
      Returns: HTMLNodeThe method will return the instance at which the method is called on.
      public function comment(string$txt)Adds a comment node as a child. The comment node will be added to the body of the node only if it is not a void node.

      Parameters:

      • string $txt The text that will be in the node.
      Returns: HTMLNodeThe method will return the instance that this method is called on.
      public function component(string$path, array$slotsVals)Loads HTML-like component and make it a child of current node. This method can be used to load any component that uses HTML syntax into an object and make it a child of the instance at which the method is called in. If the component file contains more than one node as a root note, all nodes will be added as children.

      Parameters:

      • string $path The location of the file that will have the HTML component.
      • array $slotsVals An array that contains slots values. A slot in the component is a string which is enclosed between two curly braces (such as {{name}}). This array must be associative. The indices of the array are slots names and values of the indices are slots values. The values of the slots can be also sub-array that contains more values. For example, if we have a slot with the name {{ user-name }}, then the array can have the index 'user-name' with the value of the slot.
      public function count()Returns the number of child nodes attached to the node. If the node is a text node, a comment node or a void node, the method will return 0.Returns: intThe number of child nodes attached to the node.public static function createComment(string$text)Creates new comment node.

      Parameters:

      • string $text The text that will be inserted in the body of the comment.
      Returns: HTMLNodeAn object of type HTMLNode.
      public static function createTextNode(string$nodeText, boolean$escHtmlEntities)Creates new text node.

      Parameters:

      • string $nodeText The text that will be inserted in the body of the node.
      • boolean $escHtmlEntities If set to true, the method will replace the characters '<', '>' and '&' with the following HTML entities: '&lt;', '&gt;' and '&amp;' in the given text.
      Returns: HTMLNodeAn object of type HTMLNode.
      public function current()Returns the element that the iterator is currently is pointing to. This method is only used if the list is used in a 'foreach' loop. The developer should not call it manually unless he knows what he is doing.Returns: HTMLNodeThe element that the iterator is currently is pointing to.public function div(array$attributes)Adds a <div> element to the body of the node.

      Parameters:

      • array $attributes An optional array of attributes that will be set in the div element.
      Returns: HTMLNodeThe method will return the instance which was added to the body of the instance that the method is called on.
      public function form(array$attributes)Adds a <form> element to the body of the node.

      Parameters:

      • array $attributes An optional array of attributes that will be set in the form element.
      Returns: HTMLNodeThe method will return the instance which was added to the body of the instance that the method is called on.
      public static function fromHTMLText(string$text, boolean$asHTMLDocObj)Creates HTMLNode object given a string of HTML code. Note that this method is still under implementation.

      Parameters:

      • string $text A string that represents HTML code.
      • boolean $asHTMLDocObj If set to 'true' and given HTML represents a structured HTML document, the method will convert the code to an object of type 'HTMLDoc'. Default is 'true'.
      Returns: array|HeadNode|HTMLDoc|HTMLNodeIf the given code represents HTML document and the parameter $asHTMLDocObj is set to 'true', an object of type 'HTMLDoc' is returned. If the given code has multiple top level nodes (e.g. '<div></div><div></div>'), an array that contains an objects of type 'HTMLNode' is returned. If the given code has one top level node, an object of type 'HTMLNode' is returned. Note that it is possible that the method will return an instance which is a sub-class of the class 'HTMLNode'.
      public function getAttribute(string$attrName)Returns the value of an attribute. Calling this method is similar to calling HTMLNode::getAttributeValue().

      Parameters:

      • string $attrName The name of the attribute. Upper case name and lower case name is treated same way. Which means 'ID' is like 'id'.
      Returns: string|nullThe method will return the value of the attribute if found. If no such attribute or the value of the attribute is set to null, the method will return null.
      public function getAttributeValue(string$attrName)Returns the value of an attribute.

      Parameters:

      • string $attrName The name of the attribute. It can be in upper or lower case.
      Returns: string|nullThe method will return the value of the attribute if found. If no such attribute or the value of the attribute is set to null, the method will return null.
      public function getAttributes()Returns an associative array of all node attributes alongside the values. Returns: array|nullan associative array. The keys will act as the attribute name and the value will act as the value of the attribute. If the node is a text node, the method will return null.public function getChild(int$index)Returns a child node given its index.

      Parameters:

      • int $index The position of the child node. This must be an integer value starting from 0.
      Returns: HTMLNode|nullIf the child does exist, the method will return an object of type 'HTMLNode'. If no element was found, the method will return null.
      public function getChildByAttributeValue(string$attrName, string$attrVal)Returns a node based on its attribute value (Direct child). Note that if there are multiple children with the same attribute and value, the first occurrence is returned.

      Parameters:

      • string $attrName The name of the attribute. Supplying lower case name or upper case name is the same.
      • string $attrVal The value of the attribute.
      Returns: HTMLNode|nullThe method will return an object of type HTMLNode if a node is found. Other than that, the method will return null.
      public function getChildByID(string$val)Returns a child node given its ID.

      Parameters:

      • string $val The ID of the child.
      Returns: null|HTMLNodeThe method returns an object of type HTMLNode if found. If no node has the given ID, the method will return null.
      public function getChildrenByTag(string$val)Returns a linked list that contains all child nodes which has the given tag name. If the given tag name is empty string or the node has no children which has the given tag name, the returned list will be empty.

      Parameters:

      • string $val The name of the tag (such as 'div' or 'a').
      Returns: LinkedListA linked list that contains all child nodes which has the given tag name.
      public function getClassName()Returns the value of the attribute 'class' of the element. Returns: string|nullIf the attribute 'class' is set, the method will return its value. If not set, the method will return null.public function getComment()Returns the node as HTML comment. Returns: stringThe node as HTML comment. if the node is not a comment, the method will return empty string.public function getID()Returns the value of the attribute 'id' of the element. Returns: string|nullIf the attribute 'id' is set, the method will return its value. If not set, the method will return null.public function getLastChild()Returns the last added child. Returns: HTMLNode|nullThe child will be returned as an object of type 'HTMLNode'. If the node has no children, the method will return null.public function getName()Returns the value of the attribute 'name' of the element. Returns: string|nullIf the attribute 'name' is set, the method will return its value. If not set, the method will return null.public function getNodeName()Returns the name of the node. Returns: stringThe name of the node. If the node is a text node, the method will return the value '#TEXT'. If the node is a comment node, the method will return the value '#COMMENT'.public function getOriginalText()Returns the original text which was set in the body of the node. This only applies to text nodes and comment nodes.Returns: stringThe original text without any modifications.public function getParent()Returns the parent node. Returns: HTMLNode|nullAn object of type HTMLNode if the node has a parent. If the node has no parent, the method will return null.public function getStyle()Returns an array that contains in-line CSS declarations. If the attribute is not set, the array will be empty.Returns: array'white').public function getTabIndex()Returns the value of the attribute 'tabindex' of the element. Returns: string|nullIf the attribute 'tabindex' is set, the method will return its value. If not set, the method will return null.public function getText()Returns the value of the text that this node represents. Returns: stringIf the node is a text node or a comment node, the method will return the text in the body of the node. If not, the method will return empty string. Note that if the node represents a text node and HTML entities where escaped while setting its text, the returned value will have HTML entities escaped.public function getTextUnescaped()Returns the value of the text that this node represents. The method will return a string which has HTML entities unescaped.Returns: stringIf the node is a text node, the method will return the text in the body of the node. If not, the method will return empty string.public function getTitle()Returns the value of the attribute 'title' of the element. Returns: string|nullIf the attribute 'title' is set, the method will return its value. If not set, the method will return null.public function getWritingDir()Returns the value of the attribute 'dir' of the element. Returns: string|nullIf the attribute 'dir' is set, the method will return its value. If not set, the method will return null.public function hasAttribute(string$attrName)Checks if the node has a given attribute or not. Note that if the node is a text node or a comment node, it will always return false.

      Parameters:

      • string $attrName The name of the attribute. It can be in upper case or lower case.
      Returns: booleantrue if the attribute is set.
      public function hasChild(HTMLNode$node)Checks if a given node is a direct child of the instance.

      Parameters:

      • HTMLNode $node The node that will be checked.
      Returns: booleantrue is returned if the node is a child of the instance. false if not. Also if the current instance is a text node or a comment node, the function will always return false.
      public function hr()Adds a horizontal rule (<hr/>) to the body of the node. Returns: HTMLNodeThe method will return the instance that this method is called on.public static function htmlAsArray(string$text)Converts a string of HTML code to an array that looks like a tree of HTML elements. This method parses text based on the specifications which are found in https://html.spec.whatwg.org/multipage/syntax.html#start-tags

      Parameters:

      Returns: arrayAn indexed array. Each index will contain parsed element information. For example, if the given code is as follows:
            <html><head></head><body></body></html>      
      Then the output will be as follows:
      Array        (          [0] => Array          (            [tag-name] => html            [is-void-tag] =>             [attributes] => Array              (              )            [children] => Array              (                [0] => Array                (                  [tag-name] => head                  [is-void-tag] =>                   [attributes] => Array                    (                    )                  [children] => Array                    (                    )                )          [1] => Array            (            [tag-name] => body            [is-void-tag] =>             [attributes] => Array              (              )            [children] => Array              (              )            )          )        )      )      
      public function img(array$attributes)Adds an image element (<img>) to the body of the node.

      Parameters:

      • array $attributes An optional array of attributes that will be set in the image element.
      Returns: HTMLNodeThe method will return the instance which was added to the body of the instance that the method is called on.
      public function input(string$inputType, array$attributes)Adds new input (<input>, <select> or <textarea>) element as a child to the body of the node. The method will create an object of type 'Input' and add it as a child.

      Parameters:

      • string $inputType The type of the input element. The values of this parameter must be taken from the array Input::INPUT_TYPES. Default value is 'text'.
      • array $attributes An optional array that contains attributes to set for the input. If the array contains the attribute 'type', it will be ignored.
      Returns: HTMLNodeThe method will return the instance which was added to the body of the instance that the method is called on.
      public function insert(HTMLNode$el, int$position)Insert new HTML element at specific position.

      Parameters:

      • HTMLNode $el The new element that will be inserted. It is possible to insert child elements to the element if the following conditions are met:
        • If the node is not a text node.
        • The node is not a comment node.
        • The note is not a void node.
        • The note is not it self. (making a node as a child of it self)
      • int $position The position at which the element will be added. it must be a value between 0 and HTMLNode::childrenCount() inclusive.
      Returns: HTMLNodeThe method will return the instance that this method is called on.
      public function isComment()Checks if the given node represents a comment or not. Returns: booleanThe method will return true if the given node is a comment.public function isFormatted()Returns the value of the property $isFormatted. The property is used to control how the HTML code that will be generated will look like. If set to true, the code will be user-readable. If set to false, it will be compact and the load size will be come less since no new line characters or spaces will be added in the code.Returns: boolean|nullIf the property is set, the method will return its value. If not set, the method will return null.public function isQuotedAttribute()Checks if the node will rendere all attributes quoted or not. This method is used to make sure that all attributes are quotated when rendering the node. If false is returned, then the quoted attributes will be decided based on the value of the attribute.Returns: booleanThe method will return true if all attributes will be quoted. False if not.public function isTextNode()Checks if the node is a text node or not. Returns: booleantrue if the node is a text node. false otherwise.public function isUseOriginalText()Returns the value of the property $useOriginalTxt. The property is used when parsing text nodes. If it is set to true, the text that will be in the body of the node will be the exact text which was set using the method HTMLNode::setText() (The value which will be returned by the method HTMLNode::getOriginalText()). If it is set to false, then the text which is in the body of the node will be the value which is returned by the method HTMLNode::getText().Returns: booleanTrue if original text will be used in the body of the text node. False if not. Default is false.public function isVoidNode()Checks if the given node is a void node. A void node is a node which cannot have child nodes in its body.Returns: booleanIf the node is a void node, the method will return true. False if not. Note that text nodes and comment nodes are considered as void tags.public function key()Returns the current node in the iterator. This method is only used if the list is used in a 'foreach' loop. The developer should not call it manually unless he knows what he is doing.Returns: HTMLNodeAn object of type 'HTMLNode' or null if the node has no children is empty or the iterator is finished.public function label(string|array$body, array$attributes)Adds new label (<label>) element to the body of the node. The method will create an object of type 'Label' and add it as a child to the body.

      Parameters:

      • string|array $body The body of the label. It can be a simple text or it can be an object of type 'HTMLNode'.
      • array $attributes An optional array that contains attributes to set for the label.
      Returns: LabelThe method will return the newly added label.
      public function li(HTMLNode|string$itemBody, array$attributes)Adds a list item element (<li>) to the body of the node. The method will add the node as an object of type 'ListItem'. Note that it will be added only if the node is of type 'ul' or 'li'.

      Parameters:

      • HTMLNode|string $itemBody The body of the list item. It can be a simple text or an object of type 'HTMLNode'.
      • array $attributes An optional array of attributes that will be set in the list item element.
      Returns: HTMLNodeThe method will return the instance that this method is called on.
      public static function loadComponent(string$htmlTemplatePath, array$slotsValsArr)Loads HTML-like component. This method can be used to load any component that uses HTML or XML syntax into an object. The method can return many types depending on the loaded component.

      Parameters:

      • string $htmlTemplatePath The location of the file that will have the component. It can be of any type (HTML, XML, ...).
      • array $slotsValsArr An array that contains slots values. A slot in the component is a string which is enclosed between two curly braces (such as {{name}}). This array must be associative. The indices of the array are slots names and values of the indices are slots values. For example, if we have a slot with the name {{ user-name }}, then the array can have the index 'user-name' with the value of the slot.
      Returns: HeadNode|HTMLDoc|HTMLNode|arrayIf the given component represents HTML document, an object of type 'HTMLDoc' is returned. If the given component represents <head> node, the method will return an object of type 'HeadNode'. Other than that, the method will return an object of type 'HTMLNode'. If the file has more than one node in the root, the method will return an array that contains objects of type 'HTMLNode'.
      public function next()Returns the next element in the iterator. This method is only used if the list is used in a 'foreach' loop. The developer should not call it manually unless he knows what he is doing.Returns: HTMLNodeThe next element in the iterator. If the iterator is finished or the list is empty, the method will return null.public function ol(array$items, array$attributes)Adds a list (<ol>) to the body of the node. The method will create an object of type 'UnorderedList' and add it as a child. Note that if the node of type 'ul' or 'ol', nothing will be added.

      Parameters:

      • array $items An array that contains list items. They can be a simple text, objects of type 'ListItem' or object of type 'HTMLNode'. Note that if the list item is a text, the item will be added without placing HTML entities in the text if the text has HTMLCode.
      • array $attributes An optional array of attributes to set for the list.
      Returns: HTMLNodeThe method will always return the same instance at which the method is called on.
      public function open()Returns a string that represents the opening part of the node. Returns: stringA string that represents the opening part of the node. if the node is a text node or a comment node, the returned value will be an empty string.public function paragraph(string|HTMLNode$body, type$attributes, boolean$escEntities)Adds a paragraph (<p>) as a child element.

      Parameters:

      • string|HTMLNode $body An optional text to add to the body of the paragraph. This also can be an object of type 'HTMLNode'. Note that if HTMLNode object is given, its name must be part of the array PNode::ALLOWED_CHILDS or the method will not add it.
      • type $attributes
      • boolean $escEntities If set to true, the method will replace the characters '<', '>' and '&' with the following HTML entities: '&lt;', '&gt;' and '&amp;' in the given text. Default is true.
      Returns: HTMLNodeThe method will return the instance at which the method is called on.
      public function removeAllChildNodes()Removes all child nodes. Returns: HTMLNodeThe method will return the instance that this method is called on.public function removeAttribute(string$name)Removes an attribute from the node given its name.

      Parameters:

      • string $name The name of the attribute.
      Returns: HTMLNodeThe method will return the instance that this method is called on.
      public function removeAttributes()Removes all attributes from the node. This method will simply re-initialize the array that holds all the attributes.public function removeChild(HTMLNode|string$nodeInstOrId)Removes a direct child node.

      Parameters:

      • HTMLNode|string $nodeInstOrId The node that will be removed. This also can be the ID of the child that will be removed. In addition to that, this can be the index of the element that will be removed starting from 0.
      Returns: HTMLNode|nullThe method will return the node if removed. If not removed, the method will return null.
      public function removeLastChild()Removes the last child on the node. Returns: HTMLNode|nullIf a node is removed, the method will return it as an object of type 'HTMLNode'. Other than that, the method will return null.public function replaceChild(HTMLNode$oldNode, HTMLNode$replacement)Replace a direct child node with a new one.

      Parameters:

      • HTMLNode $oldNode The old node. It must be a child of the instance.
      • HTMLNode $replacement The replacement node.
      Returns: booleantrue is returned if the node replaced. false if not.
      public function rewind()Return iterator pointer to the first element in the list. This method is only used if the list is used in a 'foreach' loop. The developer should not call it manually unless he knows what he is doing.public function section(string|HTMLNode$title, int$headingLvl, array$attributes)Adds a section (<section>) as a child element. This method will create a section element with a heading element in its body. Note that if the title of the contains HTML entities, they will be not escaped and will be treated as HTML code.

      Parameters:

      • string|HTMLNode $title The title that will be set in the heading tag. This also can be an object of type 'HTMLNode'.
      • int $headingLvl Heading level. It can be a value between 1 and 6 inclusive. Default value is 1.
      • array $attributes An optional array of attributes that will be set in the section element.
      Returns: HTMLNodeThe method will return an object that represents the added section.
      public function setAttribute(string$name, string|null$val)Sets a value for an attribute.

      Parameters:

      • string $name The name of the attribute. If the attribute does not exist, it will be created. If already exists, its value will be updated. Note that if the node type is text node, the attribute will never be created.
      • string|null $val The value of the attribute. Default is null. Note that if the value has any extra spaces, they will be trimmed. Also, if the given value is null, the attribute will be set with no value.
      Returns: HTMLNodeThe method will return the instance that this method is called on.
      public function setAttributes(array$attrsArr)Sets multiple attributes at once.

      Parameters:

      • array $attrsArr An associative array that has attributes names and values. The indices will represents attributes names and the value of each index represents the values of the attributes. If the given array has elements without keys, they will be added without values.
      Returns: HTMLNodeThe method will return the instance that this method is called on.
      public function setClassName(string$val, boolean$override)Sets the value of the attribute 'class' of the node.

      Parameters:

      • string $val The name of the class.
      • boolean $override If this parameter is set to false and the node has a class already set, the given class name will be appended to the existing one. Default is true which means the attribute will be set as new.
      Returns: HTMLNodeThe method will return the instance that this method is called on.
      public function setID(string$idVal)Sets the value of the attribute 'id' of the node.

      Parameters:

      • string $idVal The value to set.
      Returns: HTMLNodeThe method will return the instance that this method is called on.
      public function setIsFormatted(boolean$bool)Sets the value of the property $isFormatted.

      Parameters:

      • boolean $bool true to make the document that will be generated from the node user-readable. false to make it compact.
      public function setIsQuotedAttribute(boolean$bool)Sets the value of the property which is used to tell if all node attributes will be quoted or not. Note that this method is only applicable if the element that the method is called on has no parent (root node).

      Parameters:

      • boolean $bool True to make the node render quoted attributes. False to not.
      public function setIsVoidNode(boolean$bool)Make the node a void node or not. A void node is a node which does not require closing tag. The developer does not have to set the node type to void or not since this is done automatically. For custom made elements, this might be required.

      Parameters:

      • boolean $bool If the developer would like to make the node a void node, then he must pass true.
      public function setName(string$val)Sets the value of the attribute 'name' of the node.

      Parameters:

      Returns: HTMLNodeThe method will return the instance that this method is called on.
      public function setNodeName(string$name)Updates the name of the node. If the node type is a text or a comment, developer can only switch between the two types. If the node type is of another type and has child nodes, type will be changed only if the given node name is not a void node. If the node is a void node and it has no children, it will switch without problems.

      Parameters:

      Returns: booleanThe method will return true if the type is updated.
      public function setStyle(array$cssStyles, boolean$override)Sets the value of the attribute 'style' of the node.

      Parameters:

      • array $cssStyles 'white').
      • boolean $override If this value is set to true and a style is already set, then the old style will be overridden by the given style. Default is false.
      Returns: HTMLNodeThe method will return the instance that this method is called on.
      public function setTabIndex(int$val)Sets the value of the attribute 'tabindex' of the node.

      Parameters:

      • int $val The value to set. From MDN: An integer attribute indicating if the element can take input focus. It can takes several values:
        • A negative value means that the element should be focusable, but should not be reachable via sequential keyboard navigation.
        • 0 means that the element should be focusable and reachable via sequential keyboard navigation, but its relative order is defined by the platform convention
        • A positive value means that the element should be focusable and reachable via sequential keyboard navigation; the order in which the elements are focused is the increasing value of the tabindex. If several elements share the same tabindex, their relative order follows their relative positions in the document.
      Returns: HTMLNodeThe method will return the instance that this method is called on.
      public function setText(string$text, boolean$escHtmlEntities)Sets the value of the property $text. Note that if the type of the node is comment, the method will replace '<!--' and '-->' with ' --' and '-- ' if it was found in the given text.

      Parameters:

      • string $text The text to set. If the node is not a text node or a comment node, the value will never be set.
      • boolean $escHtmlEntities If set to true, the method will replace the characters '<', '>' and '&' with the following HTML entities: '&lt;', '&gt;' and '&amp;' in the given text. Default is true. Ignored in case the node type is comment.
      Returns: HTMLNodeThe method will return the instance that this method is called on.
      public function setTitle(string$val)Sets the value of the attribute 'title' of the node.

      Parameters:

      • string $val The value to set. From MDN: Contains a text representing advisory information related to the element it belongs to. Such information can typically, but not necessarily, be presented to the user as a tooltip.
      Returns: HTMLNodeThe method will return the instance that this method is called on.
      public function setUseOriginal(boolean$boolean)Sets the value of the property $useOriginalTxt. The property is used when parsing text nodes. If it is set to true, the text that will be in the body of the node will be the exact text which was set using the method HTMLNode::setText() (The value which will be returned by the method HTMLNode::getOriginalText()). If it is set to false, then the text which is in the body of the node will be the value which is returned by the method HTMLNode::getText().

      Parameters:

      public function setWritingDir(string$val)Sets the value of the attribute 'dir' of the node.

      Parameters:

      • string $val The value to set. It can be 'ltr' or 'rtl'.
      Returns: HTMLNodeThe method will return the instance that this method is called on.
      public function table(array$attributes)Adds a table node (<table>) to the body of the node.

      Parameters:

      • array $attributes An optional array of attributes to set on the child.
      Returns: HTMLNodeThe method will return the newly added instance.
      public function text(string$txt, boolean$escEntities)Adds a text node as a child. The text node will be added to the body of the node only if it is not a void node.

      Parameters:

      • string $txt The text that will be in the node.
      • boolean $escEntities If set to true, the method will replace the characters '<', '>' and '&' with the following HTML entities: '&lt;', '&gt;' and '&amp;' in the given text. Default is true.
      Returns: HTMLNodeThe method will return the instance that this method is called on.
      public function toHTML(boolean$formatted, int$initTab)Returns HTML string that represents the node as a whole.

      Parameters:

      • boolean $formatted Set to true to return a well formatted HTML document (has new lines and indentations). Note that the size of generated node will increase if this one is set to true. Default is false.
      • int $initTab Initial tab count (indentation). Used in case of the document is well formatted. This number represents the size of code indentation.
      Returns: stringHTML string that represents the node.
      public function tr(array$data, array$attributes, boolean$headerRow)Adds a row (<tr>) to the body of the node. The method will create the row as an object of type 'TableRow'. Note that the row will be added only if the node name is 'tbody' or 'table'.

      Parameters:

      • array $data An array that holds the data that will be added to the row. This array can hold strings or objects of type 'HTMLNode'.
      • array $attributes An optional array of attributes to set for the row.
      • boolean $headerRow If set to true, the method will add the data in a 'th' cell instead of 'td' cell. Default is false.
      Returns: HTMLNodeThe method will return the same instance at which the method is called on.
      public function ul(array$items, array$attributes)Adds a list (<ul>) to the body of the node. The method will create an object of type 'UnorderedList' and add it as a child. Note that if the node of type 'ul' or 'ol', nothing will be added.

      Parameters:

      • array $items An array that contains list items. They can be a simple text, objects of type 'ListItem' or object of type 'HTMLNode'. Note that if the list item is a text, the item will be added without placing HTML entities in the text if the text has HTMLCode.
      • array $attributes An optional array of attributes to set for the list.
      Returns: HTMLNodeThe method will always return the same instance at which the method is called on.
      public function valid()Checks if the iterator has more elements or not. This method is only used if the list is used in a 'foreach' loop. The developer should not call it manually unless he knows what he is doing.Returns: booleanIf there is a next element, the method will return true. False otherwise.
      mdi-menuAll Classesmdi-chevron-leftAnchorBrCodeSnippetHTMLDocHTMLListHTMLNodeHTMLTableHeadNodeInputJsCodeLabelListItemOrderedListParagraphRadioGroupTableCellTableRowUnorderedListInvalidNodeNameExceptionTemplateNotFoundExceptionCaseConverterJsonJsonConverterJsonIJsonTypesPropertyAPIFilterAbstractWebServiceManagerInfoServiceParamTypesRequestRequestParameterResponseUriWebServicesManagerAccessAutoLoaderConfigConfigControllerDBEAbstractWebServiceExtendedWebServicesManagerFileLoggerPrivilegePrivilegesGroupThemeThemeLoaderUploadFileUploaderUserUtilWebFioriAppLanguageErrorBoxHTTPCodeViewMessageBoxServerErrViewStarterPageWebPageDatabaseSessionStorageDefaultSessionStorageMSSQLSessionDataTableMSSQLSessionsTableMySQLSessionDataTableMySQLSessionsTableSessionSessionOperationsSessionStorageSessionsManagerRouterRouterUriAbstractMiddlewareMiddlewareManagerEmailMessageSMTPAccountSMTPServerClassLoaderExceptionFileExceptionInitializationExceptionInvalidCRONExprExceptionMissingLangExceptionNoSuchThemeExceptionRoutingExceptionSMTPExceptionSessionExceptionUIExceptionAbstractJobCronCronEmailCronJobJobArgumentCronLoginViewCronTasksViewCronViewCronLoginServiceCronLogoutServiceCronServicesManagerForceCronExecutionServiceGetJobsServiceCLICLICommandInputStreamOutputStreamStdInStdOutClassWriterLangClassWriterQueryClassWriterServiceHolderThemeClassWriterWebServiceWriterCreateCLIClassHelperCreateCronJobCreateMiddlewareCreateTableCreateTableObjCreateThemeHelperCreateWebServiceAddCommandCreateCommandCronCommandHelpCommandListCronCommandListRoutesCommandListThemesCommandRunSQLQueryCommandSettingsCommandTestRouteCommandUpdateSettingsCommandUpdateTableCommandVersionCommandAbstractQueryColumnColumnFactoryConditionConnectionConnectionInfoDatabaseDatabaseExceptionDateTimeValidatorEntityMapperExpressionForeignKeyJoinTableResultSetSelectExpressionTableWhereExpressionMySQLColumnMySQLConnectionMySQLQueryMySQLTableMSSQLColumnMSSQLConnectionMSSQLQueryMSSQLTableAbstractCollectionComparableLinkedListNodeQueueStack
      Powered By: WebFiori Framework, Vue and VuetifyAll Rights Reserved © 2018 - 2024