On Fri, 16 Sep 2005 18:01:17 +0100 "Chris Smith" <chris@xxxxxxxxxxxxx> wrote: > > > Hows about a pair of functions, Hi! Again: Sorry for the delay. > I am struggling to visualise your extension of my idea. Let me try > ... > > hooks: > - hook handler, three functions, register, activate & load action > plugins Yes. I think of something like simplified event handlers as known from from windowsystem based programming (think windows) > - parts of dokuwiki can register an ACTION for a particular HOOK by > calling the hook handler Certain parts of DokuWiki create events (I called them hooks but events may be the better idea). Example: the function that saves the wiki text, gathers all needed information (id, the text submitted, userinfo, whatever) and stuffes all of this into an array $data. Then it calls fireEvent('beforeSave',$data); This will trigger all plugind that registered on the event (maybe using a sort again). Now the function uses the data: if(!$data['saveOK']) return false; // continue with saving > - action plugins are plugins which are instantiated by the hook > handler and given the opportunity to register themselves as ACTIONs > for HOOKs.(2) Yes. Something like this //constructor: function plugin_foo(){ $this->registerEvent('beforeSave','_saveHandler',20); // 20 = sort } // handler function _saveHandler(&$data){ if($data['user'] == 'BadBoy'){ msg('I don't like you',-1); $data['saveOK'] == false; }else{ $data['saveOK'] == true; } } > (1) do hooks have the opportunity to cancel further actions of the > hook activator where appropriate. e.g. if one of the "pre-save" hooks > were to return false, should the page be saved? Yes. See above. Which things need to be returned depend on the event. > (2) could use the standard register hook interface (say in their > constructor) or use a more restricted interface. The first way would > allow more than one hook per action plugin class, the second probably > wouldn't (say, two required functions - ->register() return the hook > this plugin attaches itself to; ->actiion() the action to be carried > out when the hook is activated. Not sure if I understood you correctly here, but I like to register on multiple events for a single plugin. Eg. printing another field to the edit form, checking this field later in the save Event. > Note: as mentioned previously, syntax plugins and the parser would not > be able to use this facility (without other modifications to Dokuwiki > outside the scope of action plugin themselves) Again not sure what you mean here (it's late and I had some drinks - sorry if my mind is slow). But action plugins should be simply another PluginClass beside the action and syntax plugins (<plugin>/action.php) so you can combine a synax and an actionplugin class in on plugin. Andi -- http://www.splitbrain.org -- DokuWiki mailing list - more info at http://wiki.splitbrain.org/wiki:mailinglist