Blame
Date:
Fri Jul 22 04:00:49 2022 UTC
Message:
Daily backup
01
2021-12-17
jrmu
<?php if (!defined('PmWiki')) exit();
02
2021-12-17
jrmu
/* Copyright 2001-2017 Patrick R. Michaud (pmichaud@pobox.com)
03
2021-12-17
jrmu
This file is part of PmWiki; you can redistribute it and/or modify
04
2021-12-17
jrmu
it under the terms of the GNU General Public License as published
05
2021-12-17
jrmu
by the Free Software Foundation; either version 2 of the License, or
06
2021-12-17
jrmu
(at your option) any later version. See pmwiki.php for full details.
07
2021-12-17
jrmu
08
2021-12-17
jrmu
This script adds WikiWord (CamelCase) processing to PmWiki.
09
2021-12-17
jrmu
Originally WikiWords were part of the default configuration,
10
2021-12-17
jrmu
but their usage has died out over time and so it's now optional.
11
2021-12-17
jrmu
12
2021-12-17
jrmu
To enable WikiWord links, simply add the following to
13
2021-12-17
jrmu
a local customization file:
14
2021-12-17
jrmu
15
2021-12-17
jrmu
$EnableWikiWords = 1;
16
2021-12-17
jrmu
17
2021-12-17
jrmu
To have PmWiki recognize and process WikiWords but not link
18
2021-12-17
jrmu
them (i.e., the default behavior in PmWiki 2.1), also add
19
2021-12-17
jrmu
20
2021-12-17
jrmu
$LinkWikiWords = 0;
21
2021-12-17
jrmu
22
2021-12-17
jrmu
If you want only the first occurrence of a WikiWord to be converted
23
2021-12-17
jrmu
to a link, set $WikiWordCountMax=1.
24
2021-12-17
jrmu
25
2021-12-17
jrmu
$WikiWordCountMax = 1; # converts only first WikiWord
26
2021-12-17
jrmu
$WikiWordCountMax = 0; # another way to disable WikiWord links
27
2021-12-17
jrmu
28
2021-12-17
jrmu
The $WikiWordCount array can be used to control the number of times
29
2021-12-17
jrmu
a WikiWord is converted to a link. This is useful for disabling
30
2021-12-17
jrmu
or limiting specific WikiWords.
31
2021-12-17
jrmu
32
2021-12-17
jrmu
$WikiWordCount['PhD'] = 0; # disables 'PhD'
33
2021-12-17
jrmu
$WikiWordCount['PmWiki'] = 1; # convert only first 'PmWiki'
34
2021-12-17
jrmu
$WikiWordCount['WikiWord'] = -1; # ignore $SpaceWikiWord setting
35
2021-12-17
jrmu
36
2021-12-17
jrmu
By default, PmWiki is configured such that only the first occurrence
37
2021-12-17
jrmu
of 'PmWiki' in a page is treated as a WikiWord. If you want to
38
2021-12-17
jrmu
restore 'PmWiki' to be treated like other WikiWords, uncomment the
39
2021-12-17
jrmu
line below.
40
2021-12-17
jrmu
unset($WikiWordCount['PmWiki']);
41
2021-12-17
jrmu
42
2021-12-17
jrmu
If you want to disable WikiWords matching a pattern, you can use
43
2021-12-17
jrmu
something like the following. Note that the first argument has to
44
2021-12-17
jrmu
be different for each call to Markup(). The example below disables
45
2021-12-17
jrmu
WikiWord links like COM1, COM2, COM1234, etc.
46
2021-12-17
jrmu
Markup('COM\d+', '<wikilink', '/\\bCOM\\d+/', "Keep");
47
2021-12-17
jrmu
48
2021-12-17
jrmu
Script maintained by Petko YOTOV www.pmwiki.org/petko
49
2021-12-17
jrmu
*/
50
2021-12-17
jrmu
51
2021-12-17
jrmu
SDV($LinkWikiWords, 1);
52
2021-12-17
jrmu
53
2021-12-17
jrmu
## bare wikilinks
54
2021-12-17
jrmu
Markup('wikilink', '>urllink',
55
2021-12-17
jrmu
"/\\b(?<![#&])($GroupPattern([\\/.]))?($WikiWordPattern)/",
56
2021-12-17
jrmu
"MarkupWikiLink");
57
2021-12-17
jrmu
58
2021-12-17
jrmu
function MarkupWikiLink($m) {
59
2021-12-17
jrmu
extract($GLOBALS["MarkupToHTML"]); # get $pagename
60
2021-12-17
jrmu
return Keep('<span class="wikiword">'.WikiLink($pagename,$m[0]).'</span>', 'L');
61
2021-12-17
jrmu
}
62
2021-12-17
jrmu
63
2021-12-17
jrmu
function WikiLink($pagename, $word) {
64
2021-12-17
jrmu
global $LinkWikiWords, $WikiWordCount, $SpaceWikiWords, $AsSpacedFunction,
65
2021-12-17
jrmu
$MarkupFrame, $WikiWordCountMax;
66
2021-12-17
jrmu
if (!$LinkWikiWords || ($WikiWordCount[$word] < 0)) return $word;
67
2021-12-17
jrmu
$text = ($SpaceWikiWords) ? $AsSpacedFunction($word) : $word;
68
2021-12-17
jrmu
$text = preg_replace('!.*/!', '', $text);
69
2021-12-17
jrmu
if (!isset($MarkupFrame[0]['wwcount'][$word]))
70
2021-12-17
jrmu
$MarkupFrame[0]['wwcount'][$word] = $WikiWordCountMax;
71
2021-12-17
jrmu
if ($MarkupFrame[0]['wwcount'][$word]-- < 1) return $text;
72
2021-12-17
jrmu
return MakeLink($pagename, $word, $text);
73
2021-12-17
jrmu
}
74
2021-12-17
jrmu
75
2021-12-17
jrmu
IRCNow