> to be used to build "trails" through wiki documents. The modification enables the markup <<(:pagelist ... :)>>, to build a trail from a pagelist directive, or to expand and include any pagelist directive found on an index page for a normal WikiTrail. This version should be downloaded to the cookbook folder. The original "trails.php" should be disabled, and this new one included by putting $EnableWikiTrails=0; include_once("cookbook/pagelisttrails.php"); in the config.php file. Once enabled, the <<|TrailPage|>> markup is replaced with << PrevPage | TrailPage | NextPage >> on output. TrailPage should contain either a bullet or number list defining the sequence of pages in the "trail". The ^|TrailPage|^ markup uses the depth of the bullets to display the ancestry of the TrailPage to the current one. The <|TrailPage|> markup is like <<|TrailPage|>> except that "< PrevPage |" and "| NextPage >" are omitted if at the beginning or end of the trail respectively. Thanks to John Rankin for contributing these markups and the original suggestion for WikiTrails. */ $HTMLStylesFmt['extend'] = " .trailRight { float:right; } "; Markup_e('<<|','<<|','/<\\|([^|]+|\\[\\[(.+?)\\]\\])\\|>/', "MakeTrailStopB(\$pagename,\$m[1])"); Markup_e('^|','(:','/<<(\(:[^|]+|\\[\\[(.+?)\\]\\]:\))>>/', "MakeTrailStopC(\$pagename,\$m[1])"); SDVA($FPLFunctions,array('bygroup'=>'FPLByGroup','simple'=>'FPLSimple', 'group'=>'FPLGroup', 'markup'=>'FPLMarkup')); function FPLMarkup($pagename, &$matches, $opt) { global $FPLMarkupFmt, $FPLMarkupOpt; SDV($FPLMarkupFmt,"\n* [[\$Name|+]]"); SDVA($FPLMarkupOpt, array('readf' => 0)); $topt['order'] = (@$opt['trail']) ? '' : 'name'; $matches = MakePageList($pagename, array_merge($topt, (array)$FPLMarkupOpt, $opt)); $out = array(); foreach($matches as $pc) $out[] = FmtPageName($FPLMarkupFmt, $pc['pagename']); return implode('', $out); } function ExpandPageList($trailname,$options) { $options = preg_replace('/fmt=\w+/i','',$options)." fmt=markup "; $opt = array('o'=>$options); return FmtPageList('$MatchList',$trailname,$opt); } function ReadTrail($pagename,$trailname) { global $SuffixPattern,$GroupPattern,$WikiWordPattern,$LinkWikiWords; if (preg_match('/^\\[\\[(.+?)(->|\\|)(.+?)\\]\\]$/', $trailname, $m)) $trailname = ($m[2] == '|') ? $m[1] : $m[3]; if (substr($trailname,0,10) != '(:pagelist') { $trailname = MakePageName($pagename,$trailname); $trailpage = ReadPage($trailname, READPAGE_CURRENT); if (!$trailpage) return false; } else $trailpage['text'] = $trailname; $trailpage['text'] = preg_replace("/\\(:pagelist\\s*(.*):\\)/e","ExpandPageList('$trailname','\\1')",$trailpage['text']); $t = array(); $n = 0; foreach(explode("\n",@$trailpage['text']) as $x) { $x = preg_replace("/\\[\\[([^\\]]*)->([^\\]]*)\\]\\]/",'[[$2|$1]]',$x); if (!preg_match("/^([#*:]+) \\s* (\\[\\[([^|]*?)(\\|.*?)?\\]\\]($SuffixPattern) | (($GroupPattern([\\/.]))?$WikiWordPattern))/x",$x,$match)) continue; if (@$match[6]) { if (!$LinkWikiWords) continue; $tgt = MakePageName($trailname,$match[6]); } else $tgt = MakePageName($trailname,$match[3]); $t[$n]['depth'] = $depth = strlen($match[1]); $t[$n]['pagename'] = $tgt; $t[$n]['markup'] = $match[2]; for($i=$depth;$i<10;$i++) $d[$i]=$n; if ($depth>1) $t[$n]['parent']=@$d[$depth-1]; $n++; } return $t; } function MakeTrailStop($pagename,$trailname) { $t = ReadTrail($pagename,$trailname); $prev=''; $next=''; for($i=0;$i0) $prev = $t[$i-1]['markup']; if ($i+1<< $prev | $trailname | $next >>"; } function MakeTrailStopB($pagename,$trailname) { $t = ReadTrail($pagename,$trailname); $prev = ''; $next = ''; for($i=0;$i0) $prev = '< '.$t[$i-1]['markup'].' | '; if ($i+1$prev$trailname$next"; } function MakeTrailStopC($pagename,$trailname) { $t = ReadTrail($pagename,$trailname); $prev=''; $next=''; for($i=0;$i0) $prev = "<< ".$t[$i-1]['markup'].""; if ($i+1"; } } return "$next$prev"; } function MakeTrailPath($pagename,$trailname) { global $TrailPathSep; SDV($TrailPathSep,' | '); $t = ReadTrail($pagename,$trailname); $crumbs = ''; for($i=0;$i0) { $crumbs = $TrailPathSep.$t[$i]['markup'].$crumbs; $i = @$t[$i]['parent']; } return "$trailname$crumbs"; } } return $trailname; }