[pmwiki-users] Unifying variables, attributes, properties, part 1

Patrick R. Michaud pmichaud at pobox.com
Wed Dec 14 17:02:05 CST 2005


On Wed, Dec 14, 2005 at 08:15:27PM +0100, chr at home.se wrote:
> On Wed, 14 Dec 2005, Patrick R. Michaud wrote:
> > Yes, and for a variety of reasons we need to be able to support
> > *all* of the above behaviors and restrictions, so unification 
> > is going to be a bit tricky.
> 
> Anyway... maybe it'd be a good idea to illustrate why (and for what) we 
> need all these things...

Well, I'm not sure I can do that quite yet, and as I said earlier
unification would be tricky.  However, I think I see a few baby steps
we ought to take...and let's start with the current situation before
we deal with properties and attributes.

Yesterday while thinking about properties I recalled that there's often
been confusion about "page variables", "global PHP variables",
and "markup variables", and that we may be able to simplify things
greatly if we can resolve that confusion.

Here's the current situation:

"page variables" are those substitutions that are relative to
a given page (which may not be the currently viewed page).
For example, [[SomePage]] and [[OtherPage]] in markup have to
generate different values for "$PageUrl".  Thus $PageUrl can't
be a global PHP variable that remains relatively constant, because 
the value of $PageUrl depends heavily on the specific page
we happen to be targeting at the moment.  The same is true for
$Group, $Name, $FullName, $Title, $Namespaced, $Titlespaced, 
$LastModified, and $LastModifiedBy -- they're highly dependent
on the page being targeted.

"markup variables" are those substitutions that are allowed
in wiki markup, and in 2.x the syntax has always been {$...}.
There's generally a good correspondence between markup variables
and page variables (i.e., {$Group} in markup corresponds to the
'$Group' page variable), but for security and efficiency reasons
not every global variable is available as a markup variable.

But someone writing a PHP recipe has to know to use '$Group',
and furthermore they have to know to do it in the context of
a call to FmtPageName, since $Group as a global variable is
meaningless.

Thus, my first thought about unification is that we make all
of the page variables look like markup variables, so that
PHP scripts and PHP templates use {$Group}, {$FullName},
{$PageUrl}, etc. exactly as markup authors would do.  This
would help to highlight that these aren't "global variables"
in the PHP sense, as well as remove some of the confusion
about when to use braces.

Of course, there are lots and lots of scripts, recipes, skins,
and configuration files that depend on the existing syntax,
so a change like this will have to be a gradual transition
over a long period of time (I'm thinking a year) before
we can eliminate the existing syntax.  But for newcomers to
PmWiki it could make things a lot more understandable.

This is just a first baby step, we would still have to figure out
the relationship between variables, properties, and attributes.
But at least it gets a consistent syntax for the variables that
are page-dependent and so that they don't immediately look like
they are PHP global variables.

Pm




More information about the pmwiki-users mailing list