JDocumentJSON
Extends \JDocumentJDocumentJSON class, provides an easy interface to parse and display JSON output
This class allows for simple but smart objects with get and set methods and an internal error handler.
| package |
Joomla.Platform |
|---|---|
| subpackage |
Document |
| see | |
| since |
11.1 |
Methods
__construct
Class constructor, overridden in descendant classes.
__construct(mixed $properties = null)
| 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
| since |
11.1 |
|---|---|
| deprecated |
12.3 Classes should provide their own __toString() implementation. |
Response
stringThe classname.
_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
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
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
| 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
| 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
| 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
def
Sets a default value if not alreay assigned
def(string $property, mixed $default = null) : mixed
| 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
| 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
| since |
11.1 |
|---|
Response
string
getBuffer
Get the contents of the document buffer
getBuffer() : \The
| since |
11.1 |
|---|
Response
\Thecontents 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
integerOption error index.- $toString
booleanIndicates if JError objects should return their error message.
Response
stringError message
getErrors
Return all errors, if any.
getErrors() : array
| 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
| since |
11.1 |
|---|
Response
string
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
stringThe document type to instantiate- $attributes
arrayArray of attributes
Response
objectThe 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
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
| since |
11.1 |
|---|
Response
string
getModifiedDate
Returns the document modified date
getModifiedDate() : string
| since |
11.1 |
|---|
Response
string
getName
Returns the document name
getName() : 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
booleanIf 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
stringThe renderer type
Response
\JDocumentRendererObject or null if class does not exist
parse
Parses the document and prepares the buffers
parse(array $params = array()) : \JDocument
| 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
| 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
| 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
| 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
| 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
| 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
| 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
| 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
| 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
| since |
11.1 |
|---|
Arguments
- $generator
stringThe generator to be set
Response
\JDocumentinstance 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
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
| since |
11.1 |
|---|
Arguments
- $style
string"win", "mac", "unix" or custom string.
Response
\JDocumentinstance 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
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
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
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
| since |
11.1 |
|---|
Arguments
- $date
stringThe date to be set
Response
\JDocumentinstance of $this to allow chaining
setName
Sets the document name
setName(string $name = 'joomla') : \JDocumentJSON
| since |
11.1 |
|---|
Arguments
- $name
stringDocument name
Response
\JDocumentJSONinstance 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
mixedEither 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
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
| 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
| 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
Properties
_name
Document name
| since |
11.1 |
|---|
Type(s)
string
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.