[Pmwiki-users] Feature request?
Christian Ridderström
chr
Mon Dec 1 10:58:23 CST 2003
Taking my own suggestion in another mail I recently sent, I put the code
for automatically creating links to groups on this page:
http://www.pmichaud.com/wiki/Development/AutoCreateGroupLinks
The comments of the code, and it's problems are also on the page.
/Christian
On Sun, 30 Nov 2003, Christian Ridderstr?m wrote:
> On 24 Nov 2003, John Rankin wrote:
>
> > Good morning...
> >
> > For consistency it should also do $ref = "$t.\{\{$DefaultTitle}}";
> >
> > And there will be a problem, I think, if there are entries
> > in local/group.php that redefine $DefaultTitle -- you end up
> > trying to find whatever the current group has $DefaultTitle set
> > to, which may not be the same as that set for the $t group.
> >
> > If one wants to be *really* pedantic, perhaps also:
> >
> > global $SpaceWikiWords;
> >
> > $tref = ($SpaceWikiWords) ? AsSpaced($t) : $t;
> >
> > and
> >
> > $ref = "$t/\{\{$tref}}";
>
> Ok... something like this? (What is local/group.php, I don't have it...).
> I've also added a hack so that this works with selfreference.php
>
> //
> // Automatic creation of group links
> //
> // The hook below changes a wiki-link pointing to a non-existing page,
> // so that it points to the homepage of a group with the same name as the
> // link (if that group and it's homepage exists).
> //
> + // Caveat: If $DefaultTitle is different for different groups, this code
> + // might not work properly.
> //
> - $FmtWikiLink = 'MyFmtWikiLink';
> + $oldFmtFcn_AutoCreateGroupLink = $FmtWikiLink;
> + $FmtWikiLink = 'AutoCreateGroupLink';
> - function MyFmtWikiLink($pat,$ref,$btext,$out=NULL,$pname=NULL) {
> + function AutoCreateGroupLink($pat,$ref,$btext,$out=NULL,$pname=NULL) {
> - global $DefaultTitle;
> + global $DefaultTitle, $SpaceWikiWords, $oldFmtFcn_AutoCreateGroupLink;
> $pg = FmtWikiLink($pat,$ref,$btext,'PageName',$pname);
> if (!PageExists($pg)) {
> $t = preg_replace("/^.*\\./",'',$pg);
> if (PageExists("$t.$t")) {
> - $ref = "$t/\{\{$t}}"; // in case $t isn't a wikiword
> + $tref = ($SpaceWikiWords) ? AsSpaced($t) : $t;
> + $ref = "$t/\{\{$tref}}";
> } elseif (PageExists("$t.$DefaultTitle")) // try HomePage
> - $ref = "$t.$DefaultTitle";
> + $ref = "$t.\{\{$DefaultTitle}}";
> }
> - return FmtWikiLink($pat,$ref,$btext,$out,$pname);
> + return $oldFmtFcn_AutoCreateGroupLink($pat,$ref,$btext,$out,$pname);
> }
>
> /Christian
>
>
--
Dr. Christian Ridderstr?m, +46-8-768 39 44 http://www.md.kth.se/~chr
More information about the pmwiki-users
mailing list