23use HtmlFormatter\HtmlFormatter;
88 public static function link(
89 $target, $html =
null, $customAttribs = [], $query = [], $options = []
92 wfWarn( __METHOD__ .
': Requires $target to be a LinkTarget object.', 2 );
93 return "<!-- ERROR -->$html";
96 $services = MediaWikiServices::getInstance();
97 $options = (array)$options;
100 $linkRenderer = $services->getLinkRendererFactory()
101 ->createFromLegacyOptions( $options );
103 $linkRenderer = $services->getLinkRenderer();
106 if ( $html !==
null ) {
112 if ( in_array(
'known', $options,
true ) ) {
113 return $linkRenderer->makeKnownLink( $target, $text, $customAttribs, $query );
116 if ( in_array(
'broken', $options,
true ) ) {
117 return $linkRenderer->makeBrokenLink( $target, $text, $customAttribs, $query );
120 if ( in_array(
'noclasses', $options,
true ) ) {
121 return $linkRenderer->makePreloadedLink( $target, $text,
'', $customAttribs, $query );
124 return $linkRenderer->makeLink( $target, $text, $customAttribs, $query );
141 $target, $html =
null, $customAttribs = [],
142 $query = [], $options = [
'known' ]
144 return self::link( $target, $html, $customAttribs, $query, $options );
162 public static function makeSelfLinkObj( $nt, $html =
'', $query =
'', $trail =
'', $prefix =
'' ) {
163 $nt = Title::newFromLinkTarget( $nt );
164 $ret =
"<a class=\"mw-selflink selflink\">{$prefix}{$html}</a>{$trail}";
165 if ( !Hooks::runner()->onSelfLinkBegin( $nt, $html, $trail, $prefix, $ret ) ) {
170 $html = htmlspecialchars( $nt->getPrefixedText() );
173 return "<a class=\"mw-selflink selflink\">{$prefix}{$html}{$inside}</a>{$trail}";
188 if ( MediaWikiServices::getInstance()->getNamespaceInfo()->exists( $namespace ) ) {
190 $name = $context->
msg(
'blanknamespace' )->text();
192 $name = MediaWikiServices::getInstance()->getContentLanguage()->
193 getFormattedNsText( $namespace );
195 return $context->
msg(
'invalidtitle-knownnamespace', $namespace, $name,
$title )->text();
198 return $context->
msg(
'invalidtitle-unknownnamespace', $namespace,
$title )->text();
209 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
210 return $linkRenderer->normalizeTarget( $target );
222 $basename = strrchr( $url,
'/' );
223 if ( $basename ===
false ) {
226 $basename = substr( $basename, 1 );
246 $success = Hooks::runner()->onLinkerMakeExternalImage( $url, $alt, $img );
248 wfDebug(
"Hook LinkerMakeExternalImage changed the output of external image "
249 .
"with url {$url} and alt text {$alt} to {$img}" );
252 return Html::element(
'img',
298 $file, $frameParams = [], $handlerParams = [], $time =
false,
299 $query =
"", $widthOption =
null
304 if ( !Hooks::runner()->onImageBeforeProduceHTML( $dummy,
$title,
305 $file, $frameParams, $handlerParams, $time,
$res,
306 $parser, $query, $widthOption )
311 if (
$file && !
$file->allowInlineDisplay() ) {
312 wfDebug( __METHOD__ .
': ' .
$title->getPrefixedDBkey() .
" does not allow inline display" );
317 $page = $handlerParams[
'page'] ??
false;
318 if ( !isset( $frameParams[
'align'] ) ) {
319 $frameParams[
'align'] =
'';
321 if ( !isset( $frameParams[
'alt'] ) ) {
322 $frameParams[
'alt'] =
'';
324 if ( !isset( $frameParams[
'title'] ) ) {
325 $frameParams[
'title'] =
'';
327 if ( !isset( $frameParams[
'class'] ) ) {
328 $frameParams[
'class'] =
'';
331 $services = MediaWikiServices::getInstance();
332 $config = $services->getMainConfig();
333 $enableLegacyMediaDOM = $config->get(
'ParserEnableLegacyMediaDOM' );
336 if ( !isset( $handlerParams[
'width'] ) ) {
337 $classes[] =
'mw-default-size';
340 $prefix = $postfix =
'';
342 if ( $enableLegacyMediaDOM ) {
343 if ( $frameParams[
'align'] ==
'center' ) {
344 $prefix =
'<div class="center">';
346 $frameParams[
'align'] =
'none';
350 if (
$file && !isset( $handlerParams[
'width'] ) ) {
351 if ( isset( $handlerParams[
'height'] ) &&
$file->isVectorized() ) {
354 $svgMaxSize = $config->get(
'SVGMaxSize' );
355 $handlerParams[
'width'] = $svgMaxSize;
357 $handlerParams[
'width'] =
$file->getWidth( $page );
360 if ( isset( $frameParams[
'thumbnail'] )
361 || isset( $frameParams[
'manualthumb'] )
362 || isset( $frameParams[
'framed'] )
363 || isset( $frameParams[
'frameless'] )
364 || !$handlerParams[
'width']
366 $thumbLimits = $config->get(
'ThumbLimits' );
367 $thumbUpright = $config->get(
'ThumbUpright' );
368 if ( $widthOption ===
null || !isset( $thumbLimits[$widthOption] ) ) {
374 if ( isset( $frameParams[
'upright'] ) && $frameParams[
'upright'] == 0 ) {
375 $frameParams[
'upright'] = $thumbUpright;
381 $prefWidth = isset( $frameParams[
'upright'] ) ?
382 round( $thumbLimits[$widthOption] * $frameParams[
'upright'], -1 ) :
383 $thumbLimits[$widthOption];
387 if ( !isset( $handlerParams[
'height'] ) && ( $handlerParams[
'width'] <= 0 ||
388 $prefWidth < $handlerParams[
'width'] ||
$file->isVectorized() ) ) {
389 $handlerParams[
'width'] = $prefWidth;
394 if ( isset( $frameParams[
'thumbnail'] ) || isset( $frameParams[
'manualthumb'] )
395 || isset( $frameParams[
'framed'] )
397 if ( $enableLegacyMediaDOM ) {
402 # Create a thumbnail. Alignment depends on the writing direction of
403 # the page content language (right-aligned for LTR languages,
404 # left-aligned for RTL languages)
405 # If a thumbnail width has not been provided, it is set
406 # to the default user option as specified in Language*.php
407 if ( $frameParams[
'align'] ==
'' ) {
412 $title,
$file, $frameParams, $handlerParams, $time, $query,
417 switch (
$file ?
$file->getMediaType() :
'' ) {
419 $rdfaType =
'mw:Audio';
422 $rdfaType =
'mw:Video';
425 $rdfaType =
'mw:Image';
428 if (
$file && isset( $frameParams[
'frameless'] ) ) {
429 $rdfaType .=
'/Frameless';
430 $srcWidth =
$file->getWidth( $page );
431 # For "frameless" option: do not present an image bigger than the
432 # source (for bitmap-style images). This is the same behavior as the
433 # "thumb" option does it already.
434 if ( $srcWidth && !
$file->mustRender() && $handlerParams[
'width'] > $srcWidth ) {
435 $handlerParams[
'width'] = $srcWidth;
439 if (
$file && isset( $handlerParams[
'width'] ) ) {
440 # Create a resized image, without the additional thumbnail features
441 $thumb =
$file->transform( $handlerParams );
446 $isBadFile =
$file && $thumb &&
449 if ( !$thumb || $isBadFile ) {
450 $rdfaType =
'mw:Error ' . $rdfaType;
452 if ( $enableLegacyMediaDOM ) {
455 $label = $frameParams[
'title'];
458 $title, $label,
'',
'',
'', (
bool)$time, $handlerParams
463 'alt' => $frameParams[
'alt'],
464 'title' => $frameParams[
'title'],
466 if ( $enableLegacyMediaDOM ) {
468 'valign' => $frameParams[
'valign'] ??
false,
469 'img-class' => $frameParams[
'class'],
471 if ( isset( $frameParams[
'border'] ) ) {
472 $params[
'img-class'] .= ( $params[
'img-class'] !==
'' ?
' ' :
'' ) .
'thumbborder';
476 $s = $thumb->toHtml( $params );
479 if ( $enableLegacyMediaDOM ) {
480 if ( $frameParams[
'align'] !=
'' ) {
481 $s = Html::rawElement(
483 [
'class' =>
'float' . $frameParams[
'align'] ],
487 return str_replace(
"\n",
' ', $prefix .
$s . $postfix );
493 if ( $frameParams[
'align'] !=
'' ) {
496 $classes[] =
"mw-halign-{$frameParams['align']}";
497 $caption = Html::rawElement(
498 'figcaption', [], $frameParams[
'caption'] ??
''
500 } elseif ( isset( $frameParams[
'valign'] ) ) {
504 $classes[] =
"mw-valign-{$frameParams['valign']}";
507 if ( isset( $frameParams[
'border'] ) ) {
508 $classes[] =
'mw-image-border';
511 if ( isset( $frameParams[
'class'] ) ) {
512 $classes[] = $frameParams[
'class'];
517 'typeof' => $rdfaType,
520 $s = Html::rawElement( $wrapper, $attribs,
$s . $caption );
522 return str_replace(
"\n",
' ',
$s );
535 if ( isset( $frameParams[
'link-url'] ) && $frameParams[
'link-url'] !==
'' ) {
536 $mtoParams[
'custom-url-link'] = $frameParams[
'link-url'];
537 if ( isset( $frameParams[
'link-target'] ) ) {
538 $mtoParams[
'custom-target-link'] = $frameParams[
'link-target'];
541 $extLinkAttrs = $parser->getExternalLinkAttribs( $frameParams[
'link-url'] );
542 foreach ( $extLinkAttrs as $name => $val ) {
544 $mtoParams[
'parser-extlink-' . $name] = $val;
547 } elseif ( isset( $frameParams[
'link-title'] ) && $frameParams[
'link-title'] !==
'' ) {
548 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
549 $mtoParams[
'custom-title-link'] = Title::newFromLinkTarget(
550 $linkRenderer->normalizeTarget( $frameParams[
'link-title'] )
552 if ( isset( $frameParams[
'link-title-query'] ) ) {
553 $mtoParams[
'custom-title-link-query'] = $frameParams[
'link-title-query'];
555 } elseif ( !empty( $frameParams[
'no-link'] ) ) {
558 $mtoParams[
'desc-link'] =
true;
559 $mtoParams[
'desc-query'] = $query;
578 $params = [], $framed =
false, $manualthumb =
""
586 $frameParams[
'framed'] =
true;
588 if ( $manualthumb ) {
589 $frameParams[
'manualthumb'] = $manualthumb;
591 $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(
'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[
'title'] ) ) {
628 $frameParams[
'title'] =
'';
630 if ( !isset( $frameParams[
'caption'] ) ) {
631 $frameParams[
'caption'] =
'';
634 if ( empty( $handlerParams[
'width'] ) ) {
636 $handlerParams[
'width'] = isset( $frameParams[
'upright'] ) ? 130 : 180;
641 $manualthumb =
false;
645 $outerWidth = $handlerParams[
'width'] + 2;
647 if ( isset( $frameParams[
'manualthumb'] ) ) {
648 # Use manually specified thumbnail
649 $manual_title = Title::makeTitleSafe(
NS_FILE, $frameParams[
'manualthumb'] );
650 if ( $manual_title ) {
651 $manual_img = $services->getRepoGroup()
652 ->findFile( $manual_title );
654 $thumb = $manual_img->getUnscaledThumb( $handlerParams );
660 } elseif ( isset( $frameParams[
'framed'] ) ) {
662 $thumb =
$file->getUnscaledThumb( $handlerParams );
664 $rdfaType =
'/Frame';
666 # Do not present an image bigger than the source, for bitmap-style images
667 # This is a hack to maintain compatibility with arbitrary pre-1.10 behavior
668 $srcWidth =
$file->getWidth( $page );
669 if ( $srcWidth && !
$file->mustRender() && $handlerParams[
'width'] > $srcWidth ) {
670 $handlerParams[
'width'] = $srcWidth;
672 $thumb =
$file->transform( $handlerParams );
676 $outerWidth = $thumb->getWidth() + 2;
678 $outerWidth = $handlerParams[
'width'] + 2;
682 $url = Title::newFromLinkTarget(
$title )->getLocalURL( $query );
683 $linkTitleQuery = [];
686 $linkTitleQuery[
'page'] = $page;
687 # ThumbnailImage::toHtml() already adds page= onto the end of DjVu URLs
688 # So we don't need to pass it here in $query. However, the URL for the
689 # zoom icon still needs it, so we make a unique query for it. See T16771
690 # FIXME: What about "lang" and other querystring parameters
695 && !isset( $frameParams[
'link-title'] )
696 && !isset( $frameParams[
'link-url'] )
697 && !isset( $frameParams[
'no-link'] ) ) {
698 $frameParams[
'link-title'] =
$title;
699 $frameParams[
'link-title-query'] = $linkTitleQuery;
702 if ( $frameParams[
'align'] !=
'' ) {
704 $classes[] =
"mw-halign-{$frameParams['align']}";
707 if ( isset( $frameParams[
'class'] ) ) {
708 $classes[] = $frameParams[
'class'];
713 if ( $enableLegacyMediaDOM ) {
714 $s .=
"<div class=\"thumb t{$frameParams['align']}\">"
715 .
"<div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">";
718 $isBadFile = $exists && $thumb && $parser &&
719 $parser->getBadFileLookup()->isBadFile(
720 $manualthumb ? $manual_title :
$title->getDBkey(),
726 if ( $enableLegacyMediaDOM ) {
729 $label = $frameParams[
'title'];
732 $title, $label,
'',
'',
'', (
bool)$time, $handlerParams
735 } elseif ( !$thumb || $isBadFile ) {
736 if ( $enableLegacyMediaDOM ) {
737 $s .=
wfMessage(
'thumbnail_error',
'' )->escaped();
740 $title,
'',
'',
'',
'', (
bool)$time, $handlerParams
745 if ( !$noscale && !$manualthumb ) {
749 'alt' => $frameParams[
'alt'],
750 'title' => $frameParams[
'title'],
752 if ( $enableLegacyMediaDOM ) {
754 'img-class' => ( isset( $frameParams[
'class'] ) && $frameParams[
'class'] !==
''
755 ? $frameParams[
'class'] .
' '
756 :
'' ) .
'thumbimage'
760 $s .= $thumb->toHtml( $params );
761 if ( isset( $frameParams[
'framed'] ) ) {
764 $zoomIcon = Html::rawElement(
'div', [
'class' =>
'magnify' ],
765 Html::rawElement(
'a', [
767 'class' =>
'internal',
768 'title' =>
wfMessage(
'thumbnail-more' )->text() ],
773 if ( $enableLegacyMediaDOM ) {
774 $s .=
' <div class="thumbcaption">' . $zoomIcon . $frameParams[
'caption'] .
"</div></div></div>";
775 return str_replace(
"\n",
' ',
$s );
778 $s .= Html::rawElement(
779 'figcaption', [], $frameParams[
'caption'] ??
''
782 $rdfaType = $rdfaType ?:
'/Thumb';
784 switch (
$file ?
$file->getMediaType() :
'' ) {
786 $rdfaType =
'mw:Audio' . $rdfaType;
789 $rdfaType =
'mw:Video' . $rdfaType;
792 $rdfaType =
'mw:Image' . $rdfaType;
795 if ( !$exists || !$thumb ) {
796 $rdfaType =
'mw:Error ' . $rdfaType;
801 'typeof' => $rdfaType,
804 $s = Html::rawElement(
'figure', $attribs,
$s );
806 return str_replace(
"\n",
' ',
$s );
818 $responsiveImages = MediaWikiServices::getInstance()->getMainConfig()->get(
'ResponsiveImages' );
819 if ( $responsiveImages && $thumb && !$thumb->isError() ) {
821 $hp15[
'width'] = round( $hp[
'width'] * 1.5 );
823 $hp20[
'width'] = $hp[
'width'] * 2;
824 if ( isset( $hp[
'height'] ) ) {
825 $hp15[
'height'] = round( $hp[
'height'] * 1.5 );
826 $hp20[
'height'] = $hp[
'height'] * 2;
829 $thumb15 =
$file->transform( $hp15 );
830 $thumb20 =
$file->transform( $hp20 );
831 if ( $thumb15 && !$thumb15->isError() && $thumb15->getUrl() !== $thumb->getUrl() ) {
832 $thumb->responsiveUrls[
'1.5'] = $thumb15->getUrl();
834 if ( $thumb20 && !$thumb20->isError() && $thumb20->getUrl() !== $thumb->getUrl() ) {
835 $thumb->responsiveUrls[
'2'] = $thumb20->getUrl();
854 $title, $label =
'', $query =
'', $unused1 =
'', $unused2 =
'',
855 $time =
false, array $handlerParams = []
858 wfWarn( __METHOD__ .
': Requires $title to be a LinkTarget object.' );
859 return "<!-- ERROR -->" . htmlspecialchars( $label );
863 $services = MediaWikiServices::getInstance();
864 $mainConfig = $services->getMainConfig();
865 $enableUploads = $mainConfig->get(
'EnableUploads' );
866 $uploadMissingFileUrl = $mainConfig->get(
'UploadMissingFileUrl' );
867 $uploadNavigationUrl = $mainConfig->get(
'UploadNavigationUrl' );
868 if ( $label ==
'' ) {
869 $label =
$title->getPrefixedText();
872 $html = Html::element(
'span', [
874 'data-width' => $handlerParams[
'width'] ??
null,
875 'data-height' => $handlerParams[
'height'] ??
null,
878 if ( $mainConfig->get(
'ParserEnableLegacyMediaDOM' ) ) {
879 $html = htmlspecialchars( $label, ENT_COMPAT );
882 $repoGroup = $services->getRepoGroup();
883 $currentExists = $time
884 && $repoGroup->findFile(
$title ) !==
false;
886 if ( ( $uploadMissingFileUrl || $uploadNavigationUrl || $enableUploads )
889 if ( $repoGroup->getLocalRepo()->checkRedirect(
$title ) ) {
894 [
'class' =>
'mw-redirect' ],
896 [
'known',
'noclasses' ]
899 return Html::rawElement(
'a', [
900 'href' => self::getUploadUrl(
$title, $query ),
902 'title' =>
$title->getPrefixedText()
910 [
'known',
'noclasses' ]
923 $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
924 $uploadMissingFileUrl = $mainConfig->get(
'UploadMissingFileUrl' );
925 $uploadNavigationUrl = $mainConfig->get(
'UploadNavigationUrl' );
926 $q =
'wpDestFile=' . Title::castFromLinkTarget( $destFile )->getPartialURL();
927 if ( $query !=
'' ) {
931 if ( $uploadMissingFileUrl ) {
935 if ( $uploadNavigationUrl ) {
941 return $upload->getLocalURL( $q );
954 $img = MediaWikiServices::getInstance()->getRepoGroup()->findFile(
955 $title, [
'time' => $time ]
974 $url =
$file->getUrl();
993 if ( !Hooks::runner()->onLinkerMakeMediaLinkFile(
994 Title::castFromLinkTarget(
$title ),
$file, $html, $attribs, $ret )
996 wfDebug(
"Hook LinkerMakeMediaLinkFile changed the output of link "
997 .
"with url {$url} and text {$html} to {$ret}" );
1001 return Html::rawElement(
'a', $attribs, $html );
1016 $key = strtolower( $name );
1041 $linktype =
'', $attribs = [],
$title =
null
1044 $class =
"external";
1046 $class .=
" $linktype";
1048 if ( isset( $attribs[
'class'] ) && $attribs[
'class'] ) {
1049 $class .=
" {$attribs['class']}";
1051 $attribs[
'class'] = $class;
1054 $text = htmlspecialchars( $text, ENT_COMPAT );
1061 if ( !isset( $attribs[
'rel'] ) || $attribs[
'rel'] ===
'' ) {
1062 $attribs[
'rel'] = $newRel;
1063 } elseif ( $newRel !==
null ) {
1065 $newRels = explode(
' ', $newRel );
1066 $oldRels = explode(
' ', $attribs[
'rel'] );
1067 $combined = array_unique( array_merge( $newRels, $oldRels ) );
1068 $attribs[
'rel'] = implode(
' ', $combined );
1071 $success = Hooks::runner()->onLinkerMakeExternalLink(
1072 $url, $text, $link, $attribs, $linktype );
1074 wfDebug(
"Hook LinkerMakeExternalLink changed the output of link "
1075 .
"with url {$url} and text {$text} to {$link}" );
1078 $attribs[
'href'] = $url;
1079 return Html::rawElement(
'a', $attribs, $text );
1093 public static function userLink( $userId, $userName, $altUserName =
false ) {
1094 if ( $userName ===
'' || $userName ===
false || $userName ===
null ) {
1095 wfDebug( __METHOD__ .
' received an empty username. Are there database errors ' .
1096 'that need to be fixed?' );
1097 return wfMessage(
'empty-username' )->parse();
1100 $classes =
'mw-userlink';
1102 if ( $userId == 0 ) {
1103 $page = ExternalUserNames::getUserLinkTitle( $userName );
1105 if ( ExternalUserNames::isExternal( $userName ) ) {
1106 $classes .=
' mw-extuserlink';
1107 } elseif ( $altUserName ===
false ) {
1108 $altUserName = IPUtils::prettifyIP( $userName );
1110 $classes .=
' mw-anonuserlink';
1112 $page = TitleValue::tryNew(
NS_USER, strtr( $userName,
' ',
'_' ) );
1117 '<bdi>' . htmlspecialchars( $altUserName !==
false ? $altUserName : $userName ) .
'</bdi>';
1120 ?
self::link( $page, $linkText, [
'class' => $classes ] )
1121 : Html::rawElement(
'span', [
'class' => $classes ], $linkText );
1139 $userId, $userText, $redContribsWhenNoEdits =
false, $flags = 0, $edits =
null,
1140 $useParentheses =
true
1142 if ( $userText ===
'' ) {
1143 wfDebug( __METHOD__ .
' received an empty username. Are there database errors ' .
1144 'that need to be fixed?' );
1145 return ' ' .
wfMessage(
'empty-username' )->parse();
1148 $disableAnonTalk = MediaWikiServices::getInstance()->getMainConfig()->get(
'DisableAnonTalk' );
1149 $talkable = !( $disableAnonTalk && $userId == 0 );
1151 $addEmailLink = $flags & self::TOOL_LINKS_EMAIL && $userId;
1153 if ( $userId == 0 && ExternalUserNames::isExternal( $userText ) ) {
1165 $attribs[
'class'] =
'mw-usertoollinks-contribs';
1166 if ( $redContribsWhenNoEdits ) {
1167 if ( intval( $edits ) === 0 && $edits !== 0 ) {
1169 $edits = $user->getEditCount();
1171 if ( $edits === 0 ) {
1172 $attribs[
'class'] .=
' new';
1179 $userCanBlock = RequestContext::getMain()->getAuthority()->isAllowed(
'block' );
1180 if ( $blockable && $userCanBlock ) {
1184 $user = RequestContext::getMain()->getUser();
1185 if ( $addEmailLink && $user->canSendEmail() ) {
1189 Hooks::runner()->onUserToolLinksEdit( $userId, $userText, $items );
1195 if ( $useParentheses ) {
1196 return wfMessage(
'word-separator' )->escaped()
1197 .
'<span class="mw-usertoollinks">'
1198 .
wfMessage(
'parentheses' )->rawParams(
$wgLang->pipeList( $items ) )->escaped()
1203 foreach ( $items as $tool ) {
1204 $tools[] = Html::rawElement(
'span', [], $tool );
1206 return ' <span class="mw-usertoollinks mw-changeslist-links">' .
1207 implode(
' ', $tools ) .
'</span>';
1220 $userId, $userText, $edits =
null, $useParentheses =
true
1232 if ( $userText ===
'' ) {
1233 wfDebug( __METHOD__ .
' received an empty username. Are there database errors ' .
1234 'that need to be fixed?' );
1235 return wfMessage(
'empty-username' )->parse();
1238 $userTalkPage = TitleValue::tryNew(
NS_USER_TALK, strtr( $userText,
' ',
'_' ) );
1239 $moreLinkAttribs = [
'class' =>
'mw-usertoollinks-talk' ];
1240 $linkText =
wfMessage(
'talkpagelinktext' )->escaped();
1242 return $userTalkPage
1243 ?
self::link( $userTalkPage, $linkText, $moreLinkAttribs )
1244 : Html::rawElement(
'span', $moreLinkAttribs, $linkText );
1254 if ( $userText ===
'' ) {
1255 wfDebug( __METHOD__ .
' received an empty username. Are there database errors ' .
1256 'that need to be fixed?' );
1257 return wfMessage(
'empty-username' )->parse();
1261 $moreLinkAttribs = [
'class' =>
'mw-usertoollinks-block' ];
1275 if ( $userText ===
'' ) {
1276 wfLogWarning( __METHOD__ .
' received an empty username. Are there database errors ' .
1277 'that need to be fixed?' );
1278 return wfMessage(
'empty-username' )->parse();
1282 $moreLinkAttribs = [
'class' =>
'mw-usertoollinks-mail' ];
1302 $authority = RequestContext::getMain()->getAuthority();
1304 if ( $revRecord->
isDeleted( RevisionRecord::DELETED_USER ) && $isPublic ) {
1305 $link =
wfMessage(
'rev-deleted-user' )->escaped();
1306 } elseif ( $revRecord->
userCan( RevisionRecord::DELETED_USER, $authority ) ) {
1307 $revUser = $revRecord->
getUser( RevisionRecord::FOR_THIS_USER, $authority );
1309 $revUser ? $revUser->getId() : 0,
1310 $revUser ? $revUser->getName() :
''
1313 $link =
wfMessage(
'rev-deleted-user' )->escaped();
1315 if ( $revRecord->
isDeleted( RevisionRecord::DELETED_USER ) ) {
1317 return '<span class="' . $class .
'">' . $link .
'</span>';
1329 $class =
'history-deleted';
1330 if ( $revisionRecord->
isDeleted( RevisionRecord::DELETED_RESTRICTED ) ) {
1331 $class .=
' mw-history-suppressed';
1351 $useParentheses =
true
1354 $authority = RequestContext::getMain()->getAuthority();
1356 if ( $revRecord->
userCan( RevisionRecord::DELETED_USER, $authority ) &&
1357 ( !$revRecord->
isDeleted( RevisionRecord::DELETED_USER ) || !$isPublic )
1359 $revUser = $revRecord->
getUser( RevisionRecord::FOR_THIS_USER, $authority );
1360 $userId = $revUser ? $revUser->getId() : 0;
1361 $userText = $revUser ? $revUser->getName() :
'';
1363 if ( $userId || $userText !==
'' ) {
1364 $link = self::userLink( $userId, $userText )
1365 . self::userToolLinks( $userId, $userText,
false, 0,
null,
1370 if ( !isset( $link ) ) {
1371 $link =
wfMessage(
'rev-deleted-user' )->escaped();
1374 if ( $revRecord->
isDeleted( RevisionRecord::DELETED_USER ) ) {
1375 $class = self::getRevisionDeletedClass( $revRecord );
1376 return ' <span class="' . $class .
' mw-userlink">' . $link .
'</span>';
1392 $formatter =
new HtmlFormatter( $html );
1393 $doc = $formatter->getDoc();
1394 $xpath =
new DOMXPath( $doc );
1395 $nodes = $xpath->query(
'//a[@href]' );
1397 foreach ( $nodes as $node ) {
1398 $node->setAttribute(
1403 return $formatter->getText(
'html' );
1427 $comment,
$title =
null, $local =
false, $wikiId =
null
1429 $formatter = MediaWikiServices::getInstance()->getCommentFormatter();
1430 return $formatter->format( $comment,
$title, $local, $wikiId );
1453 $comment,
$title =
null, $local =
false, $wikiId =
null
1455 $formatter = MediaWikiServices::getInstance()->getCommentFormatter();
1456 return $formatter->formatLinksUnsafe( $comment,
$title, $local, $wikiId );
1468 # :Foobar -- override special treatment of prefix (images, language links)
1469 # /Foobar -- convert to CurrentPage/Foobar
1470 # /Foobar/ -- convert to CurrentPage/Foobar, strip the initial and final / from text
1471 # ../ -- convert to CurrentPage, from CurrentPage/CurrentSubPage
1472 # ../Foobar -- convert to CurrentPage/Foobar,
1473 # (from CurrentPage/CurrentSubPage)
1474 # ../Foobar/ -- convert to CurrentPage/Foobar, use 'Foobar' as text
1475 # (from CurrentPage/CurrentSubPage)
1477 $ret = $target; #
default return value is no change
1479 # Some namespaces don't allow subpages,
1480 # so only perform processing if subpages are allowed
1482 $contextTitle && MediaWikiServices::getInstance()->getNamespaceInfo()->
1483 hasSubpages( $contextTitle->getNamespace() )
1485 $hash = strpos( $target,
'#' );
1486 if ( $hash !==
false ) {
1487 $suffix = substr( $target, $hash );
1488 $target = substr( $target, 0, $hash );
1493 $target = trim( $target );
1494 $contextPrefixedText = MediaWikiServices::getInstance()->getTitleFormatter()->
1495 getPrefixedText( $contextTitle );
1496 # Look at the first character
1497 if ( $target !=
'' && $target[0] ===
'/' ) {
1498 # / at end means we don't want the slash to be shown
1500 $trailingSlashes = preg_match_all(
'%(/+)$%', $target, $m );
1501 if ( $trailingSlashes ) {
1502 $noslash = $target = substr( $target, 1, -strlen( $m[0][0] ) );
1504 $noslash = substr( $target, 1 );
1507 $ret = $contextPrefixedText .
'/' . trim( $noslash ) . $suffix;
1508 if ( $text ===
'' ) {
1509 $text = $target . $suffix;
1510 } #
this might be changed
for ugliness reasons
1512 # check for .. subpage backlinks
1514 $nodotdot = $target;
1515 while ( strncmp( $nodotdot,
"../", 3 ) == 0 ) {
1517 $nodotdot = substr( $nodotdot, 3 );
1519 if ( $dotdotcount > 0 ) {
1520 $exploded = explode(
'/', $contextPrefixedText );
1521 if ( count( $exploded ) > $dotdotcount ) { # not allowed to go below top level page
1522 $ret = implode(
'/', array_slice( $exploded, 0, -$dotdotcount ) );
1523 # / at the end means don't show full path
1524 if ( substr( $nodotdot, -1, 1 ) ===
'/' ) {
1525 $nodotdot = rtrim( $nodotdot,
'/' );
1526 if ( $text ===
'' ) {
1527 $text = $nodotdot . $suffix;
1530 $nodotdot = trim( $nodotdot );
1531 if ( $nodotdot !=
'' ) {
1532 $ret .=
'/' . $nodotdot;
1563 $comment,
$title =
null, $local =
false, $wikiId =
null, $useParentheses =
true
1565 return MediaWikiServices::getInstance()->getCommentFormatter()
1566 ->formatBlock( $comment,
$title, $local, $wikiId, $useParentheses );
1588 $useParentheses =
true
1590 $authority = RequestContext::getMain()->getAuthority();
1591 $formatter = MediaWikiServices::getInstance()->getCommentFormatter();
1592 return $formatter->formatRevision( $revRecord, $authority, $local, $isPublic, $useParentheses );
1602 $stxt =
wfMessage(
'historyempty' )->escaped();
1604 $stxt =
wfMessage(
'nbytes' )->numParams( $size )->escaped();
1606 return "<span class=\"history-size mw-diff-bytes\" data-mw-bytes=\"$size\">$stxt</span>";
1627 return "</li>\n" . str_repeat(
"</ul>\n</li>\n", $level > 0 ? $level : 0 );
1641 public static function tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex =
false ) {
1642 $classes =
"toclevel-$level";
1643 if ( $sectionIndex !==
false ) {
1644 $classes .=
" tocsection-$sectionIndex";
1649 return Html::openElement(
'li', [
'class' => $classes ] )
1650 . Html::rawElement(
'a',
1651 [
'href' =>
"#$anchor" ],
1652 Html::element(
'span', [
'class' =>
'tocnumber' ], $tocnumber )
1654 . Html::rawElement(
'span', [
'class' =>
'toctext' ], $tocline )
1678 $lang =
$lang ?? RequestContext::getMain()->getLanguage();
1682 return '<div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading">'
1683 . Html::element(
'input', [
1684 'type' =>
'checkbox',
1686 'id' =>
'toctogglecheckbox',
1687 'class' =>
'toctogglecheckbox',
1688 'style' =>
'display:none',
1690 . Html::openElement(
'div', [
1691 'class' =>
'toctitle',
1692 'lang' =>
$lang->getHtmlCode(),
1693 'dir' =>
$lang->getDir(),
1695 .
'<h2 id="mw-toc-heading">' .
$title .
'</h2>'
1696 .
'<span class="toctogglespan">'
1697 . Html::label(
'',
'toctogglecheckbox', [
1698 'class' =>
'toctogglelabel',
1703 .
"</ul>\n</div>\n";
1717 foreach ( $tree as $section ) {
1718 if ( $section[
'toclevel'] > $lastLevel ) {
1719 $toc .= self::tocIndent();
1720 } elseif ( $section[
'toclevel'] < $lastLevel ) {
1721 $toc .= self::tocUnindent(
1722 $lastLevel - $section[
'toclevel'] );
1724 $toc .= self::tocLineEnd();
1727 $toc .= self::tocLine( $section[
'anchor'],
1728 $section[
'line'], $section[
'number'],
1729 $section[
'toclevel'], $section[
'index'] );
1730 $lastLevel = $section[
'toclevel'];
1732 $toc .= self::tocLineEnd();
1733 return self::tocList( $toc,
$lang );
1753 $link, $fallbackAnchor =
false
1755 $anchorEscaped = htmlspecialchars( $anchor, ENT_COMPAT );
1757 if ( $fallbackAnchor !==
false && $fallbackAnchor !== $anchor ) {
1758 $fallbackAnchor = htmlspecialchars( $fallbackAnchor, ENT_COMPAT );
1759 $fallback =
"<span id=\"$fallbackAnchor\"></span>";
1761 return "<h$level$attribs"
1762 .
"$fallback<span class=\"mw-headline\" id=\"$anchorEscaped\">$html</span>"
1774 $regex = MediaWikiServices::getInstance()->getContentLanguage()->linkTrail();
1776 if ( $trail !==
'' && preg_match( $regex, $trail, $m ) ) {
1777 list( , $inside, $trail ) = $m;
1779 return [ $inside, $trail ];
1814 $options = [
'verify' ]
1816 if ( $context ===
null ) {
1817 $context = RequestContext::getMain();
1821 if ( in_array(
'verify', $options,
true ) ) {
1822 $editCount = self::getRollbackEditCount( $revRecord,
true );
1823 if ( $editCount ===
false ) {
1828 $inner = self::buildRollbackLink( $revRecord, $context, $editCount );
1832 if ( !Hooks::runner()->onLinkerGenerateRollbackLink(
1833 $revRecord, $context, $options, $inner ) ) {
1837 if ( !in_array(
'noBrackets', $options,
true ) ) {
1838 $inner = $context->msg(
'brackets' )->rawParams( $inner )->escaped();
1841 if ( MediaWikiServices::getInstance()->getUserOptionsLookup()
1842 ->getBoolOption( $context->getUser(),
'showrollbackconfirmation' )
1844 $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
1845 $stats->increment(
'rollbackconfirmation.event.load' );
1846 $context->getOutput()->addModules(
'mediawiki.misc-authed-curate' );
1849 return '<span class="mw-rollback-link">' . $inner .
'</span>';
1871 $showRollbackEditCount = MediaWikiServices::getInstance()->getMainConfig()->get(
'ShowRollbackEditCount' );
1873 if ( !is_int( $showRollbackEditCount ) || !$showRollbackEditCount > 0 ) {
1881 $revQuery = MediaWikiServices::getInstance()->getRevisionStore()->getQueryInfo();
1883 $revIndex =
$dbr->indexExists(
'revision',
'page_timestamp', __METHOD__ )
1885 :
'rev_page_timestamp';
1888 [
'rev_user_text' =>
$revQuery[
'fields'][
'rev_user_text'],
'rev_deleted' ],
1889 [
'rev_page' => $revRecord->
getPageId() ],
1892 'USE INDEX' => [
'revision' => $revIndex ],
1893 'ORDER BY' => [
'rev_timestamp DESC',
'rev_id DESC' ],
1894 'LIMIT' => $showRollbackEditCount + 1
1899 $revUser = $revRecord->
getUser( RevisionRecord::RAW );
1900 $revUserText = $revUser ? $revUser->getName() :
'';
1904 foreach (
$res as $row ) {
1905 if ( $row->rev_user_text != $revUserText ) {
1907 ( $row->rev_deleted & RevisionRecord::DELETED_TEXT
1908 || $row->rev_deleted & RevisionRecord::DELETED_USER
1921 if ( $verify && $editCount <= $showRollbackEditCount && !$moreRevs ) {
1949 $config = MediaWikiServices::getInstance()->getMainConfig();
1950 $showRollbackEditCount = $config->get(
'ShowRollbackEditCount' );
1951 $miserMode = $config->get(
'MiserMode' );
1953 $disableRollbackEditCountSpecialPage = [
'Recentchanges',
'Watchlist' ];
1955 if ( $context ===
null ) {
1956 $context = RequestContext::getMain();
1960 $revUser = $revRecord->
getUser();
1961 $revUserText = $revUser ? $revUser->getName() :
'';
1964 'action' =>
'rollback',
1965 'from' => $revUserText,
1966 'token' => $context->getUser()->getEditToken(
'rollback' ),
1970 'data-mw' =>
'interface',
1971 'title' => $context->msg(
'tooltip-rollback' )->text()
1974 $options = [
'known',
'noclasses' ];
1976 if ( $context->getRequest()->getBool(
'bot' ) ) {
1978 $query[
'hidediff'] =
'1';
1979 $query[
'bot'] =
'1';
1983 foreach ( $disableRollbackEditCountSpecialPage as $specialPage ) {
1984 if ( $context->getTitle()->isSpecial( $specialPage ) ) {
1985 $showRollbackEditCount =
false;
1992 $msg = [
'rollbacklink' ];
1993 if ( is_int( $showRollbackEditCount ) && $showRollbackEditCount > 0 ) {
1994 if ( !is_numeric( $editCount ) ) {
1995 $editCount = self::getRollbackEditCount( $revRecord,
false );
1998 if ( $editCount > $showRollbackEditCount ) {
1999 $msg = [
'rollbacklinkcount-morethan',
Message::numParam( $showRollbackEditCount ) ];
2000 } elseif ( $editCount ) {
2005 $html = $context->msg( ...$msg )->parse();
2006 return self::link(
$title, $html, $attrs, $query, $options );
2019 if ( count( $hiddencats ) > 0 ) {
2020 # Construct the HTML
2021 $outText =
'<div class="mw-hiddenCategoriesExplanation">';
2022 $outText .=
wfMessage(
'hiddencategories' )->numParams( count( $hiddencats ) )->parseAsBlock();
2023 $outText .=
"</div><ul>\n";
2025 foreach ( $hiddencats as $titleObj ) {
2026 # If it's hidden, it must exist - no need to check with a LinkBatch
2028 . self::link( $titleObj,
null, [], [],
'known' )
2031 $outText .=
'</ul>';
2040 $context = RequestContext::getMain();
2062 public static function titleAttrib( $name, $options =
null, array $msgParams = [], $localizer =
null ) {
2063 if ( !$localizer ) {
2064 $localizer = self::getContextFromMain();
2066 $message = $localizer->msg(
"tooltip-$name", $msgParams );
2067 if ( $message->isDisabled() ) {
2070 $tooltip = $message->text();
2071 # Compatibility: formerly some tooltips had [alt-.] hardcoded
2072 $tooltip = preg_replace(
"/ ?\[alt-.\]$/",
'', $tooltip );
2075 $options = (array)$options;
2077 if ( in_array(
'nonexisting', $options ) ) {
2078 $tooltip = $localizer->msg(
'red-link-title', $tooltip ?:
'' )->text();
2080 if ( in_array(
'withaccess', $options ) ) {
2081 $accesskey = self::accesskey( $name, $localizer );
2082 if ( $accesskey !==
false ) {
2084 if ( $tooltip ===
false || $tooltip ===
'' ) {
2085 $tooltip = $localizer->msg(
'brackets', $accesskey )->text();
2087 $tooltip .= $localizer->msg(
'word-separator' )->text();
2088 $tooltip .= $localizer->msg(
'brackets', $accesskey )->text();
2110 public static function accesskey( $name, $localizer =
null ) {
2111 if ( !isset( self::$accesskeycache[$name] ) ) {
2112 if ( !$localizer ) {
2113 $localizer = self::getContextFromMain();
2115 $msg = $localizer->msg(
"accesskey-$name" );
2116 self::$accesskeycache[$name] = $msg->isDisabled() ? false : $msg->plain();
2118 return self::$accesskeycache[$name];
2140 $canHide = $performer->
isAllowed(
'deleterevision' );
2141 $canHideHistory = $performer->
isAllowed(
'deletedhistory' );
2142 if ( !$canHide && !( $revRecord->
getVisibility() && $canHideHistory ) ) {
2146 if ( !$revRecord->
userCan( RevisionRecord::DELETED_RESTRICTED, $performer ) ) {
2147 return self::revDeleteLinkDisabled( $canHide );
2149 $prefixedDbKey = MediaWikiServices::getInstance()->getTitleFormatter()->
2150 getPrefixedDBkey(
$title );
2151 if ( $revRecord->
getId() ) {
2155 'type' =>
'revision',
2156 'target' => $prefixedDbKey,
2157 'ids' => $revRecord->
getId()
2163 'type' =>
'archive',
2164 'target' => $prefixedDbKey,
2168 return self::revDeleteLink(
2170 $revRecord->
isDeleted( RevisionRecord::DELETED_RESTRICTED ),
2187 public static function revDeleteLink( $query = [], $restricted =
false, $delete =
true ) {
2189 $msgKey = $delete ?
'rev-delundel' :
'rev-showdeleted';
2190 $html =
wfMessage( $msgKey )->escaped();
2191 $tag = $restricted ?
'strong' :
'span';
2192 $link = self::link( $sp, $html, [], $query, [
'known',
'noclasses' ] );
2195 [
'class' =>
'mw-revdelundel-link' ],
2196 wfMessage(
'parentheses' )->rawParams( $link )->escaped()
2212 $msgKey = $delete ?
'rev-delundel' :
'rev-showdeleted';
2213 $html =
wfMessage( $msgKey )->escaped();
2214 $htmlParentheses =
wfMessage(
'parentheses' )->rawParams( $html )->escaped();
2215 return Xml::tags(
'span', [
'class' =>
'mw-revdelundel-link' ], $htmlParentheses );
2230 string &$tooltip, array &$msgParams, $config, $user, $relevantTitle
2232 if ( !$config || !$user || !$relevantTitle ) {
2233 $mainContext = self::getContextFromMain();
2235 $config = $mainContext->getConfig();
2238 $user = $mainContext->getUser();
2240 if ( !$relevantTitle ) {
2241 $relevantTitle = $mainContext->getSkin()->getRelevantTitle();
2245 $isWatchlistExpiryEnabled = $config->get(
'WatchlistExpiry' );
2246 if ( !$isWatchlistExpiryEnabled ) {
2249 $watchStore = MediaWikiServices::getInstance()->getWatchedItemStore();
2250 $watchedItem = $watchStore->getWatchedItem( $user, $relevantTitle );
2252 $diffInDays = $watchedItem->getExpiryInDays();
2254 if ( $diffInDays ) {
2255 $msgParams = [ $diffInDays ];
2257 $tooltip =
'ca-unwatch-expiring';
2259 $tooltip =
'ca-unwatch-expiring-hours';
2282 array $msgParams = [],
2287 $relevantTitle =
null
2289 $options = (array)$options;
2290 $options[] =
'withaccess';
2291 $tooltipTitle = $name;
2294 if ( !$localizer ) {
2295 $localizer = self::getContextFromMain();
2299 if ( $name ===
'ca-unwatch' ) {
2300 self::updateWatchstarTooltipMessage( $tooltipTitle, $msgParams, $config, $user, $relevantTitle );
2304 'title' => self::titleAttrib( $tooltipTitle, $options, $msgParams, $localizer ),
2305 'accesskey' => self::accesskey( $name, $localizer )
2307 if ( $attribs[
'title'] ===
false ) {
2308 unset( $attribs[
'title'] );
2310 if ( $attribs[
'accesskey'] ===
false ) {
2311 unset( $attribs[
'accesskey'] );
2323 public static function tooltip( $name, $options =
null ) {
2324 $tooltip = self::titleAttrib( $name, $options );
2325 if ( $tooltip ===
false ) {
2328 return Xml::expandAttributes( [
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'))
Expand dynamic defaults and shortcuts.
An IContextSource implementation which will inherit context from another source but allow individual ...
Marks HTML that shouldn't be escaped.
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 );.
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.
getBadFileLookup()
Get the BadFileLookup instance that this Parser is using.
static getExternalLinkRel( $url=false, LinkTarget $title=null)
Get the rel attribute for a particular external link.
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 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.
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