[ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 <?php 2 3 namespace dokuwiki\Action; 4 5 use dokuwiki\Action\Exception\ActionException; 6 use dokuwiki\Action\Exception\FatalException; 7 8 /** 9 * Class AbstractAction 10 * 11 * Base class for all actions 12 * 13 * @package dokuwiki\Action 14 */ 15 abstract class AbstractAction { 16 17 /** @var string holds the name of the action (lowercase class name, no namespace) */ 18 protected $actionname; 19 20 /** 21 * AbstractAction constructor. 22 * 23 * @param string $actionname the name of this action (see getActionName() for caveats) 24 */ 25 public function __construct($actionname = '') { 26 if($actionname !== '') { 27 $this->actionname = $actionname; 28 } else { 29 // http://stackoverflow.com/a/27457689/172068 30 $this->actionname = strtolower(substr(strrchr(get_class($this), '\\'), 1)); 31 } 32 } 33 34 /** 35 * Return the minimum permission needed 36 * 37 * This needs to return one of the AUTH_* constants. It will be checked against 38 * the current user and page after checkPermissions() ran through. If it fails, 39 * the user will be shown the Denied action. 40 * 41 * @return int 42 */ 43 abstract public function minimumPermission(); 44 45 /** 46 * Check conditions are met to run this action 47 * 48 * @throws ActionException 49 * @return void 50 */ 51 public function checkPreconditions() { 52 } 53 54 /** 55 * Process data 56 * 57 * This runs before any output is sent to the browser. 58 * 59 * Throw an Exception if a different action should be run after this step. 60 * 61 * @throws ActionException 62 * @return void 63 */ 64 public function preProcess() { 65 } 66 67 /** 68 * Output whatever content is wanted within tpl_content(); 69 * 70 * @fixme we may want to return a Ui class here 71 * @throws FatalException 72 */ 73 public function tplContent() { 74 throw new FatalException('No content for Action ' . $this->actionname); 75 } 76 77 /** 78 * Returns the name of this action 79 * 80 * This is usually the lowercased class name, but may differ for some actions. 81 * eg. the export_ modes or for the Plugin action. 82 * 83 * @return string 84 */ 85 public function getActionName() { 86 return $this->actionname; 87 } 88 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body