"outputReplaceMatches",
$text);
wfProfileOut( $fname.'-replace' );
+
+ wfProfileIn( $fname.'-interwiki' );
+ global $wgInterwikiLinkHolders;
+ $outputReplace = $wgInterwikiLinkHolders;
+ $text = preg_replace_callback(
+ '/<!--IWLINK (.*?)-->/',
+ "outputReplaceMatches",
+ $text);
+ wfProfileOut( $fname.'-interwiki' );
}
wfProfileOut( $fname );
return $colours;
<?php
-// require_once('Tokenizer.php');
-
/**
* File for Parser and related classes
*
$text = $wgDateFormatter->reformat( $this->mOptions->getDateFormat(), $text );
}
$text = $this->doAllQuotes( $text );
- $text = $this->replaceExternalLinks( $text );
$text = $this->doMagicLinks( $text );
$text = $this->replaceInternalLinks ( $text );
# Another call to replace links and images inside captions of images
$text = $this->replaceInternalLinks ( $text );
-
+ $text = $this->replaceExternalLinks( $text );
$text = $this->doTableStuff( $text );
$text = $this->formatHeadings( $text, $isMain );
$sk =& $this->mOptions->getSkin();
continue;
}
+ # Don't allow internal links to pages containing
+ # PROTO: where PROTO is a valid URL protocol; these
+ # should be external links.
+ if (preg_match('/((?:'.URL_PROTOCOLS.'):)/', $m[1])) {
+ $s .= $prefix . '[[' . $line ;
+ continue;
+ }
+
# Valid link forms:
# Foobar -- normal
# :Foobar -- override special treatment of prefix (images, language links)
# Did we encounter this template already? If yes, it is in the cache
# and we need to check for loops.
if ( !$found && isset( $this->mTemplates[$part1] ) ) {
+ # set $text to cached message.
+ $text = $this->mTemplates[$part1];
+ $found = true;
+
# Infinite loop test
if ( isset( $this->mTemplatePath[$part1] ) ) {
$noparse = true;
$found = true;
+ $text .= '<!-- WARNING: template loop detected -->';
}
- # set $text to cached message.
- $text = $this->mTemplates[$part1];
- $found = true;
}
# Load from database
'texts' => array(),
'titles' => array()
);
+global $wgInterwikiLinkHolders;
+$wgInterwikiLinkHolders = array();
/**
* @todo document
$trail = $m[2];
}
}
- $retVal = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
+ # Assume $this->postParseLinkColour(). This prevents
+ # interwiki links from being parsed as external links.
+ global $wgInterwikiLinkHolders;
+ $t = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>";
+ $nr = array_push($wgInterwikiLinkHolders, $t);
+ $retVal = '<!--IWLINK '. ($nr-1) ."-->{$trail}";
} elseif ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
$retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
} elseif ( ( -1 == $nt->getNamespace() ) ||