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

namespace \webfiori\ui

class HeadNode

Class Attributes Summary

const ALLOWED_CHILDRENAn array that contains the names of allowed child tags.

Class Methods Summary

public function __construct(string$title, string$canonical, string$base)Creates new HTML node that represents head tag of HTML document.public function addAlternate(string$url, string$lang, array$otherAttrs)Adds new alternate tag to the header.public function addCSS(string$href, $otherAttrsAn)Adds new CSS source file.public function addChild(HTMLNode$node, array|boolean$attrs, boolean$chainOnParent)Adds new child node.public function addJs(string$loc, $otherAttrsAn)Adds new JavsScript source file.public function addLink(string$rel, string$href, array$otherAttrs)Adds new 'link' node.public function addMeta(string$name, string$content, boolean$override)Adds new meta tag.public function getAlternates()Returns a linked list of all alternate nodes that was added to the header.public function getBaseNode()Returns a node that represents the tag 'base'.public function getBaseURL()Returns the value of the attribute 'href' of the node 'base'.public function getCSSNodes()Returns a linked list of all link tags that link to a CSS file.public function getCanonical()Returns the canonical URL if set.public function getCanonicalNode()Returns an object of type HTMLNode that represents the canonical URL.public function getCharSet()Returns the value of the attribute 'charset' of the meta tag that is used to specify character set of the document.public function getCharsetNode()Returns an object of type HTMLNode that represents the meta tag which has the attribute 'charset'.public function getJSNodes()Returns a linked list of all script tags that link to a JS file.public function getLinkNodes()Returns a linked list of all link tags which has the name 'link'.public function getMeta(string$name)Returns HTML node that represents a meta tag.public function getMetaNodes()Returns a linked list of all meta tags.public function getTitle()Returns the text that was set for the note 'title'.public function getTitleNode()Returns an object of type HTMLNode that represents the title node.public function hasCss(string$loc)Checks if a CSS node with specific 'href' does exist or not.public function hasJs(string$src)Checks if a JavaScript node with specific 'src' value does exist or not.public function hasMeta(string$name)Checks if a meta tag which has the given name exist or not.public function setBase(string|null$url)Sets the value of the attribute 'href' for the 'base' tag.public function setCanonical(string|null$link)Sets the canonical URL.public function setCharSet(string|null$charset)Set the value of the meta tag which has the attribute 'charset'.public function setTitle(string|null$title)Sets the text value of the node 'title'.

Class Attributes Details

const ALLOWED_CHILDRENAn array that contains the names of allowed child tags. The array has the following values:
  • base
  • title
  • meta
  • link
  • script
  • noscript
  • #COMMENT
  • style

Class Methods Details

public function __construct(string$title, string$canonical, string$base)
Creates new HTML node that represents head tag of HTML document. Note that by default, the node will have the following nodes in its body:
  • A meta tag with "name"="viewport" and "content"="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
  • A title tag.

Parameters:

  • string $title The value to set for the node 'title'. Default is 'Default'.
  • string $canonical The value to set for the link node with attribute = 'canonical'. Default is empty string.
  • string $base The value to set for the node 'base'. Default is empty string.
public function addAlternate(string$url, string$lang, array$otherAttrs)Adds new alternate tag to the header.

Parameters:

  • string $url The link to the alternate page. Must be non-empty string.
  • string $lang The language of the page. Must be non-empty string.
  • array $otherAttrs An associative array of additional attributes to set for the node. The indices are the names of attributes and the value of each index is the value of the attribute. Also, the array can only have attribute name if its empty attribute. Default is empty array.
Returns: HeadNoteThe method will return the instance at which the method is called on.
public function addCSS(string$href, $otherAttrsAn)Adds new CSS source file.

Parameters:

  • string $href The link to the file. Must be non empty string. It is possible to append query string to the end of the link.
  • $otherAttrs An associative array of additional attributes to set for the node. The indices are the names of attributes and the value of each index is the value of the attribute. Also, the array can only have attribute name if its empty attribute. One special attribute is 'revision'. If this attribute is set to true, a string in the form '?cv=xxxxxxxxxx' will be appended to the 'href' attribute value. It is used to invalidate browser cache. This one can be also a string that represents the version of CSS file. Default is false. 'cv' = CSS Version. Default is empty array.
Returns: HeadNoteThe method will return the instance at which the method is called on.
public function addChild(HTMLNode$node, array|boolean$attrs, boolean$chainOnParent)Adds new child node.

Parameters:

  • HTMLNode $node The node that will be added. The node will be added only if the following conditions are met:
    • It must be not a 'title' or 'base' node.
    • It is a 'link' node but 'rel' attribute is not 'canonical'.
    • It is a 'script' or 'noscript' node.
    • It is a 'meta' node which is not added before.
    • It is a '#COMMENT' node.
    Other than that, the node will be not added.
  • array|boolean $attrs Not used if array is given. If boolean is given, it will be treated as last method argument.
  • 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 true. It means the chaining will happen at parent level.
Returns: HeadNode|HTMLNode|nullIf 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. Note that if no child is added, the method will return null.
public function addJs(string$loc, $otherAttrsAn)Adds new JavsScript source file.

Parameters:

  • string $loc The location of the file. Must be non-empty string. It can have query string at the end.
  • $otherAttrs An associative array of additional attributes to set for the node. The indices are the names of attributes and the value of each index is the value of the attribute. Also, the array can only have attribute name if its empty attribute. One special attribute is 'revision'. If the attribute is set to true, a string in the form '?jv=xxxxxxxxxx' will be appended to the 'src' attribute value. It is used to invalidate browser cache. This also can be a string that represents the version of the file. 'jv' = JavaScript Version. Default is empty array.
Returns: HeadNoteThe method will return the instance at which the method is called on.
public function addLink(string$rel, string$href, array$otherAttrs)Adds new 'link' node. Note that if the 'rel' attribute value is 'canonical' or 'alternate', no node will be created.

Parameters:

  • string $rel The value of the attribute 'rel'.
  • string $href The value of the attribute 'href'.
  • array $otherAttrs An associative array of keys and values. The keys will be used as an attribute and the key value will be used as attribute value.
Returns: HeadNoteThe method will return the instance at which the method is called on.
public function addMeta(string$name, string$content, boolean$override)Adds new meta tag.

Parameters:

  • string $name The value of the property 'name'. Must be non empty string.
  • string $content The value of the property 'content'.
  • boolean $override A boolean attribute. If a meta node was found which has the given name and this attribute is set to true, the content of the meta will be overridden by the passed value.
Returns: HeadNoteThe method will return the instance at which the method is called on.
public function getAlternates()Returns a linked list of all alternate nodes that was added to the header. Returns: LinkedList public function getBaseNode()Returns a node that represents the tag 'base'. Note that the base note has a fixed position in the head node which is 0.Returns: HTMLNodeA node that represents the tag 'base'.public function getBaseURL()Returns the value of the attribute 'href' of the node 'base'. Returns: string|nullThe value of the attribute 'href' of the node 'base'. if the value of the base URL is not set, the method will return null.public function getCSSNodes()Returns a linked list of all link tags that link to a CSS file. Returns: LinkedListA linked list of all link tags that link to a CSS file. If the node has no CSS link tags, the method will return an empty list.public function getCanonical()Returns the canonical URL if set. Returns: string|nullThe canonical URL if set. If the URL is not set, the method will return null.public function getCanonicalNode()Returns an object of type HTMLNode that represents the canonical URL. Returns: HTMLNode|nullIf the canonical URL is set, the method will return an object of type HTMLNode. If not set, the method will return null.public function getCharSet()Returns the value of the attribute 'charset' of the meta tag that is used to specify character set of the document. Returns: string|nullA string such as 'UTF-8'. If character set is not set, the method will return null.public function getCharsetNode()Returns an object of type HTMLNode that represents the meta tag which has the attribute 'charset'. Note that the node that represents charset of the will always have a position between 0 and 2 in the body of the head node.Returns: HTMLNodeAn object of type HTMLNode.public function getJSNodes()Returns a linked list of all script tags that link to a JS file. Returns: LinkedListA linked list of all script tags with type = "text/javascript". If the node has no such nodes, the list will be empty.public function getLinkNodes()Returns a linked list of all link tags which has the name 'link'. Returns: LinkedListA linked list of all link tags which has the name 'link'. the node has no link tags, the method will return an empty list.public function getMeta(string$name)Returns HTML node that represents a meta tag.

Parameters:

  • string $name The value of the attribute 'name' of the meta tag. Note that if the meta node that you would like to get is the tag which has the attribute 'charset', then the passed attribute must have the value 'charset'.
Returns: HTMLNode|nullIf a meta tag which has the given name was found, It will be returned. If no meta node was found, null is returned.
public function getMetaNodes()Returns a linked list of all meta tags. Returns: LinkedListA linked list of all meta tags. If the node has no meta nodes, the list will be empty.public function getTitle()Returns the text that was set for the note 'title'. Returns: stringThe text that was set for the note 'title'. If it was not set, the method will return empty string.public function getTitleNode()Returns an object of type HTMLNode that represents the title node. Note that the title node will be always in position 0 or 1 in the body of the head node.Returns: HTMLNodeThe method will return an object of type HTMLNode that represents title node.public function hasCss(string$loc)Checks if a CSS node with specific 'href' does exist or not. Note that the method will not check for query string in the passed value. It will simply ignore it.

Parameters:

  • string $loc The value of the attribute 'href' of the CSS node.
Returns: booleanIf a link node with the given 'href' value does exist, the method will return true. Other than that, the method will return false.
public function hasJs(string$src)Checks if a JavaScript node with specific 'src' value does exist or not. Note that the method will not check for query string in the passed value. It will simply ignore it.

Parameters:

  • string $src The value of the attribute 'src' of the script node.
Returns: booleanIf a JavaScript node with the given 'src' value does exist, the method will return true. Other than that, the method will return false.
public function hasMeta(string$name)Checks if a meta tag which has the given name exist or not.

Parameters:

  • string $name The value of the attribute 'name' of the meta tag. If the developer would like to check for the existence of the node which has the attribute 'charset', he can pass the value 'charset'.
Returns: booleanIf a meta tag which has the given name was found, true is returned. false otherwise.
public function setBase(string|null$url)Sets the value of the attribute 'href' for the 'base' tag.

Parameters:

  • string|null $url The value to set. The base URL will be updated only if the given parameter is a string and it is not empty. If null is given, the node will be removed from the body of the head tag.
Returns: HeadNoteThe method will return the instance at which the method is called on.
public function setCanonical(string|null$link)Sets the canonical URL. Note that the canonical URL will be set only if the given string is not empty. Also, the node will always have a position between 0 and 3 in the body of the head node.

Parameters:

  • string|null $link The URL to set. If null is given, the link node which represents the canonical URL will be removed from the body of the head tag.
Returns: HeadNoteThe method will return the instance at which the method is called on.
public function setCharSet(string|null$charset)Set the value of the meta tag which has the attribute 'charset'.

Parameters:

  • string|null $charset The character set that will be used to render the document (such as 'UTF-8' or 'ISO-8859-8'. If null is given, the node will be removed from the head body.
Returns: HeadNoteThe method will return the instance at which the method is called on.
public function setTitle(string|null$title)Sets the text value of the node 'title'.

Parameters:

  • string|null $title The title to set. It must be non-empty string in order to set. If null is given, 'title' node will be omitted from the body of the 'head' tag.
Returns: HeadNoteThe method will return the instance at which the method is called on.
mdi-menuAll Classesmdi-chevron-leftAnchorBrCodeSnippetHTMLDocHTMLListHTMLNodeHTMLTableHeadNodeInputJsCodeLabelListItemOrderedListParagraphRadioGroupTableCellTableRowUnorderedListInvalidNodeNameExceptionTemplateNotFoundExceptionCaseConverterJsonJsonConverterJsonIJsonTypesPropertyAPIFilterAbstractWebServiceManagerInfoServiceParamTypesRequestRequestParameterResponseUriWebServicesManagerAccessAutoLoaderConfigConfigControllerDBEAbstractWebServiceExtendedWebServicesManagerFileLoggerPrivilegePrivilegesGroupThemeThemeLoaderUploadFileUploaderUserUtilWebFioriAppLanguageErrorBoxHTTPCodeViewMessageBoxServerErrViewStarterPageWebPageDatabaseSessionStorageDefaultSessionStorageMSSQLSessionDataTableMSSQLSessionsTableMySQLSessionDataTableMySQLSessionsTableSessionSessionOperationsSessionStorageSessionsManagerRouterRouterUriAbstractMiddlewareMiddlewareManagerEmailMessageSMTPAccountSMTPServerClassLoaderExceptionFileExceptionInitializationExceptionInvalidCRONExprExceptionMissingLangExceptionNoSuchThemeExceptionRoutingExceptionSMTPExceptionSessionExceptionUIExceptionAbstractJobCronCronEmailCronJobJobArgumentCronLoginViewCronTasksViewCronViewCronLoginServiceCronLogoutServiceCronServicesManagerForceCronExecutionServiceGetJobsServiceCLICLICommandInputStreamOutputStreamStdInStdOutClassWriterLangClassWriterQueryClassWriterServiceHolderThemeClassWriterWebServiceWriterCreateCLIClassHelperCreateCronJobCreateMiddlewareCreateTableCreateTableObjCreateThemeHelperCreateWebServiceAddCommandCreateCommandCronCommandHelpCommandListCronCommandListRoutesCommandListThemesCommandRunSQLQueryCommandSettingsCommandTestRouteCommandUpdateSettingsCommandUpdateTableCommandVersionCommandAbstractQueryColumnColumnFactoryConditionConnectionConnectionInfoDatabaseDatabaseExceptionDateTimeValidatorEntityMapperExpressionForeignKeyJoinTableResultSetSelectExpressionTableWhereExpressionMySQLColumnMySQLConnectionMySQLQueryMySQLTableMSSQLColumnMSSQLConnectionMSSQLQueryMSSQLTableAbstractCollectionComparableLinkedListNodeQueueStack
Powered By: WebFiori Framework, Vue and VuetifyAll Rights Reserved © 2018 - 2024