124 $this->forceArticlePath = $force;
138 $this->expandUrls = $expand;
152 $this->stubThreshold = $threshold;
177 LinkTarget $target, $text =
null, array $extraAttribs = [], array $query = []
179 $title = Title::newFromLinkTarget( $target );
180 if (
$title->isKnown() ) {
181 return $this->
makeKnownLink( $target, $text, $extraAttribs, $query );
183 return $this->
makeBrokenLink( $target, $text, $extraAttribs, $query );
195 if ( $this->forceArticlePath ) {
196 $options[] =
'forcearticlepath';
201 $options[] =
'https';
204 $options[] = $isKnown ?
'known' :
'broken';
211 if ( !$this->hookRunner->onHtmlPageLinkRendererBegin(
212 $this, $target, $text, $extraAttribs, $query, $ret )
224 if ( !$this->
runLegacyBeginHook || !$this->hookContainer->isRegistered(
'LinkBegin' ) ) {
232 $title = Title::newFromLinkTarget( $target );
233 if ( $text !==
null ) {
234 $realHtml = $html = HtmlArmor::getHtml( $text );
236 $realHtml = $html =
null;
238 if ( !$this->hookRunner->onLinkBegin(
239 $dummy,
$title, $html, $extraAttribs, $query, $options, $ret )
244 if ( $html !==
null && $html !== $realHtml ) {
250 if ( $options !== $realOptions ) {
253 $newRenderer = $factory->createFromLegacyOptions( $options );
255 $newRenderer->setRunLegacyBeginHook(
false );
256 if ( in_array(
'known', $options,
true ) ) {
257 return $newRenderer->makeKnownLink(
$title, $text, $extraAttribs, $query );
258 } elseif ( in_array(
'broken', $options,
true ) ) {
259 return $newRenderer->makeBrokenLink(
$title, $text, $extraAttribs, $query );
261 return $newRenderer->makeLink(
$title, $text, $extraAttribs, $query );
280 LinkTarget $target, $text =
null, $classes =
'', array $extraAttribs = [], array $query = []
283 $ret = $this->
runBeginHook( $target, $text, $extraAttribs, $query,
true );
284 if ( $ret !==
null ) {
289 $attribs = [
'class' => $classes ];
290 $prefixedText = $this->titleFormatter->getPrefixedText( $target );
291 if ( $prefixedText !==
'' ) {
292 $attribs[
'title'] = $prefixedText;
299 if ( $text ===
null ) {
303 return $this->
buildAElement( $target, $text, $attribs,
true );
314 LinkTarget $target, $text =
null, array $extraAttribs = [], array $query = []
318 $classes[] =
'extiw';
321 if ( $colour !==
'' ) {
322 $classes[] = $colour;
328 implode(
' ', $classes ),
343 LinkTarget $target, $text =
null, array $extraAttribs = [], array $query = []
346 $ret = $this->
runBeginHook( $target, $text, $extraAttribs, $query,
false );
347 if ( $ret !==
null ) {
351 # We don't want to include fragments for broken links, because they
352 # generally make no sense.
359 $query[
'action'] =
'edit';
360 $query[
'redlink'] =
'1';
364 $attribs = [
'class' =>
'new' ];
365 $prefixedText = $this->titleFormatter->getPrefixedText( $target );
366 if ( $prefixedText !==
'' ) {
368 $attribs[
'title'] =
wfMessage(
'red-link-title', $prefixedText )
369 ->inContentLanguage()
377 if ( $text ===
null ) {
381 return $this->
buildAElement( $target, $text, $attribs,
false );
395 if ( !$this->hookRunner->onHtmlPageLinkRendererEnd(
396 $this, $target, $isKnown, $text, $attribs, $ret )
401 $html = HtmlArmor::getHtml( $text );
404 if ( $this->hookContainer->isRegistered(
'LinkEnd' ) ) {
406 $title = Title::newFromLinkTarget( $target );
408 if ( !$this->hookRunner->onLinkEnd(
409 $dummy,
$title, $options, $html, $attribs, $ret )
415 return Html::rawElement(
'a', $attribs, $html );
423 $prefixedText = $this->titleFormatter->getPrefixedText( $target );
426 if ( $prefixedText ===
'' && $target->
hasFragment() ) {
430 return $prefixedText;
435 $title = Title::newFromLinkTarget( $target );
436 if ( $this->forceArticlePath ) {
442 $url =
$title->getLinkURL( $query,
false, $this->expandUrls );
444 if ( $this->forceArticlePath && $realQuery ) {
461 list( $name, $subpage ) = $this->specialPageFactory->resolveAlias(
484 # Merge the custom attribs with the default ones, and iterate
485 # over that, deleting all "false" attributes.
487 $merged = Sanitizer::mergeAttributes( $defaults, $attribs );
488 foreach ( $merged as $key => $val ) {
489 # A false value suppresses the attribute
490 if ( $val !==
false ) {
505 $id = $this->linkCache->addLinkObj( $target );
511 if ( $this->linkCache->getGoodLinkFieldObj( $target,
'redirect' ) ) {
513 return 'mw-redirect';
515 $this->stubThreshold > 0 && $this->nsInfo->isContent( $target->
getNamespace() ) &&
516 $this->linkCache->getGoodLinkFieldObj( $target,
'length' ) < $this->stubThreshold
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Marks HTML that shouldn't be escaped.
This class is a collection of static functions that serve two purposes:
Cache for article titles (prefixed DB keys) and ids linked from one source.
Factory for handling the special page list and generating SpecialPage objects.
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
HTML sanitizer for MediaWiki.
Parent class for all special pages.
static getTitleValueFor( $name, $subpage=false, $fragment='')
Get a localised TitleValue object for a specified special page name.
Represents a title within MediaWiki.