2005-07-02 22:49:04 +00:00
|
|
|
<?php
|
2005-08-21 06:49:02 +00:00
|
|
|
/* SVN FILE: $Id$ */
|
2005-06-21 23:44:49 +00:00
|
|
|
|
|
|
|
/**
|
2006-02-07 02:19:53 +00:00
|
|
|
* Methods for displaying presentation data in the view.
|
2005-12-27 03:33:44 +00:00
|
|
|
*
|
2005-08-21 06:49:02 +00:00
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
|
|
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
2006-01-20 07:46:14 +00:00
|
|
|
* Copyright (c) 2006, Cake Software Foundation, Inc.
|
2005-12-23 21:57:26 +00:00
|
|
|
* 1785 E. Sahara Avenue, Suite 490-204
|
|
|
|
* Las Vegas, Nevada 89104
|
2005-12-27 03:33:44 +00:00
|
|
|
*
|
2005-12-23 21:57:26 +00:00
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
2005-08-21 06:49:02 +00:00
|
|
|
*
|
2005-12-27 03:33:44 +00:00
|
|
|
* @filesource
|
2006-01-20 07:46:14 +00:00
|
|
|
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
|
2005-12-23 21:57:26 +00:00
|
|
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
2005-08-21 06:49:02 +00:00
|
|
|
* @package cake
|
2005-10-09 01:56:21 +00:00
|
|
|
* @subpackage cake.cake.libs.view
|
|
|
|
* @since CakePHP v 0.10.0.1076
|
2005-08-21 06:49:02 +00:00
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
|
|
|
* @lastmodified $Date$
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
|
|
|
*/
|
2005-06-21 23:44:49 +00:00
|
|
|
|
2005-08-21 06:49:02 +00:00
|
|
|
/**
|
2006-02-18 23:42:21 +00:00
|
|
|
* Included libraries.
|
|
|
|
*/
|
2005-12-27 03:33:44 +00:00
|
|
|
uses(DS.'view'.DS.'helper');
|
2005-07-02 22:49:04 +00:00
|
|
|
|
|
|
|
/**
|
2005-12-22 01:07:28 +00:00
|
|
|
* View, the V in the MVC triad.
|
2005-08-21 06:49:02 +00:00
|
|
|
*
|
2005-08-25 16:40:50 +00:00
|
|
|
* Class holding methods for displaying presentation data.
|
2005-07-02 22:49:04 +00:00
|
|
|
*
|
2005-12-27 03:33:44 +00:00
|
|
|
* @package cake
|
|
|
|
* @subpackage cake.cake.libs.view
|
|
|
|
* @since CakePHP v 0.10.0.1076
|
2005-07-02 22:49:04 +00:00
|
|
|
*/
|
|
|
|
class View extends Object
|
|
|
|
{
|
2005-07-10 05:08:19 +00:00
|
|
|
/**
|
|
|
|
* Name of the controller.
|
|
|
|
*
|
2005-08-25 16:40:50 +00:00
|
|
|
* @var string Name of controller
|
2005-07-10 05:08:19 +00:00
|
|
|
* @access public
|
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
var $name = null;
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Stores the current URL (for links etc.)
|
|
|
|
*
|
|
|
|
* @var string Current URL
|
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
var $here = null;
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
2006-01-20 07:46:14 +00:00
|
|
|
* Not used. 2006-09
|
2005-07-10 05:08:19 +00:00
|
|
|
*
|
|
|
|
* @var unknown_type
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
var $parent = null;
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Action to be performed.
|
|
|
|
*
|
2005-08-25 16:40:50 +00:00
|
|
|
* @var string Name of action
|
2005-07-10 05:08:19 +00:00
|
|
|
* @access public
|
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
var $action = null;
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An array of names of models the particular controller wants to use.
|
|
|
|
*
|
|
|
|
* @var mixed A single name as a string or a list of names as an array.
|
|
|
|
* @access protected
|
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
var $uses = false;
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An array of names of built-in helpers to include.
|
|
|
|
*
|
|
|
|
* @var mixed A single name as a string or a list of names as an array.
|
|
|
|
* @access protected
|
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
var $helpers = array('Html');
|
2005-07-10 05:08:19 +00:00
|
|
|
|
2005-07-21 04:02:32 +00:00
|
|
|
/**
|
2005-08-25 16:40:50 +00:00
|
|
|
* Path to View.
|
2005-07-21 04:02:32 +00:00
|
|
|
*
|
2005-08-25 16:40:50 +00:00
|
|
|
* @var string Path to View
|
2005-07-21 04:02:32 +00:00
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
var $viewPath;
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Variables for the view
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access private
|
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
var $_viewVars = array();
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
2005-08-25 16:40:50 +00:00
|
|
|
* Title HTML element of this View.
|
2005-07-10 05:08:19 +00:00
|
|
|
*
|
|
|
|
* @var boolean
|
|
|
|
* @access private
|
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
var $pageTitle = false;
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An array of model objects.
|
|
|
|
*
|
|
|
|
* @var array Array of model objects.
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
var $models = array();
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
2005-08-25 16:40:50 +00:00
|
|
|
* Path parts for creating links in views.
|
2005-07-10 05:08:19 +00:00
|
|
|
*
|
2005-08-25 16:40:50 +00:00
|
|
|
* @var string Base URL
|
2005-07-10 05:08:19 +00:00
|
|
|
* @access public
|
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
var $base = null;
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
2005-08-25 16:40:50 +00:00
|
|
|
* Name of layout to use with this View.
|
2005-07-10 05:08:19 +00:00
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
var $layout = 'default';
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
2005-08-25 16:40:50 +00:00
|
|
|
* Turns on or off Cake's conventional mode of rendering views. On by default.
|
2005-07-10 05:08:19 +00:00
|
|
|
*
|
|
|
|
* @var boolean
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
var $autoRender = true;
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
2005-08-25 16:40:50 +00:00
|
|
|
* Turns on or off Cake's conventional mode of finding layout files. On by default.
|
2005-07-10 05:08:19 +00:00
|
|
|
*
|
|
|
|
* @var boolean
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
var $autoLayout = true;
|
2005-07-10 05:08:19 +00:00
|
|
|
|
2005-07-21 04:02:32 +00:00
|
|
|
/**
|
2005-08-25 16:40:50 +00:00
|
|
|
* Array of parameter data
|
2005-07-21 04:02:32 +00:00
|
|
|
*
|
2005-08-25 16:40:50 +00:00
|
|
|
* @var array Parameter data
|
2005-07-21 04:02:32 +00:00
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
var $params;
|
2005-07-21 04:02:32 +00:00
|
|
|
/**
|
2005-10-18 22:27:39 +00:00
|
|
|
* True when the view has been rendered.
|
2005-07-21 04:02:32 +00:00
|
|
|
*
|
2005-08-25 16:40:50 +00:00
|
|
|
* @var boolean
|
2005-07-21 04:02:32 +00:00
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
var $hasRendered = null;
|
2005-12-22 01:07:28 +00:00
|
|
|
|
2005-09-17 07:56:32 +00:00
|
|
|
/**
|
2006-02-07 02:19:53 +00:00
|
|
|
* Reference to the Controller for this view.
|
2005-09-17 07:56:32 +00:00
|
|
|
*
|
2006-02-07 02:19:53 +00:00
|
|
|
* @var Controller
|
2005-09-17 07:56:32 +00:00
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
var $controller = null;
|
2005-07-10 05:08:19 +00:00
|
|
|
|
2005-12-28 17:23:12 +00:00
|
|
|
/**
|
2006-02-07 02:19:53 +00:00
|
|
|
* Array of loaded view helpers.
|
2005-12-28 17:23:12 +00:00
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
var $loaded = array();
|
|
|
|
|
2006-01-01 02:05:01 +00:00
|
|
|
/**
|
2006-02-07 02:19:53 +00:00
|
|
|
* File extension. Defaults to Cake's conventional ".thtml".
|
2006-01-01 02:05:01 +00:00
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
var $ext = '.thtml';
|
|
|
|
|
|
|
|
/**
|
2006-02-07 02:19:53 +00:00
|
|
|
* Sub-directory for this view file.
|
2006-01-01 02:05:01 +00:00
|
|
|
*
|
2006-02-07 02:19:53 +00:00
|
|
|
* @var string
|
2006-01-01 02:05:01 +00:00
|
|
|
*/
|
|
|
|
var $subDir = null;
|
|
|
|
|
2006-02-01 13:26:23 +00:00
|
|
|
/**
|
2006-02-07 02:19:53 +00:00
|
|
|
* Enter description here... Themes. New in Cake RC4.
|
2006-02-01 13:26:23 +00:00
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
var $themeWeb = null;
|
|
|
|
|
|
|
|
/**
|
2006-02-07 02:19:53 +00:00
|
|
|
* Plugin name. A Plugin is a sub-application. New in Cake RC4.
|
2006-02-01 13:26:23 +00:00
|
|
|
*
|
2006-02-07 02:19:53 +00:00
|
|
|
* @link http://wiki.cakephp.org/docs:plugins
|
|
|
|
* @var string
|
2006-02-01 13:26:23 +00:00
|
|
|
*/
|
|
|
|
var $plugin = null;
|
|
|
|
|
2005-07-21 04:02:32 +00:00
|
|
|
/**
|
2005-08-25 16:40:50 +00:00
|
|
|
* Constructor
|
2005-07-21 04:02:32 +00:00
|
|
|
*
|
|
|
|
* @return View
|
|
|
|
*/
|
2006-03-14 03:04:28 +00:00
|
|
|
function __construct (&$controller)
|
2006-02-18 23:42:21 +00:00
|
|
|
{
|
2006-02-28 07:35:01 +00:00
|
|
|
if ($controller != null)
|
|
|
|
{
|
|
|
|
$this->controller =& $controller;
|
|
|
|
$this->_viewVars =& $this->controller->_viewVars;
|
|
|
|
$this->action =& $this->controller->action;
|
|
|
|
$this->autoLayout =& $this->controller->autoLayout;
|
|
|
|
$this->autoRender =& $this->controller->autoRender;
|
|
|
|
$this->base =& $this->controller->base;
|
|
|
|
$this->webroot =& $this->controller->webroot;
|
|
|
|
$this->helpers =& $this->controller->helpers;
|
|
|
|
$this->here =& $this->controller->here;
|
|
|
|
$this->layout =& $this->controller->layout;
|
|
|
|
$this->modelNames =& $this->controller->modelNames;
|
|
|
|
$this->name =& $this->controller->name;
|
|
|
|
$this->pageTitle =& $this->controller->pageTitle;
|
|
|
|
$this->parent =& $this->controller->parent;
|
|
|
|
$this->viewPath =& $this->controller->viewPath;
|
|
|
|
$this->params =& $this->controller->params;
|
|
|
|
$this->data =& $this->controller->data;
|
|
|
|
$this->displayFields =& $this->controller->displayFields;
|
|
|
|
$this->webservices =& $this->controller->webservices;
|
|
|
|
$this->plugin =& $this->controller->plugin;
|
|
|
|
}
|
2005-12-28 17:23:12 +00:00
|
|
|
parent::__construct();
|
2006-02-18 23:42:21 +00:00
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
2005-12-22 01:07:28 +00:00
|
|
|
* Renders view for given action and layout. If $file is given, that is used
|
2005-07-10 05:08:19 +00:00
|
|
|
* for a view filename (e.g. customFunkyView.thtml).
|
|
|
|
*
|
2006-02-07 02:19:53 +00:00
|
|
|
* @param string $action Name of action to render for
|
|
|
|
* @param string $layout Layout to use
|
|
|
|
* @param string $file Custom filename for view
|
2005-07-10 05:08:19 +00:00
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
function render($action=null, $layout=null, $file=null)
|
|
|
|
{
|
|
|
|
if (isset($this->hasRendered) && $this->hasRendered)
|
2006-02-23 08:24:23 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->hasRendered = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$action)
|
|
|
|
{
|
|
|
|
$action = $this->action;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($layout)
|
|
|
|
{
|
|
|
|
$this->setLayout($layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($file)
|
|
|
|
{
|
|
|
|
$viewFileName = $file;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$viewFileName = $this->_getViewFileName($action);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!is_null($this->plugin) && is_null($file))
|
|
|
|
{
|
|
|
|
return $this->pluginView($action, $layout);
|
|
|
|
}
|
|
|
|
|
2006-02-25 04:42:31 +00:00
|
|
|
if (!is_file($viewFileName) && !fileExistsInPath($viewFileName) || $viewFileName === '/' || $viewFileName === '\\')
|
2006-02-23 08:24:23 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if (strpos($action, 'missingAction') !== false)
|
2005-07-10 05:08:19 +00:00
|
|
|
{
|
2006-02-23 08:24:23 +00:00
|
|
|
$errorAction = 'missingAction';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$errorAction = 'missingView';
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
2006-01-13 23:53:23 +00:00
|
|
|
|
2006-02-23 08:24:23 +00:00
|
|
|
foreach(array($this->name, 'errors') as $viewDir)
|
2005-07-10 05:08:19 +00:00
|
|
|
{
|
2006-02-23 08:24:23 +00:00
|
|
|
$errorAction =Inflector::underscore($errorAction);
|
|
|
|
if(file_exists(VIEWS.$viewDir.DS.$errorAction.$this->ext))
|
|
|
|
{
|
|
|
|
$missingViewFileName = VIEWS.$viewDir.DS.$errorAction.$this->ext;
|
|
|
|
}
|
|
|
|
elseif($missingViewFileName = fileExistsInPath(LIBS.'view'.DS.'templates'.DS.$viewDir.DS.$errorAction.'.thtml'))
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$missingViewFileName = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$missingViewExists = is_file($missingViewFileName);
|
|
|
|
if ($missingViewExists)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
2006-02-23 08:24:23 +00:00
|
|
|
|
|
|
|
if (strpos($action, 'missingView') === false)
|
2005-07-10 05:08:19 +00:00
|
|
|
{
|
2006-02-23 08:24:23 +00:00
|
|
|
return $this->cakeError('missingView',
|
|
|
|
array(array('className' => $this->controller->name,
|
|
|
|
'action' => $action,
|
|
|
|
'file' => $viewFileName)));
|
|
|
|
|
|
|
|
$isFatal = isset($this->isFatal) ? $this->isFatal : false;
|
|
|
|
if (!$isFatal)
|
|
|
|
{
|
|
|
|
$viewFileName = $missingViewFileName;
|
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-02-23 08:24:23 +00:00
|
|
|
$missingViewExists = false;
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
|
|
|
|
2006-02-23 08:24:23 +00:00
|
|
|
if (!$missingViewExists || $isFatal)
|
2005-07-10 05:08:19 +00:00
|
|
|
{
|
2006-02-23 08:24:23 +00:00
|
|
|
if (DEBUG)
|
|
|
|
{
|
|
|
|
trigger_error(sprintf(__("No template file for view %s (expected %s), create it first'"), $action, $viewFileName), E_USER_ERROR);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->error('404', 'Not found', sprintf("The requested address %s was not found on this server.", '', "missing view \"{$action}\""));
|
|
|
|
}
|
|
|
|
die();
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
2006-02-23 08:24:23 +00:00
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
|
2006-02-23 08:24:23 +00:00
|
|
|
if ($viewFileName && !$this->hasRendered)
|
|
|
|
{
|
|
|
|
if(substr($viewFileName, -5) === 'thtml')
|
|
|
|
{
|
2006-02-28 07:35:01 +00:00
|
|
|
$out = View::_render($viewFileName, $this->_viewVars);
|
2006-02-23 08:24:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-02-28 07:35:01 +00:00
|
|
|
$out = $this->_render($viewFileName, $this->_viewVars);
|
2006-02-23 08:24:23 +00:00
|
|
|
}
|
|
|
|
if ($out !== false)
|
|
|
|
{
|
|
|
|
if ($this->layout && $this->autoLayout)
|
|
|
|
{
|
|
|
|
$out = $this->renderLayout($out);
|
|
|
|
}
|
|
|
|
print $out;
|
|
|
|
$this->hasRendered = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-02-28 07:35:01 +00:00
|
|
|
$out = $this->_render($viewFileName, $this->_viewVars);
|
2006-02-23 08:24:23 +00:00
|
|
|
trigger_error(sprintf(__("Error in view %s, got: <blockquote>%s</blockquote>"), $viewFileName, $out), E_USER_ERROR);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2006-02-18 23:42:21 +00:00
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders a piece of PHP with provided parameters and returns HTML, XML, or any other string.
|
|
|
|
*
|
2005-08-25 16:40:50 +00:00
|
|
|
* This realizes the concept of Elements, (or "partial layouts")
|
2005-12-22 01:07:28 +00:00
|
|
|
* and the $params array is used to send data to be used in the
|
2005-08-25 16:40:50 +00:00
|
|
|
* Element.
|
|
|
|
*
|
2006-02-07 02:19:53 +00:00
|
|
|
* @link http://wiki.cakephp.org/docs:view:renderelement
|
2006-02-18 23:42:21 +00:00
|
|
|
* @param string $name Name of template file in the/app/views/elements/ folder
|
2006-02-07 02:19:53 +00:00
|
|
|
* @param array $params Array of data to be made available to the for rendered view (i.e. the Element)
|
|
|
|
* @return string Rendered output
|
2005-07-10 05:08:19 +00:00
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
function renderElement($name, $params=array())
|
|
|
|
{
|
2006-01-01 02:05:01 +00:00
|
|
|
$fn = ELEMENTS.$name.$this->ext;
|
2005-07-10 05:08:19 +00:00
|
|
|
|
2006-02-03 06:06:15 +00:00
|
|
|
if(!is_null($this->plugin))
|
|
|
|
{
|
|
|
|
if(file_exists(APP.'plugins'.DS.$this->plugin.'views'.DS.'elements'.DS.$name.$this->ext))
|
|
|
|
{
|
|
|
|
$fn = APP.'plugins'.DS.$this->plugin.'views'.DS.'elements'.DS.$name.$this->ext;
|
|
|
|
$params = array_merge_recursive($params, $this->loaded);
|
2006-02-28 07:35:01 +00:00
|
|
|
return $this->_render($fn, array_merge($this->_viewVars, $params), false);
|
2006-02-03 06:06:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-10 05:08:19 +00:00
|
|
|
if (!file_exists($fn))
|
|
|
|
{
|
|
|
|
return "(Error rendering {$name})";
|
|
|
|
}
|
2006-02-03 06:06:15 +00:00
|
|
|
|
2005-12-28 17:23:12 +00:00
|
|
|
$params = array_merge_recursive($params, $this->loaded);
|
2006-02-28 07:35:01 +00:00
|
|
|
return $this->_render($fn, array_merge($this->_viewVars, $params), false);
|
|
|
|
}
|
|
|
|
|
|
|
|
function element($name)
|
|
|
|
{
|
2006-02-28 19:45:28 +00:00
|
|
|
return ELEMENTS.$name.$this->ext;
|
2006-02-18 23:42:21 +00:00
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders a layout. Returns output from _render(). Returns false on error.
|
|
|
|
*
|
2005-08-25 16:40:50 +00:00
|
|
|
* @param string $content_for_layout Content to render in a view, wrapped by the surrounding layout.
|
2005-10-18 22:27:39 +00:00
|
|
|
* @return mixed Rendered output, or false on error
|
2005-07-10 05:08:19 +00:00
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
function renderLayout($content_for_layout)
|
|
|
|
{
|
2005-07-10 05:08:19 +00:00
|
|
|
$layout_fn = $this->_getLayoutFileName();
|
|
|
|
|
2006-02-28 07:35:01 +00:00
|
|
|
if(DEBUG > 2 && $this->controller != null)
|
2006-01-13 05:56:04 +00:00
|
|
|
{
|
2006-02-28 07:35:01 +00:00
|
|
|
$debug = View::_render(LIBS.'view'.DS.'templates'.DS.'elements'.DS.'dump.thtml', array('controller' => $this->controller), false);
|
2006-01-13 05:56:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$debug = '';
|
|
|
|
}
|
2006-02-28 07:35:01 +00:00
|
|
|
|
|
|
|
if ($this->pageTitle !== false)
|
|
|
|
{
|
|
|
|
$pageTitle = $this->pageTitle;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$pageTitle = Inflector::humanize($this->viewPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
$data_for_layout = array_merge($this->_viewVars, array('title_for_layout' => $pageTitle,
|
|
|
|
'content_for_layout'=> $content_for_layout,
|
|
|
|
'cakeDebug' => $debug));
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
if (is_file($layout_fn))
|
|
|
|
{
|
2006-02-28 07:35:01 +00:00
|
|
|
$data_for_layout = array_merge($data_for_layout, $this->loaded);
|
2006-01-01 02:05:01 +00:00
|
|
|
|
|
|
|
if(substr($layout_fn, -5) === 'thtml')
|
|
|
|
{
|
2006-03-13 03:48:39 +00:00
|
|
|
$out = View::_render($layout_fn, $data_for_layout, false, true);
|
2006-01-01 02:05:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-02-28 07:35:01 +00:00
|
|
|
$out = $this->_render($layout_fn, $data_for_layout, false);
|
2006-01-01 02:05:01 +00:00
|
|
|
}
|
|
|
|
|
2005-07-10 05:08:19 +00:00
|
|
|
if ($out === false)
|
|
|
|
{
|
2006-02-28 07:35:01 +00:00
|
|
|
$out = $this->_render($layout_fn, $data_for_layout);
|
2006-01-12 02:10:47 +00:00
|
|
|
trigger_error(sprintf(__("Error in layout %s, got: <blockquote>%s</blockquote>"), $layout_fn, $out), E_USER_ERROR);
|
2005-07-10 05:08:19 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-01-13 23:53:23 +00:00
|
|
|
return $this->cakeError('missingLayout',
|
|
|
|
array(array('layout' => $this->layout,
|
|
|
|
'file' => $layout_fn)));
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
2006-02-18 23:42:21 +00:00
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
2005-10-18 22:27:39 +00:00
|
|
|
* Sets layout to be used when rendering.
|
2005-07-10 05:08:19 +00:00
|
|
|
*
|
2006-02-07 02:19:53 +00:00
|
|
|
* @param string $layout Name of layout.
|
2005-07-10 05:08:19 +00:00
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
function setLayout($layout)
|
|
|
|
{
|
2005-07-10 05:08:19 +00:00
|
|
|
$this->layout = $layout;
|
2006-02-18 23:42:21 +00:00
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays an error page to the user. Uses layouts/error.html to render the page.
|
|
|
|
*
|
2006-02-07 02:19:53 +00:00
|
|
|
* @param int $code HTTP Error code (for instance: 404)
|
|
|
|
* @param string $name Name of the error (for instance: Not Found)
|
|
|
|
* @param string $message Error message as a web page
|
2005-07-10 05:08:19 +00:00
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
function error ($code, $name, $message)
|
|
|
|
{
|
2005-07-10 05:08:19 +00:00
|
|
|
header ("HTTP/1.0 {$code} {$name}");
|
|
|
|
print ($this->_render(VIEWS.'layouts/error.thtml', array('code'=>$code,'name'=>$name,'message'=>$message)));
|
2006-02-18 23:42:21 +00:00
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
2006-02-18 23:42:21 +00:00
|
|
|
* Private methods.
|
|
|
|
*************************************************************************/
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns filename of given action's template file (.thtml) as a string. CamelCased action names will be under_scored! This means that you can have LongActionNames that refer to long_action_names.thtml views.
|
|
|
|
*
|
|
|
|
* @param string $action Controller action to find template filename for
|
|
|
|
* @return string Template filename
|
|
|
|
* @access private
|
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
function _getViewFileName($action)
|
|
|
|
{
|
|
|
|
$action = Inflector::underscore($action);
|
2006-03-19 03:26:43 +00:00
|
|
|
$paths = Configure::getInstance();
|
2006-02-18 23:42:21 +00:00
|
|
|
|
|
|
|
if(!is_null($this->webservices))
|
|
|
|
{
|
|
|
|
$type = strtolower($this->webservices).DS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$type = null;
|
|
|
|
}
|
2006-03-02 06:23:16 +00:00
|
|
|
|
|
|
|
$position = strpos($action, '..');
|
|
|
|
if ($position === false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$action = explode('/', $action);
|
|
|
|
$i = array_search('..', $action);
|
|
|
|
unset($action[$i-1]);
|
|
|
|
unset($action[$i]);
|
|
|
|
$action = '..'.DS.implode(DS, $action);
|
|
|
|
}
|
|
|
|
|
2006-03-19 05:03:42 +00:00
|
|
|
foreach ($paths->viewPaths as $path)
|
2006-02-18 23:42:21 +00:00
|
|
|
{
|
2006-03-19 03:26:43 +00:00
|
|
|
if(file_exists($path.$this->viewPath.DS.$this->subDir.$type.$action.$this->ext))
|
|
|
|
{
|
|
|
|
$viewFileName = $path.$this->viewPath.DS.$this->subDir.$type.$action.$this->ext;
|
|
|
|
return $viewFileName;
|
|
|
|
}
|
2006-02-18 23:42:21 +00:00
|
|
|
}
|
2006-03-19 03:26:43 +00:00
|
|
|
|
|
|
|
if($viewFileName = fileExistsInPath(LIBS.'view'.DS.'templates'.DS.'errors'.DS.$type.$action.'.thtml'))
|
2006-02-18 23:42:21 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
elseif($viewFileName = fileExistsInPath(LIBS.'view'.DS.'templates'.DS.$this->viewPath.DS.$type.$action.'.thtml'))
|
|
|
|
{
|
|
|
|
|
2006-03-12 15:59:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$viewFileName = VIEWS.$this->viewPath.DS.$this->subDir.$type.$action.$this->ext;
|
2006-02-18 23:42:21 +00:00
|
|
|
}
|
2006-03-02 06:23:16 +00:00
|
|
|
return $viewFileName;
|
2006-02-18 23:42:21 +00:00
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns layout filename for this template as a string.
|
|
|
|
*
|
|
|
|
* @return string Filename for layout file (.thtml).
|
|
|
|
* @access private
|
|
|
|
*/
|
2005-12-22 01:07:28 +00:00
|
|
|
function _getLayoutFileName()
|
|
|
|
{
|
2006-02-28 07:35:01 +00:00
|
|
|
if(isset($this->webservices) && !is_null($this->webservices))
|
2005-12-22 01:07:28 +00:00
|
|
|
{
|
2006-02-18 23:42:21 +00:00
|
|
|
$type = strtolower($this->webservices).DS;
|
2005-12-22 01:07:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$type = null;
|
|
|
|
}
|
2006-02-03 06:06:15 +00:00
|
|
|
|
2006-02-28 07:35:01 +00:00
|
|
|
if(isset($this->plugin) && !is_null($this->plugin))
|
2006-02-03 06:06:15 +00:00
|
|
|
{
|
|
|
|
if(file_exists(APP.'plugins'.DS.$this->plugin.'views'.DS.'layouts'.DS.$this->layout.$this->ext))
|
|
|
|
{
|
|
|
|
$layoutFileName = APP.'plugins'.DS.$this->plugin.'views'.DS.'layouts'.DS.$this->layout.$this->ext;
|
|
|
|
return $layoutFileName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-01 02:05:01 +00:00
|
|
|
if(file_exists(LAYOUTS.$this->subDir.$type."{$this->layout}$this->ext"))
|
2005-12-27 03:33:44 +00:00
|
|
|
{
|
2006-01-01 02:05:01 +00:00
|
|
|
$layoutFileName = LAYOUTS.$this->subDir.$type."{$this->layout}$this->ext";
|
2005-12-27 03:33:44 +00:00
|
|
|
}
|
2006-02-16 09:29:28 +00:00
|
|
|
elseif($layoutFileName = fileExistsInPath(LIBS.'view'.DS.'templates'.DS."layouts".DS.$type."{$this->layout}.thtml"))
|
2005-12-27 03:33:44 +00:00
|
|
|
{
|
|
|
|
}
|
2006-03-12 15:59:46 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$layoutFileName = LAYOUTS.$type."{$this->layout}$this->ext";
|
|
|
|
}
|
2005-12-27 03:33:44 +00:00
|
|
|
return $layoutFileName;
|
2006-02-18 23:42:21 +00:00
|
|
|
}
|
2005-12-22 01:07:28 +00:00
|
|
|
|
2005-07-10 05:08:19 +00:00
|
|
|
/**
|
2005-12-22 01:07:28 +00:00
|
|
|
* Renders and returns output for given view filename with its
|
2005-07-10 05:08:19 +00:00
|
|
|
* array of data.
|
|
|
|
*
|
|
|
|
* @param string $___viewFn Filename of the view
|
2006-02-18 23:42:21 +00:00
|
|
|
* @param array $___dataForView Data to include in rendered view
|
2005-07-10 05:08:19 +00:00
|
|
|
* @return string Rendered output
|
|
|
|
* @access private
|
|
|
|
*/
|
2006-03-13 03:48:39 +00:00
|
|
|
function _render($___viewFn, $___dataForView, $loadHelpers = true, $cached = false)
|
2005-12-28 17:23:12 +00:00
|
|
|
{
|
|
|
|
if ($this->helpers != false && $loadHelpers === true)
|
|
|
|
{
|
|
|
|
$loadedHelpers = array();
|
|
|
|
$loadedHelpers = $this->_loadHelpers($loadedHelpers, $this->helpers);
|
2005-12-22 01:07:28 +00:00
|
|
|
|
2005-12-28 17:23:12 +00:00
|
|
|
foreach(array_keys($loadedHelpers) as $helper)
|
|
|
|
{
|
|
|
|
$replace = strtolower(substr($helper, 0, 1));
|
|
|
|
$camelBackedHelper = preg_replace('/\\w/', $replace, $helper, 1);
|
2005-12-28 01:52:56 +00:00
|
|
|
|
2005-12-28 17:23:12 +00:00
|
|
|
${$camelBackedHelper} =& $loadedHelpers[$helper];
|
|
|
|
|
|
|
|
if(isset(${$camelBackedHelper}->helpers) && is_array(${$camelBackedHelper}->helpers))
|
|
|
|
{
|
|
|
|
foreach(${$camelBackedHelper}->helpers as $subHelper)
|
|
|
|
{
|
|
|
|
${$camelBackedHelper}->{$subHelper} =& $loadedHelpers[$subHelper];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->loaded[$camelBackedHelper] = (${$camelBackedHelper});
|
|
|
|
}
|
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
|
2006-02-28 07:35:01 +00:00
|
|
|
extract($___dataForView, EXTR_SKIP);
|
|
|
|
$BASE = $this->base;
|
|
|
|
$params = &$this->params;
|
|
|
|
$page_title = $this->pageTitle;
|
2005-07-10 05:08:19 +00:00
|
|
|
|
2006-02-28 07:35:01 +00:00
|
|
|
ob_start();
|
|
|
|
if(DEBUG)
|
|
|
|
{
|
|
|
|
include($___viewFn);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
@include($___viewFn);
|
|
|
|
}
|
2006-03-12 00:11:40 +00:00
|
|
|
|
2006-03-13 03:48:39 +00:00
|
|
|
$out = ob_get_clean();
|
2006-03-19 03:26:43 +00:00
|
|
|
if(isset($this->loaded['cache']) && ((isset($this->controller) && $this->controller->cacheAction != false)) &&
|
|
|
|
(defined('CACHE_CHECK') && CACHE_CHECK === true))
|
2006-03-12 00:11:40 +00:00
|
|
|
{
|
2006-03-13 03:48:39 +00:00
|
|
|
if (is_a($this->loaded['cache'], 'CacheHelper'))
|
2006-03-12 00:11:40 +00:00
|
|
|
{
|
2006-03-13 03:48:39 +00:00
|
|
|
$cache =& $this->loaded['cache'];
|
2006-03-14 02:26:08 +00:00
|
|
|
if($cached === true)
|
|
|
|
{
|
|
|
|
$cache->view =& $this;
|
|
|
|
}
|
2006-03-13 03:48:39 +00:00
|
|
|
$cache->base = $this->base;
|
|
|
|
$cache->here = $this->here;
|
2006-03-14 11:54:03 +00:00
|
|
|
$cache->action = $this->action;
|
2006-03-13 03:48:39 +00:00
|
|
|
$cache->controllerName = $this->params['controller'];
|
|
|
|
$cache->cacheAction = $this->controller->cacheAction;
|
|
|
|
$cache->cache($___viewFn, $out, $cached);
|
2006-03-12 00:11:40 +00:00
|
|
|
}
|
|
|
|
}
|
2006-03-13 03:48:39 +00:00
|
|
|
return $out;
|
2006-02-18 23:42:21 +00:00
|
|
|
}
|
2005-12-22 01:07:28 +00:00
|
|
|
|
2006-03-13 03:48:39 +00:00
|
|
|
|
2005-12-27 03:33:44 +00:00
|
|
|
/**
|
2006-02-18 23:42:21 +00:00
|
|
|
* Loads helpers, with their dependencies.
|
|
|
|
*
|
|
|
|
* @param array $loaded List of helpers that are already loaded.
|
|
|
|
* @param array $helpers List of helpers to load.
|
|
|
|
* @return array
|
2005-10-09 01:56:21 +00:00
|
|
|
*/
|
2005-12-27 03:33:44 +00:00
|
|
|
function &_loadHelpers(&$loaded, $helpers)
|
|
|
|
{
|
2006-01-12 02:10:47 +00:00
|
|
|
static $tags;
|
|
|
|
if(empty($tags))
|
|
|
|
{
|
|
|
|
$helperTags = new Helper();
|
|
|
|
$tags = $helperTags->loadConfig();
|
|
|
|
}
|
|
|
|
|
2005-12-27 03:33:44 +00:00
|
|
|
foreach ($helpers as $helper)
|
2005-10-03 04:48:00 +00:00
|
|
|
{
|
2005-12-27 03:33:44 +00:00
|
|
|
$helperCn = $helper.'Helper';
|
2005-12-22 01:07:28 +00:00
|
|
|
|
2005-12-27 03:33:44 +00:00
|
|
|
if(in_array($helper, array_keys($loaded)) !== true)
|
2005-10-03 04:48:00 +00:00
|
|
|
{
|
2005-12-27 03:33:44 +00:00
|
|
|
if(!class_exists($helperCn))
|
|
|
|
{
|
|
|
|
$helperFn = Inflector::underscore($helper).'.php';
|
2006-02-01 13:26:23 +00:00
|
|
|
|
|
|
|
if(file_exists(APP.'plugins'.DS.$this->plugin.'views'.DS.'helpers'.DS.$helperFn))
|
|
|
|
{
|
|
|
|
$helperFn = APP.'plugins'.DS.$this->plugin.'views'.DS.'helpers'.DS.$helperFn;
|
|
|
|
}
|
|
|
|
else if(file_exists(HELPERS.$helperFn))
|
2005-12-27 03:33:44 +00:00
|
|
|
{
|
|
|
|
$helperFn = HELPERS.$helperFn;
|
|
|
|
}
|
2006-02-16 09:29:28 +00:00
|
|
|
else if($helperFn = fileExistsInPath(LIBS.'view'.DS.'helpers'.DS.$helperFn))
|
2005-12-27 03:33:44 +00:00
|
|
|
{
|
2006-02-16 09:29:28 +00:00
|
|
|
|
2005-12-27 03:33:44 +00:00
|
|
|
}
|
|
|
|
if (is_file($helperFn))
|
|
|
|
{
|
2006-02-17 10:12:15 +00:00
|
|
|
require $helperFn;
|
2005-12-27 03:33:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-01-13 23:53:23 +00:00
|
|
|
return $this->cakeError('missingHelperFile',
|
|
|
|
array(array('helper' => $helper,
|
|
|
|
'file' => Inflector::underscore($helper).'.php')));
|
2005-12-27 03:33:44 +00:00
|
|
|
}
|
|
|
|
}
|
2005-12-22 01:07:28 +00:00
|
|
|
|
2005-12-27 03:33:44 +00:00
|
|
|
$replace = strtolower(substr($helper, 0, 1));
|
|
|
|
$camelBackedHelper = preg_replace('/\\w/', $replace, $helper, 1);
|
[1210]
Author: phpnut
Date: 4:44:45 AM, Wednesday, October 26, 2005
Message:
AJAX is now available as a by default in the $html variable in the templates.
You access it like this:
$html->Ajax->xxx();
Updated default templates.
[1208]
Author: phpnut
Date: 6:49:26 PM, Tuesday, October 25, 2005
Message:
Adding fix in Controller::generateFieldNames();
[1203]
Author: phpnut
Date: 10:40:28 AM, Tuesday, October 25, 2005
Message:
Changes made to core templates and css.
Fixed added for Ticket #60
[1202]
Author: phpnut
Date: 2:30:58 AM, Tuesday, October 25, 2005
Message:
Fix for cake error templates
Fixed a key for tables that are underscored in scaffolded code.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1211 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-26 10:55:44 +00:00
|
|
|
|
2005-12-27 17:14:32 +00:00
|
|
|
if(class_exists($helperCn))
|
2005-10-03 04:48:00 +00:00
|
|
|
{
|
2006-02-28 07:35:01 +00:00
|
|
|
${$camelBackedHelper} =& new $helperCn;
|
2005-12-27 03:33:44 +00:00
|
|
|
${$camelBackedHelper}->base = $this->base;
|
|
|
|
${$camelBackedHelper}->webroot = $this->webroot;
|
|
|
|
${$camelBackedHelper}->here = $this->here;
|
2006-02-28 07:35:01 +00:00
|
|
|
${$camelBackedHelper}->params = $this->params;
|
|
|
|
${$camelBackedHelper}->action = $this->action;
|
2005-12-27 03:33:44 +00:00
|
|
|
${$camelBackedHelper}->data = $this->data;
|
2006-02-01 13:26:23 +00:00
|
|
|
${$camelBackedHelper}->themeWeb = $this->themeWeb;
|
2005-12-28 17:23:12 +00:00
|
|
|
${$camelBackedHelper}->tags = $tags;
|
2006-03-19 03:26:43 +00:00
|
|
|
${$camelBackedHelper}->plugin = $this->plugin;
|
2005-12-27 03:33:44 +00:00
|
|
|
|
|
|
|
if(!empty($this->validationErrors))
|
|
|
|
{
|
|
|
|
${$camelBackedHelper}->validationErrors = $this->validationErrors;
|
|
|
|
}
|
|
|
|
$loaded[$helper] =& ${$camelBackedHelper};
|
|
|
|
if (isset(${$camelBackedHelper}->helpers) && is_array(${$camelBackedHelper}->helpers))
|
|
|
|
{
|
|
|
|
$loaded =& $this->_loadHelpers($loaded, ${$camelBackedHelper}->helpers);
|
|
|
|
}
|
2005-10-03 04:48:00 +00:00
|
|
|
}
|
2005-12-27 03:33:44 +00:00
|
|
|
else
|
2005-10-03 04:48:00 +00:00
|
|
|
{
|
2006-01-13 23:53:23 +00:00
|
|
|
return $this->cakeError('missingHelperClass',
|
|
|
|
array(array('helper' => $helper,
|
|
|
|
'file' => Inflector::underscore($helper).'.php')));
|
2005-10-03 04:48:00 +00:00
|
|
|
}
|
2005-12-27 03:33:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $loaded;
|
|
|
|
}
|
2005-06-21 23:44:49 +00:00
|
|
|
|
2006-02-28 07:35:01 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @param unknown_type $action
|
|
|
|
* @param unknown_type $layout
|
|
|
|
* @return unknown
|
|
|
|
*/
|
2006-02-01 13:26:23 +00:00
|
|
|
function pluginView($action, $layout)
|
|
|
|
{
|
|
|
|
$viewFileName = APP.'plugins'.DS.$this->plugin.'views'.DS.$this->viewPath.DS.$action.$this->ext;
|
|
|
|
if(file_exists($viewFileName))
|
|
|
|
{
|
|
|
|
$this->render($action, $layout, $viewFileName);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return $this->cakeError('missingView',
|
|
|
|
array(array('className' => $this->controller->name,
|
|
|
|
'action' => $action,
|
|
|
|
'file' => $viewFileName)));
|
|
|
|
}
|
|
|
|
}
|
2006-03-14 02:26:08 +00:00
|
|
|
|
2006-03-15 20:45:59 +00:00
|
|
|
function renderCache($filename, $timeStart)
|
2006-03-14 02:26:08 +00:00
|
|
|
{
|
|
|
|
ob_start();
|
|
|
|
include($filename);
|
|
|
|
if (DEBUG)
|
|
|
|
{
|
2006-03-15 20:45:59 +00:00
|
|
|
echo "<!-- Cached Render Time: ". round(getMicrotime() - $timeStart, 4) ."s -->";
|
2006-03-14 02:26:08 +00:00
|
|
|
}
|
|
|
|
$out = ob_get_clean();
|
|
|
|
if (preg_match('/^<!--cachetime:(\\d+)-->/', $out, $match))
|
|
|
|
{
|
|
|
|
if(time() >= $match['1'])
|
|
|
|
{
|
|
|
|
@unlink($filename);
|
|
|
|
unset($out);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
e($out);
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-02-01 13:26:23 +00:00
|
|
|
}
|
2005-06-21 23:44:49 +00:00
|
|
|
?>
|