[pmwiki-users] Page file formats

The Editor editor at fast.st
Thu Aug 24 13:20:38 CDT 2006


Thanks for the info Patrick!  A few additional questions though...

On 8/24/06, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> > 1)  How does one use page variables in recipes.  For example I'm wanting to set
> >
> >       version={$version} ordered=1 urlencoded=1
>
> Use the FmtPageName() function, or the PageVar() function.

Sorry to be dense but after several tries could not figure out how to
extract the version # so I could set it via my recipe. After looking
at the docs, my best try was:

        $myversion = PageVar($datapage, $version, $myversion = ' ');

But it doesn't seem to work.

> > 2)  Can you manually set the title right in the page headers without
> > having to use a title directive

Thanks!  Got this working.

> > 3)  Is there anyway to override PmWiki's rewriting of the author
> > header whenever a page is  edited by an entry in a group config file.
>
> As part of my blogging/comment recipes, I'm working on a way to
> update pages without completely rewriting all of the automatic
> attributes, yes.

OK!  I have a functional workaround, until then.  Nothing critical.

> > 4) In setting the ctime and time lines...
>
> See the bottom of http://www.pmwiki.org/wiki/PmWiki/PageVariables
> for an example (in fact, the example uses ctime).

I'm sorry.  I missed that.

> > 5) How do you retrieve the page creator's "host" ip address in a
> > recipe function?
>
> The page variable {$LastModifiedHost} returns the ip address.
> Or, use the 'host' page attribute for a page.

Actually, I'm wanting to put the ip address into a new page that is
being constructed.  I need something like

       $MyIP = $GET[ip address];

> > 6) There does not seem to be any indication of the order of parameters
> > in the Pmwiki/PageFileFormat documentation.

Guess that explains what ordered means!  :)  Of course I noted even
with ordered=1 the title tag seems to work out of order.

> > 7) The docs say that in the text string, newlines must be converted to
> > %0a and %'s to %25.  Is there a pmwiki function that automatically
> > does that?
>
> I simply use . . .

Great, that should solve some data entry problems.  I know line breaks
break the recipe.  Haven't noticed problems with %'s or <'s.  Will
test some more just to see.

> > I've noticed a couple other things don't work right.  For example a ' is returned as
> > \'
>
> It's probably the /e modifier in preg_replace that is converting
> ' into \'.  Or, PHP will automatically convert quotes in forms to have
> a backslash in front of them if the PHP configuration variable
> "get_magic_quotes_gpc" is set.  PmWiki offers the stripslashes()
> function to remove any backslashes added by PHP's magic quotes,
> and the PSS() function to remove any backslashes added by the /e
> option to preg_replace.  PmWiki itself never adds backslashes
> on its own.

OK, great.  I'll tinker with both of those and see if I can't get them
to work for me.

> BTW, FWIW, I highly recommend re-using PmWiki's existing WritePage()
> function as opposed to creating a separate, duplicate version.
> If there are minor changes that you need to have added, we can see
> about doing this.

My hesitation to switching over to WritePage() is mostly having to
change everything when it is all working so well...  But on a
practical note--one feature I wanted was to be able to have users
write data to a wiki page they could not edit or read.  (I used wiki
pages so admin's could edit--but users shouldn't mess with them). I
suspect WritePage() requires authorization to work.  Is there a way
around that?

Assuming there was a way to do it, and assuming I had the text value
of the page prepared as string $data, would the format be as simple
as:

         WritePage($datapage, $data);

This would automatically clearstatcache, do the pageindexing, set the
title, and pull in all required page formatting values?  Wow... why
didn't I try that first!

To read the current contents of the page, I presume I could use

         $data = ReadPage($datapage);

Anyway, thanks again for all the help...

Cheers,
Caveman




More information about the pmwiki-users mailing list