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

namespace \webfiori\framework\ui

class WebPage

Class Attributes Summary

const MAIN_ELEMENTSAn array that contains the IDs of the 3 main page elements.

Class Methods Summary

public function __construct()Creates new instance of the class.public function addBeforeRender(callback$callable, array$params)Adds a function which will be executed before the page is fully rendered.public function addCSS(string$href, array$attrs)Adds new CSS source file.public function addJS(string$src, array$attrs)Adds new JavsScript source file.public function addMeta(string$name, string$content, boolean$override)Adds new meta tag.public function createHTMLNode(array$nodeInfo)Create HTML node based on the method which exist on the applied theme.public function get(string$label)Returns the value of a language label.public function getActiveSession()Returns the session which is currently active.public function getBase()Returns the value of the attribute 'href' of the node 'base' of page document.public function getCanonical()Returns the canonical URL of the page.public function getChildByID(string$id)Returns a child node given its ID.public function getDescription()Returns the description of the page.public function getDocument()Returns the document that is associated with the page.public function getLangCode()Returns the language code of the page.public function getTheme()Returns an object which holds applied theme information.public function getThemeCSSDir()Returns the name of the directory at which CSS files of the applied theme exists.public function getThemeImagesDir()Returns the name of the directory at which image files of the applied theme exists.public function getThemeJSDir()Returns the name of the directory at which JavaScript files of the applied theme exists.public function getTitle()Returns the title of the page.public function getTitleSep()Returns the character or string that is used to separate web page title and web site name.public function getTranslation()Returns an object which holds i18n labels.public function getWebsiteName()Returns the name of the web site.public function getWritingDir()Returns the writing direction of the page.public function hasAside()Checks if the page will have an aside section or not.public function hasFooter()Checks if the page will have a footer section or not.public function hasHeader()Checks if the page will have a header section or not.public function includeI18nLables(boolean|null$bool)Sets the value of the property which is used to determine if the JavaScript variable 'window.public function insert(HTMLNode|string$node, string$parentNodeId)Adds a child node inside the body of a node given its ID.public function isThemeLoaded()Checks if a theme is loaded or not.public function removeChild(HTMLNode|string$node)Removes a child node from the document of the page.public function render(boolean$formatted, boolean$returnResult)Display the page in the web browser or gets the rendered document as string.public function reset()Resets page attributes to default values.public function setCanonical(string$url)Sets the canonical URL of the page.public function setDescription(string$val)Sets the description of the page.public function setHasAside(boolean$bool)Sets the property that is used to check if page has an aside section or not.public function setHasFooter(boolean$bool)Sets the property that is used to check if page has a footer section or not.public function setHasHeader(boolean$bool)Sets the property that is used to check if page has a header section or not.public function setLang(string$lang)Sets the display language of the page.public function setTheme(string$themeNameOrClass)Loads a theme given its name.public function setTitle(string$val)Sets the title of the page.public function setTitleSep(string$str)Sets the character or string that is used to separate web page title.public function setWebsiteName(string$name)Sets the name of the web site.public function setWritingDir(string$dir)Sets the writing direction of the page.

Class Attributes Details

const MAIN_ELEMENTSAn array that contains the IDs of the 3 main page elements. The array has the following values:
  • page-body
  • page-header
  • main-content-area
  • side-content-area
  • page-footer

Class Methods Details

public function __construct()Creates new instance of the class. public function addBeforeRender(callback$callable, array$params)Adds a function which will be executed before the page is fully rendered. The function will be executed when the method 'WebPage::render()' is called. One possible use is to do some modifications to the DOM before the page is displayed. It is possible to have multiple callbacks.

Parameters:

  • callback $callable A PHP function that will be get executed. before the page is rendered. Note that the first argument of the function will always be an object of type "WebPage".
  • array $params An array of parameters which will be passed to the callback. The parameters can be accessed in the callback in the same order at which they appear in the array.
Returns: int|nullIf the callable is added, the method will return a number that represents its ID. If not added, the method will return null.
public function addCSS(string$href, array$attrs)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.
  • array $attrs An associative array of additional attributes to set for the node. One special attribute has the name 'revision'. If set to true, a query string parameter in the form '?cv=x.x' is appended to the 'href' attribute value. The 'x.x' represent application version taken from the class 'AppConfig' Default value of the attribute is true.
public function addJS(string$src, array$attrs)Adds new JavsScript source file.

Parameters:

  • string $src The location of the file. Must be non-empty string. It can have query string at the end.
  • array $attrs An associative array of additional attributes to set for the JavaScript node. One special attribute has the name 'revision'. If set to true, a query string parameter in the form '?jv=x.x' is appended to the 'href' attribute value. The 'x.x' represent application version taken from the class 'AppConfig' Default value of the attribute is true.
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 parameter. 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 createHTMLNode(array$nodeInfo)Create HTML node based on the method which exist on the applied theme. This method can be only used if a theme is applied and the method Theme::createHTMLNode() is implemented.

Parameters:

  • array $nodeInfo An array that holds node information.
Returns: HTMLNode|nullThe returned HTML node will depend on how the developer has implemented the method Theme::createHTMLNode(). If no theme is applied, the method will return null.
public function get(string$label)Returns the value of a language label.

Parameters:

  • string $label A directory to the language variable (such as 'pages/login/login-label').
Returns: string|arrayIf the given directory represents a label, the method will return its value. If it represents an array, the array will be returned. If nothing was found, the returned value will be the passed value to the method.
public function getActiveSession()Returns the session which is currently active. Returns: Session|nullIf a session is active, the method will return its data stored in an object. If no session is active, the method will return null.public function getBase()Returns the value of the attribute 'href' of the node 'base' of page document. Returns: string|nullIf the base URL is set, the method will return its value. If the value of the base URL is not set, the method will return null.public function getCanonical()Returns the canonical URL of the page. Returns: null|stringThe method will return the canonical URL of the page if set. If not, the method will return null.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 getDescription()Returns the description of the page. Returns: string|nullThe description of the page. If the description is not set, the method will return null.public function getDocument()Returns the document that is associated with the page. Returns: HTMLDocAn object of type 'HTMLDoc'.public function getLangCode()Returns the language code of the page. Returns: string|nullTwo digit language code. In case language is not set, the method will return nullpublic function getTheme()Returns an object which holds applied theme information. Returns: Theme|nullIf no theme is applied, the method will return null. Other than than, the method will return an object that holds applied theme info.public function getThemeCSSDir()Returns the name of the directory at which CSS files of the applied theme exists. Returns: stringThe directory at which CSS files of the theme exists (e.g. 'assets/my-theme/css' ). The folder will always exist inside the folder 'public/assets'. If no theme is applied, the method will return empty string.public function getThemeImagesDir()Returns the name of the directory at which image files of the applied theme exists. Returns: stringThe directory at which image files of the theme exists (e.g. 'assets/my-theme/images' ). If no theme is applied, the method will return empty string.public function getThemeJSDir()Returns the name of the directory at which JavaScript files of the applied theme exists. Returns: stringThe directory at which JavaScript files of the theme exists (e.g. 'assets/my-theme/js' ). If no theme is applied, the method will return empty string.public function getTitle()Returns the title of the page. Returns: string|nullThe title of the page. Default return value is 'Default X'.public function getTitleSep()Returns the character or string that is used to separate web page title and web site name. Returns: stringThe character or string that is used to separate web page title and web site name. If the separator was not set using the method WebPage::setTitleSep(), the returned value will be ' | '.public function getTranslation()Returns an object which holds i18n labels. Returns: LanguageThe returned object labels will be based on the language of the page.public function getWebsiteName()Returns the name of the web site. Returns: stringThe name of the web site. If the name was not set using the method WebPage::siteName(), the returned value will be 'My X Website'.public function getWritingDir()Returns the writing direction of the page. Returns: string|null'ltr' or 'rtl'. If the writing direction is not set, the method will return null.public function hasAside()Checks if the page will have an aside section or not. Returns: booleantrue if the page has an aside section.public function hasFooter()Checks if the page will have a footer section or not. Returns: booleantrue if the page has a footer section.public function hasHeader()Checks if the page will have a header section or not. Returns: booleantrue if the page has a header section.public function includeI18nLables(boolean|null$bool)Sets the value of the property which is used to determine if the JavaScript variable 'window. i18n' will be included or not.

Parameters:

  • boolean|null $bool true to include it. False to not. Passing null will cause no change.
Returns: booleanThe method will return true if the variable will be included. False if not. Default return value is true.
public function insert(HTMLNode|string$node, string$parentNodeId)Adds a child node inside the body of a node given its ID.

Parameters:

  • HTMLNode|string $node The node that will be inserted. Also, this can be the tag name of the node such as 'div'.
  • string $parentNodeId The ID of the node that the given node will be inserted to. Default value is 'main-content-area'.
Returns: HTMLNode|nullThe method will return the inserted node if it was inserted. If it is not, the method will return null.
public function isThemeLoaded()Checks if a theme is loaded or not. Returns: booleantrue if loaded. false if not loaded.public function removeChild(HTMLNode|string$node)Removes a child node from the document of the page.

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 render(boolean$formatted, boolean$returnResult)Display the page in the web browser or gets the rendered document as string.

Parameters:

  • boolean $formatted If this parameter is set to true, the rendered HTML document will be well formatted and readable. Note that by adding formatting to the page, the size of rendered HTML document will increase. The document will be compressed if this parameter is set to false. Default is false.
  • boolean $returnResult If this parameter is set to true, the method will return the rendered HTML document as string. Default value is false.
Returns: null|HTMLDocIf the parameter $returnResult is set to true, the method will return an object of type 'HTMLDoc' that represents the rendered page. Other than that, it will return null.
public function reset()Resets page attributes to default values. public function setCanonical(string$url)Sets the canonical URL of the page. Note that if empty string is given, it won't be set. To unset the canonical, use 'null' as value.

Parameters:

  • string $url The canonical URL of the page.
public function setDescription(string$val)Sets the description of the page.

Parameters:

  • string $val The description of the page. If null is given, the description meta tag will be removed from the <head> node. If empty string is given, nothing will change.
public function setHasAside(boolean$bool)Sets the property that is used to check if page has an aside section or not.

Parameters:

  • boolean $bool true to include aside section. false if not.
public function setHasFooter(boolean$bool)Sets the property that is used to check if page has a footer section or not.

Parameters:

  • boolean $bool true to include the footer section. false if not.
public function setHasHeader(boolean$bool)Sets the property that is used to check if page has a header section or not.

Parameters:

  • boolean $bool true to include the header section. false if not.
public function setLang(string$lang)Sets the display language of the page. The length of the given string must be 2 characters in order to set the language code.

Parameters:

  • string $lang a two digit language code such as AR or EN. Default value is 'EN'.
public function setTheme(string$themeNameOrClass)Loads a theme given its name.

Parameters:

  • string $themeNameOrClass The name of the theme as specified by the variable 'name' in theme definition. If the given name is 'null', the method will load the default theme as specified by the method 'AppConfig::getBaseThemeName()'. Note that once the theme is updated, the document content of the page will reset if it was set before calling this method. This also can be the value which can be taken from 'ClassName::class'.
public function setTitle(string$val)Sets the title of the page.

Parameters:

  • string $val The title of the page. If null is given, the title will not updated. Also note that if page document was created, calling this method will set the value of the <titlt> node. The format of the title is PAGE_NAME TITLE_SEP WEBSITE_NAME. for example, if the page name is 'Home' and title separator is '|' and the name of the website is 'Programming Academia'. The title of the page will be 'Home | Programming Academia'.
public function setTitleSep(string$str)Sets the character or string that is used to separate web page title. The given character or string is used in setting the title of the page. The format of the title is 'PAGE_NAME TITLE_SEP WEBSITE_NAME'. for example, if the page name is 'Home' and title separator is '|' and the name of the web site is 'Programming Academia'. The title of the page will be 'Home | Programming Academia'. The character be updated only if the given string is not empty. Also note that if page document was created, calling this method will set the value of the <titlt> node.

Parameters:

  • string $str The new character or string that will be used to separate page title and web site name.
public function setWebsiteName(string$name)Sets the name of the web site. The name of the web site is used in setting the title of the page. The format of the title is 'PAGE_NAME TITLE_SEP WEBSITE_NAME'. for example, if the page name is 'Home' and title separator is '|' and the name of the web site is 'Programming Academia'. The title of the page will be 'Home | Programming Academia'. The name will be updated only if the given string is not empty. Also note that if page document was created, calling this method will set the value of the <titlt> node.

Parameters:

  • string $name The name of the web site that will be appended with the title of the page.
public function setWritingDir(string$dir)Sets the writing direction of the page.

Parameters:

  • string $dir Language::DIR_LTR or Language::DIR_RTL.
Returns: booleanTrue if the direction was not set and its the first time to set. if it was set before, the method will return false.
mdi-menuAll Classesmdi-chevron-leftAnchorBrCodeSnippetHTMLDocHTMLListHTMLNodeHTMLTableHeadNodeInputJsCodeLabelListItemOrderedListParagraphRadioGroupTableCellTableRowUnorderedListInvalidNodeNameExceptionTemplateNotFoundExceptionCaseConverterJsonJsonConverterJsonIJsonTypesPropertyAPIFilterAbstractWebServiceManagerInfoServiceParamTypesRequestRequestParameterResponseUriWebServicesManagerAccessAutoLoaderConfigConfigControllerDBEAbstractWebServiceExtendedWebServicesManagerFileLoggerPrivilegePrivilegesGroupThemeThemeLoaderUploadFileUploaderUserUtilWebFioriAppLanguageErrorBoxHTTPCodeViewMessageBoxServerErrViewStarterPageWebPageDatabaseSessionStorageDefaultSessionStorageMSSQLSessionDataTableMSSQLSessionsTableMySQLSessionDataTableMySQLSessionsTableSessionSessionOperationsSessionStorageSessionsManagerRouterRouterUriAbstractMiddlewareMiddlewareManagerEmailMessageSMTPAccountSMTPServerClassLoaderExceptionFileExceptionInitializationExceptionInvalidCRONExprExceptionMissingLangExceptionNoSuchThemeExceptionRoutingExceptionSMTPExceptionSessionExceptionUIExceptionAbstractJobCronCronEmailCronJobJobArgumentCronLoginViewCronTasksViewCronViewCronLoginServiceCronLogoutServiceCronServicesManagerForceCronExecutionServiceGetJobsServiceCLICLICommandInputStreamOutputStreamStdInStdOutClassWriterLangClassWriterQueryClassWriterServiceHolderThemeClassWriterWebServiceWriterCreateCLIClassHelperCreateCronJobCreateMiddlewareCreateTableCreateTableObjCreateThemeHelperCreateWebServiceAddCommandCreateCommandCronCommandHelpCommandListCronCommandListRoutesCommandListThemesCommandRunSQLQueryCommandSettingsCommandTestRouteCommandUpdateSettingsCommandUpdateTableCommandVersionCommandAbstractQueryColumnColumnFactoryConditionConnectionConnectionInfoDatabaseDatabaseExceptionDateTimeValidatorEntityMapperExpressionForeignKeyJoinTableResultSetSelectExpressionTableWhereExpressionMySQLColumnMySQLConnectionMySQLQueryMySQLTableMSSQLColumnMSSQLConnectionMSSQLQueryMSSQLTableAbstractCollectionComparableLinkedListNodeQueueStack
Powered By: WebFiori Framework, Vue and VuetifyAll Rights Reserved © 2018 - 2024