* @since 1.16.3
* @deprecated since 1.28, use MediaWiki\Linker\LinkRenderer instead
* @see Linker::link
+ * @param Title $target
+ * @param string $html
+ * @param array $customAttribs
+ * @param array $query
+ * @param string|array $options
* @return string
*/
public static function linkKnown(
Title $title, $text, $wikiId = null, $options = []
) {
if ( $wikiId !== null && !$title->isExternal() ) {
- $link = Linker::makeExternalLink(
+ $link = self::makeExternalLink(
WikiMap::getForeignURL(
$wikiId,
- $title->getPrefixedText(),
+ $title->getNamespace() === 0
+ ? $title->getDBkey()
+ : MWNamespace::getCanonicalName( $title->getNamespace() ) . ':'
+ . $title->getDBkey(),
$title->getFragment()
),
$text,
/* escape = */ false // Already escaped
);
} else {
- $link = Linker::link( $title, $text, [], [], $options );
+ $link = self::link( $title, $text, [], [], $options );
}
return $link;
/**
* @param Title $contextTitle
* @param string $target
- * @param string $text
+ * @param string &$text
* @return string
*/
public static function normalizeSubpageLink( $contextTitle, $target, &$text ) {
$title = wfMessage( 'toc' )->inLanguage( $lang )->escaped();
return '<div id="toc" class="toc">'
- . '<div id="toctitle"><h2>' . $title . "</h2></div>\n"
+ . '<div class="toctitle"><h2>' . $title . "</h2></div>\n"
. $toc
. "</ul>\n</div>\n";
}
* a space and ending with '>'
* This *must* be at least '>' for no attribs
* @param string $anchor The anchor to give the headline (the bit after the #)
- * @param string $html Html for the text of the header
+ * @param string $html HTML for the text of the header
* @param string $link HTML to add for the section edit link
- * @param bool|string $legacyAnchor A second, optional anchor to give for
+ * @param string|bool $fallbackAnchor A second, optional anchor to give for
* backward compatibility (false to omit)
*
* @return string HTML headline
*/
public static function makeHeadline( $level, $attribs, $anchor, $html,
- $link, $legacyAnchor = false
+ $link, $fallbackAnchor = false
) {
+ $anchorEscaped = htmlspecialchars( $anchor );
$ret = "<h$level$attribs"
- . "<span class=\"mw-headline\" id=\"$anchor\">$html</span>"
+ . "<span class=\"mw-headline\" id=\"$anchorEscaped\">$html</span>"
. $link
. "</h$level>";
- if ( $legacyAnchor !== false ) {
- $ret = "<div id=\"$legacyAnchor\"></div>$ret";
+ if ( $fallbackAnchor !== false && $fallbackAnchor !== $anchor ) {
+ $fallbackAnchor = htmlspecialchars( $fallbackAnchor );
+ $ret = "<div id=\"$fallbackAnchor\"></div>$ret";
}
return $ret;
}
* @return string HTML output
*/
public static function formatHiddenCategories( $hiddencats ) {
-
$outText = '';
if ( count( $hiddencats ) > 0 ) {
# Construct the HTML
}
if ( !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
- return Linker::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
+ return self::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
} else {
if ( $rev->getId() ) {
// RevDelete links using revision ID are stable across
'ids' => $rev->getTimestamp()
];
}
- return Linker::revDeleteLink( $query,
+ return self::revDeleteLink( $query,
$rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide );
}
}
* @return array
*/
public static function tooltipAndAccesskeyAttribs( $name, array $msgParams = [] ) {
- # @todo FIXME: If Sanitizer::expandAttributes() treated "false" as "output
- # no attribute" instead of "output '' as value for attribute", this
- # would be three lines.
$attribs = [
'title' => self::titleAttrib( $name, 'withaccess', $msgParams ),
'accesskey' => self::accesskey( $name )
* @return null|string
*/
public static function tooltip( $name, $options = null ) {
- # @todo FIXME: If Sanitizer::expandAttributes() treated "false" as "output
- # no attribute" instead of "output '' as value for attribute", this
- # would be two lines.
$tooltip = self::titleAttrib( $name, $options );
if ( $tooltip === false ) {
return '';