[pmwiki-users] Conditional Markup enhancement

Knut Alboldt pmwiki at alboldt.de
Tue Mar 1 16:39:53 CST 2005


Patrick R. Michaud schrieb:
> On Mon, Feb 28, 2005 at 10:51:55PM +0100, Dominique Faure wrote:
> 
>>Hi,
>>
>>I just published the 
>>http://www.pmwiki.org/wiki/Cookbook/ConditionalExtensions recipe, and 
>>before improving it, I wanted to know, if something near 
>>http://www.pmwiki.org/wiki/Cookbook/GettingMarkupArguments would be 
>>available in pmwiki.php.
> 
> 
> Yes, I've just prototyped it into the current pmwiki.org code where it's
> currently running to process the (:pagelist:) and (:searchresults:) markup.
> 
> The version I have isn't identical to the way that GettingMarkupArguments
> works because GettingMarkupArguments wouldn't really work for
> pagelist and searchresults.  The version I have is called using
> 
>     $arg = ParseArgs($x);
> 
> where $x is the string with arguments to be processed.  The $arg
> variable is populated as follows:
> 
>   - arguments of the form key=value or key:value are returned
>     in $arg['key']
>   - arguments of the form +value or -value are return as arrays
>     in $arg['+'] and $arg['-']
>   - all other arguments are returned as an array in $arg['']
> 
> ParseArgs also understands single and double quotes, thus one 
> can have arguments like key="value with spaces".
> 
> For example, if $x contains
> 
>     123 list=none +list -any "apple pie" title="my page" "+plus" +"something"
> 
> then after executing $args=ParseArgs($x), $args will be:
> 
>     $args['']        array('123', 'apple pie', '+plus')
>     $args['list']    'none'
>     $args['+']       array('list', 'something')
>     $args['-']       array('any')
>     $args['title']   'my page'
> 
> This will be available in the next release (and I'll hurry the release
> of beta24 so people can start using this).  Comments and suggestions welcome.
> 
I think I need a little help:

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)

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'])) ...

or even better, if I provide defaults

$argdefaults['this'] = 0;
$args = GetDirectiveArgs($args,$argdefaults)

by using

if ($args['this'] = 1) ...

How will this checks be implemented in ParseArg() ?

I'm also missing that default-stuff. Ok, I don't know what the 
requirements for (:pagelist:) and (:searchlist:) are, but if I have to 
use it for own markups, I can't see the advantages (right now).

I think the multiple occurence of a parameter in a call can't be solved 
by any of both solutions.

Knut



More information about the pmwiki-users mailing list