Action Plugins

FIXME

plugins

Action plugins are designed to work with Dokuwiki events to allow for customisation/extension of any part of Dokuwiki that signals its activity using events!

Description

Action plugins are loaded before any significant dokuwiki processing takes place. Immediately after loading, each plugin is called by its register() method to give it the opportunity to register any of its event handlers. When an event is signalled all event handlers registered for that event are called in turn (and in no particular order) and passed the event object by reference. The handler has the opportunity to take action based on the event data and to alter either the event data or the event's subsequent processing. For more details of how the events system works and lists of events refer to the events page.

Technical

Action plugins follow the same basic format and naming convention as the other Dokuwiki plugin types.

  • each plugin is located in its own directory within lib/plugins
  • an action plugin should be called action.php, or if located in the sub-directory action within its plugin sub directory can be called anything.
  • an action plugin consists of a single class action_plugin_<plugin name> which extends the base class DokuWiki_Action_Plugin, found in lib/plugins/action.php. If the action plugin is a file in the action subfolder of the plugin folder then the class will need to be action_plugin_<plugin name>_<action plugin filename>. This filename is without the .php extension.
  • the plugin is provided with standard introspection, localisation and configuration functions via the ultimate base class, DokuWiki_Plugin, found in lib/plugins/base.php, see Common Plugin Functions.
  • the plugin must declare two methods, getInfo() and register().

getInfo()

required

    function getInfo(){
      return array(
        'author' => '<plugin author name>',
        'email'  => '<plugin author contact email address>',
        'date'   => '<date applicable to this version of the plugin>',
        'name'   => '<the plugin\'s name',
        'desc'   => '<brief description of what the plugin does (multiline acceptable)',
        'url'    => '<plugin homepage: a url to find more information on the plugin>',
      );
    }

register()

required

    /**
     * plugin should use this method to register its handlers with the dokuwiki's event controller
     *
     * @param    $controller   Dokuwiki's event controller object. Also available as global $EVENT_HANDLER
     *
     * @return   not required
     */
    function register(&$controller) {
      $controller->register_hook(<EVENT NAME>, <EVENT ADVISE>, $this, <event handler function>, <parameters to be passed to event handler>);
    }

<event handler>()

optional have as many as necessary, can be given any name not already in use in this plugin or its ancestor classes

    /**
     * custom event handler
     *
     * @param    $param   (mixed)   the parameters passed to register_hook when this handler was registered
     * @param    $event   (object)  event object by reference
     *
     * @return   not required
     */
    function <event_handler>(&$event, $param) {
      // custom script statements ...
    }
wiki/plugin_action.txt · Zuletzt geändert: 2009/12/25 22:18 (Externe Bearbeitung)
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki