1<?php
2
3define(DOKU_ACTIONS_ROOT, dirname(__FILE__) . '/../commands');
4
5/**
6 * These renderers renders the output of an action.
7 * If a renderer class is extended, then the subclass replaces the parent
8 * as the renderer. Two subclasses of a the same parent renderer will cause a
9 * conflict, and which renderer wins out is not unpredictable.
10 *
11 * @author Junling Ma <junlingm@gmail.com>
12 */
13abstract class Doku_Action_Renderer {
14    /**
15     * Specifies the action name that this process responds to
16     *
17     * @return string the action name
18     */
19    abstract public function action();
20
21    /**
22     * renders the xhtml output of an action
23     */
24    abstract public function xhtml();
25}
26
27/**
28 * Doku_Action class is the parent class of all actions.
29 * It has two interfaces:
30 *   - a static one that acts as action handler managers
31 *     * act($action_name) to handle an action;
32 *     * render($action_name) to render the output of an action.
33 *   - an interface that specifies what each action should implement, namely
34 *     * action() returning the action name;
35 *     * permission_required() returning the permission level for the action;
36 *     * handle() as the action handler;
37 *
38 * We require that actions are defined as subclasses of Doku_Action, and if
39 * a class is extended, then the subclass replaces the parent as a handler.
40 * Two subclasses of a the same parent handler will cause a conflict, and
41 * which handler wins out is not unpredictable.
42 *
43 * The action definitions are put in a file with the same name as the action
44 * in the inc/commands folder, and a plugin's commands folder (to avoid
45 * conflicts with the action (event_handler) plugins
46 *
47 * @author Junling Ma <junglingm@gmail.com>
48 */
49abstract class Doku_Action
50{
51    /** action() should return the name of the action that this handler
52     *  can handle, e.g., 'edit', 'show', etc.
53     */
54    abstract public function action();
55
56    /** permission_required() should return the permission level that
57     *  this action needs, e.g., 'AUTH_NONE', 'AUTH_READ', etc.
58     */
59    abstract public function permission_required();
60
61    /** handle() method perform the action,
62     *  and return a command to be passed to
63     *  the main template to display the result.
64     *  If there should be no change in action name,
65     *  the return value can be omitted.
66     */
67    abstract public function handle();
68}
69