Index: trunk/phase3/includes/Parser.php |
— | — | @@ -1133,9 +1133,14 @@ |
1134 | 1134 | continue; |
1135 | 1135 | } |
1136 | 1136 | |
1137 | | - # Make subpage if necessary, and check for leading ':' |
1138 | | - $noforce = true; |
1139 | | - $link = $this->maybeDoSubpageLink( $m[1], $noforce, $text ); |
| 1137 | + # Make subpage if necessary |
| 1138 | + $link = $this->maybeDoSubpageLink( $m[1], $text ); |
| 1139 | + |
| 1140 | + $noforce = (substr($m[1], 0, 1) != ':'); |
| 1141 | + if (!$noforce) { |
| 1142 | + # Strip off leading ':' |
| 1143 | + $link = substr($link, 1); |
| 1144 | + } |
1140 | 1145 | |
1141 | 1146 | $wasblank = ( '' == $text ); |
1142 | 1147 | if( $wasblank ) $text = $link; |
— | — | @@ -1217,12 +1222,11 @@ |
1218 | 1223 | /** |
1219 | 1224 | * Handle link to subpage if necessary |
1220 | 1225 | * @param $target string the source of the link |
1221 | | - * @param $target set to true unless target began with ':' |
1222 | 1226 | * @param &$text the link text, modified as necessary |
1223 | 1227 | * @return string the full name of the link |
1224 | 1228 | * @access private |
1225 | 1229 | */ |
1226 | | - function maybeDoSubpageLink($target, &$noforce, &$text) { |
| 1230 | + function maybeDoSubpageLink($target, &$text) { |
1227 | 1231 | # Valid link forms: |
1228 | 1232 | # Foobar -- normal |
1229 | 1233 | # :Foobar -- override special treatment of prefix (images, language links) |
— | — | @@ -1231,11 +1235,7 @@ |
1232 | 1236 | global $wgNamespacesWithSubpages; |
1233 | 1237 | |
1234 | 1238 | # Look at the first character |
1235 | | - $c = $target{0}; |
1236 | | - $noforce = ($c != ':'); |
1237 | | - |
1238 | | - # subpage |
1239 | | - if( $c == '/' ) { |
| 1239 | + if( $target{0} == '/' ) { |
1240 | 1240 | # / at end means we don't want the slash to be shown |
1241 | 1241 | if(substr($target,-1,1)=='/') { |
1242 | 1242 | $target=substr($target,1,-1); |
— | — | @@ -1255,12 +1255,9 @@ |
1256 | 1256 | # no subpage allowed, use standard link |
1257 | 1257 | $ret = $target; |
1258 | 1258 | } |
1259 | | - } elseif( $noforce ) { |
| 1259 | + } else { |
1260 | 1260 | # no subpage |
1261 | 1261 | $ret = $target; |
1262 | | - } else { |
1263 | | - # We don't want to keep the first character |
1264 | | - $ret = substr( $target, 1 ); |
1265 | 1262 | } |
1266 | 1263 | |
1267 | 1264 | return $ret; |
— | — | @@ -1812,7 +1809,7 @@ |
1813 | 1810 | $itcamefromthedatabase = false; |
1814 | 1811 | if ( !$found ) { |
1815 | 1812 | $ns = NS_TEMPLATE; |
1816 | | - $part1 = $this->maybeDoSubpageLink( $part1, $noforce, $subpage='' ); |
| 1813 | + $part1 = $this->maybeDoSubpageLink( $part1, $subpage='' ); |
1817 | 1814 | if ($subpage !== '') { |
1818 | 1815 | $ns = $this->mTitle->getNamespace(); |
1819 | 1816 | } |