[Pmwiki-users] Why groups?
J. Perkins
jason
Thu Jun 10 12:42:07 CDT 2004
Accidentally hit "reply" instead of "replay to all", sorry.
-------- Original Message --------
Subject: Re: [Pmwiki-users] Why groups?
From: "J. Perkins" <jason at sim8.com>
Date: Thu, June 10, 2004 12:28 pm
To: <chr at home.se>
> While reading some of it, I wondered why we have groups at all... why
> must we say that a "group can contain subgroups". Couldn't we instead
> talk about this as a page having subpages? The pages would then be
> organized as a tree (or many trees).
This is my take exactly, which is why I called them "nested pages"
instead of groups. To remove all ambiguity, here is my implementation of
a "resolver" which can handle every case I have thought of so far.
function Resolve($from, $to)
{
if ($to[0] == '/')
return $to;
if ($to[0] != '.')
return GetPath($from).$to;
if (strncmp($to, './', 2)==0)
return $from.substr($to, 1);
/* Handle ".." operators */
while (strncmp($to, '../', 3) == 0) {
$from = GetPath($from);
$to = substr($to, 3);
}
if ($to == '..')
return dirname($from)
else
return GetPath($from).$to;
}
function GetPath($page)
{
$path = dirname($page);
if ($path == '/' || $path == '\\')
return $path;
else
return $path;
}
My current set of tests...
/HomePage -> [[AnotherPage]] = /AnotherPage
/HomePage/Child -> [[/AnotherPage]] = /AnotherPage
/HomePage -> [[./PmWiki]] = /HomePage/PmWiki
/HomePage/Child -> [[..]] = /HomePage
/HomePage/Child -> [[../Another]] = /Another
/Home/One/Two -> [[../../]] = /Home
/Home -> [[One/Two]] = /One/Two
/HomePage/Child -> [[./Another]] = /Home/Child/Another
Jason
More information about the pmwiki-users
mailing list