[pmwiki-users] Conditional Markup enhancement

Patrick R. Michaud pmichaud at pobox.com
Tue Mar 1 17:45:52 CST 2005


On Tue, Mar 01, 2005 at 11:39:53PM +0100, Knut Alboldt wrote:
> 
> The usage of "string with blanks" will be really an improvement, but I 
> can't see the improvement of using an array of arrays for different 
> types of args when processing that (keep in mind that I'm not a php 
> guru, so please, maybe I only need a little help to understand)

Okay, I'll see if I can make it clearer then.  Let me start with
an example of something that GettingMarkupArguments can't handle.
Suppose I want to display all pages in the PmWiki group that
contain the word "group".  The markup for this would normally be:

    (:searchresults group=PmWiki "group" :)

With GettingMarkupArguments, $arg['group'] would end up being
1, which isn't what I want.  In general, GettingMarkupArguments
doesn't allow someone to specify an argument with the same
name as a name=value option.  I can come up with tons of
other real-world examples where this will be needed.

> In the argument parsing originated in PITS (and modified in the Cookbook 
> recipe GettingMarkupArguments) I can check if a arg is passed simply by 
> name:
>    if (isset($arg['name'])) ...

In the new version you can still do this:
 
    $arg = ParseArgs($x);
    if ($arg['xyz']) ... // xyz=something was specified

> or even better, if I provide defaults
>     $argdefaults['this'] = 0;
>     $args = GetDirectiveArgs($args,$argdefaults)

    $argdefaults['this'] = 0;
    $arg = array_merge($argdefaults, ParseArgs($x));

And if you're wanting to have +"value" and -"value" come
back as a one or a zero (indicating "on" and "off"):

    $arg = ParseArgs($x);
    foreach((array)$arg[''] as $a) $arg[$a]=1;
    foreach((array)$arg['+'] as $a) $arg[$a]=1;
    foreach((array)$arg['-'] as $a) $arg[$a]=0;

    if ($arg['xyz']==0) ... // either -xyz or xyz=0
    if ($arg['xyz']==1) ... // either +xyz or xyz=1
    if (isset($arg['xyz'])) ... // xyz was specified somewhere
    
> I think the multiple occurence of a parameter in a call can't be solved 
> by any of both solutions.

I think this pretty much handles the cases we'd need
to worry about.

Pm



More information about the pmwiki-users mailing list