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

namespace \webfiori\ui

class HTMLDoc

Class Attributes Summary

const NLA constant that represents new line character

Class Methods Summary

public function __construct()Constructs a new HTML document.public function __toString()Returns a string of HTML code that represents the document.public function addChild(HTMLNode|string$node, array$attributes, boolean$chainOnParent)Appends new node to the body of the document.public function asCode(array$formattingOptions)Returns the document as readable HTML code wrapped inside 'pre' element.public function getBody()Returns the node that represents the body of the document.public function getChildByID(string$id)Returns a child node given its ID.public function getChildrenByAttributeValue(string$attrName, string$attrVal)Returns a list that contains a set of elements at which they have specific attribute value.public function getChildrenByTag(string$val)Returns a linked list that contains all children which has the given tag value.public function getDocumentRoot()Returns the node that represents the root of the document.public function getHeadNode()Returns the node that represents the 'head' node.public function getLanguage()Returns the language of the document.public function removeChild(HTMLNode|string$node)Removes a child node from the document.public function saveToHTMLFile(string$path, string$fileName, boolean$wellFormatted)Saves the document to .public function setHeadNode(HeadNode$node)Updates the head node that is used by the document.public function setLanguage(string|null$lang)Sets the language of the document.public function toHTML(boolean$formatted)Returns HTML string that represents the document.

Class Attributes Details

const NLA constant that represents new line character

Class Methods Details

public function __construct()
Constructs a new HTML document. The document that will be generated will look like the following by default:
      <!DOCTYPE html
public function __toString()Returns a string of HTML code that represents the document. Returns: stringA string of HTML code that represents the document.public function addChild(HTMLNode|string$node, array$attributes, boolean$chainOnParent)Appends new node to the body of the document.

Parameters:

  • HTMLNode|string $node The node that will be added. It can be an instance of 'HTMLNode' or tag name. It will be added only if the name of the node is not 'html', 'head' or body.
  • array $attributes An optional array of attributes which will be set in the newly added child.
  • 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 parent level.
Returns: HTMLNodeIf the parameter $chainOnParent is set to true, the method will return the 'body' HTML Node. If set to false, it will return the newly added child.
public function asCode(array$formattingOptions)Returns the document 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 document as readable HTML code wrapped inside 'pre' element.
public function getBody()Returns the node that represents the body of the document. Returns: HTMLNodeThe node that represents the body.public function getChildByID(string$id)Returns a child node given its ID.

Parameters:

  • string $id 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 getChildrenByAttributeValue(string$attrName, string$attrVal)Returns a list that contains a set of elements at which they have specific attribute value.

Parameters:

  • string $attrName The name of the attribute such as 'class' or 'href'.
  • string $attrVal The value of the attribute.
Returns: LinkedListThe method will return an object of type 'LinkedList' that contains all matched nodes.
public function getChildrenByTag(string$val)Returns a linked list that contains all children which has the given tag value.

Parameters:

  • string $val The value of the tag (such as 'div' or 'input').
Returns: LinkedListA linked list that contains all children which has the given tag value.
public function getDocumentRoot()Returns the node that represents the root of the document. The root node of the document is the node which has the name 'html'.Returns: HTMLNodean object of type HTMLNode.public function getHeadNode()Returns the node that represents the 'head' node. Returns: HeadNodeThe node that represents the 'head' node.public function getLanguage()Returns the language of the document. Returns: stringA two characters language code. If the language is not set, the method will return empty string.public function removeChild(HTMLNode|string$node)Removes a child node from the document.

Parameters:

  • HTMLNode|string $node The node that will be removed. This also can be the value of the attribute ID of the node that will be removed.
Returns: HTMLNode|nullThe method will return the node if removed. If not removed, the method will return null.
public function saveToHTMLFile(string$path, string$fileName, boolean$wellFormatted)Saves the document to . html file.

Parameters:

  • string $path The location where the content will be written to (e.g. 'C:\user\html\pages'). must be non empty string.
  • string $fileName The name of the file (such as 'index'). Must be non empty string.
  • boolean $wellFormatted If set to true, The generated file will be well formatted (readable by humans).
Returns: booleanThe method will return true if the file is successfully created. False if not. Default is true.
public function setHeadNode(HeadNode$node)Updates the head node that is used by the document.

Parameters:

Returns: booleanIf head node is set, the method will return true. if it is not set, the method will return false.
public function setLanguage(string|null$lang)Sets the language of the document.

Parameters:

  • string|null $lang A two characters language code. If the given string is empty or its length does not equal to 2, language won't be set. If null is given, then the attribute will be removed if it was set.
Returns: booleanIf the attribute 'lang' of the document is set, or removed, the method will return true. Note that the method will always return true if null is given. Other than that, it will return false.
public function toHTML(boolean$formatted)Returns HTML string that represents the document.

Parameters:

  • boolean $formatted If set to true, The generated HTML code will be well formatted. Default is true. Note that this attribute will take effect only if the formatting option is not set using the method HTMLNode::setIsFormatted().
Returns: stringHTML string that represents the document.
mdi-menuAll Classesmdi-chevron-leftAnchorBrCodeSnippetHTMLDocHTMLListHTMLNodeHTMLTableHeadNodeInputJsCodeLabelListItemOrderedListParagraphRadioGroupTableCellTableRowUnorderedListInvalidNodeNameExceptionTemplateNotFoundExceptionCaseConverterJsonJsonConverterJsonIJsonTypesPropertyAPIFilterAbstractWebServiceManagerInfoServiceParamTypesRequestRequestParameterResponseUriWebServicesManagerAccessAutoLoaderConfigConfigControllerDBEAbstractWebServiceExtendedWebServicesManagerFileLoggerPrivilegePrivilegesGroupThemeThemeLoaderUploadFileUploaderUserUtilWebFioriAppLanguageErrorBoxHTTPCodeViewMessageBoxServerErrViewStarterPageWebPageDatabaseSessionStorageDefaultSessionStorageMSSQLSessionDataTableMSSQLSessionsTableMySQLSessionDataTableMySQLSessionsTableSessionSessionOperationsSessionStorageSessionsManagerRouterRouterUriAbstractMiddlewareMiddlewareManagerEmailMessageSMTPAccountSMTPServerClassLoaderExceptionFileExceptionInitializationExceptionInvalidCRONExprExceptionMissingLangExceptionNoSuchThemeExceptionRoutingExceptionSMTPExceptionSessionExceptionUIExceptionAbstractJobCronCronEmailCronJobJobArgumentCronLoginViewCronTasksViewCronViewCronLoginServiceCronLogoutServiceCronServicesManagerForceCronExecutionServiceGetJobsServiceCLICLICommandInputStreamOutputStreamStdInStdOutClassWriterLangClassWriterQueryClassWriterServiceHolderThemeClassWriterWebServiceWriterCreateCLIClassHelperCreateCronJobCreateMiddlewareCreateTableCreateTableObjCreateThemeHelperCreateWebServiceAddCommandCreateCommandCronCommandHelpCommandListCronCommandListRoutesCommandListThemesCommandRunSQLQueryCommandSettingsCommandTestRouteCommandUpdateSettingsCommandUpdateTableCommandVersionCommandAbstractQueryColumnColumnFactoryConditionConnectionConnectionInfoDatabaseDatabaseExceptionDateTimeValidatorEntityMapperExpressionForeignKeyJoinTableResultSetSelectExpressionTableWhereExpressionMySQLColumnMySQLConnectionMySQLQueryMySQLTableMSSQLColumnMSSQLConnectionMSSQLQueryMSSQLTableAbstractCollectionComparableLinkedListNodeQueueStack
Powered By: WebFiori Framework, Vue and VuetifyAll Rights Reserved © 2018 - 2024