JDocumentHTML

Extends \JDocument

DocumentHTML 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) 
inherited
since

11.1

Arguments

$properties

mixedEither 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
inherited deprecated
since

11.1

deprecated

12.3 Classes should provide their own __toString() implementation.

Response

stringThe classname.

_fetchTemplate

Fetch the template, and initialise the params

_fetchTemplate(array $params = array()) : \JDocumentHTML
since

11.1

Arguments

$params

arrayParameters to determine the template

Response

\JDocumentHTMLinstance of $this to allow chaining

_getLineEnd

Returns the lineEnd

_getLineEnd() : string
inherited
since

11.1

Response

string

_getTab

Returns a string containing the unit for indenting HTML

_getTab() : string
inherited
since

11.1

Response

string

_loadTemplate

Load a template file

_loadTemplate(string $directory, string $filename) : string
since

11.1

Arguments

$directory

stringThe name of the template

$filename

stringThe actual filename

Response

stringThe contents of the template

_parseTemplate

Parse a document template

_parseTemplate() : \The
since

11.1

Response

\Theparsed contents of the template

_renderTemplate

Render pre-parsed template

_renderTemplate() : string
since

11.1

Response

stringrendered template

addCustomTag

Adds a custom HTML string to the head block

addCustomTag(string $html) : \JDocumentHTML
since

11.1

Arguments

$html

stringThe HTML to add to the head

Response

\JDocumentHTMLinstance 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

stringThe link that is being related.

$type

stringFile type

$relation

stringRelation of link

Response

\JDocumentHTMLinstance 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
inherited
since

11.1

Arguments

$url

stringURL to the linked script

$type

stringType of script. Defaults to 'text/javascript'

$defer

booleanAdds the defer attribute.

$async

booleanAdds the async attribute.

Response

\JDocumentinstance of $this to allow chaining

addScriptDeclaration

Adds a script to the page

addScriptDeclaration(string $content, string $type = 'text/javascript') : \JDocument
inherited
since

11.1

Arguments

$content

stringScript

$type

stringScripting mime (defaults to 'text/javascript')

Response

\JDocumentinstance of $this to allow chaining

addStyleDeclaration

Adds a stylesheet declaration to the page

addStyleDeclaration(string $content, string $type = 'text/css') : \JDocument
inherited
since

11.1

Arguments

$content

stringStyle declarations

$type

stringType of stylesheet (defaults to 'text/css')

Response

\JDocumentinstance 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
inherited
since

11.1

Arguments

$url

stringURL to the linked style sheet

$type

stringMime encoding type

$media

stringMedia type that this stylesheet applies to

$attribs

arrayArray of attributes

Response

\JDocumentinstance of $this to allow chaining

countMenuChildren

Count the number of child menu items

countMenuChildren() : integer
since

11.1

Response

integerNumber of child menu items

countModules

Count the modules based on the given condition

countModules(string $condition) : integer
since

11.1

Arguments

$condition

stringThe condition to use

Response

integerNumber of modules found

def

Sets a default value if not alreay assigned

def(string $property, mixed $default = null) : mixed
inherited
since

11.1

Arguments

$property

stringThe name of the property.

$default

mixedThe 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
inherited
since

11.1

see \JObject::getProperties()

Arguments

$property

stringThe name of the property.

$default

mixedThe default value.

Response

mixedThe value of the property.

getBase

Return the base URI of the document.

getBase() : string
inherited
since

11.1

Response

string

getBuffer

Get the contents of the document buffer

getBuffer() : \The
inherited
since

11.1

Response

\Thecontents of the document buffer

getCharset

Returns the document charset encoding.

getCharset() : string
inherited
since

11.1

Response

string

getDescription

Return the title of the page.

getDescription() : string
inherited
since

11.1

Response

string

getDirection

Returns the document direction declaration.

getDirection() : string
inherited
since

11.1

Response

string

getError

Get the most recent error message.

getError(integer $i = null, boolean $toString = true) : string
inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Arguments

$i

integerOption error index.

$toString

booleanIndicates if JError objects should return their error message.

Response

stringError message

getErrors

Return all errors, if any.

getErrors() : array
inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Response

arrayArray of error messages or JErrors.

getGenerator

Returns the document generator

getGenerator() : string
inherited
since

11.1

Response

string

getHeadData

Get the HTML document head data

getHeadData() : array
since

11.1

Response

arrayThe 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
inherited static
since

11.1

Arguments

$type

stringThe document type to instantiate

$attributes

arrayArray of attributes

Response

objectThe document object.

getLanguage

Returns the document language.

getLanguage() : string
inherited
since

11.1

Response

string

getMetaData

Gets a meta tag.

getMetaData(string $name, boolean $httpEquiv = false) : string
inherited
since

11.1

Arguments

$name

stringValue of name or http-equiv tag

$httpEquiv

booleanMETA type "http-equiv" defaults to null

Response

string

getMimeEncoding

Return the document MIME encoding that is sent to the browser.

getMimeEncoding() : string
inherited
since

11.1

Response

string

getModifiedDate

Returns the document modified date

getModifiedDate() : string
inherited
since

11.1

Response

string

getProperties

Returns an associative array of object properties.

getProperties(boolean $public = true) : array
inherited
since

11.1

see \JObject::get()

Arguments

$public

booleanIf true, returns only the public properties.

Response

array

getTitle

Return the title of the document.

getTitle() : string
inherited
since

11.1

Response

string

getType

Returns the document type

getType() : string
inherited
since

11.1

Response

string

loadRenderer

Load a renderer

loadRenderer(string $type) : \JDocumentRenderer
inherited
since

11.1

Arguments

$type

stringThe renderer type

Response

\JDocumentRendererObject or null if class does not exist

mergeHeadData

Merge the HTML document head data

mergeHeadData(array $data) : \JDocumentHTML
since

11.1

Arguments

$data

arrayThe document head data in array form

Response

\JDocumentHTMLinstance of $this to allow chaining

parse

Parses the document and prepares the buffers

parse(array $params = array()) : \JDocument
inherited
since

11.1

Arguments

$params

arrayThe array of parameters

Response

\JDocumentinstance of $this to allow chaining

render

Outputs the document

render(boolean $cache = false, array $params = array()) : \The
inherited
since

11.1

Arguments

$cache

booleanIf true, cache the output

$params

arrayAssociative array of attributes

Response

\Therendered data

set

Modifies a property of the object, creating it if it does not already exist.

set(string $property, mixed $value = null) : mixed
inherited
since

11.1

Arguments

$property

stringThe name of the property.

$value

mixedThe value of the property to set.

Response

mixedPrevious value of the property.

setBase

Sets the base URI of the document

setBase(string $base) : \JDocument
inherited
since

11.1

Arguments

$base

stringThe base URI to be set

Response

\JDocumentinstance of $this to allow chaining

setBuffer

Set the contents of the document buffer

setBuffer(string $content, array $options = array()) : \JDocument
inherited
since

11.1

Arguments

$content

stringThe content to be set in the buffer.

$options

arrayArray of optional elements.

Response

\JDocumentinstance of $this to allow chaining

setCharset

Sets the document charset

setCharset(string $type = 'utf-8') : \JDocument
inherited
since

11.1

Arguments

$type

stringCharset encoding string

Response

\JDocumentinstance of $this to allow chaining

setDescription

Sets the description of the document

setDescription(string $description) : \JDocument
inherited
since

11.1

Arguments

$description

stringThe description to set

Response

\JDocumentinstance of $this to allow chaining

setDirection

Sets the global document direction declaration. Default is left-to-right (ltr).

setDirection(string $dir = "ltr") : \JDocument
inherited
since

11.1

Arguments

$dir

stringThe language direction to be set

Response

\JDocumentinstance of $this to allow chaining

setError

Add an error message.

setError(string $error) : void
inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Arguments

$error

stringError message.

setGenerator

Sets the document generator

setGenerator(string $generator) : \JDocument
inherited
since

11.1

Arguments

$generator

stringThe generator to be set

Response

\JDocumentinstance of $this to allow chaining

setHeadData

Set the HTML document head data

setHeadData(array $data) : \JDocumentHTML
since

11.1

Arguments

$data

arrayThe document head data in array form

Response

\JDocumentHTMLinstance of $this to allow chaining

setLanguage

Sets the global document language declaration. Default is English (en-gb).

setLanguage(string $lang = "en-gb") : \JDocument
inherited
since

11.1

Arguments

$lang

stringThe language to be set

Response

\JDocumentinstance of $this to allow chaining

setLineEnd

Sets the line end style to Windows, Mac, Unix or a custom string.

setLineEnd(string $style) : \JDocument
inherited
since

11.1

Arguments

$style

string"win", "mac", "unix" or custom string.

Response

\JDocumentinstance of $this to allow chaining

setMetaData

Sets or alters a meta tag.

setMetaData(string $name, string $content, boolean $http_equiv = false, boolean $sync = true) : \JDocument
inherited
since

11.1

Arguments

$name

stringValue of name or http-equiv tag

$content

stringValue of the content tag

$http_equiv

booleanMETA type "http-equiv" defaults to null

$sync

booleanShould http-equiv="content-type" by synced with HTTP-header?

Response

\JDocumentinstance 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
inherited

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

http://www.w3.org/TR/xhtml-media-types

Arguments

$type

stringThe document type to be sent

$sync

booleanShould the type be synced with HTML?

Response

\JDocumentinstance of $this to allow chaining

setModifiedDate

Sets the document modified date

setModifiedDate(string $date) : \JDocument
inherited
since

11.1

Arguments

$date

stringThe date to be set

Response

\JDocumentinstance of $this to allow chaining

setProperties

Set the object properties based on a named array/hash.

setProperties(mixed $properties) : boolean
inherited
since

11.1

see \JObject::set()

Arguments

$properties

mixedEither an associative array or another object.

Response

boolean

setTab

Sets the string used to indent HTML

setTab(string $string) : \JDocument
inherited
since

11.1

Arguments

$string

stringString used to indent ("\11", "\t", ' ', etc.).

Response

\JDocumentinstance of $this to allow chaining

setTitle

Sets the title of the document

setTitle(string $title) : \JDocument
inherited
since

11.1

Arguments

$title

stringThe title to be set

Response

\JDocumentinstance of $this to allow chaining

setType

Set the document type

setType(string $type) : \JDocument
inherited
since

11.1

Arguments

$type

stringType document is to set to

Response

\JDocumentinstance of $this to allow chaining

toString

Converts the object to a string (the class name).

toString() : string
inherited deprecated
since

11.1

deprecated

12.1 Use magic method __toString()

see \JObject::__toString()

Response

string

Properties

_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

inherited
since

11.1

Type(s)

string

description

Document description

inherited
since

11.1

Type(s)

string

base

Document base URL

inherited
since

11.1

Type(s)

string

language

Contains the document language setting

inherited
since

11.1

Type(s)

string

direction

Contains the document direction setting

inherited
since

11.1

Type(s)

string

_generator

Document generator

inherited

Type(s)

string

_mdate

Document modified date

inherited
since

11.1

Type(s)

string

_tab

Tab string

inherited
since

11.1

Type(s)

string

_lineEnd

Contains the line end string

inherited
since

11.1

Type(s)

string

_charset

Contains the character encoding string

inherited
since

11.1

Type(s)

string

_mime

Document mime type

inherited
since

11.1

Type(s)

string

_namespace

Document namespace

inherited
since

11.1

Type(s)

string

_profile

Document profile

inherited
since

11.1

Type(s)

string

_scripts

Array of linked scripts

inherited
since

11.1

Type(s)

array

_script

Array of scripts placed in the header

inherited
since

11.1

Type(s)

array

_styleSheets

Array of linked style sheets

inherited
since

11.1

Type(s)

array

_style

Array of included style declarations

inherited
since

11.1

Type(s)

array

_metaTags

Array of meta tags

inherited
since

11.1

Type(s)

array

_engine

The rendering engine

inherited
since

11.1

Type(s)

object

_type

The document type

inherited
since

11.1

Type(s)

string

_buffer

Array of buffered output

inherited static
since

11.1

Type(s)

mixed

instances

JDocument instances container.

inherited static
since

11.3

Type(s)

array

_errors

An array of error messages or Exception objects.

inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Type(s)

array