|
Cookbook /
DotsInLinksSummary: How to enable dots in wiki links
Version:
Status: Experimental
Maintainer: Petko
Categories: Administration Links
Questions answered by this recipeIn PmWiki links, dots are separators between a WikiGroup and a page in that group. So, Is it possible have links like See also this thread on the mailing list. DescriptionAllow wiki links to the current group to contain dots. Currently, the recipe only ignores "dot followed by a space" as a separator in pagenames (in wikilinks, wikitrails, pagelists, and other functions calling MakePageName). Links like A dot followed by another character is considered a Group.Page separator. Links like Main.WikiSandbox, where the dot is not followed by a space, will lead to an external wiki group. InstallationPlace the following code in config.php
function MakePageNameDot($basepage, $str) {
global $PageNameChars, $PagePathFmt,
$MakePageNamePatterns;
SDV($PageNameChars,'-[:alnum:]');
SDV($MakePageNamePatterns, array(
"/'/" => '', # strip single-quotes
"/[^$PageNameChars]+/" => ' ', # convert everything else to space
'/((^|[^-\\w])\\w)/e' => "strtoupper('$1')",
'/ /' => ''));
$str = preg_replace('/[#?].*$/', '', $str);
$m = preg_split('/\\/|\\.(?!\\s)/', $str);
if (count($m)<1 || count($m)>2 || $m[0]=='') return '';
## handle "Group.Name" conversions
if (@$m[1] > '') {
$group = preg_replace(array_keys($MakePageNamePatterns),
array_values($MakePageNamePatterns), $m[0]);
$name = preg_replace(array_keys($MakePageNamePatterns),
array_values($MakePageNamePatterns), $m[1]);
return "$group.$name";
}
$name = preg_replace(array_keys($MakePageNamePatterns),
array_values($MakePageNamePatterns), $m[0]);
$isgrouphome = count($m) > 1;
foreach((array)$PagePathFmt as $pg) {
if ($isgrouphome && strncmp($pg, '$1.', 3) !== 0) continue;
$pn = FmtPageName(str_replace('$1', $name, $pg), $basepage);
if (PageExists($pn)) return $pn;
}
if ($isgrouphome) {
foreach((array)$PagePathFmt as $pg)
if (strncmp($pg, '$1.', 3) == 0)
return FmtPageName(str_replace('$1', $name, $pg), $basepage);
return "$name.$name";
}
return preg_replace('/[^\\/\\.]+$/', $name, $basepage);
}
$MakePageNameFunction = 'MakePageNameDot';
NotesSee Also
Contributors
Comments |