In MediaWiki, self links (links to the page itself) are rendered as normal bold text (without a link). In cargo, if a table contains a link to the page itself, it is rendered as any other link. I think it would be good to follow the MediaWiki style and check for self links to render them as bold text. I have been looking into this and this patch solves the problem:
diff --git a/includes/CargoUtils.php b/includes/CargoUtils.php index 91a935f..abcaff6 100644 --- a/includes/CargoUtils.php +++ b/includes/CargoUtils.php @@ -1143,6 +1143,17 @@ class CargoUtils { public static function makeLink( $linkRenderer, $title, $msg = null, $attrs = array(), $params = array() ) { if ( is_null( $title ) ) { return null; + } + + $ctx = RequestContext::getMain(); + $tempTitle = $ctx->getTitle(); + + if ( !is_null( $tempTitle ) && $title->getArticleId() == $tempTitle->getArticleId() ) { + if ( is_null( $msg ) ) { + return Html::element('strong', $attrs, $title->getBaseText()); + } else { + return Html::element('strong', $attrs, $msg); + } } elseif ( !is_null( $linkRenderer ) ) { // MW 1.28+ // Is there a makeLinkKnown() method? We'll just add the
To obtain the current page, the context is obtained through the RequestContext::getMain() function. However, the MediaWiki documentation about this function (https://www.mediawiki.org/wiki/Manual:RequestContext.php) says that it should be used as a last resort, so I don't know if it is better to modify the function signature to include the context as a parameter.