JDocumentHTML
Extends \JDocumentDocumentHTML class, provides an easy interface to parse and display a HTML document
This class allows for simple but smart objects with get and set methods and an internal error handler.
package |
Joomla.Platform |
---|---|
subpackage |
Document |
since |
11.1 |
Methods
__construct
Class constructor, overridden in descendant classes.
__construct(mixed $properties = null)
since |
11.1 |
---|
Arguments
- $properties
mixed
Either and associative array or another object to set the initial properties of the object.
__toString
Magic method to convert the object to a string gracefully.
__toString() : string
since |
11.1 |
---|---|
deprecated |
12.3 Classes should provide their own __toString() implementation. |
Response
string
The classname.
_fetchTemplate
Fetch the template, and initialise the params
_fetchTemplate(array $params = array()) : \JDocumentHTML
since |
11.1 |
---|
Arguments
- $params
array
Parameters to determine the template
Response
\JDocumentHTML
instance of $this to allow chaining
_getLineEnd
Returns the lineEnd
_getLineEnd() : string
since |
11.1 |
---|
Response
string
_getTab
Returns a string containing the unit for indenting HTML
_getTab() : string
since |
11.1 |
---|
Response
string
_loadTemplate
Load a template file
_loadTemplate(string $directory, string $filename) : string
since |
11.1 |
---|
Arguments
- $directory
string
The name of the template- $filename
string
The actual filename
Response
string
The contents of the template
_parseTemplate
Parse a document template
_parseTemplate() : \The
since |
11.1 |
---|
Response
\The
parsed contents of the template
_renderTemplate
Render pre-parsed template
_renderTemplate() : string
since |
11.1 |
---|
Response
string
rendered template
addCustomTag
Adds a custom HTML string to the head block
addCustomTag(string $html) : \JDocumentHTML
since |
11.1 |
---|
Arguments
- $html
string
The HTML to add to the head
Response
\JDocumentHTML
instance of $this to allow chaining
addFavicon
Adds a shortcut icon (favicon)
addFavicon(string $href, string $type = 'image/vnd.microsoft.icon', string $relation = 'shortcut icon') : \JDocumentHTML
This adds a link to the icon shown in the favorites list or on the left of the url in the address bar. Some browsers display it on the tab, as well.
since |
11.1 |
---|
Arguments
- $href
string
The link that is being related.- $type
string
File type- $relation
string
Relation of link
Response
\JDocumentHTML
instance of $this to allow chaining
addHeadLink
Adds tags to the head of the document
addHeadLink(string $href, string $relation, string $relType = 'rel', array $attribs = array()) : \JDocumentHTML
$relType defaults to 'rel' as it is the most common relation type used. ('rev' refers to reverse relation, 'rel' indicates normal, forward relation.) Typical tag:
since |
11.1 |
---|
Arguments
- $href
string
The link that is being related.- $relation
string
Relation of link.- $relType
string
Relation type attribute. Either rel or rev (default: 'rel').- $attribs
array
Associative array of remaining attributes.
Response
\JDocumentHTML
instance of $this to allow chaining
addScript
Adds a linked script to the page
addScript(string $url, string $type = "text/javascript", boolean $defer = false, boolean $async = false) : \JDocument
since |
11.1 |
---|
Arguments
- $url
string
URL to the linked script- $type
string
Type of script. Defaults to 'text/javascript'- $defer
boolean
Adds the defer attribute.- $async
boolean
Adds the async attribute.
Response
\JDocument
instance of $this to allow chaining
addScriptDeclaration
Adds a script to the page
addScriptDeclaration(string $content, string $type = 'text/javascript') : \JDocument
since |
11.1 |
---|
Arguments
- $content
string
Script- $type
string
Scripting mime (defaults to 'text/javascript')
Response
\JDocument
instance of $this to allow chaining
addStyleDeclaration
Adds a stylesheet declaration to the page
addStyleDeclaration(string $content, string $type = 'text/css') : \JDocument
since |
11.1 |
---|
Arguments
- $content
string
Style declarations- $type
string
Type of stylesheet (defaults to 'text/css')
Response
\JDocument
instance of $this to allow chaining
addStyleSheet
Adds a linked stylesheet to the page
addStyleSheet(string $url, string $type = 'text/css', string $media = null, array $attribs = array()) : \JDocument
since |
11.1 |
---|
Arguments
- $url
string
URL to the linked style sheet- $type
string
Mime encoding type- $media
string
Media type that this stylesheet applies to- $attribs
array
Array of attributes
Response
\JDocument
instance of $this to allow chaining
countMenuChildren
Count the number of child menu items
countMenuChildren() : integer
since |
11.1 |
---|
Response
integer
Number of child menu items
countModules
Count the modules based on the given condition
countModules(string $condition) : integer
since |
11.1 |
---|
Arguments
- $condition
string
The condition to use
Response
integer
Number of modules found
def
Sets a default value if not alreay assigned
def(string $property, mixed $default = null) : mixed
since |
11.1 |
---|
Arguments
- $property
string
The name of the property.- $default
mixed
The default value.
Response
mixed
get
Returns a property of the object or the default value if the property is not set.
get(string $property, mixed $default = null) : mixed
since |
11.1 |
---|---|
see | \JObject::getProperties() |
Arguments
- $property
string
The name of the property.- $default
mixed
The default value.
Response
mixed
The value of the property.
getBase
Return the base URI of the document.
getBase() : string
since |
11.1 |
---|
Response
string
getBuffer
Get the contents of the document buffer
getBuffer() : \The
since |
11.1 |
---|
Response
\The
contents of the document buffer
getCharset
Returns the document charset encoding.
getCharset() : string
since |
11.1 |
---|
Response
string
getDescription
Return the title of the page.
getDescription() : string
since |
11.1 |
---|
Response
string
getDirection
Returns the document direction declaration.
getDirection() : string
since |
11.1 |
---|
Response
string
getError
Get the most recent error message.
getError(integer $i = null, boolean $toString = true) : string
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Arguments
- $i
integer
Option error index.- $toString
boolean
Indicates if JError objects should return their error message.
Response
string
Error message
getErrors
Return all errors, if any.
getErrors() : array
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Response
array
Array of error messages or JErrors.
getGenerator
Returns the document generator
getGenerator() : string
since |
11.1 |
---|
Response
string
getHeadData
Get the HTML document head data
getHeadData() : array
since |
11.1 |
---|
Response
array
The document head data in array form
getInstance
Returns the global JDocument object, only creating it if it doesn't already exist.
getInstance(string $type = 'html', array $attributes = array()) : object
since |
11.1 |
---|
Arguments
- $type
string
The document type to instantiate- $attributes
array
Array of attributes
Response
object
The document object.
getLanguage
Returns the document language.
getLanguage() : string
since |
11.1 |
---|
Response
string
getLink
Returns the document base url
getLink() : string
since |
11.1 |
---|
Response
string
getMetaData
Gets a meta tag.
getMetaData(string $name, boolean $httpEquiv = false) : string
since |
11.1 |
---|
Arguments
- $name
string
Value of name or http-equiv tag- $httpEquiv
boolean
META type "http-equiv" defaults to null
Response
string
getMimeEncoding
Return the document MIME encoding that is sent to the browser.
getMimeEncoding() : string
since |
11.1 |
---|
Response
string
getModifiedDate
Returns the document modified date
getModifiedDate() : string
since |
11.1 |
---|
Response
string
getProperties
Returns an associative array of object properties.
getProperties(boolean $public = true) : array
since |
11.1 |
---|---|
see | \JObject::get() |
Arguments
- $public
boolean
If true, returns only the public properties.
Response
array
getTitle
Return the title of the document.
getTitle() : string
since |
11.1 |
---|
Response
string
getType
Returns the document type
getType() : string
since |
11.1 |
---|
Response
string
loadRenderer
Load a renderer
loadRenderer(string $type) : \JDocumentRenderer
since |
11.1 |
---|
Arguments
- $type
string
The renderer type
Response
\JDocumentRenderer
Object or null if class does not exist
mergeHeadData
Merge the HTML document head data
mergeHeadData(array $data) : \JDocumentHTML
since |
11.1 |
---|
Arguments
- $data
array
The document head data in array form
Response
\JDocumentHTML
instance of $this to allow chaining
parse
Parses the document and prepares the buffers
parse(array $params = array()) : \JDocument
since |
11.1 |
---|
Arguments
- $params
array
The array of parameters
Response
\JDocument
instance of $this to allow chaining
render
Outputs the document
render(boolean $cache = false, array $params = array()) : \The
since |
11.1 |
---|
Arguments
- $cache
boolean
If true, cache the output- $params
array
Associative array of attributes
Response
\The
rendered data
set
Modifies a property of the object, creating it if it does not already exist.
set(string $property, mixed $value = null) : mixed
since |
11.1 |
---|
Arguments
- $property
string
The name of the property.- $value
mixed
The value of the property to set.
Response
mixed
Previous value of the property.
setBase
Sets the base URI of the document
setBase(string $base) : \JDocument
since |
11.1 |
---|
Arguments
- $base
string
The base URI to be set
Response
\JDocument
instance of $this to allow chaining
setBuffer
Set the contents of the document buffer
setBuffer(string $content, array $options = array()) : \JDocument
since |
11.1 |
---|
Arguments
- $content
string
The content to be set in the buffer.- $options
array
Array of optional elements.
Response
\JDocument
instance of $this to allow chaining
setCharset
Sets the document charset
setCharset(string $type = 'utf-8') : \JDocument
since |
11.1 |
---|
Arguments
- $type
string
Charset encoding string
Response
\JDocument
instance of $this to allow chaining
setDescription
Sets the description of the document
setDescription(string $description) : \JDocument
since |
11.1 |
---|
Arguments
- $description
string
The description to set
Response
\JDocument
instance of $this to allow chaining
setDirection
Sets the global document direction declaration. Default is left-to-right (ltr).
setDirection(string $dir = "ltr") : \JDocument
since |
11.1 |
---|
Arguments
- $dir
string
The language direction to be set
Response
\JDocument
instance of $this to allow chaining
setError
Add an error message.
setError(string $error) : void
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Arguments
- $error
string
Error message.
setGenerator
Sets the document generator
setGenerator(string $generator) : \JDocument
since |
11.1 |
---|
Arguments
- $generator
string
The generator to be set
Response
\JDocument
instance of $this to allow chaining
setHeadData
Set the HTML document head data
setHeadData(array $data) : \JDocumentHTML
since |
11.1 |
---|
Arguments
- $data
array
The document head data in array form
Response
\JDocumentHTML
instance of $this to allow chaining
setLanguage
Sets the global document language declaration. Default is English (en-gb).
setLanguage(string $lang = "en-gb") : \JDocument
since |
11.1 |
---|
Arguments
- $lang
string
The language to be set
Response
\JDocument
instance of $this to allow chaining
setLineEnd
Sets the line end style to Windows, Mac, Unix or a custom string.
setLineEnd(string $style) : \JDocument
since |
11.1 |
---|
Arguments
- $style
string
"win", "mac", "unix" or custom string.
Response
\JDocument
instance of $this to allow chaining
setLink
Sets the document link
setLink(string $url) : \JDocument
setMetaData
Sets or alters a meta tag.
setMetaData(string $name, string $content, boolean $http_equiv = false, boolean $sync = true) : \JDocument
since |
11.1 |
---|
Arguments
- $name
string
Value of name or http-equiv tag- $content
string
Value of the content tag- $http_equiv
boolean
META type "http-equiv" defaults to null- $sync
boolean
Should http-equiv="content-type" by synced with HTTP-header?
Response
\JDocument
instance of $this to allow chaining
setMimeEncoding
Sets the document MIME encoding that is sent to the browser.
setMimeEncoding(string $type = 'text/html', boolean $sync = true) : \JDocument
This usually will be text/html because most browsers cannot yet accept the proper mime settings for XHTML: application/xhtml+xml and to a lesser extent application/xml and text/xml. See the W3C note (http://www.w3.org/TR/xhtml-media-types/) for more details.
since |
11.1 |
---|---|
link |
Arguments
- $type
string
The document type to be sent- $sync
boolean
Should the type be synced with HTML?
Response
\JDocument
instance of $this to allow chaining
setModifiedDate
Sets the document modified date
setModifiedDate(string $date) : \JDocument
since |
11.1 |
---|
Arguments
- $date
string
The date to be set
Response
\JDocument
instance of $this to allow chaining
setProperties
Set the object properties based on a named array/hash.
setProperties(mixed $properties) : boolean
since |
11.1 |
---|---|
see | \JObject::set() |
Arguments
- $properties
mixed
Either an associative array or another object.
Response
boolean
setTab
Sets the string used to indent HTML
setTab(string $string) : \JDocument
since |
11.1 |
---|
Arguments
- $string
string
String used to indent ("\11", "\t", ' ', etc.).
Response
\JDocument
instance of $this to allow chaining
setTitle
Sets the title of the document
setTitle(string $title) : \JDocument
since |
11.1 |
---|
Arguments
- $title
string
The title to be set
Response
\JDocument
instance of $this to allow chaining
setType
Set the document type
setType(string $type) : \JDocument
since |
11.1 |
---|
Arguments
- $type
string
Type document is to set to
Response
\JDocument
instance of $this to allow chaining
toString
Converts the object to a string (the class name).
toString() : string
Properties
_links
Array of Header tags
since |
11.1 |
---|
Type(s)
array
_custom
Array of custom tags
since |
11.1 |
---|
Type(s)
array
template
Name of the template
since |
11.1 |
---|
Type(s)
string
baseurl
Base url
since |
11.1 |
---|
Type(s)
string
params
Array of template parameters
since |
11.1 |
---|
Type(s)
array
_file
File name
since |
11.1 |
---|
Type(s)
array
_template
String holding parsed template
since |
11.1 |
---|
Type(s)
string
_template_tags
Array of parsed template JDoc tags
since |
11.1 |
---|
Type(s)
array
_caching
Integer with caching setting
since |
11.1 |
---|
Type(s)
integer
title
Document title
since |
11.1 |
---|
Type(s)
string
description
Document description
since |
11.1 |
---|
Type(s)
string
link
Document full URL
since |
11.1 |
---|
Type(s)
string
base
Document base URL
since |
11.1 |
---|
Type(s)
string
language
Contains the document language setting
since |
11.1 |
---|
Type(s)
string
direction
Contains the document direction setting
since |
11.1 |
---|
Type(s)
string
_generator
Document generator
Type(s)
string
_mdate
Document modified date
since |
11.1 |
---|
Type(s)
string
_tab
Tab string
since |
11.1 |
---|
Type(s)
string
_lineEnd
Contains the line end string
since |
11.1 |
---|
Type(s)
string
_charset
Contains the character encoding string
since |
11.1 |
---|
Type(s)
string
_mime
Document mime type
since |
11.1 |
---|
Type(s)
string
_namespace
Document namespace
since |
11.1 |
---|
Type(s)
string
_profile
Document profile
since |
11.1 |
---|
Type(s)
string
_scripts
Array of linked scripts
since |
11.1 |
---|
Type(s)
array
_script
Array of scripts placed in the header
since |
11.1 |
---|
Type(s)
array
_styleSheets
Array of linked style sheets
since |
11.1 |
---|
Type(s)
array
_style
Array of included style declarations
since |
11.1 |
---|
Type(s)
array
_metaTags
Array of meta tags
since |
11.1 |
---|
Type(s)
array
_engine
The rendering engine
since |
11.1 |
---|
Type(s)
object
_type
The document type
since |
11.1 |
---|
Type(s)
string
_buffer
Array of buffered output
since |
11.1 |
---|
Type(s)
mixed
instances
JDocument instances container.
since |
11.3 |
---|
Type(s)
array
_errors
An array of error messages or Exception objects.