Source for file document.php
Documentation is available at document.php
* @package Joomla.Platform
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* Document class, provides an easy interface to parse and display a document
* @package Joomla.Platform
* Contains the document language setting
* Contains the document direction setting
public $_generator =
'Joomla! - Open Source Content Management';
* Contains the line end string
* Contains the character encoding string
* Array of linked scripts
* Array of scripts placed in the header
* Array of linked style sheets
* Array of included style declarations
* Array of buffered output
* @var mixed (depends on the renderer)
public static $_buffer =
null;
* JDocument instances container.
protected static $instances =
array();
* Media version added to assets
* @param array $options Associative array of options
$this->setTab($options['tab']);
* Returns the global JDocument object, only creating it
* if it doesn't already exist.
* @param string $type The document type to instantiate
* @param array $attributes Array of attributes
* @return object The document object.
* @throws RuntimeException
public static function getInstance($type =
'html', $attributes =
array())
$signature =
serialize(array($type, $attributes));
if (empty(self::$instances[$signature]))
$type =
preg_replace('/[^A-Z0-9_\.-]/i', '', $type);
$path = __DIR__ .
'/' .
$type .
'/' .
$type .
'.php';
// Check if the document type exists
// Default to the raw format
// Determine the path and class
$class =
'JDocument' .
$type;
$path = __DIR__ .
'/' .
$type .
'/' .
$type .
'.php';
throw
new RuntimeException('Invalid JDocument Class', 500);
$instance =
new $class($attributes);
self::$instances[$signature] =
$instance;
// Set the type to the Document type originally requested
$instance->setType($ntype);
return self::$instances[$signature];
* @param string $type Type document is to set to
* @return JDocument instance of $this to allow chaining
* Returns the document type
* Get the contents of the document buffer
* @return The contents of the document buffer
* Set the contents of the document buffer
* @param string $content The content to be set in the buffer.
* @param array $options Array of optional elements.
* @return JDocument instance of $this to allow chaining
public function setBuffer($content, $options =
array())
self::$_buffer =
$content;
* @param string $name Value of name or http-equiv tag
* @param boolean $httpEquiv META type "http-equiv" defaults to null
$name =
strtolower($name);
if ($name ==
'generator')
elseif ($name ==
'description')
$result =
@$this->_metaTags['http-equiv'][$name];
$result =
@$this->_metaTags['standard'][$name];
* Sets or alters a meta tag.
* @param string $name Value of name or http-equiv tag
* @param string $content Value of the content tag
* @param boolean $http_equiv META type "http-equiv" defaults to null
* @return JDocument instance of $this to allow chaining
public function setMetaData($name, $content, $http_equiv =
false)
if ($name ==
'generator')
elseif ($name ==
'description')
$this->_metaTags['http-equiv'][$name] =
$content;
$this->_metaTags['standard'][$name] =
$content;
* Adds a linked script to the page
* @param string $url URL to the linked script
* @param string $type Type of script. Defaults to 'text/javascript'
* @param boolean $defer Adds the defer attribute.
* @param boolean $async Adds the async attribute.
* @return JDocument instance of $this to allow chaining
public function addScript($url, $type =
"text/javascript", $defer =
false, $async =
false)
$this->_scripts[$url]['defer'] =
$defer;
$this->_scripts[$url]['async'] =
$async;
* Adds a linked script to the page with a version to allow to flush it. Ex: myscript.js54771616b5bceae9df03c6173babf11d
* If not specified Joomla! automatically handles versioning
* @param string $url URL to the linked script
* @param string $version Version of the script
* @param string $type Type of script. Defaults to 'text/javascript'
* @param boolean $defer Adds the defer attribute.
* @param boolean $async [description]
* @return JDocument instance of $this to allow chaining
public function addScriptVersion($url, $version =
null, $type =
"text/javascript", $defer =
false, $async =
false)
if (!empty($version) &&
strpos($url, '?') ===
false)
return $this->addScript($url, $type, $defer, $async);
* Adds a script to the page
* @param string $content Script
* @param string $type Scripting mime (defaults to 'text/javascript')
* @return JDocument instance of $this to allow chaining
* Adds a linked stylesheet to the page
* @param string $url URL to the linked style sheet
* @param string $type Mime encoding type
* @param string $media Media type that this stylesheet applies to
* @param array $attribs Array of attributes
* @return JDocument instance of $this to allow chaining
public function addStyleSheet($url, $type =
'text/css', $media =
null, $attribs =
array())
* Adds a linked stylesheet version to the page. Ex: template.css?54771616b5bceae9df03c6173babf11d
* If not specified Joomla! automatically handles versioning
* @param string $url URL to the linked style sheet
* @param string $version Version of the stylesheet
* @param string $type Mime encoding type
* @param string $media Media type that this stylesheet applies to
* @param array $attribs Array of attributes
* @return JDocument instance of $this to allow chaining
public function addStyleSheetVersion($url, $version =
null, $type =
"text/css", $media =
null, $attribs =
array())
if (!empty($version) &&
strpos($url, '?') ===
false)
* Adds a stylesheet declaration to the page
* @param string $content Style declarations
* @param string $type Type of stylesheet (defaults to 'text/css')
* @return JDocument instance of $this to allow chaining
* Sets the document charset
* @param string $type Charset encoding string
* @return JDocument instance of $this to allow chaining
* Returns the document charset encoding.
* Sets the global document language declaration. Default is English (en-gb).
* @param string $lang The language to be set
* @return JDocument instance of $this to allow chaining
* Returns the document language.
* Sets the global document direction declaration. Default is left-to-right (ltr).
* @param string $dir The language direction to be set
* @return JDocument instance of $this to allow chaining
* Returns the document direction declaration.
* Sets the title of the document
* @param string $title The title to be set
* @return JDocument instance of $this to allow chaining
* Return the title of the document.
* @param string $mediaVersion Media version to use
* @return JDocument instance of $this to allow chaining
* Return the media version
* Sets the base URI of the document
* @param string $base The base URI to be set
* @return JDocument instance of $this to allow chaining
* Return the base URI of the document.
* Sets the description of the document
* @param string $description The description to set
* @return JDocument instance of $this to allow chaining
* Return the title of the page.
* @param string $url A url
* @return JDocument instance of $this to allow chaining
* Returns the document base url
* Sets the document generator
* @param string $generator The generator to be set
* @return JDocument instance of $this to allow chaining
* Returns the document generator
* Sets the document modified date
* @param string $date The date to be set
* @return JDocument instance of $this to allow chaining
* Returns the document modified date
* Sets the document MIME encoding that is sent to the browser.
* 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
* ({@link http://www.w3.org/TR/xhtml-media-types/}
* http://www.w3.org/TR/xhtml-media-types/}) for more details.
* @param string $type The document type to be sent
* @param boolean $sync Should the type be synced with HTML?
* @return JDocument instance of $this to allow chaining
* @link http://www.w3.org/TR/xhtml-media-types
// Syncing with meta-data
* Return the document MIME encoding that is sent to the browser.
* Sets the line end style to Windows, Mac, Unix or a custom string.
* @param string $style "win", "mac", "unix" or custom string.
* @return JDocument instance of $this to allow chaining
* Sets the string used to indent HTML
* @param string $string String used to indent ("\11", "\t", ' ', etc.).
* @return JDocument instance of $this to allow chaining
public function setTab($string)
* Returns a string containing the unit for indenting HTML
* @param string $type The renderer type
* @return JDocumentRenderer Object or null if class does not exist
* @throws RuntimeException
$class =
'JDocumentRenderer' .
$type;
$path = __DIR__ .
'/' .
$this->_type .
'/renderer/' .
$type .
'.php';
throw
new RuntimeException('Unable to load renderer class', 500);
$instance =
new $class($this);
* Parses the document and prepares the buffers
* @param array $params The array of parameters
* @return JDocument instance of $this to allow chaining
public function parse($params =
array())
* @param boolean $cache If true, cache the output
* @param array $params Associative array of attributes
* @return The rendered data
public function render($cache =
false, $params =
array())
$app->modifiedDate =
$mdate;
$app->mimeType =
$this->_mime;
Documentation generated on Tue, 19 Nov 2013 15:01:37 +0100 by phpDocumentor 1.4.3