r5507 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r5506‎ | r5507 | r5508 >
Date:20:35, 25 September 2004
Author:wmahan
Status:old
Tags:
Comment:
Don't strip leading ':' in maybeDoSubpageLink() so that
{{:foo}} works for including from main namespace.
Modified paths:
  • /trunk/phase3/includes/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Parser.php
@@ -1133,9 +1133,14 @@
11341134 continue;
11351135 }
11361136
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+ }
11401145
11411146 $wasblank = ( '' == $text );
11421147 if( $wasblank ) $text = $link;
@@ -1217,12 +1222,11 @@
12181223 /**
12191224 * Handle link to subpage if necessary
12201225 * @param $target string the source of the link
1221 - * @param $target set to true unless target began with ':'
12221226 * @param &$text the link text, modified as necessary
12231227 * @return string the full name of the link
12241228 * @access private
12251229 */
1226 - function maybeDoSubpageLink($target, &$noforce, &$text) {
 1230+ function maybeDoSubpageLink($target, &$text) {
12271231 # Valid link forms:
12281232 # Foobar -- normal
12291233 # :Foobar -- override special treatment of prefix (images, language links)
@@ -1231,11 +1235,7 @@
12321236 global $wgNamespacesWithSubpages;
12331237
12341238 # Look at the first character
1235 - $c = $target{0};
1236 - $noforce = ($c != ':');
1237 -
1238 - # subpage
1239 - if( $c == '/' ) {
 1239+ if( $target{0} == '/' ) {
12401240 # / at end means we don't want the slash to be shown
12411241 if(substr($target,-1,1)=='/') {
12421242 $target=substr($target,1,-1);
@@ -1255,12 +1255,9 @@
12561256 # no subpage allowed, use standard link
12571257 $ret = $target;
12581258 }
1259 - } elseif( $noforce ) {
 1259+ } else {
12601260 # no subpage
12611261 $ret = $target;
1262 - } else {
1263 - # We don't want to keep the first character
1264 - $ret = substr( $target, 1 );
12651262 }
12661263
12671264 return $ret;
@@ -1812,7 +1809,7 @@
18131810 $itcamefromthedatabase = false;
18141811 if ( !$found ) {
18151812 $ns = NS_TEMPLATE;
1816 - $part1 = $this->maybeDoSubpageLink( $part1, $noforce, $subpage='' );
 1813+ $part1 = $this->maybeDoSubpageLink( $part1, $subpage='' );
18171814 if ($subpage !== '') {
18181815 $ns = $this->mTitle->getNamespace();
18191816 }

Status & tagging log