* Has compatibility issues on some setups, so avoid wherever possible.
* 'http': Force a full URL with http:// as the scheme.
* 'https': Force a full URL with https:// as the scheme.
+ * 'stubThreshold' => (int): Stub threshold to use when determining link classes.
* @return string HTML <a> attribute
*/
public static function link(
$target = self::normaliseSpecialPage( $target );
# If we don't know whether the page exists, let's find out.
- if ( !in_array( 'known', $options ) && !in_array( 'broken', $options ) ) {
+ if ( !in_array( 'known', $options, true ) && !in_array( 'broken', $options, true ) ) {
if ( $target->isKnown() ) {
$options[] = 'known';
} else {
}
$oldquery = array();
- if ( in_array( "forcearticlepath", $options ) && $query ) {
+ if ( in_array( "forcearticlepath", $options, true ) && $query ) {
$oldquery = $query;
$query = array();
}
# Note: we want the href attribute first, for prettiness.
$attribs = array( 'href' => self::linkUrl( $target, $query, $options ) );
- if ( in_array( 'forcearticlepath', $options ) && $oldquery ) {
+ if ( in_array( 'forcearticlepath', $options, true ) && $oldquery ) {
$attribs['href'] = wfAppendQuery( $attribs['href'], $oldquery );
}
private static function linkUrl( $target, $query, $options ) {
# We don't want to include fragments for broken links, because they
# generally make no sense.
- if ( in_array( 'broken', $options ) && $target->hasFragment() ) {
+ if ( in_array( 'broken', $options, true ) && $target->hasFragment() ) {
$target = clone $target;
$target->setFragment( '' );
}
# If it's a broken link, add the appropriate query pieces, unless
# there's already an action specified, or unless 'edit' makes no sense
# (i.e., for a nonexistent special page).
- if ( in_array( 'broken', $options ) && empty( $query['action'] )
+ if ( in_array( 'broken', $options, true ) && empty( $query['action'] )
&& !$target->isSpecialPage() ) {
$query['action'] = 'edit';
$query['redlink'] = '1';
}
- if ( in_array( 'http', $options ) ) {
+ if ( in_array( 'http', $options, true ) ) {
$proto = PROTO_HTTP;
- } elseif ( in_array( 'https', $options ) ) {
+ } elseif ( in_array( 'https', $options, true ) ) {
$proto = PROTO_HTTPS;
} else {
$proto = PROTO_RELATIVE;
global $wgUser;
$defaults = array();
- if ( !in_array( 'noclasses', $options ) ) {
+ if ( !in_array( 'noclasses', $options, true ) ) {
# Now build the classes.
$classes = array();
- if ( in_array( 'broken', $options ) ) {
+ if ( in_array( 'broken', $options, true ) ) {
$classes[] = 'new';
}
$classes[] = 'extiw';
}
- if ( !in_array( 'broken', $options ) ) { # Avoid useless calls to LinkCache (see r50387)
- $colour = self::getLinkColour( $target, $wgUser->getStubThreshold() );
+ if ( !in_array( 'broken', $options, true ) ) { # Avoid useless calls to LinkCache (see r50387)
+ $colour = self::getLinkColour(
+ $target,
+ isset( $options['stubThreshold'] ) ? $options['stubThreshold'] : $wgUser->getStubThreshold()
+ );
if ( $colour !== '' ) {
$classes[] = $colour; # mw-redirect or stub
}
if ( $target->getPrefixedText() == '' ) {
# A link like [[#Foo]]. This used to mean an empty title
# attribute, but that's silly. Just don't output a title.
- } elseif ( in_array( 'known', $options ) ) {
+ } elseif ( in_array( 'known', $options, true ) ) {
$defaults['title'] = $target->getPrefixedText();
} else {
// This ends up in parser cache!
}
$editCount = false;
- if ( in_array( 'verify', $options ) ) {
+ if ( in_array( 'verify', $options, true ) ) {
$editCount = self::getRollbackEditCount( $rev, true );
if ( $editCount === false ) {
return '';
$inner = self::buildRollbackLink( $rev, $context, $editCount );
- if ( !in_array( 'noBrackets', $options ) ) {
+ if ( !in_array( 'noBrackets', $options, true ) ) {
$inner = $context->msg( 'brackets' )->rawParams( $inner )->escaped();
}