Source code for file /joomla/document/document.php
Documentation is available at document.php
* @version $Id: document.php 6684 2007-02-19 18:53:46Z louis $
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
// Check to ensure this file is within the rest of the framework
* Document class, provides an easy interface to parse and display a document
* @package Joomla.Framework
* Contains the document language setting
* Contains the document direction setting
var $_generator =
'Joomla! 1.5 - 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
var $_styleSheets =
array();
* Array of included style declarations
var $_metaTags =
array();
* Array of buffered output
* @var mixed (depends on the renderer)
* @param array $options Associative array of options
if (isset
($options['lineend'])) {
if (isset
($options['charset'])) {
if (isset
($options['language'])) {
if (isset
($options['direction'])) {
if (isset
($options['tab'])) {
$this->setTab($options['tab']);
if (isset
($options['link'])) {
* Returns a reference to the global JDocument object, only creating it
* if it doesn't already exist.
* This method must be invoked as:
* <pre> $document = &JDocument::getInstance();</pre>
* @param type $type The document type to instantiate
* @return object The document object.
function &getInstance($type =
'html', $attributes =
array())
if (!isset
( $instances )) {
$signature =
serialize(array($type, $attributes));
if (empty($instances[$signature])) {
jimport('joomla.document.'.
$type.
'.'.
$type);
$class =
'JDocument'.
$type;
$instances[$signature] =
new $class($attributes);
return $instances[$signature];
* Returns the document type
* Get the document head data
* @return array The document head data in array form
// Impelemented in child classes
* Set the document head data
* @param array $data The document head data in array form
// Impelemented in child classes
* 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
$this->_buffer =
$content;
* @param string $name Value of name or http-equiv tag
* @param bool $http_equiv META type "http-equiv" defaults to null
if ($http_equiv ==
true) {
$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 bool $http_equiv META type "http-equiv" defaults to null
function setMetaData($name, $content, $http_equiv =
false)
if ($http_equiv ==
true) {
$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'
function addScript($url, $type=
"text/javascript") {
$this->_scripts[$url] =
$type;
* Adds a script to the page
* @param string $content Script
* @param string $type Scripting mime (defaults to 'text/javascript')
* 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
function addStyleSheet($url, $type =
'text/css', $media =
null, $attribs =
array())
$this->_styleSheets[$url]['mime'] =
$type;
$this->_styleSheets[$url]['media'] =
$media;
$this->_styleSheets[$url]['attribs'] =
$attribs;
* Adds a stylesheet declaration to the page
* @param string $content Style declarations
* @param string $type Type of stylesheet (defaults to 'text/css')
* Sets the document charset
* @param string $type Charset encoding string
* Returns the document charset encoding.
* Sets the global document language declaration. Default is English (en).
* Returns the document language.
* Sets the global document direction declaration. Default is left-to-right (ltr).
* Returns the document language.
* Sets the title of the document
* Return the title of the document.
* Sets the description of the document
* Return the title of the page.
* @param string $url A url
* Returns the document base url
* Sets the document generator
* Returns the document generator
* Sets the document modified date
* Returns the document modified date
* Sets the document MIME encoding that is sent to the browser.
* <p>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.</p>
* Sets the line end style to Windows, Mac, Unix or a custom string.
* @param string $style "win", "mac", "unix" or custom string.
$this->_lineEnd =
"\15\12";
$this->_lineEnd =
$style;
* Sets the string used to indent HTML
* @param string $string String used to indent ("\11", "\t", ' ', etc.).
* Returns a string containing the unit for indenting HTML
* @param string The renderer type
jimport('joomla.document.renderer');
$class =
'JDocumentRenderer_' .
$type;
jimport('joomla.document.'.
$this->_type.
'.renderer.'.
$type);
$instance =
new $class($this);
* @param boolean $cache If true, cache the output
* @param boolean $compress If true, compress the output
* @param array $params Associative array of attributes
* @return The rendered data
function render( $cache =
false, $params =
array())
JResponse::setHeader( 'Last-Modified', $mdate /* gmdate( 'D, d M Y H:i:s', time() + 900 ) . ' GMT' */ );
* Document helper functions
* @package Joomla.Framework
function implodeAttribs($inner_glue =
"=", $outer_glue =
"\n", $array =
null, $keepOuterKey =
false)
foreach($array as $key =>
$item)
// This is value is an array, go and do it again!
$output[] =
$key .
$inner_glue .
'"'.
$item.
'"';
return implode($outer_glue, $output);