*/
public static function userLink( $userId, $userName, $altUserName = false ) {
$classes = 'mw-userlink';
+ $page = null;
if ( $userId == 0 ) {
- $page = SpecialPage::getTitleFor( 'Contributions', $userName );
- if ( $altUserName === false ) {
- $altUserName = IP::prettifyIP( $userName );
+ $pos = strpos( $userName, '>' );
+ if ( $pos !== false ) {
+ $iw = explode( ':', substr( $userName, 0, $pos ) );
+ $firstIw = array_shift( $iw );
+ $interwikiLookup = MediaWikiServices::getInstance()->getInterwikiLookup();
+ if ( $interwikiLookup->isValidInterwiki( $firstIw ) ) {
+ $title = MWNamespace::getCanonicalName( NS_USER ) . ':' . substr( $userName, $pos + 1 );
+ if ( $iw ) {
+ $title = join( ':', $iw ) . ':' . $title;
+ }
+ $page = Title::makeTitle( NS_MAIN, $title, '', $firstIw );
+ }
+ $classes .= ' mw-extuserlink';
+ } else {
+ $page = SpecialPage::getTitleFor( 'Contributions', $userName );
+ if ( $altUserName === false ) {
+ $altUserName = IP::prettifyIP( $userName );
+ }
}
$classes .= ' mw-anonuserlink'; // Separate link class for anons (T45179)
} else {
}
// Wrap the output with <bdi> tags for directionality isolation
- return self::link(
- $page,
- '<bdi>' . htmlspecialchars( $altUserName !== false ? $altUserName : $userName ) . '</bdi>',
- [ 'class' => $classes ]
- );
+ $linkText =
+ '<bdi>' . htmlspecialchars( $altUserName !== false ? $altUserName : $userName ) . '</bdi>';
+
+ return $page
+ ? self::link( $page, $linkText, [ 'class' => $classes ] )
+ : Html::rawElement( 'span', [ 'class' => $classes ], $linkText );
}
/**
$blockable = !( $flags & self::TOOL_LINKS_NOBLOCK );
$addEmailLink = $flags & self::TOOL_LINKS_EMAIL && $userId;
+ if ( $userId == 0 && strpos( $userText, '>' ) !== false ) {
+ // No tools for an external user
+ return '';
+ }
+
$items = [];
if ( $talkable ) {
$items[] = self::userTalkLink( $userId, $userText );
$section = str_replace( '[[', '', $section );
$section = str_replace( ']]', '', $section );
- $section = Sanitizer::normalizeSectionNameWhitespace( $section ); # T24784
+ $section = substr( Parser::guessSectionNameFromStrippedText( $section ), 1 );
if ( $local ) {
- $sectionTitle = Title::newFromText( '#' . $section );
+ $sectionTitle = Title::makeTitleSafe( NS_MAIN, '', $section );
} else {
$sectionTitle = Title::makeTitleSafe( $title->getNamespace(),
- $title->getDBkey(), Sanitizer::decodeCharReferences( $section ) );
+ $title->getDBkey(), $section );
}
if ( $sectionTitle ) {
$link = Linker::makeCommentLink( $sectionTitle, $wgLang->getArrow(), $wikiId, 'noclasses' );
$title = wfMessage( 'toc' )->inLanguage( $lang )->escaped();
return '<div id="toc" class="toc">'
- . '<div class="toctitle"><h2>' . $title . "</h2></div>\n"
+ . Html::openElement( 'div', [
+ 'class' => 'toctitle',
+ 'lang' => $lang->getHtmlCode(),
+ 'dir' => $lang->getDir(),
+ ] )
+ . '<h2>' . $title . "</h2></div>\n"
. $toc
. "</ul>\n</div>\n";
}
return Xml::tags( 'span', [ 'class' => 'mw-revdelundel-link' ], $htmlParentheses );
}
- /* Deprecated methods */
-
/**
* Returns the attributes for the tooltip and access key.
*