Source code for file /joomla/cache/handler/view.php
Documentation is available at view.php
* @version $Id: view.php 10707 2008-08-21 09:52:47Z eddieajau $
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2008 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
* Joomla! Cache view type object
* @package Joomla.Framework
* Get the cached view data
* @param object $view The view object to cache output for
* @param string $method The method name of the view method to cache output for
* @param string $group The cache data group
* @param string $id The cache data id
* @return boolean True if the cache is hit (false else)
function get( &$view, $method, $id=
false )
// If an id is not given generate it from the request
$id =
$this->_makeId($view, $method);
$data =
parent::get($id);
// Get the document head out of the cache.
$document->setHeadData((isset
($data['head'])) ?
$data['head'] :
array());
// If the pathway buffer is set in the cache data, get it.
if (isset
($data['pathway']) &&
is_array($data['pathway']))
// Push the pathway data into the pathway object.
$pathway =
&$mainframe->getPathWay();
$pathway->setPathway($data['pathway']);
// If a module buffer is set in the cache data, get it.
if (isset
($data['module']) &&
is_array($data['module']))
// Iterate through the module positions and push them into the document buffer.
foreach ($data['module'] as $name =>
$contents) {
$document->setBuffer($contents, 'module', $name);
// Get the document body out of the cache.
echo
(isset
($data['body'])) ?
$data['body'] :
null;
* No hit so we have to execute the view
// Get the modules buffer before component execution.
$buffer1 =
$document->getBuffer();
// Make sure the module buffer is an array.
if (!isset
($buffer1['module']) ||
!is_array($buffer1['module'])) {
$buffer1['module'] =
array();
// Capture and echo output
* For a view we have a special case. We need to cache not only the output from the view, but the state
* of the document head after the view has been rendered. This will allow us to properly cache any attached
* scripts or stylesheets or links or any other modifications that the view has made to the document object
$cached['head'] =
$document->getHeadData();
$pathway =
&$mainframe->getPathWay();
$cached['pathway'] =
$pathway->getPathway();
// Get the module buffer after component execution.
$buffer2 =
$document->getBuffer();
// Make sure the module buffer is an array.
if (!isset
($buffer2['module']) ||
!is_array($buffer2['module'])) {
$buffer2['module'] =
array();
// Compare the second module buffer against the first buffer.
* Generate a view cache id
* @param object $view The view object to cache output for
* @param string $method The method name to cache for the view object
* @return string MD5 Hash : view cache id
function _makeId(&$view, $method)