10 defined(
'JPATH_PLATFORM') or die;
36 public function __construct($options = array())
38 parent::__construct($options);
41 $this->_mime =
'text/html';
44 $this->_type =
'error';
56 public function setError($error)
58 if ($error instanceof Exception)
60 $this->_error = & $error;
79 public function render($cache =
false, $params = array())
82 if (!isset($this->_error))
88 JFactory::getApplication()->setHeader(
'status', $this->_error->getCode() .
' ' . str_replace(
"\n",
' ', $this->_error->getMessage()));
92 $directory = isset($params[
'directory']) ? $params[
'directory'] :
'templates';
95 if (!file_exists($directory .
'/' . $template .
'/' . $file))
102 $this->
template = $template;
103 $this->debug = isset($params[
'debug']) ? $params[
'debug'] :
false;
104 $this->error = $this->_error;
107 $data = $this->_loadTemplate($directory .
'/' . $template, $file);
123 public function _loadTemplate($directory, $filename)
128 if (file_exists($directory .
'/' . $filename))
131 $this->_file = $directory .
'/' . $filename;
135 require_once $directory .
'/' . $filename;
136 $contents = ob_get_contents();
150 public function renderBacktrace()
153 $backtrace = $this->_error->getTrace();
154 if (is_array($backtrace))
158 echo
'<table cellpadding="0" cellspacing="0" class="Table">';
160 echo
' <td colspan="3" class="TD"><strong>Call stack</strong></td>';
163 echo
' <td class="TD"><strong>#</strong></td>';
164 echo
' <td class="TD"><strong>Function</strong></td>';
165 echo
' <td class="TD"><strong>Location</strong></td>';
167 for ($i = count($backtrace) - 1; $i >= 0; $i--)
170 echo
' <td class="TD">' . $j .
'</td>';
171 if (isset($backtrace[$i][
'class']))
173 echo
' <td class="TD">' . $backtrace[$i][
'class'] . $backtrace[$i][
'type'] . $backtrace[$i][
'function'] .
'()</td>';
177 echo
' <td class="TD">' . $backtrace[$i][
'function'] .
'()</td>';
179 if (isset($backtrace[$i][
'file']))
181 echo
' <td class="TD">' . $backtrace[$i][
'file'] .
':' . $backtrace[$i][
'line'] .
'</td>';
185 echo
' <td class="TD"> </td>';
191 $contents = ob_get_contents();