* Return the CSS colour of a known link
*
* @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() ) {
+ public static function getLinkColour( LinkTarget $t, $threshold ) {
+ $linkCache = MediaWikiServices::getInstance()->getLinkCache();
+ // Make sure the target is in the cache
+ $id = $linkCache->addLinkObj( $t );
+ if ( $id == 0 ) {
+ // Doesn't exist
+ return '';
+ }
+
+ if ( $linkCache->getGoodLinkFieldObj( $t, 'redirect' ) ) {
# Page is a redirect
- $colour = 'mw-redirect';
- } elseif ( $threshold > 0 && $t->isContentPage() &&
- $t->exists() && $t->getLength() < $threshold
+ return 'mw-redirect';
+ } elseif ( $threshold > 0 && MWNamespace::isContent( $t->getNamespace() )
+ && $linkCache->getGoodLinkFieldObj( $t, 'length' ) < $threshold
) {
# Page is a stub
- $colour = 'stub';
+ return 'stub';
}
- return $colour;
+
+ return '';
}
/**
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 );
}
*
* 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',