[pmwiki-devel] ZAP rewrite advice requested...
editor at fast.st
Wed Dec 13 16:20:21 CST 2006
I must have pulled out handfuls of hair trying to get the new locking
mechanism to work right, and at first seemed to be at a level of
complexity beyond my capacity to solve. I thought it was working last
night, and it did work fine when there is one form on the page, but
when there are multiple forms, (forms in sidebars, footers, hidden in
conditionals, etc.), it got problematic.
Finally I came up with what seems to me a simpler approach. Thought I
would ask for feedback if it seems clear to others? Or see if there
were suggestions on a better way to tackle this...
* (:zapform action="" upload name="":) takes markup for action, upload
(enctype), and name, and sets pmwiki action to zap and adds the form
name to post values. A unique form name is *required* if more than one
zap form is around on a page.
* (:zap field=value name:) Sets $_SESSION[ZAP][pagename(+formname if
set)][field] = value; Name must match formname if set, otherwise leave
* All regular POST fields are ignored by ZAP unless you tell ZAP to
include them for processing by this line:
(:zap fields=Field1,Field2 name:)
* When the form is submitted, ZAP gets the corresponding form name
from the post, retrieves the appropriate session array, adds any
specified post fields to the array, and renames it "$ZAParray".
ZAParray is then sent to the engine for processing rather than the
post. If the array is not set, no processing at all occurs. It also
clears up all the ZAP forms session garbage with a foreach loop.
I don't like the hassle of having to specify the POST fields (it
breaks most existing zap forms), but don't see any other way to do it
without losing your forged header protection. But it is definitely
simpler syntax than the lock pattern! Easier still if there's only
one form on the page and you don't have to worry about a form name.
In other regards it seems to be a good change. Everything is sent as
session variables. The only fields visible in the html are those that
require user input. I think it should accommodate Ben's needs. And
maybe it will be helpful to admins conceptually to see the (:input :)
lines as being for data input and the (:zap :) lines being for zap
commands, though technically that's not exactly correct.
PS. I want to wait until I can get all the snippets tested and
working under the new script before I release it to make sure it's
working like it should. I also radically restructured what was in the
various modules--and want to have those available at the same time.
Any one wanting to try out the zap script in advance and help with
debugging, I'd be happy to email it to you.
More information about the pmwiki-devel