Back to Joomla project (class list)

Class Document - list of methods

Document class, provides an easy interface to parse and display a document

Direct known subclasses

Package: Joomla\CMS\Document
Copyright: (C) 2005 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
Located at: Joomla/Document/Document.php
Project: Joomla

Method Summary

public
(mixed $options = array())

Class constructor.
Parameters
  • array $options Associative array of options
Since
  • 1.7.0
Show source code of this method: __construct Source Code

public static static
(mixed $type = 'html', mixed $attributes = array())

Returns the global Document object, only creating it if it doesn't already exist.
Parameters
  • string $type The document type to instantiate
  • array $attributes Array of attributes
Returns
  • static The document object.
Since
  • 1.7.0
Deprecated
  • 5.0
Show source code of this method: getInstance Source Code

public \Joomla\CMS\Document\Document
(\Joomla\CMS\Document\FactoryInterface $factory)

Set the factory instance
Parameters
  • \Joomla\CMS\Document\FactoryInterface $factory The factory instance
Returns
  • \Joomla\CMS\Document\Document
Since
  • 4.0.0
Show source code of this method: setFactory Source Code

public \Joomla\CMS\Document\Document
(mixed $type)

Set the document type
Parameters
  • string $type Type document is to set to
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
Show source code of this method: setType Source Code

public string
()

Returns the document type
Returns
  • string
Since
  • 1.7.0
Show source code of this method: getType Source Code

public mixed
()

Get the contents of the document buffer
Returns
  • mixed
Since
  • 1.7.0
Show source code of this method: getBuffer Source Code

public \Joomla\CMS\Document\Document
(mixed $content, mixed $options = array())

Set the contents of the document buffer
Parameters
  • string $content The content to be set in the buffer.
  • array $options Array of optional elements.
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
Show source code of this method: setBuffer Source Code

public string
(mixed $name, mixed $attribute = 'name')

Gets a meta tag.
Parameters
  • string $name Name of the meta HTML tag
  • string $attribute Attribute to use in the meta HTML tag
Returns
  • string
Since
  • 1.7.0
Show source code of this method: getMetaData Source Code

public \Joomla\CMS\Document\Document
(mixed $name, mixed $content, mixed $attribute = 'name')

Sets or alters a meta tag.
Parameters
  • string $name Name of the meta HTML tag
  • mixed $content Value of the meta HTML tag as array or string
  • string $attribute Attribute to use in the meta HTML tag
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
Show source code of this method: setMetaData Source Code

public \Joomla\CMS\Document\Document
(mixed $url, mixed $options = array(), mixed $attribs = array())

Adds a linked script to the page
Parameters
  • string $url URL to the linked script.
  • array $options Array of options. Example: array('version' => 'auto', 'conditional' => 'lt IE 9', 'preload' => array('preload'))
  • array $attribs Array of attributes. Example: array('id' => 'scriptid', 'async' => 'async', 'data-test' => 1)
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
Deprecated
  • 5.0
Show source code of this method: addScript Source Code

public \Joomla\CMS\Document\Document
(mixed $content, mixed $type = 'text/javascript')

Adds a script to the page
Parameters
  • string $content Script
  • string $type Scripting mime (defaults to 'text/javascript')
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
Deprecated
  • 5.0
Show source code of this method: addScriptDeclaration Source Code

public \Joomla\CMS\Document\Document
(mixed $key, mixed $options, mixed $merge = true)

Add option for script
Parameters
  • string $key Name in Storage
  • mixed $options Scrip options as array or string
  • bool $merge Whether merge with existing (true) or replace (false)
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 3.5
Show source code of this method: addScriptOptions Source Code

public array
(mixed $key = null)

Get script(s) options
Parameters
  • string $key Name in Storage
Returns
  • array Options for given $key, or all script options
Since
  • 3.5
Show source code of this method: getScriptOptions Source Code

public \Joomla\CMS\Document\Document
(mixed $url, mixed $options = array(), mixed $attribs = array())

Adds a linked stylesheet to the page
Parameters
  • string $url URL to the linked style sheet
  • array $options Array of options. Example: array('version' => 'auto', 'conditional' => 'lt IE 9', 'preload' => array('preload'))
  • array $attribs Array of attributes. Example: array('id' => 'stylesheet', 'data-test' => 1)
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
Deprecated
  • 5.0
Show source code of this method: addStyleSheet Source Code

public \Joomla\CMS\Document\Document
(mixed $content, mixed $type = 'text/css')

Adds a stylesheet declaration to the page
Parameters
  • string $content Style declarations
  • string $type Type of stylesheet (defaults to 'text/css')
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
Deprecated
  • 5.0
Show source code of this method: addStyleDeclaration Source Code

public \Joomla\CMS\Document\Document
(mixed $type = 'utf-8')

Sets the document charset
Parameters
  • string $type Charset encoding string
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
Show source code of this method: setCharset Source Code

public string
()

Returns the document charset encoding.
Returns
  • string
Since
  • 1.7.0
Show source code of this method: getCharset Source Code

public \Joomla\CMS\Document\Document
(mixed $lang = 'en-gb')

Sets the global document language declaration. Default is English (en-gb).
Parameters
  • string $lang The language to be set
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
Show source code of this method: setLanguage Source Code

public string
()

Returns the document language.
Returns
  • string
Since
  • 1.7.0
Show source code of this method: getLanguage Source Code

public \Joomla\CMS\Document\Document
(mixed $dir = 'ltr')

Sets the global document direction declaration. Default is left-to-right (ltr).
Parameters
  • string $dir The language direction to be set
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
Show source code of this method: setDirection Source Code

public string
()

Returns the document direction declaration.
Returns
  • string
Since
  • 1.7.0
Show source code of this method: getDirection Source Code

public \Joomla\CMS\Document\Document
(mixed $title)

Sets the title of the document
Parameters
  • string $title The title to be set
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
Show source code of this method: setTitle Source Code

public string
()

Return the title of the document.
Returns
  • string
Since
  • 1.7.0
Show source code of this method: getTitle Source Code

public \Joomla\CMS\Document\Document
(mixed $mediaVersion)

Set the assets version
Parameters
  • string $mediaVersion Media version to use
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 3.2
Show source code of this method: setMediaVersion Source Code

public string
()

Return the media version
Returns
  • string
Since
  • 3.2
Show source code of this method: getMediaVersion Source Code

public \Joomla\CMS\Document\Document
(\Joomla\CMS\Document\PreloadManagerInterface $preloadManager)

Set the preload manager
Parameters
  • \Joomla\CMS\Document\PreloadManagerInterface $preloadManager The preload manager service
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 4.0.0
Show source code of this method: setPreloadManager Source Code

public \Joomla\CMS\Document\PreloadManagerInterface
()

Return the preload manager
Returns
  • \Joomla\CMS\Document\PreloadManagerInterface
Since
  • 4.0.0
Show source code of this method: getPreloadManager Source Code

public \Joomla\CMS\Document\Document
(\Joomla\CMS\WebAsset\WebAssetManager $webAsset)

Set WebAsset manager
Parameters
  • \Joomla\CMS\WebAsset\WebAssetManager $webAsset The WebAsset instance
Returns
  • \Joomla\CMS\Document\Document
Since
  • 4.0.0
Show source code of this method: setWebAssetManager Source Code

public \Joomla\CMS\WebAsset\WebAssetManager
()

Return WebAsset manager
Returns
  • \Joomla\CMS\WebAsset\WebAssetManager
Since
  • 4.0.0
Show source code of this method: getWebAssetManager Source Code

public \Joomla\CMS\Document\Document
(mixed $base)

Sets the base URI of the document
Parameters
  • string $base The base URI to be set
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
Show source code of this method: setBase Source Code

public string
()

Return the base URI of the document.
Returns
  • string
Since
  • 1.7.0
Show source code of this method: getBase Source Code

public \Joomla\CMS\Document\Document
(mixed $description)

Sets the description of the document
Parameters
  • string $description The description to set
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
Show source code of this method: setDescription Source Code

public string
()

Return the description of the document.
Returns
  • string
Since
  • 1.7.0
Show source code of this method: getDescription Source Code

public \Joomla\CMS\Document\Document
(mixed $url)

Sets the document link
Parameters
  • string $url A url
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
Show source code of this method: setLink Source Code

public string
()

Returns the document base url
Returns
  • string
Since
  • 1.7.0
Show source code of this method: getLink Source Code

public \Joomla\CMS\Document\Document
(mixed $generator)

Sets the document generator
Parameters
  • string $generator The generator to be set
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
Show source code of this method: setGenerator Source Code

public string
()

Returns the document generator
Returns
  • string
Since
  • 1.7.0
Show source code of this method: getGenerator Source Code

public \Joomla\CMS\Document\Document
(mixed $date)

Sets the document modified date
Parameters
  • string|\Joomla\CMS\Date\Date $date The date to be set
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
-
  • \InvalidArgumentException
Show source code of this method: setModifiedDate Source Code

public string|\Joomla\CMS\Date\Date
()

Returns the document modified date
Returns
  • string|\Joomla\CMS\Date\Date
Since
  • 1.7.0
Show source code of this method: getModifiedDate Source Code

public \Joomla\CMS\Document\Document
(mixed $type = 'text/html', mixed $sync = true)

Sets the document MIME encoding that is sent to the browser.
Parameters
  • string $type The document type to be sent
  • bool $sync Should the type be synced with HTML?
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
-
  • https://www.w3.org/TR/xhtml-media-types/
Show source code of this method: setMimeEncoding Source Code

public string
()

Return the document MIME encoding that is sent to the browser.
Returns
  • string
Since
  • 1.7.0
Show source code of this method: getMimeEncoding Source Code

public \Joomla\CMS\Document\Document
(mixed $style)

Sets the line end style to Windows, Mac, Unix or a custom string.
Parameters
  • string $style "win", "mac", "unix" or custom string.
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
Show source code of this method: setLineEnd Source Code

public string
()

Returns the lineEnd
Returns
  • string
Since
  • 1.7.0
Show source code of this method: _getLineEnd Source Code

public \Joomla\CMS\Document\Document
(mixed $string)

Sets the string used to indent HTML
Parameters
  • string $string String used to indent ("\11", "\t", ' ', etc.).
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
Show source code of this method: setTab Source Code

public string
()

Returns a string containing the unit for indenting HTML
Returns
  • string
Since
  • 1.7.0
Show source code of this method: _getTab Source Code

public \Joomla\CMS\Document\RendererInterface
(mixed $type)

Load a renderer
Parameters
  • string $type The renderer type
Returns
  • \Joomla\CMS\Document\RendererInterface
Since
  • 1.7.0
-
  • \RuntimeException
Show source code of this method: loadRenderer Source Code

public \Joomla\CMS\Document\Document
(mixed $params = array())

Parses the document and prepares the buffers
Parameters
  • array $params The array of parameters
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
Show source code of this method: parse Source Code

public string
(mixed $cache = false, mixed $params = array())

Outputs the document
Parameters
  • bool $cache If true, cache the output
  • array $params Associative array of attributes
Returns
  • string The rendered data
Since
  • 1.7.0
Show source code of this method: render Source Code

protected void
()

Generate the Link header for assets configured for preloading
Returns
  • void
Since
  • 4.0.0
Show source code of this method: preloadAssets Source Code

Properties Summary

public string
$title
Document title
Since
  • 1.7.0
public string
$description
Document description
Since
  • 1.7.0
public string
$link
Document full URL
Since
  • 1.7.0
public string
$base
Document base URL
Since
  • 1.7.0
public string
$language
Contains the document language setting
Since
  • 1.7.0
public string
$direction
Contains the document direction setting
Since
  • 1.7.0
public string
$_generator
Document generator
Since
  • 1.7.0
public string|\Joomla\CMS\Date\Date
$_mdate
Document modified date
Since
  • 1.7.0
public string
$_tab
Tab string
Since
  • 1.7.0
public string
$_lineEnd
Contains the line end string
Since
  • 1.7.0
public string
$_charset
Contains the character encoding string
Since
  • 1.7.0
public string
$_mime
Document mime type
Since
  • 1.7.0
public string
$_namespace
Document namespace
Since
  • 1.7.0
public string
$_profile
Document profile
Since
  • 1.7.0
public array
$_scripts
Array of linked scripts
Since
  • 1.7.0
-
  • array
public array
$_script
Array of scripts placed in the header
Since
  • 1.7.0
-
  • array
protected array
$scriptOptions
Array of scripts options
public array
$_styleSheets
Array of linked style sheets
Since
  • 1.7.0
-
  • array
public array
$_style
Array of included style declarations
Since
  • 1.7.0
-
  • array
public array
$_metaTags
Array of meta tags
Since
  • 1.7.0
public object
$_engine
The rendering engine
Since
  • 1.7.0
public string
$_type
The document type
Since
  • 1.7.0
public static mixed
$_buffer
Array of buffered output
Since
  • 1.7.0
protected static array
$instances
Document instances container.
Since
  • 1.7.3
protected string
$mediaVersion
Media version added to assets
Since
  • 3.2
protected \Joomla\CMS\Document\FactoryInterface
$factory
Factory for creating JDocument API objects
Since
  • 4.0.0
protected \Joomla\CMS\Document\PreloadManagerInterface
$preloadManager
Preload manager
Since
  • 4.0.0
protected array
$preloadTypes
The supported preload types
Since
  • 4.0.0
protected \Joomla\CMS\WebAsset\WebAssetManager
$webAssetManager
Web Asset instance
Since
  • 4.0.0

Tags Summary

Since
1.7.0