/**
* Return the CSS colour of a known link
*
+ * @deprecated since 1.28, use LinkRenderer::getLinkClasses() instead
+ *
* @since 1.16.3
- * @param Title $t
+ * @param LinkTarget $t
* @param int $threshold User defined threshold
* @return string CSS class
*/
- public static function getLinkColour( $t, $threshold ) {
- $colour = '';
- if ( $t->isRedirect() ) {
- # Page is a redirect
- $colour = 'mw-redirect';
- } elseif ( $threshold > 0 && $t->isContentPage() &&
- $t->exists() && $t->getLength() < $threshold
- ) {
- # Page is a stub
- $colour = 'stub';
+ public static function getLinkColour( LinkTarget $t, $threshold ) {
+ wfDeprecated( __METHOD__, '1.28' );
+ $services = MediaWikiServices::getInstance();
+ $linkRenderer = $services->getLinkRenderer();
+ if ( $threshold !== $linkRenderer->getStubThreshold() ) {
+ // Need to create a new instance with the right stub threshold...
+ $linkRenderer = $services->getLinkRendererFactory()->create();
+ $linkRenderer->setStubThreshold( $threshold );
}
- return $colour;
+
+ return $linkRenderer->getLinkClasses( $t );
}
/**
* link() replaces the old functions in the makeLink() family.
*
* @since 1.18 Method exists since 1.16 as non-static, made static in 1.18.
+ * @deprecated since 1.28, use MediaWiki\Linker\LinkRenderer instead
*
* @param Title $target Can currently only be a Title, but this may
* change to support Images, literal URLs, etc.
if ( $options ) {
// Custom options, create new LinkRenderer
if ( !isset( $options['stubThreshold'] ) ) {
- global $wgUser;
- $options['stubThreshold'] = $wgUser->getStubThreshold();
+ $defaultLinkRenderer = $services->getLinkRenderer();
+ $options['stubThreshold'] = $defaultLinkRenderer->getStubThreshold();
}
$linkRenderer = $services->getLinkRendererFactory()
->createFromLegacyOptions( $options );
return $linkRenderer->makeKnownLink( $target, $text, $customAttribs, $query );
} elseif ( in_array( 'broken', $options, true ) ) {
return $linkRenderer->makeBrokenLink( $target, $text, $customAttribs, $query );
+ } elseif ( in_array( 'noclasses', $options, true ) ) {
+ return $linkRenderer->makePreloadedLink( $target, $text, '', $customAttribs, $query );
} else {
return $linkRenderer->makeLink( $target, $text, $customAttribs, $query );
}
/**
* Identical to link(), except $options defaults to 'known'.
+ *
* @since 1.16.3
+ * @deprecated since 1.28, use MediaWiki\Linker\LinkRenderer instead
* @see Linker::link
* @return string
*/
*
* If the option noBrackets is set the rollback link wont be enclosed in "[]".
*
- * See the "mediawiki.page.rollback" module for the client-side handling of this link.
- *
* @since 1.16.3. $context added in 1.20. $options added in 1.21
*
* @param Revision $rev
$inner = $context->msg( 'brackets' )->rawParams( $inner )->escaped();
}
- $context->getOutput()->addModules( 'mediawiki.page.rollback' );
-
return '<span class="mw-rollback-link">' . $inner . '</span>';
}
$query = [
'action' => 'rollback',
'from' => $rev->getUserText(),
+ 'token' => $context->getUser()->getEditToken( 'rollback' ),
];
$attrs = [
'data-mw' => 'interface',