23 use HtmlFormatter\HtmlFormatter;
29 use Wikimedia\IPUtils;
89 public static function link(
90 $target, $html =
null, $customAttribs = [], $query = [], $options = []
93 wfWarn( __METHOD__ .
': Requires $target to be a LinkTarget object.', 2 );
94 return "<!-- ERROR -->$html";
97 $services = MediaWikiServices::getInstance();
98 $options = (array)$options;
101 $linkRenderer = $services->getLinkRendererFactory()
102 ->createFromLegacyOptions( $options );
104 $linkRenderer = $services->getLinkRenderer();
107 if ( $html !==
null ) {
113 if ( in_array(
'known', $options,
true ) ) {
114 return $linkRenderer->makeKnownLink( $target, $text, $customAttribs, $query );
117 if ( in_array(
'broken', $options,
true ) ) {
118 return $linkRenderer->makeBrokenLink( $target, $text, $customAttribs, $query );
121 if ( in_array(
'noclasses', $options,
true ) ) {
122 return $linkRenderer->makePreloadedLink( $target, $text,
'', $customAttribs, $query );
125 return $linkRenderer->makeLink( $target, $text, $customAttribs, $query );
142 $target, $html =
null, $customAttribs = [],
143 $query = [], $options = [
'known' ]
145 return self::link( $target, $html, $customAttribs, $query, $options );
163 public static function makeSelfLinkObj( $nt, $html =
'', $query =
'', $trail =
'', $prefix =
'' ) {
165 $ret =
"<a class=\"mw-selflink selflink\">{$prefix}{$html}</a>{$trail}";
166 if ( !
Hooks::runner()->onSelfLinkBegin( $nt, $html, $trail, $prefix, $ret ) ) {
171 $html = htmlspecialchars( $nt->getPrefixedText() );
174 return "<a class=\"mw-selflink selflink\">{$prefix}{$html}{$inside}</a>{$trail}";
189 if ( MediaWikiServices::getInstance()->getNamespaceInfo()->exists( $namespace ) ) {
191 $name = $context->
msg(
'blanknamespace' )->text();
193 $name = MediaWikiServices::getInstance()->getContentLanguage()->
194 getFormattedNsText( $namespace );
196 return $context->
msg(
'invalidtitle-knownnamespace', $namespace, $name,
$title )->text();
199 return $context->
msg(
'invalidtitle-unknownnamespace', $namespace,
$title )->text();
210 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
211 return $linkRenderer->normalizeTarget( $target );
223 $basename = strrchr( $url,
'/' );
224 if ( $basename ===
false ) {
227 $basename = substr( $basename, 1 );
249 wfDebug(
"Hook LinkerMakeExternalImage changed the output of external image "
250 .
"with url {$url} and alt text {$alt} to {$img}" );
300 $file, $frameParams = [], $handlerParams = [], $time =
false,
301 $query =
"", $widthOption =
null
308 $file, $frameParams, $handlerParams, $time,
$res,
310 $parser, $query, $widthOption )
315 if (
$file && !
$file->allowInlineDisplay() ) {
316 wfDebug( __METHOD__ .
': ' .
$title->getPrefixedDBkey() .
" does not allow inline display" );
321 $page = $handlerParams[
'page'] ??
false;
322 if ( !isset( $frameParams[
'align'] ) ) {
323 $frameParams[
'align'] =
'';
325 if ( !isset( $frameParams[
'alt'] ) ) {
326 $frameParams[
'alt'] =
'';
328 if ( !isset( $frameParams[
'title'] ) ) {
329 $frameParams[
'title'] =
'';
331 if ( !isset( $frameParams[
'class'] ) ) {
332 $frameParams[
'class'] =
'';
335 $services = MediaWikiServices::getInstance();
336 $config = $services->getMainConfig();
337 $enableLegacyMediaDOM = $config->get( MainConfigNames::ParserEnableLegacyMediaDOM );
341 !isset( $handlerParams[
'width'] ) &&
342 !isset( $frameParams[
'manualthumb'] ) &&
343 !isset( $frameParams[
'framed'] )
345 $classes[] =
'mw-default-size';
348 $prefix = $postfix =
'';
350 if ( $enableLegacyMediaDOM ) {
351 if ( $frameParams[
'align'] ==
'center' ) {
352 $prefix =
'<div class="center">';
354 $frameParams[
'align'] =
'none';
358 if (
$file && !isset( $handlerParams[
'width'] ) ) {
359 if ( isset( $handlerParams[
'height'] ) &&
$file->isVectorized() ) {
362 $svgMaxSize = $config->get( MainConfigNames::SVGMaxSize );
363 $handlerParams[
'width'] = $svgMaxSize;
365 $handlerParams[
'width'] =
$file->getWidth( $page );
368 if ( isset( $frameParams[
'thumbnail'] )
369 || isset( $frameParams[
'manualthumb'] )
370 || isset( $frameParams[
'framed'] )
371 || isset( $frameParams[
'frameless'] )
372 || !$handlerParams[
'width']
374 $thumbLimits = $config->get( MainConfigNames::ThumbLimits );
375 $thumbUpright = $config->get( MainConfigNames::ThumbUpright );
376 if ( $widthOption ===
null || !isset( $thumbLimits[$widthOption] ) ) {
382 if ( isset( $frameParams[
'upright'] ) && $frameParams[
'upright'] == 0 ) {
383 $frameParams[
'upright'] = $thumbUpright;
389 $prefWidth = isset( $frameParams[
'upright'] ) ?
390 round( $thumbLimits[$widthOption] * $frameParams[
'upright'], -1 ) :
391 $thumbLimits[$widthOption];
395 if ( !isset( $handlerParams[
'height'] ) && ( $handlerParams[
'width'] <= 0 ||
396 $prefWidth < $handlerParams[
'width'] ||
$file->isVectorized() ) ) {
397 $handlerParams[
'width'] = $prefWidth;
403 $hasVisibleCaption = isset( $frameParams[
'thumbnail'] ) ||
404 isset( $frameParams[
'manualthumb'] ) ||
405 isset( $frameParams[
'framed'] );
407 if ( $hasVisibleCaption ) {
408 if ( $enableLegacyMediaDOM ) {
413 # Create a thumbnail. Alignment depends on the writing direction of
414 # the page content language (right-aligned for LTR languages,
415 # left-aligned for RTL languages)
416 # If a thumbnail width has not been provided, it is set
417 # to the default user option as specified in Language*.php
418 if ( $frameParams[
'align'] ==
'' ) {
423 $title,
$file, $frameParams, $handlerParams, $time, $query,
428 $rdfaType =
'mw:File';
430 if (
$file && isset( $frameParams[
'frameless'] ) ) {
431 $rdfaType .=
'/Frameless';
432 $srcWidth =
$file->getWidth( $page );
433 # For "frameless" option: do not present an image bigger than the
434 # source (for bitmap-style images). This is the same behavior as the
435 # "thumb" option does it already.
436 if ( $srcWidth && !
$file->mustRender() && $handlerParams[
'width'] > $srcWidth ) {
437 $handlerParams[
'width'] = $srcWidth;
441 if (
$file && isset( $handlerParams[
'width'] ) ) {
442 # Create a resized image, without the additional thumbnail features
443 $thumb =
$file->transform( $handlerParams );
449 $rdfaType =
'mw:Error ' . $rdfaType;
451 if ( $enableLegacyMediaDOM ) {
454 $label = $frameParams[
'title'];
457 $title, $label,
'',
'',
'', (
bool)$time, $handlerParams
462 'alt' => $frameParams[
'alt'],
463 'title' => $frameParams[
'title'],
465 if ( $enableLegacyMediaDOM ) {
467 'valign' => $frameParams[
'valign'] ??
false,
468 'img-class' => $frameParams[
'class'],
470 if ( isset( $frameParams[
'border'] ) ) {
471 $params[
'img-class'] .= ( $params[
'img-class'] !==
'' ?
' ' :
'' ) .
'thumbborder';
475 $s = $thumb->toHtml( $params );
478 if ( $enableLegacyMediaDOM ) {
479 if ( $frameParams[
'align'] !=
'' ) {
482 [
'class' =>
'float' . $frameParams[
'align'] ],
486 return str_replace(
"\n",
' ', $prefix .
$s . $postfix );
492 if ( $frameParams[
'align'] !=
'' ) {
495 $classes[] =
"mw-halign-{$frameParams['align']}";
497 'figcaption', [], $frameParams[
'caption'] ??
''
499 } elseif ( isset( $frameParams[
'valign'] ) ) {
503 $classes[] =
"mw-valign-{$frameParams['valign']}";
506 if ( isset( $frameParams[
'border'] ) ) {
507 $classes[] =
'mw-image-border';
510 if ( isset( $frameParams[
'class'] ) ) {
511 $classes[] = $frameParams[
'class'];
516 'typeof' => $rdfaType,
521 return str_replace(
"\n",
' ',
$s );
534 if ( isset( $frameParams[
'link-url'] ) && $frameParams[
'link-url'] !==
'' ) {
535 $mtoParams[
'custom-url-link'] = $frameParams[
'link-url'];
536 if ( isset( $frameParams[
'link-target'] ) ) {
537 $mtoParams[
'custom-target-link'] = $frameParams[
'link-target'];
540 $extLinkAttrs = $parser->getExternalLinkAttribs( $frameParams[
'link-url'] );
541 foreach ( $extLinkAttrs as $name => $val ) {
543 $mtoParams[
'parser-extlink-' . $name] = $val;
546 } elseif ( isset( $frameParams[
'link-title'] ) && $frameParams[
'link-title'] !==
'' ) {
547 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
549 $linkRenderer->normalizeTarget( $frameParams[
'link-title'] )
551 if ( isset( $frameParams[
'link-title-query'] ) ) {
552 $mtoParams[
'custom-title-link-query'] = $frameParams[
'link-title-query'];
554 } elseif ( !empty( $frameParams[
'no-link'] ) ) {
557 $mtoParams[
'desc-link'] =
true;
558 $mtoParams[
'desc-query'] = $query;
577 $params = [], $framed =
false, $manualthumb =
""
585 if ( $manualthumb ) {
586 $frameParams[
'manualthumb'] = $manualthumb;
587 } elseif ( $framed ) {
588 $frameParams[
'framed'] =
true;
589 } elseif ( !isset( $params[
'width'] ) ) {
590 $classes[] =
'mw-default-size';
593 $title,
$file, $frameParams, $params,
false,
'', $classes
610 $time =
false, $query =
"", array $classes = [], ?
Parser $parser =
null
614 $services = MediaWikiServices::getInstance();
615 $enableLegacyMediaDOM = $services->getMainConfig()->get( MainConfigNames::ParserEnableLegacyMediaDOM );
617 $page = $handlerParams[
'page'] ??
false;
618 if ( !isset( $frameParams[
'align'] ) ) {
619 $frameParams[
'align'] =
'';
620 if ( $enableLegacyMediaDOM ) {
621 $frameParams[
'align'] =
'right';
624 if ( !isset( $frameParams[
'alt'] ) ) {
625 $frameParams[
'alt'] =
'';
627 if ( !isset( $frameParams[
'caption'] ) ) {
628 $frameParams[
'caption'] =
'';
631 if ( empty( $handlerParams[
'width'] ) ) {
633 $handlerParams[
'width'] = isset( $frameParams[
'upright'] ) ? 130 : 180;
638 $manualthumb =
false;
639 $rdfaType =
'mw:File/Thumb';
642 $outerWidth = $handlerParams[
'width'] + 2;
644 if ( isset( $frameParams[
'manualthumb'] ) ) {
645 # Use manually specified thumbnail
647 if ( $manual_title ) {
648 $manual_img = $services->getRepoGroup()
649 ->findFile( $manual_title );
651 $thumb = $manual_img->getUnscaledThumb( $handlerParams );
657 } elseif ( isset( $frameParams[
'framed'] ) ) {
659 $thumb =
$file->getUnscaledThumb( $handlerParams );
661 $rdfaType =
'mw:File/Frame';
663 # Do not present an image bigger than the source, for bitmap-style images
664 # This is a hack to maintain compatibility with arbitrary pre-1.10 behavior
665 $srcWidth =
$file->getWidth( $page );
666 if ( $srcWidth && !
$file->mustRender() && $handlerParams[
'width'] > $srcWidth ) {
667 $handlerParams[
'width'] = $srcWidth;
669 $thumb =
$file->transform( $handlerParams );
673 $outerWidth = $thumb->getWidth() + 2;
675 $outerWidth = $handlerParams[
'width'] + 2;
680 $linkTitleQuery = [];
683 $linkTitleQuery[
'page'] = $page;
684 # ThumbnailImage::toHtml() already adds page= onto the end of DjVu URLs
685 # So we don't need to pass it here in $query. However, the URL for the
686 # zoom icon still needs it, so we make a unique query for it. See T16771
687 # FIXME: What about "lang" and other querystring parameters
692 && !isset( $frameParams[
'link-title'] )
693 && !isset( $frameParams[
'link-url'] )
694 && !isset( $frameParams[
'no-link'] ) ) {
695 $frameParams[
'link-title'] =
$title;
696 $frameParams[
'link-title-query'] = $linkTitleQuery;
699 if ( $frameParams[
'align'] !=
'' ) {
701 $classes[] =
"mw-halign-{$frameParams['align']}";
704 if ( isset( $frameParams[
'class'] ) ) {
705 $classes[] = $frameParams[
'class'];
710 if ( $enableLegacyMediaDOM ) {
711 $s .=
"<div class=\"thumb t{$frameParams['align']}\">"
712 .
"<div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">";
718 $title, $label,
'',
'',
'', (
bool)$time, $handlerParams
721 } elseif ( !$thumb ) {
722 if ( $enableLegacyMediaDOM ) {
723 $s .=
wfMessage(
'thumbnail_error',
'' )->escaped();
726 $title,
'',
'',
'',
'', (
bool)$time, $handlerParams
731 if ( !$noscale && !$manualthumb ) {
735 'alt' => $frameParams[
'alt'],
737 if ( $enableLegacyMediaDOM ) {
739 'img-class' => ( isset( $frameParams[
'class'] ) && $frameParams[
'class'] !==
''
740 ? $frameParams[
'class'] .
' '
741 :
'' ) .
'thumbimage'
745 $s .= $thumb->toHtml( $params );
746 if ( isset( $frameParams[
'framed'] ) ) {
752 'class' =>
'internal',
753 'title' =>
wfMessage(
'thumbnail-more' )->text() ],
758 if ( $enableLegacyMediaDOM ) {
759 $s .=
' <div class="thumbcaption">' . $zoomIcon . $frameParams[
'caption'] .
"</div></div></div>";
760 return str_replace(
"\n",
' ',
$s );
764 'figcaption', [], $frameParams[
'caption'] ??
''
767 if ( !$exists || !$thumb ) {
768 $rdfaType =
'mw:Error ' . $rdfaType;
773 'typeof' => $rdfaType,
778 return str_replace(
"\n",
' ',
$s );
790 $responsiveImages = MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::ResponsiveImages );
791 if ( $responsiveImages && $thumb && !$thumb->isError() ) {
793 $hp15[
'width'] = round( $hp[
'width'] * 1.5 );
795 $hp20[
'width'] = $hp[
'width'] * 2;
796 if ( isset( $hp[
'height'] ) ) {
797 $hp15[
'height'] = round( $hp[
'height'] * 1.5 );
798 $hp20[
'height'] = $hp[
'height'] * 2;
801 $thumb15 =
$file->transform( $hp15 );
802 $thumb20 =
$file->transform( $hp20 );
803 if ( $thumb15 && !$thumb15->isError() && $thumb15->getUrl() !== $thumb->getUrl() ) {
804 $thumb->responsiveUrls[
'1.5'] = $thumb15->getUrl();
806 if ( $thumb20 && !$thumb20->isError() && $thumb20->getUrl() !== $thumb->getUrl() ) {
807 $thumb->responsiveUrls[
'2'] = $thumb20->getUrl();
826 $title, $label =
'', $query =
'', $unused1 =
'', $unused2 =
'',
827 $time =
false, array $handlerParams = []
830 wfWarn( __METHOD__ .
': Requires $title to be a LinkTarget object.' );
831 return "<!-- ERROR -->" . htmlspecialchars( $label );
835 $services = MediaWikiServices::getInstance();
836 $mainConfig = $services->getMainConfig();
837 $enableUploads = $mainConfig->get( MainConfigNames::EnableUploads );
838 $uploadMissingFileUrl = $mainConfig->get( MainConfigNames::UploadMissingFileUrl );
839 $uploadNavigationUrl = $mainConfig->get( MainConfigNames::UploadNavigationUrl );
840 if ( $label ==
'' ) {
841 $label =
$title->getPrefixedText();
845 'class' =>
'mw-broken-media',
847 'data-width' => $handlerParams[
'width'] ??
null,
848 'data-height' => $handlerParams[
'height'] ??
null,
851 if ( $mainConfig->get( MainConfigNames::ParserEnableLegacyMediaDOM ) ) {
852 $html = htmlspecialchars( $label, ENT_COMPAT );
855 $repoGroup = $services->getRepoGroup();
856 $currentExists = $time
857 && $repoGroup->findFile(
$title ) !==
false;
859 if ( ( $uploadMissingFileUrl || $uploadNavigationUrl || $enableUploads )
864 $repoGroup->getLocalRepo()->checkRedirect(
$title )
870 [
'class' =>
'mw-redirect' ],
872 [
'known',
'noclasses' ]
876 'href' => self::getUploadUrl(
$title, $query ),
878 'title' =>
$title->getPrefixedText()
886 [
'known',
'noclasses' ]
899 $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
900 $uploadMissingFileUrl = $mainConfig->get( MainConfigNames::UploadMissingFileUrl );
901 $uploadNavigationUrl = $mainConfig->get( MainConfigNames::UploadNavigationUrl );
903 if ( $query !=
'' ) {
907 if ( $uploadMissingFileUrl ) {
911 if ( $uploadNavigationUrl ) {
917 return $upload->getLocalURL( $q );
930 $img = MediaWikiServices::getInstance()->getRepoGroup()->findFile(
931 $title, [
'time' => $time ]
950 $url =
$file->getUrl();
972 wfDebug(
"Hook LinkerMakeMediaLinkFile changed the output of link "
973 .
"with url {$url} and text {$html} to {$ret}" );
992 $key = strtolower( $name );
1017 $linktype =
'', $attribs = [],
$title =
null
1020 $class =
"external";
1022 $class .=
" $linktype";
1024 if ( isset( $attribs[
'class'] ) && $attribs[
'class'] ) {
1025 $class .=
" {$attribs['class']}";
1027 $attribs[
'class'] = $class;
1030 $text = htmlspecialchars( $text, ENT_COMPAT );
1037 if ( !isset( $attribs[
'rel'] ) || $attribs[
'rel'] ===
'' ) {
1038 $attribs[
'rel'] = $newRel;
1039 } elseif ( $newRel !==
'' ) {
1041 $newRels = explode(
' ', $newRel );
1042 $oldRels = explode(
' ', $attribs[
'rel'] );
1043 $combined = array_unique( array_merge( $newRels, $oldRels ) );
1044 $attribs[
'rel'] = implode(
' ', $combined );
1048 $url, $text, $link, $attribs, $linktype );
1050 wfDebug(
"Hook LinkerMakeExternalLink changed the output of link "
1051 .
"with url {$url} and text {$text} to {$link}" );
1054 $attribs[
'href'] = $url;
1069 public static function userLink( $userId, $userName, $altUserName =
false ) {
1070 if ( $userName ===
'' || $userName ===
false || $userName ===
null ) {
1071 wfDebug( __METHOD__ .
' received an empty username. Are there database errors ' .
1072 'that need to be fixed?' );
1073 return wfMessage(
'empty-username' )->parse();
1076 $classes =
'mw-userlink';
1078 if ( $userId == 0 ) {
1082 $classes .=
' mw-extuserlink';
1083 } elseif ( $altUserName ===
false ) {
1084 $altUserName = IPUtils::prettifyIP( $userName );
1086 $classes .=
' mw-anonuserlink';
1093 '<bdi>' . htmlspecialchars( $altUserName !==
false ? $altUserName : $userName ) .
'</bdi>';
1096 ?
self::link( $page, $linkText, [
'class' => $classes ] )
1115 $userId, $userText, $redContribsWhenNoEdits =
false, $flags = 0, $edits =
null,
1116 $useParentheses =
true
1118 if ( $userText ===
'' ) {
1119 wfDebug( __METHOD__ .
' received an empty username. Are there database errors ' .
1120 'that need to be fixed?' );
1121 return ' ' .
wfMessage(
'empty-username' )->parse();
1124 $disableAnonTalk = MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::DisableAnonTalk );
1125 $talkable = !( $disableAnonTalk && $userId == 0 );
1127 $addEmailLink = $flags & self::TOOL_LINKS_EMAIL && $userId;
1141 $attribs[
'class'] =
'mw-usertoollinks-contribs';
1142 if ( $redContribsWhenNoEdits ) {
1143 if ( intval( $edits ) === 0 && $edits !== 0 ) {
1145 $edits = $user->getEditCount();
1147 if ( $edits === 0 ) {
1148 $attribs[
'class'] .=
' new';
1156 if ( $blockable && $userCanBlock ) {
1161 if ( $addEmailLink && $user->canSendEmail() ) {
1165 Hooks::runner()->onUserToolLinksEdit( $userId, $userText, $items );
1171 if ( $useParentheses ) {
1172 return wfMessage(
'word-separator' )->escaped()
1173 .
'<span class="mw-usertoollinks">'
1174 .
wfMessage(
'parentheses' )->rawParams(
$wgLang->pipeList( $items ) )->escaped()
1179 foreach ( $items as $tool ) {
1182 return ' <span class="mw-usertoollinks mw-changeslist-links">' .
1183 implode(
' ', $tools ) .
'</span>';
1196 $userId, $userText, $edits =
null, $useParentheses =
true
1208 if ( $userText ===
'' ) {
1209 wfDebug( __METHOD__ .
' received an empty username. Are there database errors ' .
1210 'that need to be fixed?' );
1211 return wfMessage(
'empty-username' )->parse();
1215 $moreLinkAttribs = [
'class' =>
'mw-usertoollinks-talk' ];
1216 $linkText =
wfMessage(
'talkpagelinktext' )->escaped();
1218 return $userTalkPage
1219 ?
self::link( $userTalkPage, $linkText, $moreLinkAttribs )
1230 if ( $userText ===
'' ) {
1231 wfDebug( __METHOD__ .
' received an empty username. Are there database errors ' .
1232 'that need to be fixed?' );
1233 return wfMessage(
'empty-username' )->parse();
1237 $moreLinkAttribs = [
'class' =>
'mw-usertoollinks-block' ];
1251 if ( $userText ===
'' ) {
1252 wfLogWarning( __METHOD__ .
' received an empty username. Are there database errors ' .
1253 'that need to be fixed?' );
1254 return wfMessage(
'empty-username' )->parse();
1258 $moreLinkAttribs = [
'class' =>
'mw-usertoollinks-mail' ];
1280 if ( $revRecord->
isDeleted( RevisionRecord::DELETED_USER ) && $isPublic ) {
1281 $link =
wfMessage(
'rev-deleted-user' )->escaped();
1282 } elseif ( $revRecord->
userCan( RevisionRecord::DELETED_USER, $authority ) ) {
1283 $revUser = $revRecord->
getUser( RevisionRecord::FOR_THIS_USER, $authority );
1285 $revUser ? $revUser->getId() : 0,
1286 $revUser ? $revUser->getName() :
''
1289 $link =
wfMessage(
'rev-deleted-user' )->escaped();
1291 if ( $revRecord->
isDeleted( RevisionRecord::DELETED_USER ) ) {
1293 return '<span class="' . $class .
'">' . $link .
'</span>';
1305 $class =
'history-deleted';
1306 if ( $revisionRecord->
isDeleted( RevisionRecord::DELETED_RESTRICTED ) ) {
1307 $class .=
' mw-history-suppressed';
1327 $useParentheses =
true
1332 if ( $revRecord->
userCan( RevisionRecord::DELETED_USER, $authority ) &&
1333 ( !$revRecord->
isDeleted( RevisionRecord::DELETED_USER ) || !$isPublic )
1335 $revUser = $revRecord->
getUser( RevisionRecord::FOR_THIS_USER, $authority );
1336 $userId = $revUser ? $revUser->getId() : 0;
1337 $userText = $revUser ? $revUser->getName() :
'';
1339 if ( $userId || $userText !==
'' ) {
1340 $link = self::userLink( $userId, $userText )
1341 . self::userToolLinks( $userId, $userText,
false, 0,
null,
1346 if ( !isset( $link ) ) {
1347 $link =
wfMessage(
'rev-deleted-user' )->escaped();
1350 if ( $revRecord->
isDeleted( RevisionRecord::DELETED_USER ) ) {
1351 $class = self::getRevisionDeletedClass( $revRecord );
1352 return ' <span class="' . $class .
' mw-userlink">' . $link .
'</span>';
1368 $formatter =
new HtmlFormatter( $html );
1369 $doc = $formatter->getDoc();
1370 $xpath =
new DOMXPath( $doc );
1371 $nodes = $xpath->query(
'//a[@href]' );
1373 foreach ( $nodes as $node ) {
1374 $node->setAttribute(
1379 return $formatter->getText(
'html' );
1403 $comment,
$title =
null, $local =
false, $wikiId =
null
1405 $formatter = MediaWikiServices::getInstance()->getCommentFormatter();
1406 return $formatter->format( $comment,
$title, $local, $wikiId );
1429 $comment,
$title =
null, $local =
false, $wikiId =
null
1431 $formatter = MediaWikiServices::getInstance()->getCommentFormatter();
1432 return $formatter->formatLinksUnsafe( $comment,
$title, $local, $wikiId );
1444 # :Foobar -- override special treatment of prefix (images, language links)
1445 # /Foobar -- convert to CurrentPage/Foobar
1446 # /Foobar/ -- convert to CurrentPage/Foobar, strip the initial and final / from text
1447 # ../ -- convert to CurrentPage, from CurrentPage/CurrentSubPage
1448 # ../Foobar -- convert to CurrentPage/Foobar,
1449 # (from CurrentPage/CurrentSubPage)
1450 # ../Foobar/ -- convert to CurrentPage/Foobar, use 'Foobar' as text
1451 # (from CurrentPage/CurrentSubPage)
1453 $ret = $target; #
default return value is no change
1455 # Some namespaces don't allow subpages,
1456 # so only perform processing if subpages are allowed
1458 $contextTitle && MediaWikiServices::getInstance()->getNamespaceInfo()->
1459 hasSubpages( $contextTitle->getNamespace() )
1461 $hash = strpos( $target,
'#' );
1462 if ( $hash !==
false ) {
1463 $suffix = substr( $target, $hash );
1464 $target = substr( $target, 0, $hash );
1469 $target = trim( $target );
1470 $contextPrefixedText = MediaWikiServices::getInstance()->getTitleFormatter()->
1471 getPrefixedText( $contextTitle );
1472 # Look at the first character
1473 if ( $target !=
'' && $target[0] ===
'/' ) {
1474 # / at end means we don't want the slash to be shown
1476 $trailingSlashes = preg_match_all(
'%(/+)$%', $target, $m );
1477 if ( $trailingSlashes ) {
1478 $noslash = $target = substr( $target, 1, -strlen( $m[0][0] ) );
1480 $noslash = substr( $target, 1 );
1483 $ret = $contextPrefixedText .
'/' . trim( $noslash ) . $suffix;
1484 if ( $text ===
'' ) {
1485 $text = $target . $suffix;
1486 } #
this might be changed
for ugliness reasons
1488 # check for .. subpage backlinks
1490 $nodotdot = $target;
1491 while ( str_starts_with( $nodotdot,
"../" ) ) {
1493 $nodotdot = substr( $nodotdot, 3 );
1495 if ( $dotdotcount > 0 ) {
1496 $exploded = explode(
'/', $contextPrefixedText );
1497 if ( count( $exploded ) > $dotdotcount ) { # not allowed to go below top level page
1498 $ret = implode(
'/', array_slice( $exploded, 0, -$dotdotcount ) );
1499 # / at the end means don't show full path
1500 if ( substr( $nodotdot, -1, 1 ) ===
'/' ) {
1501 $nodotdot = rtrim( $nodotdot,
'/' );
1502 if ( $text ===
'' ) {
1503 $text = $nodotdot . $suffix;
1506 $nodotdot = trim( $nodotdot );
1507 if ( $nodotdot !=
'' ) {
1508 $ret .=
'/' . $nodotdot;
1539 $comment,
$title =
null, $local =
false, $wikiId =
null, $useParentheses =
true
1541 return MediaWikiServices::getInstance()->getCommentFormatter()
1542 ->formatBlock( $comment,
$title, $local, $wikiId, $useParentheses );
1564 $useParentheses =
true
1567 $formatter = MediaWikiServices::getInstance()->getCommentFormatter();
1568 return $formatter->formatRevision( $revRecord, $authority, $local, $isPublic, $useParentheses );
1578 $stxt =
wfMessage(
'historyempty' )->escaped();
1580 $stxt =
wfMessage(
'nbytes' )->numParams( $size )->escaped();
1582 return "<span class=\"history-size mw-diff-bytes\" data-mw-bytes=\"$size\">$stxt</span>";
1603 return "</li>\n" . str_repeat(
"</ul>\n</li>\n", $level > 0 ? $level : 0 );
1617 public static function tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex =
false ) {
1618 $classes =
"toclevel-$level";
1619 if ( $sectionIndex !==
false ) {
1620 $classes .=
" tocsection-$sectionIndex";
1627 [
'href' =>
"#$anchor" ],
1628 Html::element(
'span', [
'class' =>
'tocnumber' ], $tocnumber )
1658 return '<div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading">'
1660 'type' =>
'checkbox',
1662 'id' =>
'toctogglecheckbox',
1663 'class' =>
'toctogglecheckbox',
1664 'style' =>
'display:none',
1667 'class' =>
'toctitle',
1668 'lang' =>
$lang->getHtmlCode(),
1669 'dir' =>
$lang->getDir(),
1671 .
'<h2 id="mw-toc-heading">' .
$title .
'</h2>'
1672 .
'<span class="toctogglespan">'
1674 'class' =>
'toctogglelabel',
1679 .
"</ul>\n</div>\n";
1693 foreach ( $tree as $section ) {
1694 if ( $section[
'toclevel'] > $lastLevel ) {
1695 $toc .= self::tocIndent();
1696 } elseif ( $section[
'toclevel'] < $lastLevel ) {
1697 $toc .= self::tocUnindent(
1698 $lastLevel - $section[
'toclevel'] );
1700 $toc .= self::tocLineEnd();
1703 $toc .= self::tocLine( $section[
'anchor'],
1704 $section[
'line'], $section[
'number'],
1705 $section[
'toclevel'], $section[
'index'] );
1706 $lastLevel = $section[
'toclevel'];
1708 $toc .= self::tocLineEnd();
1709 return self::tocList( $toc,
$lang );
1729 $link, $fallbackAnchor =
false
1731 $anchorEscaped = htmlspecialchars( $anchor, ENT_COMPAT );
1733 if ( $fallbackAnchor !==
false && $fallbackAnchor !== $anchor ) {
1734 $fallbackAnchor = htmlspecialchars( $fallbackAnchor, ENT_COMPAT );
1735 $fallback =
"<span id=\"$fallbackAnchor\"></span>";
1737 return "<h$level$attribs"
1738 .
"$fallback<span class=\"mw-headline\" id=\"$anchorEscaped\">$html</span>"
1750 $regex = MediaWikiServices::getInstance()->getContentLanguage()->linkTrail();
1752 if ( $trail !==
'' && preg_match( $regex, $trail, $m ) ) {
1753 [ , $inside, $trail ] = $m;
1755 return [ $inside, $trail ];
1790 $options = [
'verify' ]
1792 if ( $context ===
null ) {
1797 if ( in_array(
'verify', $options,
true ) ) {
1798 $editCount = self::getRollbackEditCount( $revRecord,
true );
1799 if ( $editCount ===
false ) {
1804 $inner = self::buildRollbackLink( $revRecord, $context, $editCount );
1809 $revRecord, $context, $options, $inner ) ) {
1813 if ( !in_array(
'noBrackets', $options,
true ) ) {
1814 $inner = $context->msg(
'brackets' )->rawParams( $inner )->escaped();
1817 if ( MediaWikiServices::getInstance()->getUserOptionsLookup()
1818 ->getBoolOption( $context->getUser(),
'showrollbackconfirmation' )
1820 $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
1821 $stats->increment(
'rollbackconfirmation.event.load' );
1822 $context->getOutput()->addModules(
'mediawiki.misc-authed-curate' );
1825 return '<span class="mw-rollback-link">' . $inner .
'</span>';
1847 $showRollbackEditCount = MediaWikiServices::getInstance()->getMainConfig()
1848 ->get( MainConfigNames::ShowRollbackEditCount );
1850 if ( !is_int( $showRollbackEditCount ) || !$showRollbackEditCount > 0 ) {
1858 $revQuery = MediaWikiServices::getInstance()->getRevisionStore()->getQueryInfo();
1860 $revIndex =
$dbr->indexExists(
'revision',
'page_timestamp', __METHOD__ )
1862 :
'rev_page_timestamp';
1865 [
'rev_user_text' =>
$revQuery[
'fields'][
'rev_user_text'],
'rev_deleted' ],
1866 [
'rev_page' => $revRecord->
getPageId() ],
1869 'USE INDEX' => [
'revision' => $revIndex ],
1870 'ORDER BY' => [
'rev_timestamp DESC',
'rev_id DESC' ],
1871 'LIMIT' => $showRollbackEditCount + 1
1876 $revUser = $revRecord->
getUser( RevisionRecord::RAW );
1877 $revUserText = $revUser ? $revUser->getName() :
'';
1881 foreach (
$res as $row ) {
1882 if ( $row->rev_user_text != $revUserText ) {
1884 ( $row->rev_deleted & RevisionRecord::DELETED_TEXT
1885 || $row->rev_deleted & RevisionRecord::DELETED_USER
1898 if ( $verify && $editCount <= $showRollbackEditCount && !$moreRevs ) {
1926 $config = MediaWikiServices::getInstance()->getMainConfig();
1927 $showRollbackEditCount = $config->get( MainConfigNames::ShowRollbackEditCount );
1928 $miserMode = $config->get( MainConfigNames::MiserMode );
1930 $disableRollbackEditCountSpecialPage = [
'Recentchanges',
'Watchlist' ];
1932 if ( $context ===
null ) {
1937 $revUser = $revRecord->
getUser();
1938 $revUserText = $revUser ? $revUser->getName() :
'';
1941 'action' =>
'rollback',
1942 'from' => $revUserText,
1943 'token' => $context->getUser()->getEditToken(
'rollback' ),
1947 'data-mw' =>
'interface',
1948 'title' => $context->msg(
'tooltip-rollback' )->text()
1951 $options = [
'known',
'noclasses' ];
1953 if ( $context->getRequest()->getBool(
'bot' ) ) {
1955 $query[
'hidediff'] =
'1';
1956 $query[
'bot'] =
'1';
1960 foreach ( $disableRollbackEditCountSpecialPage as $specialPage ) {
1961 if ( $context->getTitle()->isSpecial( $specialPage ) ) {
1962 $showRollbackEditCount =
false;
1969 $msg = [
'rollbacklink' ];
1970 if ( is_int( $showRollbackEditCount ) && $showRollbackEditCount > 0 ) {
1971 if ( !is_numeric( $editCount ) ) {
1972 $editCount = self::getRollbackEditCount( $revRecord,
false );
1975 if ( $editCount > $showRollbackEditCount ) {
1976 $msg = [
'rollbacklinkcount-morethan',
Message::numParam( $showRollbackEditCount ) ];
1977 } elseif ( $editCount ) {
1982 $html = $context->msg( ...$msg )->parse();
1983 return self::link(
$title, $html, $attrs, $query, $options );
1996 if ( count( $hiddencats ) > 0 ) {
1997 # Construct the HTML
1998 $outText =
'<div class="mw-hiddenCategoriesExplanation">';
1999 $outText .=
wfMessage(
'hiddencategories' )->numParams( count( $hiddencats ) )->parseAsBlock();
2000 $outText .=
"</div><ul>\n";
2002 foreach ( $hiddencats as $titleObj ) {
2003 # If it's hidden, it must exist - no need to check with a LinkBatch
2005 . self::link( $titleObj,
null, [], [],
'known' )
2008 $outText .=
'</ul>';
2039 public static function titleAttrib( $name, $options =
null, array $msgParams = [], $localizer =
null ) {
2040 if ( !$localizer ) {
2041 $localizer = self::getContextFromMain();
2043 $message = $localizer->msg(
"tooltip-$name", $msgParams );
2044 if ( $message->isDisabled() ) {
2047 $tooltip = $message->text();
2048 # Compatibility: formerly some tooltips had [alt-.] hardcoded
2049 $tooltip = preg_replace(
"/ ?\[alt-.\]$/",
'', $tooltip );
2052 $options = (array)$options;
2054 if ( in_array(
'nonexisting', $options ) ) {
2055 $tooltip = $localizer->msg(
'red-link-title', $tooltip ?:
'' )->text();
2057 if ( in_array(
'withaccess', $options ) ) {
2058 $accesskey = self::accesskey( $name, $localizer );
2059 if ( $accesskey !==
false ) {
2061 if ( $tooltip ===
false || $tooltip ===
'' ) {
2062 $tooltip = $localizer->msg(
'brackets', $accesskey )->text();
2064 $tooltip .= $localizer->msg(
'word-separator' )->text();
2065 $tooltip .= $localizer->msg(
'brackets', $accesskey )->text();
2087 public static function accesskey( $name, $localizer =
null ) {
2088 if ( !isset( self::$accesskeycache[$name] ) ) {
2089 if ( !$localizer ) {
2090 $localizer = self::getContextFromMain();
2092 $msg = $localizer->msg(
"accesskey-$name" );
2093 self::$accesskeycache[$name] = $msg->isDisabled() ? false : $msg->plain();
2095 return self::$accesskeycache[$name];
2117 $canHide = $performer->
isAllowed(
'deleterevision' );
2118 $canHideHistory = $performer->
isAllowed(
'deletedhistory' );
2119 if ( !$canHide && !( $revRecord->
getVisibility() && $canHideHistory ) ) {
2123 if ( !$revRecord->
userCan( RevisionRecord::DELETED_RESTRICTED, $performer ) ) {
2124 return self::revDeleteLinkDisabled( $canHide );
2126 $prefixedDbKey = MediaWikiServices::getInstance()->getTitleFormatter()->
2127 getPrefixedDBkey(
$title );
2128 if ( $revRecord->
getId() ) {
2132 'type' =>
'revision',
2133 'target' => $prefixedDbKey,
2134 'ids' => $revRecord->
getId()
2140 'type' =>
'archive',
2141 'target' => $prefixedDbKey,
2145 return self::revDeleteLink(
2147 $revRecord->
isDeleted( RevisionRecord::DELETED_RESTRICTED ),
2164 public static function revDeleteLink( $query = [], $restricted =
false, $delete =
true ) {
2166 $msgKey = $delete ?
'rev-delundel' :
'rev-showdeleted';
2167 $html =
wfMessage( $msgKey )->escaped();
2168 $tag = $restricted ?
'strong' :
'span';
2169 $link = self::link( $sp, $html, [], $query, [
'known',
'noclasses' ] );
2172 [
'class' =>
'mw-revdelundel-link' ],
2173 wfMessage(
'parentheses' )->rawParams( $link )->escaped()
2189 $msgKey = $delete ?
'rev-delundel' :
'rev-showdeleted';
2190 $html =
wfMessage( $msgKey )->escaped();
2191 $htmlParentheses =
wfMessage(
'parentheses' )->rawParams( $html )->escaped();
2192 return Xml::tags(
'span', [
'class' =>
'mw-revdelundel-link' ], $htmlParentheses );
2207 string &$tooltip, array &$msgParams, $config, $user, $relevantTitle
2209 if ( !$config || !$user || !$relevantTitle ) {
2210 $mainContext = self::getContextFromMain();
2212 $config = $mainContext->getConfig();
2215 $user = $mainContext->getUser();
2217 if ( !$relevantTitle ) {
2218 $relevantTitle = $mainContext->getSkin()->getRelevantTitle();
2222 $isWatchlistExpiryEnabled = $config->get( MainConfigNames::WatchlistExpiry );
2223 if ( !$isWatchlistExpiryEnabled || !$relevantTitle || !$relevantTitle->canExist() ) {
2227 $watchStore = MediaWikiServices::getInstance()->getWatchedItemStore();
2228 $watchedItem = $watchStore->getWatchedItem( $user, $relevantTitle );
2230 $diffInDays = $watchedItem->getExpiryInDays();
2232 if ( $diffInDays ) {
2233 $msgParams = [ $diffInDays ];
2235 $tooltip =
'ca-unwatch-expiring';
2237 $tooltip =
'ca-unwatch-expiring-hours';
2260 array $msgParams = [],
2265 $relevantTitle =
null
2267 $options = (array)$options;
2268 $options[] =
'withaccess';
2269 $tooltipTitle = $name;
2272 if ( !$localizer ) {
2273 $localizer = self::getContextFromMain();
2277 if ( $name ===
'ca-unwatch' ) {
2278 self::updateWatchstarTooltipMessage( $tooltipTitle, $msgParams, $config, $user, $relevantTitle );
2282 'title' => self::titleAttrib( $tooltipTitle, $options, $msgParams, $localizer ),
2283 'accesskey' => self::accesskey( $name, $localizer )
2285 if ( $attribs[
'title'] ===
false ) {
2286 unset( $attribs[
'title'] );
2288 if ( $attribs[
'accesskey'] ===
false ) {
2289 unset( $attribs[
'accesskey'] );
2301 public static function tooltip( $name, $options =
null ) {
2302 $tooltip = self::titleAttrib( $name, $options );
2303 if ( $tooltip ===
false ) {
UserOptionsLookup $userOptionsLookup
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
wfCgiToArray( $query)
This is the logical opposite of wfArrayToCgi(): it accepts a query string as its argument and returns...
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) $wgLang
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) $wgTitle
if(!defined('MW_SETUP_CALLBACK'))
The persistent session ID (if any) loaded at startup.
An IContextSource implementation which will inherit context from another source but allow individual ...
static getUserLinkTitle( $userName)
Get a target Title to link a username.
static isExternal( $username)
Tells whether the username is external or not.
static runner()
Get a HookRunner instance for calling hooks using the new interfaces.
Marks HTML that shouldn't be escaped.
static label( $label, $id, array $attribs=[])
Convenience function for generating a label for inputs.
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Some internal bits split of from Skin.php.
static accesskey( $name, $localizer=null)
Given the id of an interface element, constructs the appropriate accesskey attribute from the system ...
static makeMediaLinkFile(LinkTarget $title, $file, $html='')
Create a direct link to a given uploaded file.
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
static fnamePart( $url)
Returns the filename part of an url.
static tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex=false)
parameter level defines if we are on an indentation level
static getContextFromMain()
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
static expandLocalLinks(string $html)
Helper function to expand local links.
static getRevisionDeletedClass(RevisionRecord $revisionRecord)
Returns css class of a deleted revision.
static specialLink( $name, $key='')
Make a link to a special page given its name and, optionally, a message key from the link text.
static getRollbackEditCount(RevisionRecord $revRecord, $verify)
This function will return the number of revisions which a rollback would revert and,...
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
static makeExternalImage( $url, $alt='')
Return the code for images which were added via external links, via Parser::maybeMakeExternalImage().
static revComment(RevisionRecord $revRecord, $local=false, $isPublic=false, $useParentheses=true)
Wrap and format the given revision's comment block, if the current user is allowed to view it.
static revUserLink(RevisionRecord $revRecord, $isPublic=false)
Generate a user link if the current user is allowed to view it.
static processResponsiveImages( $file, $thumb, $hp)
Process responsive images: add 1.5x and 2x subimages to the thumbnail, where applicable.
static blockLink( $userId, $userText)
static revDeleteLinkDisabled( $delete=true)
Creates a dead (show/hide) link for deleting revisions/log entries.
static normalizeSubpageLink( $contextTitle, $target, &$text)
const TOOL_LINKS_NOBLOCK
Flags for userToolLinks()
static makeBrokenImageLinkObj( $title, $label='', $query='', $unused1='', $unused2='', $time=false, array $handlerParams=[])
Make a "broken" link to an image.
static getRevDeleteLink(Authority $performer, RevisionRecord $revRecord, LinkTarget $title)
Get a revision-deletion link, or disabled link, or nothing, depending on user permissions & the setti...
static makeSelfLinkObj( $nt, $html='', $query='', $trail='', $prefix='')
Make appropriate markup for a link to the current article.
static getUploadUrl( $destFile, $query='')
Get the URL to upload a certain file.
static tocIndent()
Add another level to the Table of Contents.
static makeImageLink(Parser $parser, LinkTarget $title, $file, $frameParams=[], $handlerParams=[], $time=false, $query="", $widthOption=null)
Given parameters derived from [[Image:Foo|options...]], generate the HTML that that syntax inserts in...
static updateWatchstarTooltipMessage(string &$tooltip, array &$msgParams, $config, $user, $relevantTitle)
Updates the tooltip message and its parameters if watchlist expiry is enabled.
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
static emailLink( $userId, $userText)
static generateRollback(RevisionRecord $revRecord, IContextSource $context=null, $options=[ 'verify'])
Generate a rollback link for a given revision.
static formatHiddenCategories( $hiddencats)
Returns HTML for the "hidden categories on this page" list.
static splitTrail( $trail)
Split a link trail, return the "inside" portion and the remainder of the trail as a two-element array...
static generateTOC( $tree, Language $lang=null)
Generate a table of contents from a section tree.
static titleAttrib( $name, $options=null, array $msgParams=[], $localizer=null)
Given the id of an interface element, constructs the appropriate title attribute from the system mess...
static makeThumbLinkObj(LinkTarget $title, $file, $label='', $alt='', $align=null, $params=[], $framed=false, $manualthumb="")
Make HTML for a thumbnail including image, border and caption.
static formatRevisionSize( $size)
static commentBlock( $comment, $title=null, $local=false, $wikiId=null, $useParentheses=true)
Wrap a comment in standard punctuation and formatting if it's non-empty, otherwise return empty strin...
static tooltip( $name, $options=null)
Returns raw bits of HTML, use titleAttrib()
static userTalkLink( $userId, $userText)
static makeThumbLink2(LinkTarget $title, $file, $frameParams=[], $handlerParams=[], $time=false, $query="", array $classes=[], ?Parser $parser=null)
static buildRollbackLink(RevisionRecord $revRecord, IContextSource $context=null, $editCount=false)
Build a raw rollback link, useful for collections of "tool" links.
static revUserTools(RevisionRecord $revRecord, $isPublic=false, $useParentheses=true)
Generate a user tool link cluster if the current user is allowed to view it.
static formatLinksInComment( $comment, $title=null, $local=false, $wikiId=null)
Formats wiki links and media links in text; all other wiki formatting is ignored.
static makeMediaLinkObj( $title, $html='', $time=false)
Create a direct link to a given uploaded file.
static makeExternalLink( $url, $text, $escape=true, $linktype='', $attribs=[], $title=null)
Make an external link.
static userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null, $useParentheses=true)
Generate standard user tool links (talk, contributions, block link, etc.)
static normaliseSpecialPage(LinkTarget $target)
static makeHeadline( $level, $attribs, $anchor, $html, $link, $fallbackAnchor=false)
Create a headline for content.
static tocUnindent( $level)
Finish one or more sublevels on the Table of Contents.
static tocList( $toc, Language $lang=null)
Wraps the TOC in a div with ARIA navigation role and provides the hide/collapse JavaScript.
static getImageLinkMTOParams( $frameParams, $query='', $parser=null)
Get the link parameters for MediaTransformOutput::toHtml() from given frame parameters supplied by th...
static revDeleteLink( $query=[], $restricted=false, $delete=true)
Creates a (show/hide) link for deleting revisions/log entries.
static tooltipAndAccesskeyAttribs( $name, array $msgParams=[], $options=null, $localizer=null, $user=null, $config=null, $relevantTitle=null)
Returns the attributes for the tooltip and access key.
static tocLineEnd()
End a Table Of Contents line.
static formatComment( $comment, $title=null, $local=false, $wikiId=null)
This function is called by all recent changes variants, by the page history, and by the user contribu...
static userToolLinksRedContribs( $userId, $userText, $edits=null, $useParentheses=true)
Alias for userToolLinks( $userId, $userText, true );.
A class containing constants representing the names of configuration variables.
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
getTargetLanguage()
Get the target language for the content being parsed.
static getExternalLinkRel( $url=false, LinkTarget $title=null)
Get the rel attribute for a particular external link.
static getMain()
Get the RequestContext object associated with the main request.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
static tryNew( $namespace, $title, $fragment='', $interwiki='')
Constructs a TitleValue, or returns null if the parameters are not valid.
static newFromLinkTarget(LinkTarget $linkTarget, $forceClone='')
Returns a Title given a LinkTarget.
static castFromLinkTarget( $linkTarget)
Same as newFromLinkTarget, but if passed null, returns null.
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
static newFromId( $id)
Static factory method for creation from a given user ID.
Representation of a pair of user and title for watchlist entries.
getExpiry(?int $style=TS_MW)
When the watched item will expire.
static expandAttributes( $attribs)
Given an array of ('attributename' => 'value'), it generates the code to set the XML attributes : att...
static tags( $element, $attribs, $contents)
Same as Xml::element(), but does not escape contents.
Interface for objects which can provide a MediaWiki context on request.
msg( $key,... $params)
This is the method for getting translated interface messages.
foreach( $mmfl['setupFiles'] as $fileName) if( $queue) if(empty( $mmfl['quiet'])) $s
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
if(!isset( $args[0])) $lang