115 $this->forceArticlePath = $force;
129 $this->expandUrls = $expand;
143 $this->stubThreshold = $threshold;
161 LinkTarget $target, $text =
null, array $extraAttribs = [], array $query = []
163 $title = Title::newFromLinkTarget( $target );
164 if (
$title->isKnown() ) {
165 return $this->
makeKnownLink( $target, $text, $extraAttribs, $query );
167 return $this->
makeBrokenLink( $target, $text, $extraAttribs, $query );
173 if ( !$this->hookRunner->onHtmlPageLinkRendererBegin(
174 $this, $target, $text, $extraAttribs, $query, $ret )
192 LinkTarget $target, $text =
null, $classes =
'', array $extraAttribs = [], array $query = []
195 $ret = $this->
runBeginHook( $target, $text, $extraAttribs, $query,
true );
196 if ( $ret !==
null ) {
201 $attribs = [
'class' => $classes ];
202 $prefixedText = $this->titleFormatter->getPrefixedText( $target );
203 if ( $prefixedText !==
'' ) {
204 $attribs[
'title'] = $prefixedText;
211 if ( $text ===
null ) {
215 return $this->
buildAElement( $target, $text, $attribs,
true );
226 LinkTarget $target, $text =
null, array $extraAttribs = [], array $query = []
230 $classes[] =
'extiw';
233 if ( $colour !==
'' ) {
234 $classes[] = $colour;
240 implode(
' ', $classes ),
255 LinkTarget $target, $text =
null, array $extraAttribs = [], array $query = []
258 $ret = $this->
runBeginHook( $target, $text, $extraAttribs, $query,
false );
259 if ( $ret !==
null ) {
263 # We don't want to include fragments for broken links, because they
264 # generally make no sense.
271 $query[
'action'] =
'edit';
272 $query[
'redlink'] =
'1';
276 $attribs = [
'class' =>
'new' ];
277 $prefixedText = $this->titleFormatter->getPrefixedText( $target );
278 if ( $prefixedText !==
'' ) {
280 $attribs[
'title'] =
wfMessage(
'red-link-title', $prefixedText )
281 ->inContentLanguage()
289 if ( $text ===
null ) {
293 return $this->
buildAElement( $target, $text, $attribs,
false );
307 if ( !$this->hookRunner->onHtmlPageLinkRendererEnd(
308 $this, $target, $isKnown, $text, $attribs, $ret )
313 return Html::rawElement(
'a', $attribs, HtmlArmor::getHtml( $text ) );
321 $prefixedText = $this->titleFormatter->getPrefixedText( $target );
324 if ( $prefixedText ===
'' && $target->
hasFragment() ) {
328 return $prefixedText;
333 $title = Title::newFromLinkTarget( $target );
334 if ( $this->forceArticlePath ) {
340 $url =
$title->getLinkURL( $query,
false, $this->expandUrls );
342 if ( $this->forceArticlePath && $realQuery ) {
359 list( $name, $subpage ) = $this->specialPageFactory->resolveAlias(
365 $this->specialPageFactory->getLocalNameFor( $name, $subpage ),
386 # Merge the custom attribs with the default ones, and iterate
387 # over that, deleting all "false" attributes.
389 $merged = Sanitizer::mergeAttributes( $defaults, $attribs );
390 foreach ( $merged as $key => $val ) {
391 # A false value suppresses the attribute
392 if ( $val !==
false ) {
407 $id = $this->linkCache->addLinkObj( $target );
413 if ( $this->linkCache->getGoodLinkFieldObj( $target,
'redirect' ) ) {
415 return 'mw-redirect';
417 $this->stubThreshold > 0 && $this->nsInfo->isContent( $target->
getNamespace() ) &&
418 $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.
Represents a page (or page fragment) title within MediaWiki.
Represents a title within MediaWiki.