[pmwiki-devel] Request to review code for Group Titles recipe
Dominique Faure
dominique.faure at gmail.com
Tue May 20 07:00:47 CDT 2008
On Tue, May 20, 2008 at 8:08 AM, Henrik Bechmann
<henrik.bechmann at sympatico.ca> wrote:
> All,
>
> Peter Bowers made some helpful observations and suggestions, which
> prompted me to make some changes resulting, I think, in safer, slightly
> faster, and more general code for this. The updated Beta 2 is at...
>>>> The code is at http://www.pmwiki.org/pmwiki/uploads/Cookbook/grouptitles.php
> Any other comments are most welcome.
>
> Best,
>
IMHO, one of the best feature of the original Pm's GroupTitle recipe
was to consider a search path when looking for titles, providing a
convenient way to 'override' the group title on specific pages:
For example, if the [[GroupName.{$DefaultName}|!+]] link is a simple
way to come back to the group home page, it isn't very useful on the
GroupName.{$DefaultName} page itself. The search feature should allow
to (re)define it there (to an empty string in this case).
The following code would be able to handle the path search, but I
haven't been able to find a "simple" way to allow fetching of empty
string definitions.
function MakeGroupTitle($pn, $group = '') {
global $GroupTitlesPathFmt, $pagename;
if (!$group) {
$page = MakePageName($pagename, $pn);
if (preg_match('/^(.+)[.\\/]([^.\\/]+)$/', $page, $match))
@list(/*$d*/, $group, $name) = $match;
if (!$group) return $pn;
}
SDV($GroupTitlesPathFmt, array(
'{{$FullName}$:GroupTitle}',
'{{$Group}.GroupAttributes$Title}',
'{{$SiteGroup}.GroupTitles$:{$Group}}',
));
global $RedoMarkupLine, $MarkupTable;
foreach($GroupTitlesPathFmt as $v) {
$rdm = $RedoMarkupLine;
while(true) {
$RedoMarkupLine = 0;
$v = preg_replace($MarkupTable['{$var}']['pat'],
$MarkupTable['{$var}']['rep'], $v);
if(!$RedoMarkupLine) break;
}
$RedoMarkupLine = $rdm;
if($v) return $v;
}
return $group;
}
--
Dominique
More information about the pmwiki-devel
mailing list