diff options
author | Andreas Gohr <andi@splitbrain.org> | 2018-04-27 21:02:25 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2018-04-27 21:02:25 +0200 |
commit | 42c2870a34a345aabdf35fb49fa8aa0b54fde2b2 (patch) | |
tree | 3c569fa74598b20184a0169188c2e8a8bb0820be /lib | |
parent | 3dc2d50c5fda9c4bf708ff4c26e266ba239af62c (diff) | |
download | dokuwiki-42c2870a34a345aabdf35fb49fa8aa0b54fde2b2.tar.gz dokuwiki-42c2870a34a345aabdf35fb49fa8aa0b54fde2b2.zip |
plugin prototype adjustments
They are now proper abstract classes
Diffstat (limited to 'lib')
-rw-r--r-- | lib/plugins/action.php | 16 | ||||
-rw-r--r-- | lib/plugins/admin.php | 18 | ||||
-rw-r--r-- | lib/plugins/auth.php | 5 | ||||
-rw-r--r-- | lib/plugins/remote.php | 1 | ||||
-rw-r--r-- | lib/plugins/syntax.php | 34 |
5 files changed, 24 insertions, 50 deletions
diff --git a/lib/plugins/action.php b/lib/plugins/action.php index 23d94a509..496c56926 100644 --- a/lib/plugins/action.php +++ b/lib/plugins/action.php @@ -2,24 +2,18 @@ /** * Action Plugin Prototype * - * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) - * @author Christopher Smith <chris@jalakai.co.uk> - */ -// must be run within Dokuwiki -if(!defined('DOKU_INC')) die(); - -/** * All DokuWiki plugins to interfere with the event system * need to inherit from this class + * + * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) + * @author Christopher Smith <chris@jalakai.co.uk> */ -class DokuWiki_Action_Plugin extends DokuWiki_Plugin { +abstract class DokuWiki_Action_Plugin extends DokuWiki_Plugin { /** * Registers a callback function for a given event * * @param Doku_Event_Handler $controller */ - public function register(Doku_Event_Handler $controller) { - trigger_error('register() not implemented in '.get_class($this), E_USER_WARNING); - } + abstract public function register(Doku_Event_Handler $controller); } diff --git a/lib/plugins/admin.php b/lib/plugins/admin.php index 4e1cbbb33..a1d99a412 100644 --- a/lib/plugins/admin.php +++ b/lib/plugins/admin.php @@ -2,17 +2,13 @@ /** * Admin Plugin Prototype * - * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) - * @author Christopher Smith <chris@jalakai.co.uk> - */ -// must be run within Dokuwiki -if(!defined('DOKU_INC')) die(); - -/** * All DokuWiki plugins to extend the admin function * need to inherit from this class + * + * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) + * @author Christopher Smith <chris@jalakai.co.uk> */ -class DokuWiki_Admin_Plugin extends DokuWiki_Plugin { +abstract class DokuWiki_Admin_Plugin extends DokuWiki_Plugin { /** * Return the text that is displayed at the main admin menu @@ -62,15 +58,13 @@ class DokuWiki_Admin_Plugin extends DokuWiki_Plugin { * Carry out required processing */ public function handle() { - trigger_error('handle() not implemented in '.get_class($this), E_USER_WARNING); + // some plugins might not need this } /** * Output html of the admin page */ - public function html() { - trigger_error('html() not implemented in '.get_class($this), E_USER_WARNING); - } + abstract public function html(); /** * Return true for access only by admins (config:superuser) or false if managers are allowed as well diff --git a/lib/plugins/auth.php b/lib/plugins/auth.php index e8151e6e4..442580b23 100644 --- a/lib/plugins/auth.php +++ b/lib/plugins/auth.php @@ -1,7 +1,4 @@ <?php -// must be run within Dokuwiki -if(!defined('DOKU_INC')) die(); - /** * Auth Plugin Prototype * @@ -12,7 +9,7 @@ if(!defined('DOKU_INC')) die(); * @author Chris Smith <chris@jalakai.co.uk> * @author Jan Schumann <js@jschumann-it.com> */ -class DokuWiki_Auth_Plugin extends DokuWiki_Plugin { +abstract class DokuWiki_Auth_Plugin extends DokuWiki_Plugin { public $success = true; /** diff --git a/lib/plugins/remote.php b/lib/plugins/remote.php index c2253dbd5..7d3d292d0 100644 --- a/lib/plugins/remote.php +++ b/lib/plugins/remote.php @@ -21,6 +21,7 @@ abstract class DokuWiki_Remote_Plugin extends DokuWiki_Plugin { * with an underscore are skipped. * * @return array Information about all provided methods. {@see RemoteAPI}. + * @throws ReflectionException */ public function _getMethods() { $result = array(); diff --git a/lib/plugins/syntax.php b/lib/plugins/syntax.php index 9e2913d78..133a64535 100644 --- a/lib/plugins/syntax.php +++ b/lib/plugins/syntax.php @@ -2,19 +2,15 @@ /** * Syntax Plugin Prototype * - * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) - * @author Andreas Gohr <andi@splitbrain.org> - */ -// must be run within Dokuwiki -if(!defined('DOKU_INC')) die(); - -/** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class + * + * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) + * @author Andreas Gohr <andi@splitbrain.org> */ -class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode_Plugin { +abstract class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode_Plugin { - var $allowedModesSetup = false; + protected $allowedModesSetup = false; /** * Syntax Type @@ -23,10 +19,7 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode_Plugin { * * @return string */ - function getType(){ - trigger_error('getType() not implemented in '.get_class($this), E_USER_WARNING); - return ''; - } + abstract public function getType(); /** * Allowed Mode Types @@ -37,7 +30,7 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode_Plugin { * * @return array */ - function getAllowedTypes() { + public function getAllowedTypes() { return array(); } @@ -55,7 +48,7 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode_Plugin { * * @return string */ - function getPType(){ + public function getPType(){ return 'normal'; } @@ -73,9 +66,7 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode_Plugin { * @param Doku_Handler $handler The Doku_Handler object * @return bool|array Return an array with all data you want to use in render, false don't add an instruction */ - function handle($match, $state, $pos, Doku_Handler $handler){ - trigger_error('handle() not implemented in '.get_class($this), E_USER_WARNING); - } + abstract public function handle($match, $state, $pos, Doku_Handler $handler); /** * Handles the actual output creation. @@ -100,10 +91,7 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode_Plugin { * @param array $data data created by handler() * @return boolean rendered correctly? (however, returned value is not used at the moment) */ - function render($format, Doku_Renderer $renderer, $data) { - trigger_error('render() not implemented in '.get_class($this), E_USER_WARNING); - - } + abstract public function render($format, Doku_Renderer $renderer, $data); /** * There should be no need to override this function @@ -111,7 +99,7 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode_Plugin { * @param string $mode * @return bool */ - function accepts($mode) { + public function accepts($mode) { if (!$this->allowedModesSetup) { global $PARSER_MODES; |