101 $this->forceArticlePath = $force;
129 $this->stubThreshold = $threshold;
154 LinkTarget $target, $text =
null, array $extraAttribs = [], array $query = []
157 if (
$title->isKnown() ) {
158 return $this->
makeKnownLink( $target, $text, $extraAttribs, $query );
160 return $this->
makeBrokenLink( $target, $text, $extraAttribs, $query );
172 if ( $this->forceArticlePath ) {
173 $options[] =
'forcearticlepath';
178 $options[] =
'https';
181 $options[] = $isKnown ?
'known' :
'broken';
188 if ( !
Hooks::run(
'HtmlPageLinkRendererBegin',
189 [ $this, $target, &$text, &$extraAttribs, &$query, &$ret ] )
210 if ( $text !==
null ) {
213 $realHtml = $html =
null;
216 [ $dummy,
$title, &$html, &$extraAttribs, &$query, &$options, &$ret ],
'1.28' )
221 if ( $html !==
null && $html !== $realHtml ) {
227 if ( $options !== $realOptions ) {
230 $newRenderer = $factory->createFromLegacyOptions( $options );
232 $newRenderer->setRunLegacyBeginHook(
false );
233 if ( in_array(
'known', $options,
true ) ) {
234 return $newRenderer->makeKnownLink(
$title, $text, $extraAttribs, $query );
235 } elseif ( in_array(
'broken', $options,
true ) ) {
236 return $newRenderer->makeBrokenLink(
$title, $text, $extraAttribs, $query );
238 return $newRenderer->makeLink(
$title, $text, $extraAttribs, $query );
257 LinkTarget $target, $text =
null, $classes =
'', array $extraAttribs = [], array $query = []
260 $ret = $this->
runBeginHook( $target, $text, $extraAttribs, $query,
true );
261 if ( $ret !==
null ) {
266 $attribs = [
'class' => $classes ];
267 $prefixedText = $this->titleFormatter->getPrefixedText( $target );
268 if ( $prefixedText !==
'' ) {
269 $attribs[
'title'] = $prefixedText;
276 if ( $text ===
null ) {
280 return $this->
buildAElement( $target, $text, $attribs,
true );
291 LinkTarget $target, $text =
null, array $extraAttribs = [], array $query = []
295 $classes[] =
'extiw';
298 if ( $colour !==
'' ) {
299 $classes[] = $colour;
305 implode(
' ', $classes ),
319 LinkTarget $target, $text =
null, array $extraAttribs = [], array $query = []
322 $ret = $this->
runBeginHook( $target, $text, $extraAttribs, $query,
false );
323 if ( $ret !==
null ) {
327 # We don't want to include fragments for broken links, because they
328 # generally make no sense.
335 $query[
'action'] =
'edit';
336 $query[
'redlink'] =
'1';
340 $attribs = [
'class' =>
'new' ];
341 $prefixedText = $this->titleFormatter->getPrefixedText( $target );
342 if ( $prefixedText !==
'' ) {
344 $attribs[
'title'] =
wfMessage(
'red-link-title', $prefixedText )
345 ->inContentLanguage()
353 if ( $text ===
null ) {
357 return $this->
buildAElement( $target, $text, $attribs,
false );
372 [ $this, $target, $isKnown, &$text, &$attribs, &$ret ] )
385 [ $dummy,
$title, $options, &$html, &$attribs, &$ret ],
'1.28' )
391 return Html::rawElement(
'a', $attribs, $html );
399 $prefixedText = $this->titleFormatter->getPrefixedText( $target );
402 if ( $prefixedText ===
'' && $target->
hasFragment() ) {
406 return $prefixedText;
412 if ( $this->forceArticlePath ) {
418 $url =
$title->getLinkURL( $query,
false, $this->expandUrls );
420 if ( $this->forceArticlePath && $realQuery ) {
450 # Merge the custom attribs with the default ones, and iterate
451 # over that, deleting all "false" attributes.
453 $merged = Sanitizer::mergeAttributes( $defaults, $attribs );
454 foreach ( $merged as $key => $val ) {
455 # A false value suppresses the attribute
456 if ( $val !==
false ) {
471 $id = $this->linkCache->addLinkObj( $target );
477 if ( $this->linkCache->getGoodLinkFieldObj( $target,
'redirect' ) ) {
479 return 'mw-redirect';
481 $this->stubThreshold > 0 && $this->nsInfo->isContent( $target->
getNamespace() ) &&