Table of Contents
Action Router
The ActionRouter is the central part that decides what should happen on a request to a Dokuwiki instance based on the action mode.
Action Routing
The ActionRouter uses the do
parameter to determine which action to load. Each action has its own class in inc/Action
inheriting from AbstractAction or one of it's descendants.
When the router considers running an action, there are several steps (methods) that are called on the Action class. All steps can still abort the action, either because some requirements aren't met or because no further processing is needed within the action. When ever an abortion happens, a different action (usually show
, redirect
or denied
) will be loaded and processing starts again.
- check if the action is disabled through disableactions or by the auth backend
- if yes, shows a message and switches to
show
orredirect
actions for GET and POST request respectively
Action::checkPreconditions
- The action itself can do custom checks that are required to use this action. An ActionException is to be thrown if permissions aren't met
Action::minimumPermission
- The action returns the minimum ACL permission needed to execute the action with the current page context. If that minimum is not met, the
denied
action is loaded
Action::preProcess
- Any code that should be executed by the action before output is sent to the browser happens here. Processing can still be aborted by throwing an
ActionExeption
Once all these steps have been processed, the final action is known and set within the ActionRouter instance.
Output
Once the action has been decided, DokuWiki continues the flow, loads the template and will finally reach a call to tpl_content() which gets the current action from the router and calls Action::tplContent()
on it which returns the actual HTML to output.
Note, that not all actions may have a tplContent
method, because they either abort to a different action earlier or because they abort the whole further flow and output their own content (think export_html
).
Action Plugins
Action Plugin authors do not need to think much about the action router, previous events still work as before.
The ACTION_ACT_PREPROCESS event basically wraps around all the steps under Action Routing. Plugins that prevent the default action in this event's BEFORE phase will then later be handled in the new Plugin
action which has a tplContent
method that triggers TPL_ACT_UNKNOWN.
Change action within a POST request
If you use the ACTION_ACT_PREPROCESS event, and you have to redirect to the 'show' action, you have to use the 'redirect' action actually. This will reset the parameters as well.