[Pmwiki-users] Feature request?

Patrick R. Michaud pmichaud
Wed Dec 3 13:03:08 CST 2003


I'm not sure, but I think the code for automatically creating links
should perhaps go in the Cookbook on the pmichaud.com site instead of
the Development group.  In general the Cookbook is the place for
working code samples, scripts, and configuration items, while the
Development group is used for discussion and design of new features.

Pm

On Monday, December 1, 2003, 11:58:18 AM, you wrote:

> 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
>> 
>> 







More information about the pmwiki-users mailing list