[pmwiki-users] $EditFunctions / stdconfig.php difficulties + proposed fix

Eemeli Aro eemeli at gmail.com
Tue Aug 4 11:06:25 CDT 2009


I'm putting together a new PmWiki blog package, but I'm running into
some rather thorny issues manipulating the $EditFunctions array in a
sane manner.

More specifically, at the moment I'm looking to overload the EditDraft
function without having to duplicate the contents of
scripts/draft.php. The simple thing to do would be something like
this:

if (IsEnabled($EnableDrafts, 0)) {
  include_once("my_draft.php");
  $EnableDrafts = 0;
}

But that won't play nice, since drafts should come after simuledit +
prefs, and hence those too would have to be included before
my_draft.php, and those in turn might be influenced by stuff in
per-page customisations, etc. So the chance of screwing up and/or
interfering with other recipes gets pretty high.

The reason it's so difficult is because much of the initialisation
code for scripts as well as cookbook recipes happens right when
they're included, which means that the order in which you put things
in your config file(s) is important. I think this isn't the best way
of doing things.

For a fix, I suggest a new table of initialisation functions that
could get called from pmwiki.php at the very end of initialisation,
just before HandleDispatch. The format for this table should be
something similar to the MarkupTable, which handles the exact same
problem, just for a different context (the order in which markup rules
get implemented). I'm quite willing to work on the code for this, if
there's interest.

Regarding my original issue, this table would let me eg. add a
function near its end that would safely replace the appropriate
$EditFunctions entry with my own function.

eemeli



More information about the pmwiki-users mailing list