Author: john_b_andrews
Description:
Please allow links with dotdot syntax to reference up the subpage
hierarchy. This is very useful for deep subpage hierarchies (which
are perhaps only useful in intranets).
Here are simple examples (assume we are editing page A/B/C/D):
[../E] --> references A/B/C/E [../../../W/X] --> references A/W/X
Here is a mediocre implementation for version 1.3.8 (if this gets mangled,
email me at john_b_andrews@yahoo.com for a copy):
Parser.php diff:
1197,1213d1196
< # JBA inserted code here
< # The two inserted code snippets allow .. syntax like this:
< # [[../Foo]] or [[../../Bar]]
< # Limitations:
< # - ..s can only occur at beginning
< # - cannot go past your top subpage
< # - cannot just do .. or ../..; must have / and something not-..
< $jba_cd_dot_dot = 0; # count # of leading ../ occurrences
< $jba_orig_m1 = $m[1];
< if(substr($m[1],0,3) == '../') {
< while(substr($m[1],0,3) == '../') {
< $jba_cd_dot_dot = $jba_cd_dot_dot + 1;
< $m[1] = substr($m[1],3);
< }
< $m[1] = '/' . $m[1];
< }
< # JBA end of code insertion
1224,1241c1207
< # JBA inserted code here
< $jba_prefix = $this->mTitle->getPrefixedText(); # Prefix to be prepended
<
< # Remove $jba_cd_dot_dot number of /words on the end of the prefix
< if ($jba_cd_dot_dot) {
< $jba_substrings = explode('/', $jba_prefix);
< $jba_substrings = array_slice($jba_substrings, 0, -$jba_cd_dot_dot);
< # Implode seems to malfunction if $jba_substrings is one element.
< if (count($jba_substrings) == 1) {
< $jba_prefix = $jba_substrings[0];
< }
< else {
< $jba_prefix = implode('/', $jba_substrings);
< }
< }
<
< # Prepend the prefix to the suffix to form the link.
< $link = $jba_prefix . '/' . trim($noslash);
$link = $this->mTitle->getPrefixedText(). '/' . trim($noslash);
1243c1209
< $text= $jba_orig_m1;
$text= $m[1];
1245,1246d1210
< # JBA end of code insertion
Version: unspecified
Severity: enhancement