$target = self::normaliseSpecialPage( $target );
# If we don't know whether the page exists, let's find out.
- wfProfileIn( __METHOD__ . '-checkPageExistence' );
if ( !in_array( 'known', $options ) && !in_array( 'broken', $options ) ) {
if ( $target->isKnown() ) {
$options[] = 'known';
$options[] = 'broken';
}
}
- wfProfileOut( __METHOD__ . '-checkPageExistence' );
$oldquery = array();
if ( in_array( "forcearticlepath", $options ) && $query ) {
$defaults = array();
if ( !in_array( 'noclasses', $options ) ) {
- wfProfileIn( __METHOD__ . '-getClasses' );
# Now build the classes.
$classes = array();
if ( $classes != array() ) {
$defaults['class'] = implode( ' ', $classes );
}
- wfProfileOut( __METHOD__ . '-getClasses' );
}
# Get a default title attribute.
* @param string $comment Text to format links in
* @param Title|null $title An optional title object used to links to sections
* @param bool $local Whether section links should refer to local page
+ * @param string|null $wikiId Id of the wiki to link to (if not the local wiki), as used by WikiMap
+ *
* @return string
*/
- public static function formatLinksInComment( $comment, $title = null, $local = false ) {
+ public static function formatLinksInComment( $comment, $title = null, $local = false, $wikiId = null ) {
return preg_replace_callback(
'/
\[\[
\]\]
([^[]*) # 3. link trail (the text up until the next link)
/x',
- function ( $match ) use ( $title, $local ) {
+ function ( $match ) use ( $title, $local, $wikiId ) {
global $wgContLang;
$medians = '(?:' . preg_quote( MWNamespace::getCanonicalName( NS_MEDIA ), '/' ) . '|';
$newTarget = clone ( $title );
$newTarget->setFragment( '#' . $target->getFragment() );
$target = $newTarget;
+
}
- $thelink = Linker::link(
- $target,
- $linkText . $inside
- ) . $trail;
+
+ if ( $wikiId !== null ) {
+ $thelink = Linker::makeExternalLink(
+ WikiMap::getForeignURL( $wikiId, $target->getPrefixedURL() ),
+ $linkText . $inside,
+ true
+ ) . $trail;
+ } else {
+ $thelink = Linker::link(
+ $target,
+ $linkText . $inside
+ ) . $trail;
+ }
+
}
}
if ( $thelink ) {
) {
wfDeprecated( __METHOD__, '1.21' );
-
if ( $text == '' ) {
$text = self::linkText( $title );
}