[pmwiki-devel] How to allow a choice of edit forms

3 views
Skip to first unread message

Randy Brown

unread,
May 8, 2011, 3:40:51 AM5/8/11
to pmwiki...@pmichaud.com
I would like to make a choice of edit forms available to users. Perhaps someday there will be a WYSIWYG editor, but even if there isn't I have a need to provide a choice now. I'd like some guidance so that I don't go too far down the wrong path and later discover it was a mistake.

If I set up my wiki so that my special edit form appears whenever action=browse and form=section in the URL, I find I can update the pre-defined elements of the page, although I'm missing the usual edit form functionality such as Preview.

However, if I set up my wiki so that when action=edit my EditForm includes the special form instead of using the PmWiki one, I find the form appears but does *not* update the page. (I assume that's because my form uses input controls of various names, rather than a single input control named the way PmWiki's "edit" action handler or form processor expects.)

So what's the best way to allow users a choice of forms? Should I create separate actions to invoke each? (I've never created an action, but I hope it's not too hard to do.) Or can I use action=edit and configure some PHP code somewhere so that it does the proper Post handling based on the edit form that was used to do the Post?

Whichever is the right way, I'm hoping there's a way to leverage PmWiki's edit form functionality. I mentioned wanting to provide a Preview button. Other functionality includes updating the change summary, and allowing guiedit buttons to modify selected text on my form which has multiple input areas. If I can't use action=edit, then is there an easy way to provide those functions with my own action or form handler?

Randy
_______________________________________________
pmwiki-devel mailing list
pmwiki...@pmichaud.com
http://www.pmichaud.com/mailman/listinfo/pmwiki-devel

John Rankin

unread,
May 8, 2011, 9:22:40 PM5/8/11
to pmwiki...@pmichaud.com
On 8/05/11 7:40 PM, Randy Brown wrote:
> So what's the best way to allow users a choice of forms? Should I create separate actions to invoke each? (I've never created an action, but I hope it's not too hard to do.) Or can I use action=edit and configure some PHP code somewhere so that it does the proper Post handling based on the edit form that was used to do the Post?
You may be able to redefine the $EditFunctions array to add another
processing step before posting the page, to put the pieces together so
that the PostPage function has the data it expects to work with. The
$EditFunctions array is processed in the UpdatePage function, so in
theory, you could completely redefine how editing works by mapping
$EditFunctions to a local set of operations. If you search the
pmwiki.php source for "$EditFunctions" you should be able to work out
what pmwiki is doing in the HandleEdit function, which handles
action=edit. As far as I can tell, "HandleEdit" doesn't know much about
what is going on -- it hands control to the processing steps defined in
$EditFunctions.

I say "in theory" as I have only done this using the other method you
identified -- introducing a new action. From the way you describe it, I
*think* you ought to be able to satisfy your requirements with an edit
function that takes a read page apart so it can populate your edit form
and another that puts an edited page back together so it can be posted,
if these are executed at the right places in the processing sequence.

JR

--
John Rankin
Affinity Limited
T 64 4 495 3737
F 64 4 473 7991
M 021 RANKIN
john....@affinity.co.nz
www.affinity.co.nz

Reply all
Reply to author
Forward
0 new messages