diff options
Diffstat (limited to 'platform/www/inc/Action/Exception')
7 files changed, 178 insertions, 0 deletions
diff --git a/platform/www/inc/Action/Exception/ActionAbort.php b/platform/www/inc/Action/Exception/ActionAbort.php new file mode 100644 index 0000000..9c188bb --- /dev/null +++ b/platform/www/inc/Action/Exception/ActionAbort.php @@ -0,0 +1,20 @@ +<?php + +namespace dokuwiki\Action\Exception; + +/** + * Class ActionAbort + * + * Strictly speaking not an Exception but an expected execution path. Used to + * signal when one action is done and another should take over. + * + * If you want to signal the same but under some error condition use ActionException + * or one of it's decendants. + * + * The message will NOT be shown to the enduser + * + * @package dokuwiki\Action\Exception + */ +class ActionAbort extends ActionException { + +} diff --git a/platform/www/inc/Action/Exception/ActionAclRequiredException.php b/platform/www/inc/Action/Exception/ActionAclRequiredException.php new file mode 100644 index 0000000..64a2c61 --- /dev/null +++ b/platform/www/inc/Action/Exception/ActionAclRequiredException.php @@ -0,0 +1,17 @@ +<?php + +namespace dokuwiki\Action\Exception; + +/** + * Class ActionAclRequiredException + * + * Thrown by AbstractACLAction when an action requires that the ACL subsystem is + * enabled but it isn't. You should not use it + * + * The message will NOT be shown to the enduser + * + * @package dokuwiki\Action\Exception + */ +class ActionAclRequiredException extends ActionException { + +} diff --git a/platform/www/inc/Action/Exception/ActionDisabledException.php b/platform/www/inc/Action/Exception/ActionDisabledException.php new file mode 100644 index 0000000..40a0c7d --- /dev/null +++ b/platform/www/inc/Action/Exception/ActionDisabledException.php @@ -0,0 +1,17 @@ +<?php + +namespace dokuwiki\Action\Exception; + +/** + * Class ActionDisabledException + * + * Thrown when the requested action has been disabled. Eg. through the 'disableactions' + * config setting. You should probably not use it. + * + * The message will NOT be shown to the enduser, but a generic information will be shown. + * + * @package dokuwiki\Action\Exception + */ +class ActionDisabledException extends ActionException { + +} diff --git a/platform/www/inc/Action/Exception/ActionException.php b/platform/www/inc/Action/Exception/ActionException.php new file mode 100644 index 0000000..381584c --- /dev/null +++ b/platform/www/inc/Action/Exception/ActionException.php @@ -0,0 +1,66 @@ +<?php + +namespace dokuwiki\Action\Exception; + +/** + * Class ActionException + * + * This exception and its subclasses signal that the current action should be + * aborted and a different action should be used instead. The new action can + * be given as parameter in the constructor. Defaults to 'show' + * + * The message will NOT be shown to the enduser + * + * @package dokuwiki\Action\Exception + */ +class ActionException extends \Exception { + + /** @var string the new action */ + protected $newaction; + + /** @var bool should the exception's message be shown to the user? */ + protected $displayToUser = false; + + /** + * ActionException constructor. + * + * When no new action is given 'show' is assumed. For requests that originated in a POST, + * a 'redirect' is used which will cause a redirect to the 'show' action. + * + * @param string|null $newaction the action that should be used next + * @param string $message optional message, will not be shown except for some dub classes + */ + public function __construct($newaction = null, $message = '') { + global $INPUT; + parent::__construct($message); + if(is_null($newaction)) { + if(strtolower($INPUT->server->str('REQUEST_METHOD')) == 'post') { + $newaction = 'redirect'; + } else { + $newaction = 'show'; + } + } + + $this->newaction = $newaction; + } + + /** + * Returns the action to use next + * + * @return string + */ + public function getNewAction() { + return $this->newaction; + } + + /** + * Should this Exception's message be shown to the user? + * + * @param null|bool $set when null is given, the current setting is not changed + * @return bool + */ + public function displayToUser($set = null) { + if(!is_null($set)) $this->displayToUser = $set; + return $set; + } +} diff --git a/platform/www/inc/Action/Exception/ActionUserRequiredException.php b/platform/www/inc/Action/Exception/ActionUserRequiredException.php new file mode 100644 index 0000000..aab06cc --- /dev/null +++ b/platform/www/inc/Action/Exception/ActionUserRequiredException.php @@ -0,0 +1,17 @@ +<?php + +namespace dokuwiki\Action\Exception; + +/** + * Class ActionUserRequiredException + * + * Thrown by AbstractUserAction when an action requires that a user is logged + * in but it isn't. You should not use it. + * + * The message will NOT be shown to the enduser + * + * @package dokuwiki\Action\Exception + */ +class ActionUserRequiredException extends ActionException { + +} diff --git a/platform/www/inc/Action/Exception/FatalException.php b/platform/www/inc/Action/Exception/FatalException.php new file mode 100644 index 0000000..42e30cc --- /dev/null +++ b/platform/www/inc/Action/Exception/FatalException.php @@ -0,0 +1,26 @@ +<?php + +namespace dokuwiki\Action\Exception; + +/** + * Class FatalException + * + * A fatal exception during handling the action + * + * Will abort all handling and display some info to the user. The HTTP status code + * can be defined. + * + * @package dokuwiki\Action\Exception + */ +class FatalException extends \Exception { + /** + * FatalException constructor. + * + * @param string $message the message to send + * @param int $status the HTTP status to send + * @param null|\Exception $previous previous exception + */ + public function __construct($message = 'A fatal error occured', $status = 500, $previous = null) { + parent::__construct($message, $status, $previous); + } +} diff --git a/platform/www/inc/Action/Exception/NoActionException.php b/platform/www/inc/Action/Exception/NoActionException.php new file mode 100644 index 0000000..1c4e4d0 --- /dev/null +++ b/platform/www/inc/Action/Exception/NoActionException.php @@ -0,0 +1,15 @@ +<?php + +namespace dokuwiki\Action\Exception; + +/** + * Class NoActionException + * + * Thrown in the ActionRouter when a wanted action can not be found. Triggers + * the unknown action event + * + * @package dokuwiki\Action\Exception + */ +class NoActionException extends \Exception { + +} |