1<?php 2 3// this exampel shows how to handle an action, and render the results. 4class Components_Action_Example extends Doku_Action { 5 /** action() should return the name of the action that this handler 6 * can handle, e.g., 'edit', 'show', etc. 7 * note that the actual command is some_plugin.some_command, for example, 8 * this action is components.example 9 */ 10 public function action() { return 'example'; } 11 12 /** permission_required() should return the permission level that 13 * this action needs, e.g., 'AUTH_NONE', 'AUTH_READ', etc. 14 */ 15 public function permission_required() { return AUTH_EDIT; } 16 17 /** handle() method perform the action, 18 * and return a command to be passed to 19 * the main template to display the result. 20 * If there should be no change in action name, 21 * the return value can be omitted. 22 */ 23 public function handle() { 24 global $EXAMPLE_TAG; 25 global $INPUT; 26 $EXAMPLE_TAG = htmlspecialchars($INPUT->str('tag', 'pre')); 27 } 28} 29 30class Components_Action_Renderer_Example extends Doku_Action_Renderer { 31 /** action() should return the name of the action that this handler 32 * can handle, e.g., 'edit', 'show', etc. 33 * note that the actual command is some_plugin.some_command, for example, 34 * this action is components.example 35 */ 36 public function action() { return 'example'; } 37 38 /** 39 * renders the xhtml output of an action 40 * note that you can define Doku_Action_Postprocessor subclasses to change 41 * the global data that is used here, e.g., $ID and $EXAMPLE_TAG, 42 */ 43 public function xhtml() { 44 global $ID; 45 global $EXAMPLE_TAG; 46 $text = htmlspecialchars(rawWiki($ID)); 47 echo '<' . $EXAMPLE_TAG . '>' . $text . '</' . $EXAMPLE_TAG . '>'; 48 } 49} 50