XMLRPC: new event XMLRPC_CALLBACK_REGISTER

By using this event, action plugins can register their own callback methods
	in DokuWikis XML-RPC server, and extend it's functionality. The event data
	is the server instance. Plugins can also remove already registered
	callbacks or replace them with their own methods.

darcs-hash:20080824080457-23886-b49b897592ce6717f0980f6044bae2d51fd73336.gz
This commit is contained in:
Michael Klier 2008-08-24 10:04:57 +02:00
parent dfd13e55ad
commit bb32615dd0
2 changed files with 25 additions and 0 deletions

View file

@ -354,6 +354,15 @@ EOD;
// Call the method
#$result = $this->$method($args);
$result = call_user_func_array(array(&$this,$method),$args);
} elseif (substr($method, 0, 7) == 'plugin:') {
require_once(DOKU_INC.'inc/pluginutils.php');
list($pluginname, $callback) = explode(':', substr($method, 7), 2);
if(!plugin_isdisabled($pluginname)) {
$plugin = plugin_load('action', $pluginname);
return call_user_func_array(array($plugin, $callback), $args);
} else {
return new IXR_Error(-99999, 'server error');
}
} else {
// It's a function - does it exist?
if (!function_exists($method)) {

View file

@ -149,6 +149,22 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer {
'Returns a struct with infos about the attachment.'
);
/**
* Trigger XMLRPC_CALLBACK_REGISTER, action plugins can use this event
* to extend the XMLRPC interface and register their own callbacks.
*
* Event data:
* The XMLRPC server object:
*
* $event->data->addCallback() - register a callback, the second
* paramter has to be of the form "plugin:<pluginname>:<plugin
* method>"
*
* $event->data->callbacks - an array which holds all awaylable
* callbacks
*/
trigger_event('XMLRPC_CALLBACK_REGISTER', $this);
$this->serve();
}