[pmwiki-users] Some answers to: More Wikiforms

John Rankin john.rankin at affinity.co.nz
Tue Jul 31 21:32:41 CDT 2007


On Tuesday, 31 July 2007 5:32 PM, Sameer Kumar <skumar at eharch.com> wrote:
>John,
>I have created a copy of my wiki on http://www.93batch.org/wiki/.
>This is publicly accessible and editable. Do let me know if you need the admin password.
>The wikiform is in the group Projects. You can see the list of
>pages under Projects here:
>http://www.93batch.org/wiki/?n=Projects/PageList
>
>Please keep in mind that because I have modified the tabs
>through Site.PageActions, all pages under the Project group
>will take you to Projecttext group when you hit 'Edit' tab. The
>only way to access the edit pages for FormTemplate is by adding
>?action=edit to the url.
>
>I hope this helps. Thank you again for you attention and I will
>do my best to enable you to understand what is going on.
>
Seeing makes it much easier :-)
>
>
>
1. I see where the value= is coming from. In wikiform.php, look for:

} elseif (preg_match('/^(\\d+)(?:\\*(\\d+))?$/',$f[$i]['etype'],$m)) {
    $col = ($m[2]) ? $m[2] : 40;
    if ($editing) $rows = explode("\\\\\n",$fv[$f[$i]['element']]);
    for($j=0;$j<$m[1];$j++) {
        $rows[$j] = (isset($rows[$j])) ? " value='".$rows[$j]."'" : '';
        $out[] = "<input type='text' size='$col' name='".
            $f[$i]['element']."[]'".$rows[$j]." />";
    }
} ...

and make the following change:

    if ($editing) $rows = explode("\\\\\n",$fv[$f[$i]['element']]);
    else $rows = array();

The first field is OK; others of that type are not. The above change 
should fix it.

2. The extra \\ characters, there are several possibilities. 
You may be able to tell from the above code that it splits the field 
value on '2 backslashes followed by a newline'. I can call up the 
edit form, but not save the results, so it's hard to see what is 
happening. Leave that one with me to test. It used to work; maybe 
I broke it at some point.

It looks as if it is recognising all the \ characters, instead of
escaping them, when I join the array of values into one field.

3. The Projectstext title.

We have to create a title for this explicitly, using the pmwiki
variable markup. In Projectstext.GroupFooter, we want to add:

(:title {Projects/{$Name}}$:Project Name} :)

However, we have a problem, because AFAIK, pmwiki doesn't support 
spaces in variable names. What I suggest you do is change 
'Project Name' in your form and all current records to 'Project'.

If you don't want to do that...

Alternatively, add the following to your local/config.php:

Markup('fparatitle','<title','/\(:fparatitle\s*([^=]+)=([^\s:]+)\s*:\)/e',
    "'(:title '.FormParagraphText(\$pagename,'$1','$2').':)'");

function FormParagraphText($pagename, $field, $page) {
    global $WikiFormPageFmt;
    $f = FormFields($page,$WikiFormPageFmt);
    $m = WikiformPrompt($f, $field);
    if (PageExists($page)) {
        $p = ReadPage($page);
        preg_match_all("/\n:([^:]+):([^\n\\\\]*)/","\n".$p['text'],$match);
        return FormParaText($match[1], $match[2], $m);
    } else
        return $page;
}
 
Then you can use (:fparatitle title=Projects.{$Name}:)
I think.

4. The discussion page links.

>From Projects/00003, I click Discussion and it takes me to
Comments/Projects-00003

This is missing a title attribute. I think you need the
following in a Comments.GroupFooter, to do the same as
in the Projecttext field:

(:fparatitle title=@3@{$Name}@3@:)

However, there is a problem: '@3@' evaluates inline,
which is after title evaluates, so this will not work.
Try changing

Markup("@3@", "inline", "/@3@(.*?)@3@/e", 'str_replace("-",".","$1")');

to

Markup("@3@", "<fparatitle", "/@3@(.*?)@3@/e", 'str_replace("-",".","$1")');

However, that might break something else; I'm not sure.

Also, the View link doesn't pick up the view template.
I think this is because of the ?action=view -- it won't
let me save edits to Comments.PageActions, so I can't test
this. Try removing the '?action=view' on the first item;
I don't think it's needed.

Let me know how you get on. Phew!
-- 
JR
--
John Rankin






More information about the pmwiki-users mailing list