[pmwiki-devel] More ZAP syntax, notation...
The Editor
editor at fast.st
Mon Mar 19 21:09:11 CDT 2007
I am thinking about a couple more syntax things, to introduce but
would like some input...
Text Var Directives
For one thing, I'd like a way to be able store directives in a hidden
text variable that could be retrieved onto a page, and then be
converted back to directives.
I'm already using the {(command parameter)} markup for various zap
functions and could extend this perhaps, as long as it's not a markup
directive zap is already using...
So (:myPagelist: {(pagelist etc...)}:) and {$:myPagelist}
would yield the pagelist you want... The {( )} markup is already
processed in the sweetspot just between text vars and the next thing
on the list, so this would be perfect. The text var pulls it in, a ZAP
markup rule changes it to (: :), and PmWiki finishes the job.
ZAPform and ZAPinput, etc are late in the markup table, so there's no
reason you couldn't put an entire ZAP form in a text var. Type
{Group.Name$:login} and you get an instant login form, ready to go...
Or whatever. Anywhere. You could even set up a page with all your
favorite ZAPforms and create a custom markup to simplify it even more:
{$ZAP$:login}
As a security issue, I would escape the field value unless entered as
a ZAP input, which requires edit permissions anyway... So no
malicious forms could be entered in a comment box say for example...
In fact if I just escape the closing ) I kill three problems at once:
directives, eval threats, and now this markup. Another option might be
to give a configurable list of accepted directives it would allow
through...
Kind of like I do with php. Then ignore the rest.
Double Replacements (Chaining)
I was also wanting to do some double field replacements for instances
where I wanted to chain zap commands. But despite my best
predictions, ZAP seems to already by chaining without any help. For
the life of my I can seem to figure out why this form doesn't throw
error messages, at least for math_3...
(:messages:)
(:zapform:)
(:zap math_1="6":){$:math_1}
(:zap math_3="{math_2} + 6":){$:math_3}
(:zap math_2="{math_1} + 6":){$:math_2}
(:zap savedata="math_1,math_2,math_3":)
(:input submit:)
(:zapend:)
Does perhaps preg_replace start over at the beginning every time it
finds a match in a string? That might explain it. Whatever the case,
chaining seems to be working. So until I can find an example it can't
handle, I guess I'll worry about double replacements later.
Finally on a minor note, I can't seem to get this pattern to match properly...
$ZAPmath = " /^[-+*/% ()0-9.]+$/";
if (! preg_match($ZAPmath, $value)) $m .= "Invalid numeric input. ";
It returns false about all the time...
Thanks in advance...
Cheers,
Dan
More information about the pmwiki-devel
mailing list