Exemple #1
0
 /** 
  * Constructor.
  *
  * @param array $config An optional KConfig object with configuration options.
  * 
  * @return void
  */
 public function __construct($errors = array(), $code = KHttpResponse::INTERNAL_SERVER_ERROR, Exception $previous = null)
 {
     foreach ($errors as $error) {
         $this->_errors[] = $error;
     }
     $message = KHttpResponse::getMessage($code);
     parent::__construct($message, $code, $previous);
 }
Exemple #2
0
 /**
  * Custom JError callback
  *
  * Push the exception call stack in the JException returned through the call back
  * adn then rener the custom error page
  *
  * @param object A JException object
  * @return void
  */
 public function errorHandler($error)
 {
     if ($error instanceof Exception) {
         $exception = $error;
         $this->_exception = $exception;
         //store the exception for later use
         //Make sure we have a valid status code
         JError::raiseError(KHttpResponse::isError($exception->getCode()) ? $exception->getCode() : 500, $exception->getMessage());
         return;
     }
     $error->setProperties(array('backtrace' => $this->_exception->getTrace(), 'file' => $this->_exception->getFile(), 'line' => $this->_exception->getLine()));
     $debug = version_compare(JVERSION, '3.0', 'ge') ? JFactory::getConfig()->get('debug') : JFactory::getConfig()->getValue('config.debug');
     if ($debug) {
         $error->set('message', (string) $this->_exception);
     } else {
         $error->set('message', KHttpResponse::getMessage($error->get('code')));
     }
     //Make sure the buffers are cleared
     while (@ob_get_clean()) {
     }
     JError::customErrorPage($error);
 }
Exemple #3
0
	/**
	 * Custom JError callback
	 *
	 * Push the exception call stack in the JException returned through the call back
	 * adn then rener the custom error page
	 *
	 * @param object A JException object
	 * @return void
	 */
	public function errorHandler($error)
	{
		$error->setProperties(array(
			'backtrace'	=> $this->_exception->getTrace(),
			'file'		=> $this->_exception->getFile(),
			'line'		=> $this->_exception->getLine()
		));
		
		if(KFactory::get('joomla:config')->getValue('config.debug')) {
			$error->set('message', (string) $this->_exception);
		} else {
			$error->set('message', KHttpResponse::getMessage($error->code));
		}
		
		//Make sure the buffers are cleared
		while(@ob_get_clean());
		JError::customErrorPage($error);
	}
 /**
  * Dispatch the controller
  *
  * @param   object		A command context object
  * @return	mixed
  */
 protected function _actionDispatch(KCommandContext $context)
 {
     //Set the default controller
     if ($context->data) {
         $this->_controller_default = KConfig::toData($context->data);
     }
     //Set the date in the context
     $context->data = $this->getData();
     //Execute the controller
     $result = $this->getController()->execute($this->getAction(), $context);
     //Set the response header
     if ($context->status) {
         header(KHttpResponse::getHeader($context->status));
     }
     return $result;
 }
 /**
  * Deep clone of this instance
  *
  * @return void
  */
 public function __clone()
 {
     parent::__clone();
     $this->_request = clone $this->_request;
     $this->_user = clone $this->_user;
 }
Exemple #6
0
 /**
  * Push the controller data into the document
  *
  * This function divert the standard behavior and will push specific controller data
  * into the document
  *
  * @return	mixed
  */
 protected function _actionRender(KCommandContext $context)
 {
     //Headers
     if ($context->headers) {
         foreach ($context->headers as $name => $value) {
             header($name . ' : ' . $value);
         }
     }
     //Status
     if ($context->status) {
         header(KHttpResponse::getHeader($context->status));
     }
     if (is_string($context->result)) {
         return $context->result;
     }
 }
 /**
  * Custom JError callback
  *
  * Push the exception call stack in the JException returned through the call back
  * adn then rener the custom error page
  *
  * @param object A JException object
  * @return void
  */
 public function errorHandler($error)
 {
     $error->setProperties(array('backtrace' => $this->_exception->getTrace(), 'file' => $this->_exception->getFile(), 'line' => $this->_exception->getLine()));
     if (JFactory::getConfig()->getValue('config.debug')) {
         $error->set('message', (string) $this->_exception);
     } else {
         $error->set('message', KHttpResponse::getMessage($error->get('code')));
     }
     if ($this->_exception->getCode() == KHttpResponse::UNAUTHORIZED) {
         header('WWW-Authenticate: Basic Realm="' . KRequest::base() . '"');
     }
     //Make sure the buffers are cleared
     while (@ob_get_clean()) {
     }
     JError::customErrorPage($error);
 }
Exemple #8
0
 /**
  * Catch all exception handler
  *
  * Calls the Joomla error handler to process the exception
  *
  * @param object an Exception object
  * @return void
  */
 public function exceptionHandler($exception)
 {
     $this->_exception = $exception;
     //store the exception for later use
     //Change the Joomla error handler to our own local handler and call it
     JError::setErrorHandling(E_ERROR, 'callback', array($this, 'errorHandler'));
     JError::raiseError(KHttpResponse::isError($exception->getCode()) ? $exception->getCode() : 500, $exception->getMessage());
 }
Exemple #9
0
 /**
  *  Set the response status
  * 
  * @param int    $status  The response status code
  * @param string $message The status message
  *
  * @return LibBaseControllerResponseAbstract
  */
 public function setStatus($status, $message = null)
 {
     if (!$status) {
         throw new InvalidArgumentException('Response status is missing');
     }
     if (!$message && !KHttpResponse::getMessage($status)) {
         throw new InvalidArgumentException('Response message is missing');
     }
     $this->_status_code = $status;
     $this->_status_message = $message;
 }