Blame
Date:
Wed May 25 04:00:23 2022 UTC
Message:
Daily backup
001
2021-12-17
jrmu
<?php if (!defined('PmWiki')) exit();
002
2021-12-17
jrmu
/* Copyright 2002-2017 Patrick R. Michaud (pmichaud@pobox.com)
003
2021-12-17
jrmu
This file is part of PmWiki; you can redistribute it and/or modify
004
2021-12-17
jrmu
it under the terms of the GNU General Public License as published
005
2021-12-17
jrmu
by the Free Software Foundation; either version 2 of the License, or
006
2021-12-17
jrmu
(at your option) any later version. See pmwiki.php for full details.
007
2021-12-17
jrmu
008
2021-12-17
jrmu
This script enables markup of the form <<|TrailPage|>> to be
009
2021-12-17
jrmu
used to build "trails" through wiki documents.
010
2021-12-17
jrmu
011
2021-12-17
jrmu
This feature is automatically included from stdconfig.php unless
012
2021-12-17
jrmu
disabled by $EnableWikiTrails = 0; . To explicitly include this feature,
013
2021-12-17
jrmu
execute
014
2021-12-17
jrmu
include_once("scripts/trails.php");
015
2021-12-17
jrmu
from config.php somewhere.
016
2021-12-17
jrmu
017
2021-12-17
jrmu
Once enabled, the <<|TrailPage|>> markup is replaced with
018
2021-12-17
jrmu
<< PrevPage | TrailPage | NextPage >> on output. TrailPage should
019
2021-12-17
jrmu
contain either a bullet or number list defining the sequence of pages
020
2021-12-17
jrmu
in the "trail".
021
2021-12-17
jrmu
022
2021-12-17
jrmu
The ^|TrailPage|^ markup uses the depth of the bullets to display
023
2021-12-17
jrmu
the ancestry of the TrailPage to the current one. The <|TrailPage|>
024
2021-12-17
jrmu
markup is like <<|TrailPage|>> except that "< PrevPage |" and
025
2021-12-17
jrmu
"| NextPage >" are omitted if at the beginning or end of the
026
2021-12-17
jrmu
trail respectively. Thanks to John Rankin for contributing these
027
2021-12-17
jrmu
markups and the original suggestion for WikiTrails.
028
2021-12-17
jrmu
029
2021-12-17
jrmu
Script maintained by Petko YOTOV www.pmwiki.org/petko
030
2021-12-17
jrmu
*/
031
2021-12-17
jrmu
032
2021-12-17
jrmu
Markup('<<|','<links','/&lt;&lt;\\|([^|]+|\\[\\[(.+?)\\]\\])\\|&gt;&gt;/',
033
2021-12-17
jrmu
"MarkupMakeTrail");
034
2021-12-17
jrmu
Markup('<|','><<|','/&lt;\\|([^|]+|\\[\\[(.+?)\\]\\])\\|&gt;/',
035
2021-12-17
jrmu
"MarkupMakeTrail");
036
2021-12-17
jrmu
Markup('^|','<links','/\\^\\|([^|]+|\\[\\[(.+?)\\]\\])\\|\\^/',
037
2021-12-17
jrmu
"MarkupMakeTrail");
038
2021-12-17
jrmu
039
2021-12-17
jrmu
function MarkupMakeTrail($m) {
040
2021-12-17
jrmu
extract($GLOBALS["MarkupToHTML"]); # get $pagename, $markupid
041
2021-12-17
jrmu
switch ($markupid) {
042
2021-12-17
jrmu
case '<<|':
043
2021-12-17
jrmu
return PRR(MakeTrailStop($pagename,$m[1]));
044
2021-12-17
jrmu
case '<|':
045
2021-12-17
jrmu
return PRR(MakeTrailStopB($pagename,$m[1]));
046
2021-12-17
jrmu
case '^|':
047
2021-12-17
jrmu
return PRR(MakeTrailPath($pagename,$m[1]));
048
2021-12-17
jrmu
}
049
2021-12-17
jrmu
}
050
2021-12-17
jrmu
051
2021-12-17
jrmu
SDVA($SaveAttrPatterns, array(
052
2021-12-17
jrmu
'/<<\\|([^|]+|\\[\\[(.+?)\\]\\])\\|>>/' => '$1',
053
2021-12-17
jrmu
'/<\\|([^|]+|\\[\\[(.+?)\\]\\])\\|>/' => '$1',
054
2021-12-17
jrmu
'/\\^\\|([^|]+|\\[\\[(.+?)\\]\\])\\|\\^/' => '$1'));
055
2021-12-17
jrmu
056
2021-12-17
jrmu
$Conditions['ontrail'] = 'CondOnTrail($pagename, $condparm)';
057
2021-12-17
jrmu
058
2021-12-17
jrmu
function CondOnTrail($pagename, $condparm) {
059
2021-12-17
jrmu
@list($trailname, $pn) = preg_split('/\\s+/', $condparm, 2);
060
2021-12-17
jrmu
$trail = ReadTrail($pagename, $trailname);
061
2021-12-17
jrmu
if (!$trail) return false;
062
2021-12-17
jrmu
$pn = ($pn > '') ? MakePageName($pagename, $pn) : $pagename;
063
2021-12-17
jrmu
foreach($trail as $t)
064
2021-12-17
jrmu
if ($t['pagename'] == $pn) return true;
065
2021-12-17
jrmu
return false;
066
2021-12-17
jrmu
}
067
2021-12-17
jrmu
068
2021-12-17
jrmu
function ReadTrail($pagename, $trailname) {
069
2021-12-17
jrmu
global $RASPageName, $SuffixPattern, $GroupPattern, $WikiWordPattern,
070
2021-12-17
jrmu
$LinkWikiWords;
071
2021-12-17
jrmu
if (preg_match('/^\\[\\[(.+?)(-&gt;|\\|)(.+?)\\]\\]$/', $trailname, $m))
072
2021-12-17
jrmu
$trailname = ($m[2] == '|') ? $m[1] : $m[3];
073
2021-12-17
jrmu
$trailtext = RetrieveAuthSection($pagename, $trailname);
074
2021-12-17
jrmu
$trailname = $RASPageName;
075
2021-12-17
jrmu
$trailtext = Qualify($trailname, $trailtext);
076
2021-12-17
jrmu
$t = array();
077
2021-12-17
jrmu
$n = 0;
078
2021-12-17
jrmu
foreach(explode("\n", PHSC(@$trailtext, ENT_NOQUOTES))
079
2021-12-17
jrmu
as $x) {
080
2021-12-17
jrmu
$x = preg_replace("/\\[\\[([^\\]]*)-&gt;([^\\]]*)\\]\\]/",'[[$2|$1]]',$x);
081
2021-12-17
jrmu
if (!preg_match("/^([#*:]+) \\s*
082
2021-12-17
jrmu
(\\[\\[([^:#!|][^|:]*?)(?:\".*?\")?(\\|.*?)?\\]\\]($SuffixPattern)
083
2021-12-17
jrmu
| (($GroupPattern([\\/.]))?$WikiWordPattern)) (.*)/x",$x,$match))
084
2021-12-17
jrmu
continue;
085
2021-12-17
jrmu
if (@$match[6]) {
086
2021-12-17
jrmu
if (!$LinkWikiWords) continue;
087
2021-12-17
jrmu
$tgt = MakePageName($trailname, $match[6]);
088
2021-12-17
jrmu
} else $tgt = MakePageName($trailname, $match[3]);
089
2021-12-17
jrmu
$t[$n]['depth'] = $depth = strlen($match[1]);
090
2021-12-17
jrmu
$t[$n]['pagename'] = $tgt;
091
2021-12-17
jrmu
$t[$n]['markup'] = $match[2];
092
2021-12-17
jrmu
$t[$n]['detail'] = $match[9];
093
2021-12-17
jrmu
for($i=$depth;$i<10;$i++) $d[$i]=$n;
094
2021-12-17
jrmu
if ($depth>1) $t[$n]['parent']=@$d[$depth-1];
095
2021-12-17
jrmu
$n++;
096
2021-12-17
jrmu
}
097
2021-12-17
jrmu
return $t;
098
2021-12-17
jrmu
}
099
2021-12-17
jrmu
100
2021-12-17
jrmu
function MakeTrailStop($pagename,$trailname) {
101
2021-12-17
jrmu
$t = ReadTrail($pagename,$trailname);
102
2021-12-17
jrmu
$prev=''; $next='';
103
2021-12-17
jrmu
for($i=0;$i<count($t);$i++) {
104
2021-12-17
jrmu
if ($t[$i]['pagename']==$pagename) {
105
2021-12-17
jrmu
if ($i>0) $prev = $t[$i-1]['markup'];
106
2021-12-17
jrmu
if ($i+1<count($t)) $next = $t[$i+1]['markup'];
107
2021-12-17
jrmu
}
108
2021-12-17
jrmu
}
109
2021-12-17
jrmu
return "<span class='wikitrail'>&lt;&lt; $prev | $trailname | $next &gt;&gt;</span>";
110
2021-12-17
jrmu
}
111
2021-12-17
jrmu
112
2021-12-17
jrmu
function MakeTrailStopB($pagename,$trailname) {
113
2021-12-17
jrmu
$t = ReadTrail($pagename,$trailname);
114
2021-12-17
jrmu
$prev = ''; $next = '';
115
2021-12-17
jrmu
for($i=0;$i<count($t);$i++) {
116
2021-12-17
jrmu
if ($t[$i]['pagename']==$pagename) {
117
2021-12-17
jrmu
if ($i>0) $prev = '&lt; '.$t[$i-1]['markup'].' | ';
118
2021-12-17
jrmu
if ($i+1<count($t)) $next = ' | '.$t[$i+1]['markup'].' &gt;';
119
2021-12-17
jrmu
}
120
2021-12-17
jrmu
}
121
2021-12-17
jrmu
return "<span class='wikitrail'>$prev$trailname$next</span>";
122
2021-12-17
jrmu
}
123
2021-12-17
jrmu
124
2021-12-17
jrmu
function MakeTrailPath($pagename,$trailname) {
125
2021-12-17
jrmu
global $TrailPathSep;
126
2021-12-17
jrmu
SDV($TrailPathSep,' | ');
127
2021-12-17
jrmu
$t = ReadTrail($pagename,$trailname);
128
2021-12-17
jrmu
$crumbs = '';
129
2021-12-17
jrmu
for($i=0;$i<count($t);$i++) {
130
2021-12-17
jrmu
if ($t[$i]['pagename']==$pagename) {
131
2021-12-17
jrmu
while (@$t[$i]['depth']>0) {
132
2021-12-17
jrmu
$crumbs = $TrailPathSep.$t[$i]['markup'].$crumbs;
133
2021-12-17
jrmu
$i = @$t[$i]['parent'];
134
2021-12-17
jrmu
}
135
2021-12-17
jrmu
return "<span class='wikitrail'>$trailname$crumbs</span>";
136
2021-12-17
jrmu
}
137
2021-12-17
jrmu
}
138
2021-12-17
jrmu
return "<span class='wikitrail'>$trailname</span>";
139
2021-12-17
jrmu
}
140
2021-12-17
jrmu
IRCNow