[pmwiki-users] Request input on soon-coming FAST Data release
Joachim Durchholz
jo at durchholz.org
Thu Oct 5 14:36:50 CDT 2006
The Editor schrieb:
> Actually not too many recipes can do everything from an instant
> messaging system, to blogging, to forums, to member authentication,
> etc, all in one script.
I'm pretty sure yours can't do all this in a single script, too. There
will still be lots of input massaging and translation going on for each
application.
> The zip part is once the recipe is installed
> all the features become available by simply cutting and pasting wiki
> markup from one page to another. Or, to put it differently, 90% of
> the recipes can be duplicated by this recipe (at least those doing
> anything with forms)--without having to install any additional
> scripts. To me that is kind of cool.
Yes, sure, but then it's not that 90% of all recipes are doing input forms.
> If FAST Data were included as an optional script in the default
> distribution of PmWiki, most users might never have to install another
> recipe, for anything.
You're over-enthusiastic. You're not doing inline markup, mail
protection, or a gazillion other things that recipes do. I'm pretty sure
that the number of recipes that do input forms is below the 50% mark.
> In the recipe I'm using, it has something like this--with one "if" for
> each available feature:
>
> function Data() {
> global $WorkDir, $WikiDir, $pagename, $ScriptUrl, $MessagesFmt, $m,
> $ts, $data, $log;
> foreach ($_POST as $field => $value) {
> if ($field == "page") { ... }
> if ($field == "create") { ... }
> if ($field == "destroy") { ... }
>
> Suppose I wanted to keep the page feature in the core engine, but put
> the create and destroy functions into a file management include (a
> secondary php file). In the main Data function, I would somehow want
> to not only trigger the include when needed, but also process that
> post field properly.
>
> I'm assuming I would basically have to transform the lines of code in
> the conditional into a function (in the include file) and then have
> the base recipe include the php file and call that function. ie,
> something like:
>
> function Data() {
> global $WorkDir, $WikiDir, $pagename, $ScriptUrl, $MessagesFmt, $m,
> $ts, $data, $log;
> foreach ($_POST as $field => $value) {
> if ($field == "page") { ... }
> if ($field == "create") {
> include_once('datafiles.php');
> Create($field,$value)
> }
> if ($field == "destroy") {
> include_once('datafiles.php');
> Destroy($field,$value)
> }
Don't include_once from a function unless you have tested the
performance ramifications with a web server that has PHP caching. You
might end up slowing down that particular configuration, doing a lot of
work just to make the recipe worse.
I'd recommend something like this cookbook/data/data.php:
<?php # PmWiki check goes here
foreach ($_POST as $field => $value) {
if ($field == "page")
include_once (basename (__FILE__) . '/page.php');
if ($field == "create")
include_once (basename (__FILE__) . '/create.php');
if ($field == "destroy")
include_once (basename (__FILE__) . '/destroy.php');
...
}
Regards,
Jo
More information about the pmwiki-users
mailing list