$Group';
$GroupListTextFmt='
`$Group';
$GroupListSearchFmt =
'$Group ';
$GroupPickSearchFmt = '';
$GroupListLinkFmt='
ThisMenu:$Group';
$LinkPatterns[90]["ThisMenu:($UrlPathPattern)"] =
"$1";
$LinkPatterns[780]["`($GroupNamePattern)"] = '$1';
$DoubleBrackets["/\\[\\[grouplist\\]\\]/e"] = 'ListGroups("$pagename");';
$TrailLinkPattern =
"(?:($GroupNamePattern)([\\/.]))?(($WikiWordPattern)|($FreeLinkPattern))";
$Exceptions =
"GroupHeader,GroupPrintHeader,GroupFooter,GroupPrintFooter,
RecentChanges,WebMenu";
$DoubleBrackets["/\\[\\[pagenavbar\\]\\]/e"] = 'NavBar("$pagename");';
$DoubleBrackets["/\\[\\[trail(\\[([0-9]+)\\])?:($TrailLinkPattern)\\]\\]/e"] =
'ShortList("$2","$3");';
function ListGroups($page) {
global $GroupListLinkFmt,$GroupListTextFmt;
$currentgroup = FmtPageName('$Group',$page);
$groups = ReadGroups($page);
$grouplist = array();
foreach($groups as $g) {
if ($g!=$lastg) {
$lastg = $g;
if ($g==$currentgroup)
$grouplist[] = str_replace('$Group',"$g",$GroupListTextFmt);
else
$grouplist[] = str_replace('$Group',"$g",$GroupListLinkFmt);
}
}
$r = join('',$grouplist);
return "- Groups
$r
";
}
function ListSearchGroups($page) {
global $GroupListSearchFmt;
$currentgroup = FmtPageName('$Group',$page);
$groups = ReadGroups($page);
$grouplist = array();
foreach($groups as $g) {
if ($g!=$lastg) {
$lastg = $g;
if ($g==$currentgroup)
$c = "checked='checked' ";
else
$c = "";
$grouplist[] =
str_replace('$Checked',"$c",str_replace('$Group',"$g",$GroupListSearchFmt));
}
}
$r = join('',$grouplist);
$all = str_replace('$Group','',str_replace('>$Group','>All groups',$GroupListSearchFmt));
return "Search in: $all$r";
}
function PickSearchGroups($page) {
global $GroupPickSearchFmt;
$currentgroup = FmtPageName('$Group',$page);
$groups = ReadGroups($page);
$grouplist = array();
foreach($groups as $g) {
if ($g!=$lastg) {
$lastg = $g;
if ($g==$currentgroup)
$s = " selected='selected'";
else
$s = "";
$grouplist[] =
str_replace('$Select',"$s",str_replace('$Group',"$g",$GroupPickSearchFmt));
}
}
$r = join('',$grouplist);
$all = str_replace('$Select',' value=\'\'',str_replace('$Group','All groups',$GroupPickSearchFmt));
return "Search for ";
}
function ReadGroups($page) {
global $GroupNamePattern;
$groupsource = 'Main.AllRecentChanges';
$grouppage = ReadPage($groupsource);
$groups = array();
if ($grouppage) {
foreach(explode("\n",$grouppage['text']) as $x) {
if (preg_match("/^([#*]+)\\s*($GroupNamePattern)/",$x,$match))
$groups[] = $match[2];
}
sort($groups); reset($groups);
}
return $groups;
}
function NavBar($page) {
global $TrailLinkPattern,$Exceptions;
$currentgroup = FmtPageName('$Group',$page);
$currenttitle = FmtPageName('$Title',$page);
$navsource = "$currentgroup.RecentChanges";
$navpage = ReadPage($navsource);
$pages = array(); $t = array();
if ($navpage) {
foreach(explode("\n",$navpage['text']) as $x) {
if (preg_match("/^([#*]+)\\s*($TrailLinkPattern)/",$x,$match)) {
$pg = Wikify(preg_replace('/^.*[\\/.]/','',$match[2]));
if (!strstr($Exceptions,$pg)) { $pages[] = $pg; $t[$pg] = $match[2]; }
}
}
sort($pages); reset($pages);
for($i=0;$i0)
$prev = $t[$pages[$i-1]];
if ($i+1« $prev$next » | ";
}
return "";
}
function ShortList($c,$link) {
global $TrailLinkPattern,$Exceptions;
if ($c==0) $c=5;
$trailname = FmtWikiLink('',$link,NULL,'PageName');
$trailpage = ReadPage($trailname);
$pages = array();
if ($trailpage) {
$trailgroup = FmtPageName('$Group',$trailname);
foreach(explode("\n",$trailpage['text']) as $x) {
if (preg_match("/([#*]+)\\s*($TrailLinkPattern)/",$x,$match)) {
$pg = Wikify(preg_replace('/^.*[\\/.]/','',$match[2]));
if (!strstr($Exceptions,$pg))
$pages[] = ($match[3]>'')?$match[2]: $trailgroup.'/'.$match[2];
}
}
for($i=0;$i