[pmwiki-users] Text variables & ZAP...

The Editor editor at fast.st
Thu Oct 12 13:34:51 CDT 2006


On 10/12/06, The Editor <editor at fast.st> wrote:
> Hi Pm (and rest)
>
> part 1:  Getting text variables to work with current ZAP format
>
> I couldn't seem to get Text Variables to work with ZAP's old format.
> Maybe you can spot where the problem is:
>
> version pmwiki-2.2.0-beta12
>
> pagelist template:
> fmt=#forum
> [[#forum]]
> ||[[Forum/{=$Name}]] ||{=$:Post} ||{=$:Date} ||{=$:Author}
> [[#forumend]]
>
> Here's the code I want them showing up in.
> (:pagelist group=Data-Forum list=simple fmt=#forum -RecentChanges:)
>
> The data pages store info as:
> field="value"
>
> I have this line in my config.php file:
> $PDataPattern[] = '/^(\\w+)="(.*?)"/m';
>
> But I'm just getting the link in my pagelist and none of the text variables.
>
> Also, can you just set the pattern in local config files for the
> actual pages calling the pagelist?
>
>
> part 2:  Getting ZAP to read either format
>
> As noted above the old format saves it as field="value".  Which might
> be an advantage, in that users CAN'T extract text variables if you
> don't let them (by setting the PDataPattern).
>
> (ie {Profiles.AdminName$:Password}...
>
> Just the same, I would like to be able to use a better formatting,
> such as  field: value.  I can get the data to save fine but not sure
> how to do the reading both ways.  The following lines work as expected
> depending on whether the first pair are commented or the second pair.
>
>                 foreach ($field as $value) {  //Data variables
> //                      $v[0] = substr($value, 0, strpos($value, '='));
> //                      $v[1] = substr($value, strpos($value, "=") + 2, -1);
>                         $v[0] = substr($value, 0, strpos($value, ':'));
>                         $v[1] = substr($value, strpos($value, ":") + 2);
>                         if ($v[0] != "") $FmtPV["$$v[0]"] = "'" . $v[1] . "'";
>                         }
>
> The question is how do you suggest getting it to switch based on the
> format of each item in the list?  I was thinking something like
>
>        if strpos ":" > "=" || strpos ":" != false use first pair of lines
>        if strpos ":" < "=" || strpos "=" != false use second pair of lines
>
> The logic is a bit challenging, as there may or may not be a : or = in
> the value. Or help with the coding of these two conditionals?
>
> Cheers,
> Caveman

In case anyone was following this perplexing drama, I finally got the
code to work.  How's this for a hairy conditional?

if ((strpos($value, ":") == false) xor ((strpos($value, "=") != false)
&& (strpos($value, "=") < strpos($value, ":")))){

Should update the new changes soon...  To the ZAP demo site, first of course.

Cheers,
Caveman




More information about the pmwiki-users mailing list