_mime = 'text/html'; // Set document type $this->_type = 'error'; } /** * Set error object * * @param object $error Error object to set * * @return boolean True on success * * @since 11.1 */ public function setError($error) { if ($error instanceof Exception) { $this->_error = & $error; return true; } else { return false; } } /** * Render the document * * @param boolean $cache If true, cache the output * @param array $params Associative array of attributes * * @return string The rendered data * * @since 11.1 */ public function render($cache = false, $params = array()) { // If no error object is set return null if (!isset($this->_error)) { return; } // Set the status header JResponse::setHeader('status', $this->_error->getCode() . ' ' . str_replace("\n", ' ', $this->_error->getMessage())); $file = 'error.php'; // Check template $directory = isset($params['directory']) ? $params['directory'] : 'templates'; $template = isset($params['template']) ? JFilterInput::getInstance()->clean($params['template'], 'cmd') : 'system'; if (!file_exists($directory . '/' . $template . '/' . $file)) { $template = 'system'; } // Set variables $this->baseurl = JUri::base(true); $this->template = $template; $this->debug = isset($params['debug']) ? $params['debug'] : false; $this->error = $this->_error; // Load $data = $this->_loadTemplate($directory . '/' . $template, $file); parent::render(); return $data; } /** * Load a template file * * @param string $directory The name of the template * @param string $filename The actual filename * * @return string The contents of the template * * @since 11.1 */ public function _loadTemplate($directory, $filename) { $contents = ''; // Check to see if we have a valid template file if (file_exists($directory . '/' . $filename)) { // Store the file path $this->_file = $directory . '/' . $filename; // Get the file content ob_start(); require_once $directory . '/' . $filename; $contents = ob_get_contents(); ob_end_clean(); } return $contents; } /** * Render the backtrace * * @return string The contents of the backtrace * * @since 11.1 */ public function renderBacktrace() { $contents = null; $backtrace = $this->_error->getTrace(); if (is_array($backtrace)) { ob_start(); $j = 1; echo ''; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; for ($i = count($backtrace) - 1; $i >= 0; $i--) { echo ' '; echo ' '; if (isset($backtrace[$i]['class'])) { echo ' '; } else { echo ' '; } if (isset($backtrace[$i]['file'])) { echo ' '; } else { echo ' '; } echo ' '; $j++; } echo '
Call stack
#FunctionLocation
' . $j . '' . $backtrace[$i]['class'] . $backtrace[$i]['type'] . $backtrace[$i]['function'] . '()' . $backtrace[$i]['function'] . '()' . $backtrace[$i]['file'] . ':' . $backtrace[$i]['line'] . ' 
'; $contents = ob_get_contents(); ob_end_clean(); } return $contents; } }