101 $this->forceArticlePath = $force;
129 $this->stubThreshold = $threshold;
154 LinkTarget $target, $text =
null, array $extraAttribs = [], array $query = []
156 $title = Title::newFromLinkTarget( $target );
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 ] )
209 $title = Title::newFromLinkTarget( $target );
210 if ( $text !==
null ) {
213 $realHtml = $html =
null;
215 if ( !Hooks::run(
'LinkBegin',
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 );
371 if ( !Hooks::run(
'HtmlPageLinkRendererEnd',
372 [ $this, $target, $isKnown, &$text, &$attribs, &$ret ] )
380 if ( Hooks::isRegistered(
'LinkEnd' ) ) {
382 $title = Title::newFromLinkTarget( $target );
384 if ( !Hooks::run(
'LinkEnd',
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;
411 $title = Title::newFromLinkTarget( $target );
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() ) &&
482 $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.
static getHtml( $input)
Provide a string or HtmlArmor object and get safe HTML back.
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.
Some internal bits split of from Skin.php.
static normaliseSpecialPage(LinkTarget $target)
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
HTML sanitizer for MediaWiki.
Represents a title within MediaWiki.
if(! $dbr->tableExists( 'profiling')) $expand