From 24bb549beb18a9d800b50cd5f4c305a15806fd0d Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 25 Apr 2006 00:01:52 +0200 Subject: event system revision This is a major revision of DokuWiki's event system. There are changes to class names, function names, function parameters and their order and event names. For action plugin writers the following changes are important: - is no longer signalled, only _BEFORE and _AFTER. - note the case change for _BEFORE and _AFTER - calling stopPropagation while processing a _BEFORE signal no longer prevents an _AFTER signal. The events _continue value is reset before the _AFTER signal is made. - events have a new readonly property, canPreventDefault. This lets the event handling hook know whether or not the event honours preventDefault calls. - parameters have changed for the register_hook method, parameters are now $event_name, $advise (can be 'BEFORE' or 'AFTER') $object $method $param (this parameter is now optional) - parameter order has changed for the hook event handler callback functions &$event $param (can now be left off) Event names have changed, they are now structured __ DOKUWIKI_START darcs-hash:20060424220152-9b6ab-00e366288f7ec8a85b85dc83694a5f43a07aa082.gz --- lib/tpl/default/main.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lib/tpl') diff --git a/lib/tpl/default/main.php b/lib/tpl/default/main.php index a63831ae4..b0034c7e3 100644 --- a/lib/tpl/default/main.php +++ b/lib/tpl/default/main.php @@ -13,6 +13,26 @@ * @link http://wiki.splitbrain.org/wiki:tpl:templates * @author Andreas Gohr */ + +/* event testing ...*/ + +function hello($data) { print $data; return strrev($data); }; +function hook($param, &$event) { + print('this is a hook ['.$param.']'); + switch ($param) { + case 'param1' : $event->preventDefault(); break; + case 'param2' : $event->stopPropagation(); break; + case 'param3' : print('action results['.$event->result.']'); + } +} + +global $EVENT_HANDLER; +$EVENT_HANDLER->register_hook('TEMPLATE','BEFORE',$tmp=NULL,hook,'param2'); +$EVENT_HANDLER->register_hook('TEMPLATE','AFTER',$tmp=NULL,hook,'param3'); + +trigger_event('TEMPLATE',$tmp2='hello!',hello); +#*/ + ?> -- cgit v1.2.3