87 public static function link(
88 $target, $html =
null, $customAttribs = [], $query = [], $options = []
91 wfWarn( __METHOD__ .
': Requires $target to be a LinkTarget object.', 2 );
92 return "<!-- ERROR -->$html";
95 $services = MediaWikiServices::getInstance();
96 $options = (array)$options;
99 $linkRenderer = $services->getLinkRendererFactory()
100 ->createFromLegacyOptions( $options );
102 $linkRenderer = $services->getLinkRenderer();
105 if ( $html !==
null ) {
111 if ( in_array(
'known', $options,
true ) ) {
112 return $linkRenderer->makeKnownLink( $target, $text, $customAttribs, $query );
115 if ( in_array(
'broken', $options,
true ) ) {
116 return $linkRenderer->makeBrokenLink( $target, $text, $customAttribs, $query );
119 if ( in_array(
'noclasses', $options,
true ) ) {
120 return $linkRenderer->makePreloadedLink( $target, $text,
'', $customAttribs, $query );
123 return $linkRenderer->makeLink( $target, $text, $customAttribs, $query );
140 $target, $html =
null, $customAttribs = [],
141 $query = [], $options = [
'known' ]
143 return self::link( $target, $html, $customAttribs, $query, $options );
161 public static function makeSelfLinkObj( $nt, $html =
'', $query =
'', $trail =
'', $prefix =
'' ) {
162 $nt = Title::newFromLinkTarget( $nt );
163 $ret =
"<a class=\"mw-selflink selflink\">{$prefix}{$html}</a>{$trail}";
164 if ( !Hooks::runner()->onSelfLinkBegin( $nt, $html, $trail, $prefix, $ret ) ) {
169 $html = htmlspecialchars( $nt->getPrefixedText() );
172 return "<a class=\"mw-selflink selflink\">{$prefix}{$html}{$inside}</a>{$trail}";
187 if ( MediaWikiServices::getInstance()->getNamespaceInfo()->exists( $namespace ) ) {
189 $name = $context->
msg(
'blanknamespace' )->text();
191 $name = MediaWikiServices::getInstance()->getContentLanguage()->
192 getFormattedNsText( $namespace );
194 return $context->
msg(
'invalidtitle-knownnamespace', $namespace, $name,
$title )->text();
197 return $context->
msg(
'invalidtitle-unknownnamespace', $namespace,
$title )->text();
208 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
209 return $linkRenderer->normalizeTarget( $target );
221 $basename = strrchr( $url,
'/' );
222 if ( $basename ===
false ) {
225 $basename = substr( $basename, 1 );
245 $success = Hooks::runner()->onLinkerMakeExternalImage( $url, $alt, $img );
247 wfDebug(
"Hook LinkerMakeExternalImage changed the output of external image "
248 .
"with url {$url} and alt text {$alt} to {$img}" );
251 return Html::element(
'img',
297 $file, $frameParams = [], $handlerParams = [], $time =
false,
298 $query =
"", $widthOption =
null
303 if ( !Hooks::runner()->onImageBeforeProduceHTML( $dummy,
$title,
304 $file, $frameParams, $handlerParams, $time,
$res,
305 $parser, $query, $widthOption )
310 if (
$file && !
$file->allowInlineDisplay() ) {
311 wfDebug( __METHOD__ .
': ' .
$title->getPrefixedDBkey() .
" does not allow inline display" );
316 $page = $handlerParams[
'page'] ??
false;
317 if ( !isset( $frameParams[
'align'] ) ) {
318 $frameParams[
'align'] =
'';
320 if ( !isset( $frameParams[
'alt'] ) ) {
321 $frameParams[
'alt'] =
'';
323 if ( !isset( $frameParams[
'title'] ) ) {
324 $frameParams[
'title'] =
'';
326 if ( !isset( $frameParams[
'class'] ) ) {
327 $frameParams[
'class'] =
'';
330 $services = MediaWikiServices::getInstance();
331 $enableLegacyMediaDOM = $services->getMainConfig()->get(
'ParserEnableLegacyMediaDOM' );
334 if ( !isset( $handlerParams[
'width'] ) ) {
335 $classes[] =
'mw-default-size';
338 $prefix = $postfix =
'';
340 if ( $enableLegacyMediaDOM ) {
341 if ( $frameParams[
'align'] ==
'center' ) {
342 $prefix =
'<div class="center">';
344 $frameParams[
'align'] =
'none';
348 if (
$file && !isset( $handlerParams[
'width'] ) ) {
349 if ( isset( $handlerParams[
'height'] ) &&
$file->isVectorized() ) {
355 $handlerParams[
'width'] =
$file->getWidth( $page );
358 if ( isset( $frameParams[
'thumbnail'] )
359 || isset( $frameParams[
'manualthumb'] )
360 || isset( $frameParams[
'framed'] )
361 || isset( $frameParams[
'frameless'] )
362 || !$handlerParams[
'width']
366 if ( $widthOption ===
null || !isset(
$wgThumbLimits[$widthOption] ) ) {
372 if ( isset( $frameParams[
'upright'] ) && $frameParams[
'upright'] == 0 ) {
379 $prefWidth = isset( $frameParams[
'upright'] ) ?
380 round(
$wgThumbLimits[$widthOption] * $frameParams[
'upright'], -1 ) :
385 if ( !isset( $handlerParams[
'height'] ) && ( $handlerParams[
'width'] <= 0 ||
386 $prefWidth < $handlerParams[
'width'] ||
$file->isVectorized() ) ) {
387 $handlerParams[
'width'] = $prefWidth;
392 if ( isset( $frameParams[
'thumbnail'] ) || isset( $frameParams[
'manualthumb'] )
393 || isset( $frameParams[
'framed'] )
395 if ( $enableLegacyMediaDOM ) {
400 # Create a thumbnail. Alignment depends on the writing direction of
401 # the page content language (right-aligned for LTR languages,
402 # left-aligned for RTL languages)
403 # If a thumbnail width has not been provided, it is set
404 # to the default user option as specified in Language*.php
405 if ( $frameParams[
'align'] ==
'' ) {
414 switch (
$file ?
$file->getMediaType() :
'' ) {
416 $rdfaType =
'mw:Audio';
419 $rdfaType =
'mw:Video';
422 $rdfaType =
'mw:Image';
425 if (
$file && isset( $frameParams[
'frameless'] ) ) {
426 $rdfaType .=
'/Frameless';
427 $srcWidth =
$file->getWidth( $page );
428 # For "frameless" option: do not present an image bigger than the
429 # source (for bitmap-style images). This is the same behavior as the
430 # "thumb" option does it already.
431 if ( $srcWidth && !
$file->mustRender() && $handlerParams[
'width'] > $srcWidth ) {
432 $handlerParams[
'width'] = $srcWidth;
436 if (
$file && isset( $handlerParams[
'width'] ) ) {
437 # Create a resized image, without the additional thumbnail features
438 $thumb =
$file->transform( $handlerParams );
444 $rdfaType =
'mw:Error ' . $rdfaType;
446 if ( $enableLegacyMediaDOM ) {
449 $label = $frameParams[
'title'];
452 $title, $label,
'',
'',
'', (
bool)$time, $handlerParams
457 'alt' => $frameParams[
'alt'],
458 'title' => $frameParams[
'title'],
460 if ( $enableLegacyMediaDOM ) {
462 'valign' => $frameParams[
'valign'] ??
false,
463 'img-class' => $frameParams[
'class'],
465 if ( isset( $frameParams[
'border'] ) ) {
466 $params[
'img-class'] .= ( $params[
'img-class'] !==
'' ?
' ' :
'' ) .
'thumbborder';
470 $s = $thumb->toHtml( $params );
473 if ( $enableLegacyMediaDOM ) {
474 if ( $frameParams[
'align'] !=
'' ) {
475 $s = Html::rawElement(
477 [
'class' =>
'float' . $frameParams[
'align'] ],
481 return str_replace(
"\n",
' ', $prefix .
$s . $postfix );
487 if ( $frameParams[
'align'] !=
'' ) {
490 $classes[] =
"mw-halign-{$frameParams['align']}";
491 $caption = Html::rawElement(
492 'figcaption', [], $frameParams[
'caption'] ??
''
494 } elseif ( isset( $frameParams[
'valign'] ) ) {
498 $classes[] =
"mw-valign-{$frameParams['valign']}";
501 if ( isset( $frameParams[
'border'] ) ) {
502 $classes[] =
'mw-image-border';
505 if ( isset( $frameParams[
'class'] ) ) {
506 $classes[] = $frameParams[
'class'];
511 'typeof' => $rdfaType,
514 $s = Html::rawElement( $wrapper, $attribs,
$s . $caption );
516 return str_replace(
"\n",
' ',
$s );
529 if ( isset( $frameParams[
'link-url'] ) && $frameParams[
'link-url'] !==
'' ) {
530 $mtoParams[
'custom-url-link'] = $frameParams[
'link-url'];
531 if ( isset( $frameParams[
'link-target'] ) ) {
532 $mtoParams[
'custom-target-link'] = $frameParams[
'link-target'];
535 $extLinkAttrs = $parser->getExternalLinkAttribs( $frameParams[
'link-url'] );
536 foreach ( $extLinkAttrs as $name => $val ) {
538 $mtoParams[
'parser-extlink-' . $name] = $val;
541 } elseif ( isset( $frameParams[
'link-title'] ) && $frameParams[
'link-title'] !==
'' ) {
542 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
543 $mtoParams[
'custom-title-link'] = Title::newFromLinkTarget(
544 $linkRenderer->normalizeTarget( $frameParams[
'link-title'] )
546 } elseif ( !empty( $frameParams[
'no-link'] ) ) {
549 $mtoParams[
'desc-link'] =
true;
550 $mtoParams[
'desc-query'] = $query;
569 $params = [], $framed =
false, $manualthumb =
""
577 $frameParams[
'framed'] =
true;
579 if ( $manualthumb ) {
580 $frameParams[
'manualthumb'] = $manualthumb;
582 $classes = [
'mw-default-size' ];
584 $title,
$file, $frameParams, $params,
false,
'', $classes
600 $time =
false, $query =
"", array $classes = []
604 $services = MediaWikiServices::getInstance();
605 $enableLegacyMediaDOM = $services->getMainConfig()->get(
'ParserEnableLegacyMediaDOM' );
607 $page = $handlerParams[
'page'] ??
false;
608 if ( !isset( $frameParams[
'align'] ) ) {
609 $frameParams[
'align'] =
'';
610 if ( $enableLegacyMediaDOM ) {
611 $frameParams[
'align'] =
'right';
614 if ( !isset( $frameParams[
'alt'] ) ) {
615 $frameParams[
'alt'] =
'';
617 if ( !isset( $frameParams[
'title'] ) ) {
618 $frameParams[
'title'] =
'';
620 if ( !isset( $frameParams[
'caption'] ) ) {
621 $frameParams[
'caption'] =
'';
624 if ( empty( $handlerParams[
'width'] ) ) {
626 $handlerParams[
'width'] = isset( $frameParams[
'upright'] ) ? 130 : 180;
631 $manualthumb =
false;
635 $outerWidth = $handlerParams[
'width'] + 2;
637 if ( isset( $frameParams[
'manualthumb'] ) ) {
638 # Use manually specified thumbnail
639 $manual_title = Title::makeTitleSafe(
NS_FILE, $frameParams[
'manualthumb'] );
640 if ( $manual_title ) {
641 $manual_img = $services->getRepoGroup()
642 ->findFile( $manual_title );
644 $thumb = $manual_img->getUnscaledThumb( $handlerParams );
650 } elseif ( isset( $frameParams[
'framed'] ) ) {
652 $thumb =
$file->getUnscaledThumb( $handlerParams );
654 $rdfaType =
'/Frame';
656 # Do not present an image bigger than the source, for bitmap-style images
657 # This is a hack to maintain compatibility with arbitrary pre-1.10 behavior
658 $srcWidth =
$file->getWidth( $page );
659 if ( $srcWidth && !
$file->mustRender() && $handlerParams[
'width'] > $srcWidth ) {
660 $handlerParams[
'width'] = $srcWidth;
662 $thumb =
$file->transform( $handlerParams );
666 $outerWidth = $thumb->getWidth() + 2;
668 $outerWidth = $handlerParams[
'width'] + 2;
672 $url = Title::newFromLinkTarget(
$title )->getLocalURL( $query );
674 if ( $enableLegacyMediaDOM && $page ) {
675 # ThumbnailImage::toHtml() already adds page= onto the end of DjVu URLs
676 # So we don't need to pass it here in $query. However, the URL for the
677 # zoom icon still needs it, so we make a unique query for it. See T16771
682 && !isset( $frameParams[
'link-title'] )
683 && !isset( $frameParams[
'link-url'] )
684 && !isset( $frameParams[
'no-link'] ) ) {
685 $frameParams[
'link-url'] = $url;
688 if ( $frameParams[
'align'] !=
'' ) {
690 $classes[] =
"mw-halign-{$frameParams['align']}";
693 if ( isset( $frameParams[
'class'] ) ) {
694 $classes[] = $frameParams[
'class'];
699 if ( $enableLegacyMediaDOM ) {
700 $s .=
"<div class=\"thumb t{$frameParams['align']}\">"
701 .
"<div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">";
706 if ( $enableLegacyMediaDOM ) {
709 $label = $frameParams[
'title'];
712 $title, $label,
'',
'',
'', (
bool)$time, $handlerParams
715 } elseif ( !$thumb ) {
717 $s .=
wfMessage(
'thumbnail_error',
'' )->escaped();
720 if ( !$noscale && !$manualthumb ) {
724 'alt' => $frameParams[
'alt'],
725 'title' => $frameParams[
'title'],
727 if ( $enableLegacyMediaDOM ) {
729 'img-class' => ( isset( $frameParams[
'class'] ) && $frameParams[
'class'] !==
''
730 ? $frameParams[
'class'] .
' '
731 :
'' ) .
'thumbimage'
735 $s .= $thumb->toHtml( $params );
736 if ( isset( $frameParams[
'framed'] ) ) {
739 $zoomIcon = Html::rawElement(
'div', [
'class' =>
'magnify' ],
740 Html::rawElement(
'a', [
742 'class' =>
'internal',
743 'title' =>
wfMessage(
'thumbnail-more' )->text() ],
748 if ( $enableLegacyMediaDOM ) {
749 $s .=
' <div class="thumbcaption">' . $zoomIcon . $frameParams[
'caption'] .
"</div></div></div>";
750 return str_replace(
"\n",
' ',
$s );
753 $s .= Html::rawElement(
754 'figcaption', [], $frameParams[
'caption'] ??
''
757 $rdfaType = $rdfaType ?:
'/Thumb';
759 switch (
$file ?
$file->getMediaType() :
'' ) {
761 $rdfaType =
'mw:Audio' . $rdfaType;
764 $rdfaType =
'mw:Video' . $rdfaType;
767 $rdfaType =
'mw:Image' . $rdfaType;
771 $rdfaType =
'mw:Error ' . $rdfaType;
776 'typeof' => $rdfaType,
779 $s = Html::rawElement(
'figure', $attribs,
$s );
781 return str_replace(
"\n",
' ',
$s );
796 $hp15[
'width'] = round( $hp[
'width'] * 1.5 );
798 $hp20[
'width'] = $hp[
'width'] * 2;
799 if ( isset( $hp[
'height'] ) ) {
800 $hp15[
'height'] = round( $hp[
'height'] * 1.5 );
801 $hp20[
'height'] = $hp[
'height'] * 2;
804 $thumb15 =
$file->transform( $hp15 );
805 $thumb20 =
$file->transform( $hp20 );
806 if ( $thumb15 && !$thumb15->isError() && $thumb15->getUrl() !== $thumb->getUrl() ) {
807 $thumb->responsiveUrls[
'1.5'] = $thumb15->getUrl();
809 if ( $thumb20 && !$thumb20->isError() && $thumb20->getUrl() !== $thumb->getUrl() ) {
810 $thumb->responsiveUrls[
'2'] = $thumb20->getUrl();
829 $title, $label =
'', $query =
'', $unused1 =
'', $unused2 =
'',
830 $time =
false, array $handlerParams = []
833 wfWarn( __METHOD__ .
': Requires $title to be a LinkTarget object.' );
834 return "<!-- ERROR -->" . htmlspecialchars( $label );
840 if ( $label ==
'' ) {
841 $label =
$title->getPrefixedText();
844 $html = Html::element(
'span', [
846 'data-width' => $handlerParams[
'width'] ??
null,
847 'data-height' => $handlerParams[
'height'] ??
null,
850 $services = MediaWikiServices::getInstance();
851 if ( $services->getMainConfig()->get(
'ParserEnableLegacyMediaDOM' ) ) {
852 $html = htmlspecialchars( $label );
855 $repoGroup = $services->getRepoGroup();
856 $currentExists = $time
857 && $repoGroup->findFile(
$title ) !==
false;
862 if ( $repoGroup->getLocalRepo()->checkRedirect(
$title ) ) {
867 [
'class' =>
'mw-redirect' ],
869 [
'known',
'noclasses' ]
872 return Html::rawElement(
'a', [
873 'href' => self::getUploadUrl(
$title, $query ),
875 'title' =>
$title->getPrefixedText()
883 [
'known',
'noclasses' ]
897 $q =
'wpDestFile=' . Title::castFromLinkTarget( $destFile )->getPartialURL();
898 if ( $query !=
'' ) {
912 return $upload->getLocalURL( $q );
925 $img = MediaWikiServices::getInstance()->getRepoGroup()->findFile(
926 $title, [
'time' => $time ]
945 $url =
$file->getUrl();
964 if ( !Hooks::runner()->onLinkerMakeMediaLinkFile(
965 Title::castFromLinkTarget(
$title ),
$file, $html, $attribs, $ret )
967 wfDebug(
"Hook LinkerMakeMediaLinkFile changed the output of link "
968 .
"with url {$url} and text {$html} to {$ret}" );
972 return Html::rawElement(
'a', $attribs, $html );
987 $key = strtolower( $name );
1012 $linktype =
'', $attribs = [],
$title =
null
1015 $class =
"external";
1017 $class .=
" $linktype";
1019 if ( isset( $attribs[
'class'] ) && $attribs[
'class'] ) {
1020 $class .=
" {$attribs['class']}";
1022 $attribs[
'class'] = $class;
1025 $text = htmlspecialchars( $text );
1032 if ( !isset( $attribs[
'rel'] ) || $attribs[
'rel'] ===
'' ) {
1033 $attribs[
'rel'] = $newRel;
1034 } elseif ( $newRel !==
null ) {
1036 $newRels = explode(
' ', $newRel );
1037 $oldRels = explode(
' ', $attribs[
'rel'] );
1038 $combined = array_unique( array_merge( $newRels, $oldRels ) );
1039 $attribs[
'rel'] = implode(
' ', $combined );
1042 $success = Hooks::runner()->onLinkerMakeExternalLink(
1043 $url, $text, $link, $attribs, $linktype );
1045 wfDebug(
"Hook LinkerMakeExternalLink changed the output of link "
1046 .
"with url {$url} and text {$text} to {$link}" );
1049 $attribs[
'href'] = $url;
1050 return Html::rawElement(
'a', $attribs, $text );
1064 public static function userLink( $userId, $userName, $altUserName =
false ) {
1065 if ( $userName ===
'' || $userName ===
false || $userName ===
null ) {
1066 wfDebug( __METHOD__ .
' received an empty username. Are there database errors ' .
1067 'that need to be fixed?' );
1068 return wfMessage(
'empty-username' )->parse();
1071 $classes =
'mw-userlink';
1073 if ( $userId == 0 ) {
1074 $page = ExternalUserNames::getUserLinkTitle( $userName );
1076 if ( ExternalUserNames::isExternal( $userName ) ) {
1077 $classes .=
' mw-extuserlink';
1078 } elseif ( $altUserName ===
false ) {
1079 $altUserName = IPUtils::prettifyIP( $userName );
1081 $classes .=
' mw-anonuserlink';
1083 $page = TitleValue::tryNew(
NS_USER, strtr( $userName,
' ',
'_' ) );
1088 '<bdi>' . htmlspecialchars( $altUserName !==
false ? $altUserName : $userName ) .
'</bdi>';
1091 ?
self::link( $page, $linkText, [
'class' => $classes ] )
1092 : Html::rawElement(
'span', [
'class' => $classes ], $linkText );
1110 $userId, $userText, $redContribsWhenNoEdits =
false, $flags = 0, $edits =
null,
1111 $useParentheses =
true
1113 if ( $userText ===
'' ) {
1114 wfDebug( __METHOD__ .
' received an empty username. Are there database errors ' .
1115 'that need to be fixed?' );
1116 return ' ' .
wfMessage(
'empty-username' )->parse();
1122 $addEmailLink = $flags & self::TOOL_LINKS_EMAIL && $userId;
1124 if ( $userId == 0 && ExternalUserNames::isExternal( $userText ) ) {
1136 $attribs[
'class'] =
'mw-usertoollinks-contribs';
1137 if ( $redContribsWhenNoEdits ) {
1138 if ( intval( $edits ) === 0 && $edits !== 0 ) {
1140 $edits = $user->getEditCount();
1142 if ( $edits === 0 ) {
1143 $attribs[
'class'] .=
' new';
1150 $userCanBlock = RequestContext::getMain()->getAuthority()->isAllowed(
'block' );
1151 if ( $blockable && $userCanBlock ) {
1155 $user = RequestContext::getMain()->getUser();
1156 if ( $addEmailLink && $user->canSendEmail() ) {
1160 Hooks::runner()->onUserToolLinksEdit( $userId, $userText, $items );
1166 if ( $useParentheses ) {
1167 return wfMessage(
'word-separator' )->escaped()
1168 .
'<span class="mw-usertoollinks">'
1169 .
wfMessage(
'parentheses' )->rawParams(
$wgLang->pipeList( $items ) )->escaped()
1174 foreach ( $items as $tool ) {
1175 $tools[] = Html::rawElement(
'span', [], $tool );
1177 return ' <span class="mw-usertoollinks mw-changeslist-links">' .
1178 implode(
' ', $tools ) .
'</span>';
1191 $userId, $userText, $edits =
null, $useParentheses =
true
1203 if ( $userText ===
'' ) {
1204 wfDebug( __METHOD__ .
' received an empty username. Are there database errors ' .
1205 'that need to be fixed?' );
1206 return wfMessage(
'empty-username' )->parse();
1209 $userTalkPage = TitleValue::tryNew(
NS_USER_TALK, strtr( $userText,
' ',
'_' ) );
1210 $moreLinkAttribs = [
'class' =>
'mw-usertoollinks-talk' ];
1211 $linkText =
wfMessage(
'talkpagelinktext' )->escaped();
1213 return $userTalkPage
1214 ?
self::link( $userTalkPage, $linkText, $moreLinkAttribs )
1215 : Html::rawElement(
'span', $moreLinkAttribs, $linkText );
1225 if ( $userText ===
'' ) {
1226 wfDebug( __METHOD__ .
' received an empty username. Are there database errors ' .
1227 'that need to be fixed?' );
1228 return wfMessage(
'empty-username' )->parse();
1232 $moreLinkAttribs = [
'class' =>
'mw-usertoollinks-block' ];
1246 if ( $userText ===
'' ) {
1247 wfLogWarning( __METHOD__ .
' received an empty username. Are there database errors ' .
1248 'that need to be fixed?' );
1249 return wfMessage(
'empty-username' )->parse();
1253 $moreLinkAttribs = [
'class' =>
'mw-usertoollinks-mail' ];
1273 $authority = RequestContext::getMain()->getAuthority();
1275 if ( $revRecord->
isDeleted( RevisionRecord::DELETED_USER ) && $isPublic ) {
1276 $link =
wfMessage(
'rev-deleted-user' )->escaped();
1277 } elseif ( $revRecord->
userCan( RevisionRecord::DELETED_USER, $authority ) ) {
1278 $revUser = $revRecord->
getUser( RevisionRecord::FOR_THIS_USER, $authority );
1280 $revUser ? $revUser->getId() : 0,
1281 $revUser ? $revUser->getName() :
''
1284 $link =
wfMessage(
'rev-deleted-user' )->escaped();
1286 if ( $revRecord->
isDeleted( RevisionRecord::DELETED_USER ) ) {
1288 return '<span class="' . $class .
'">' . $link .
'</span>';
1300 $class =
'history-deleted';
1301 if ( $revisionRecord->
isDeleted( RevisionRecord::DELETED_RESTRICTED ) ) {
1302 $class .=
' mw-history-suppressed';
1322 $useParentheses =
true
1325 $authority = RequestContext::getMain()->getAuthority();
1327 if ( $revRecord->
userCan( RevisionRecord::DELETED_USER, $authority ) &&
1328 ( !$revRecord->
isDeleted( RevisionRecord::DELETED_USER ) || !$isPublic )
1330 $revUser = $revRecord->
getUser( RevisionRecord::FOR_THIS_USER, $authority );
1331 $userId = $revUser ? $revUser->getId() : 0;
1332 $userText = $revUser ? $revUser->getName() :
'';
1334 if ( $userId || $userText !==
'' ) {
1335 $link = self::userLink( $userId, $userText )
1336 . self::userToolLinks( $userId, $userText,
false, 0,
null,
1341 if ( !isset( $link ) ) {
1342 $link =
wfMessage(
'rev-deleted-user' )->escaped();
1345 if ( $revRecord->
isDeleted( RevisionRecord::DELETED_USER ) ) {
1346 $class = self::getRevisionDeletedClass( $revRecord );
1347 return ' <span class="' . $class .
' mw-userlink">' . $link .
'</span>';
1373 $comment,
$title =
null, $local =
false, $wikiId =
null
1375 # Sanitize text a bit:
1376 $comment = str_replace(
"\n",
" ", $comment );
1377 # Allow HTML entities (for T15815)
1378 $comment = Sanitizer::escapeHtmlAllowEntities( $comment );
1380 # Render autocomments and make links:
1381 $comment = self::formatAutocomments( $comment,
$title, $local, $wikiId );
1382 return self::formatLinksInComment( $comment,
$title, $local, $wikiId );
1403 $comment,
$title =
null, $local =
false, $wikiId =
null
1411 $comment = preg_replace_callback(
1417 '!(?:(?<=(.)))?/\*\s*(.*?)\s*\*/(?:(?=(.)))?!',
1418 static function ( $match ) use (
$title, $local, $wikiId, &$append ) {
1422 $match += [
'',
'',
'',
'' ];
1424 $pre = $match[1] !==
'';
1426 $post = $match[3] !==
'';
1429 Hooks::runner()->onFormatAutocomments(
1430 $comment, $pre, $auto, $post, Title::castFromLinkTarget(
$title ), $local,
1433 if ( $comment ===
null ) {
1436 # Remove links that a user may have manually put in the autosummary
1437 # This could be improved by copying as much of Parser::stripSectionName as desired.
1438 $section = str_replace( [
1446 $sectionText = str_replace(
'[[',
'[[', $auto );
1449 if ( $section !==
'' ) {
1453 $sectionTitle =
$title->createFragmentTarget( $section );
1464 # written summary $presep autocomment (summary )
1465 $pre =
wfMessage(
'autocomment-prefix' )->inContentLanguage()->escaped();
1468 # autocomment $postsep written summary ( summary)
1469 $auto .=
wfMessage(
'colon-separator' )->inContentLanguage()->escaped();
1472 $auto =
'<span dir="auto"><span class="autocomment">' . $auto .
'</span>';
1473 $append .=
'</span>';
1475 $comment = $pre . $auto;
1481 return $comment . $append;
1504 $comment,
$title =
null, $local =
false, $wikiId =
null
1506 return preg_replace_callback(
1509 \s*+ # ignore leading whitespace, the *+ quantifier disallows backtracking
1510 :? # ignore optional leading colon
1511 ([^[\]|]+) # 1. link target; page names cannot include [, ] or |
1514 # Stop matching at ]] without relying on backtracking.
1518 ([^[]*) # 3. link trail (the text up until the next link)
1520 static function ( $match ) use (
$title, $local, $wikiId ) {
1521 $services = MediaWikiServices::getInstance();
1524 $medians .= preg_quote(
1525 $services->getNamespaceInfo()->getCanonicalName(
NS_MEDIA ),
'/' );
1527 $medians .= preg_quote(
1528 $services->getContentLanguage()->getNsText(
NS_MEDIA ),
1532 $comment = $match[0];
1534 # fix up urlencoded title texts (copied from Parser::replaceInternalLinks)
1535 if ( strpos( $match[1],
'%' ) !==
false ) {
1537 rawurldecode( $match[1] ),
1538 [
'<' =>
'<',
'>' =>
'>' ]
1542 # Handle link renaming [[foo|text]] will show link as "text"
1543 if ( $match[2] !=
"" ) {
1550 if ( preg_match(
'/^' . $medians .
'(.*)$/i', $match[1], $submatch ) ) {
1551 # Media link; trail not supported.
1552 $linkRegexp =
'/\[\[(.*?)\]\]/';
1558 # Other kind of link
1559 # Make sure its target is non-empty
1560 if ( isset( $match[1][0] ) && $match[1][0] ==
':' ) {
1561 $match[1] = substr( $match[1], 1 );
1563 if ( $match[1] !==
false && $match[1] !==
'' ) {
1565 $services->getContentLanguage()->linkTrail(),
1569 $trail = $submatch[1];
1573 $linkRegexp =
'/\[\[(.*?)\]\]' . preg_quote( $trail,
'/' ) .
'/';
1580 $target = $services->getTitleParser()->
1581 parseTitle( $linkTarget );
1583 if ( $target->getText() ==
'' && !$target->isExternal()
1586 $target =
$title->createFragmentTarget( $target->getFragment() );
1597 $comment = preg_replace(
1625 LinkTarget $linkTarget, $text, $wikiId =
null, $options = []
1627 if ( $wikiId !==
null && !$linkTarget->
isExternal() ) {
1628 $link = self::makeExternalLink(
1629 WikiMap::getForeignURL(
1633 : MediaWikiServices::getInstance()->getNamespaceInfo()->
1642 $link = self::link( $linkTarget, $text, [], [], $options );
1657 # :Foobar -- override special treatment of prefix (images, language links)
1658 # /Foobar -- convert to CurrentPage/Foobar
1659 # /Foobar/ -- convert to CurrentPage/Foobar, strip the initial and final / from text
1660 # ../ -- convert to CurrentPage, from CurrentPage/CurrentSubPage
1661 # ../Foobar -- convert to CurrentPage/Foobar,
1662 # (from CurrentPage/CurrentSubPage)
1663 # ../Foobar/ -- convert to CurrentPage/Foobar, use 'Foobar' as text
1664 # (from CurrentPage/CurrentSubPage)
1666 $ret = $target; #
default return value is no change
1668 # Some namespaces don't allow subpages,
1669 # so only perform processing if subpages are allowed
1671 $contextTitle && MediaWikiServices::getInstance()->getNamespaceInfo()->
1672 hasSubpages( $contextTitle->getNamespace() )
1674 $hash = strpos( $target,
'#' );
1675 if ( $hash !==
false ) {
1676 $suffix = substr( $target, $hash );
1677 $target = substr( $target, 0, $hash );
1682 $target = trim( $target );
1683 $contextPrefixedText = MediaWikiServices::getInstance()->getTitleFormatter()->
1684 getPrefixedText( $contextTitle );
1685 # Look at the first character
1686 if ( $target !=
'' && $target[0] ===
'/' ) {
1687 # / at end means we don't want the slash to be shown
1689 $trailingSlashes = preg_match_all(
'%(/+)$%', $target, $m );
1690 if ( $trailingSlashes ) {
1691 $noslash = $target = substr( $target, 1, -strlen( $m[0][0] ) );
1693 $noslash = substr( $target, 1 );
1696 $ret = $contextPrefixedText .
'/' . trim( $noslash ) . $suffix;
1697 if ( $text ===
'' ) {
1698 $text = $target . $suffix;
1699 } #
this might be changed
for ugliness reasons
1701 # check for .. subpage backlinks
1703 $nodotdot = $target;
1704 while ( strncmp( $nodotdot,
"../", 3 ) == 0 ) {
1706 $nodotdot = substr( $nodotdot, 3 );
1708 if ( $dotdotcount > 0 ) {
1709 $exploded = explode(
'/', $contextPrefixedText );
1710 if ( count( $exploded ) > $dotdotcount ) { # not allowed to go below top level page
1711 $ret = implode(
'/', array_slice( $exploded, 0, -$dotdotcount ) );
1712 # / at the end means don't show full path
1713 if ( substr( $nodotdot, -1, 1 ) ===
'/' ) {
1714 $nodotdot = rtrim( $nodotdot,
'/' );
1715 if ( $text ===
'' ) {
1716 $text = $nodotdot . $suffix;
1719 $nodotdot = trim( $nodotdot );
1720 if ( $nodotdot !=
'' ) {
1721 $ret .=
'/' . $nodotdot;
1750 $comment,
$title =
null, $local =
false, $wikiId =
null, $useParentheses =
true
1755 if ( $comment ==
'' || $comment ==
'*' ) {
1758 $formatted = self::formatComment( $comment,
$title, $local, $wikiId );
1759 if ( $useParentheses ) {
1760 $formatted =
wfMessage(
'parentheses' )->rawParams( $formatted )->escaped();
1761 $classNames =
'comment';
1763 $classNames =
'comment comment--without-parentheses';
1765 return " <span class=\"$classNames\">$formatted</span>";
1786 $useParentheses =
true
1789 $authority = RequestContext::getMain()->getAuthority();
1791 if ( $revRecord->
getComment( RevisionRecord::RAW ) ===
null ) {
1794 if ( $revRecord->
isDeleted( RevisionRecord::DELETED_COMMENT ) && $isPublic ) {
1795 $block =
" <span class=\"comment\">" .
wfMessage(
'rev-deleted-comment' )->escaped() .
"</span>";
1796 } elseif ( $revRecord->
userCan( RevisionRecord::DELETED_COMMENT, $authority ) ) {
1797 $comment = $revRecord->
getComment( RevisionRecord::FOR_THIS_USER, $authority );
1798 $block = self::commentBlock(
1799 $comment ? $comment->text :
null,
1806 $block =
" <span class=\"comment\">" .
wfMessage(
'rev-deleted-comment' )->escaped() .
"</span>";
1808 if ( $revRecord->
isDeleted( RevisionRecord::DELETED_COMMENT ) ) {
1809 $class = self::getRevisionDeletedClass( $revRecord );
1810 return " <span class=\"$class comment\">$block</span>";
1822 $stxt =
wfMessage(
'historyempty' )->escaped();
1824 $stxt =
wfMessage(
'nbytes' )->numParams( $size )->escaped();
1826 return "<span class=\"history-size mw-diff-bytes\" data-mw-bytes=\"$size\">$stxt</span>";
1847 return "</li>\n" . str_repeat(
"</ul>\n</li>\n", $level > 0 ? $level : 0 );
1861 public static function tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex =
false ) {
1862 $classes =
"toclevel-$level";
1863 if ( $sectionIndex !==
false ) {
1864 $classes .=
" tocsection-$sectionIndex";
1869 return Html::openElement(
'li', [
'class' => $classes ] )
1870 . Html::rawElement(
'a',
1871 [
'href' =>
"#$anchor" ],
1872 Html::element(
'span', [
'class' =>
'tocnumber' ], $tocnumber )
1874 . Html::rawElement(
'span', [
'class' =>
'toctext' ], $tocline )
1898 $lang =
$lang ?? RequestContext::getMain()->getLanguage();
1902 return '<div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading">'
1903 . Html::element(
'input', [
1904 'type' =>
'checkbox',
1906 'id' =>
'toctogglecheckbox',
1907 'class' =>
'toctogglecheckbox',
1908 'style' =>
'display:none',
1910 . Html::openElement(
'div', [
1911 'class' =>
'toctitle',
1912 'lang' =>
$lang->getHtmlCode(),
1913 'dir' =>
$lang->getDir(),
1915 .
'<h2 id="mw-toc-heading">' .
$title .
'</h2>'
1916 .
'<span class="toctogglespan">'
1917 . Html::label(
'',
'toctogglecheckbox', [
1918 'class' =>
'toctogglelabel',
1923 .
"</ul>\n</div>\n";
1937 foreach ( $tree as $section ) {
1938 if ( $section[
'toclevel'] > $lastLevel ) {
1939 $toc .= self::tocIndent();
1940 } elseif ( $section[
'toclevel'] < $lastLevel ) {
1941 $toc .= self::tocUnindent(
1942 $lastLevel - $section[
'toclevel'] );
1944 $toc .= self::tocLineEnd();
1947 $toc .= self::tocLine( $section[
'anchor'],
1948 $section[
'line'], $section[
'number'],
1949 $section[
'toclevel'], $section[
'index'] );
1950 $lastLevel = $section[
'toclevel'];
1952 $toc .= self::tocLineEnd();
1953 return self::tocList( $toc,
$lang );
1973 $link, $fallbackAnchor =
false
1975 $anchorEscaped = htmlspecialchars( $anchor );
1977 if ( $fallbackAnchor !==
false && $fallbackAnchor !== $anchor ) {
1978 $fallbackAnchor = htmlspecialchars( $fallbackAnchor );
1979 $fallback =
"<span id=\"$fallbackAnchor\"></span>";
1981 return "<h$level$attribs"
1982 .
"$fallback<span class=\"mw-headline\" id=\"$anchorEscaped\">$html</span>"
1994 $regex = MediaWikiServices::getInstance()->getContentLanguage()->linkTrail();
1996 if ( $trail !==
'' && preg_match( $regex, $trail, $m ) ) {
1997 list( , $inside, $trail ) = $m;
1999 return [ $inside, $trail ];
2034 $options = [
'verify' ]
2036 if ( $context ===
null ) {
2037 $context = RequestContext::getMain();
2041 if ( in_array(
'verify', $options,
true ) ) {
2042 $editCount = self::getRollbackEditCount( $revRecord,
true );
2043 if ( $editCount ===
false ) {
2048 $inner = self::buildRollbackLink( $revRecord, $context, $editCount );
2052 if ( !Hooks::runner()->onLinkerGenerateRollbackLink(
2053 $revRecord, $context, $options, $inner ) ) {
2057 if ( !in_array(
'noBrackets', $options,
true ) ) {
2058 $inner = $context->msg(
'brackets' )->rawParams( $inner )->escaped();
2061 if ( MediaWikiServices::getInstance()->getUserOptionsLookup()
2062 ->getBoolOption( $context->getUser(),
'showrollbackconfirmation' )
2064 $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
2065 $stats->increment(
'rollbackconfirmation.event.load' );
2066 $context->getOutput()->addModules(
'mediawiki.misc-authed-curate' );
2069 return '<span class="mw-rollback-link">' . $inner .
'</span>';
2101 $revQuery = MediaWikiServices::getInstance()->getRevisionStore()->getQueryInfo();
2103 $revIndex =
$dbr->indexExists(
'revision',
'page_timestamp', __METHOD__ )
2105 :
'rev_page_timestamp';
2108 [
'rev_user_text' =>
$revQuery[
'fields'][
'rev_user_text'],
'rev_deleted' ],
2109 [
'rev_page' => $revRecord->
getPageId() ],
2112 'USE INDEX' => [
'revision' => $revIndex ],
2113 'ORDER BY' =>
'rev_timestamp DESC',
2119 $revUser = $revRecord->
getUser( RevisionRecord::RAW );
2120 $revUserText = $revUser ? $revUser->getName() :
'';
2124 foreach (
$res as $row ) {
2125 if ( $row->rev_user_text != $revUserText ) {
2127 ( $row->rev_deleted & RevisionRecord::DELETED_TEXT
2128 || $row->rev_deleted & RevisionRecord::DELETED_USER
2172 $disableRollbackEditCountSpecialPage = [
'Recentchanges',
'Watchlist' ];
2174 if ( $context ===
null ) {
2175 $context = RequestContext::getMain();
2179 $revUser = $revRecord->
getUser();
2180 $revUserText = $revUser ? $revUser->getName() :
'';
2183 'action' =>
'rollback',
2184 'from' => $revUserText,
2185 'token' => $context->getUser()->getEditToken(
'rollback' ),
2189 'data-mw' =>
'interface',
2190 'title' => $context->msg(
'tooltip-rollback' )->text()
2193 $options = [
'known',
'noclasses' ];
2195 if ( $context->getRequest()->getBool(
'bot' ) ) {
2197 $query[
'hidediff'] =
'1';
2198 $query[
'bot'] =
'1';
2201 $disableRollbackEditCount =
false;
2203 foreach ( $disableRollbackEditCountSpecialPage as $specialPage ) {
2204 if ( $context->getTitle()->isSpecial( $specialPage ) ) {
2205 $disableRollbackEditCount =
true;
2211 if ( !$disableRollbackEditCount
2215 if ( !is_numeric( $editCount ) ) {
2216 $editCount = self::getRollbackEditCount( $revRecord,
false );
2220 $html = $context->msg(
'rollbacklinkcount-morethan' )
2223 $html = $context->msg(
'rollbacklinkcount' )->numParams( $editCount )->parse();
2226 return self::link(
$title, $html, $attrs, $query, $options );
2229 $html = $context->msg(
'rollbacklink' )->escaped();
2230 return self::link(
$title, $html, $attrs, $query, $options );
2243 if ( count( $hiddencats ) > 0 ) {
2244 # Construct the HTML
2245 $outText =
'<div class="mw-hiddenCategoriesExplanation">';
2246 $outText .=
wfMessage(
'hiddencategories' )->numParams( count( $hiddencats ) )->parseAsBlock();
2247 $outText .=
"</div><ul>\n";
2249 foreach ( $hiddencats as $titleObj ) {
2250 # If it's hidden, it must exist - no need to check with a LinkBatch
2252 . self::link( $titleObj,
null, [], [],
'known' )
2255 $outText .=
'</ul>';
2276 public static function titleAttrib( $name, $options =
null, array $msgParams = [] ) {
2277 $message =
wfMessage(
"tooltip-$name", $msgParams );
2278 if ( !$message->exists() ) {
2281 $tooltip = $message->text();
2282 # Compatibility: formerly some tooltips had [alt-.] hardcoded
2283 $tooltip = preg_replace(
"/ ?\[alt-.\]$/",
'', $tooltip );
2284 # Message equal to '-' means suppress it.
2285 if ( $tooltip ==
'-' ) {
2290 $options = (array)$options;
2292 if ( in_array(
'nonexisting', $options ) ) {
2293 $tooltip =
wfMessage(
'red-link-title', $tooltip ?:
'' )->text();
2295 if ( in_array(
'withaccess', $options ) ) {
2296 $accesskey = self::accesskey( $name );
2297 if ( $accesskey !==
false ) {
2299 if ( $tooltip ===
false || $tooltip ===
'' ) {
2300 $tooltip =
wfMessage(
'brackets', $accesskey )->text();
2302 $tooltip .=
wfMessage(
'word-separator' )->text();
2303 $tooltip .=
wfMessage(
'brackets', $accesskey )->text();
2325 if ( isset( self::$accesskeycache[$name] ) ) {
2326 return self::$accesskeycache[$name];
2329 $message =
wfMessage(
"accesskey-$name" );
2331 if ( !$message->exists() ) {
2334 $accesskey = $message->plain();
2335 if ( $accesskey ===
'' || $accesskey ===
'-' ) {
2336 # Per standard MW behavior, a value of '-' means to suppress the
2337 # attribute. It is thus forbidden to use this as an access key.
2342 self::$accesskeycache[$name] = $accesskey;
2343 return self::$accesskeycache[$name];
2365 $canHide = $performer->
isAllowed(
'deleterevision' );
2366 $canHideHistory = $performer->
isAllowed(
'deletedhistory' );
2367 if ( !$canHide && !( $revRecord->
getVisibility() && $canHideHistory ) ) {
2371 if ( !$revRecord->
userCan( RevisionRecord::DELETED_RESTRICTED, $performer ) ) {
2372 return self::revDeleteLinkDisabled( $canHide );
2374 $prefixedDbKey = MediaWikiServices::getInstance()->getTitleFormatter()->
2375 getPrefixedDBkey(
$title );
2376 if ( $revRecord->
getId() ) {
2380 'type' =>
'revision',
2381 'target' => $prefixedDbKey,
2382 'ids' => $revRecord->
getId()
2388 'type' =>
'archive',
2389 'target' => $prefixedDbKey,
2393 return self::revDeleteLink(
2395 $revRecord->
isDeleted( RevisionRecord::DELETED_RESTRICTED ),
2412 public static function revDeleteLink( $query = [], $restricted =
false, $delete =
true ) {
2414 $msgKey = $delete ?
'rev-delundel' :
'rev-showdeleted';
2415 $html =
wfMessage( $msgKey )->escaped();
2416 $tag = $restricted ?
'strong' :
'span';
2417 $link = self::link( $sp, $html, [], $query, [
'known',
'noclasses' ] );
2420 [
'class' =>
'mw-revdelundel-link' ],
2421 wfMessage(
'parentheses' )->rawParams( $link )->escaped()
2437 $msgKey = $delete ?
'rev-delundel' :
'rev-showdeleted';
2438 $html =
wfMessage( $msgKey )->escaped();
2439 $htmlParentheses =
wfMessage(
'parentheses' )->rawParams( $html )->escaped();
2440 return Xml::tags(
'span', [
'class' =>
'mw-revdelundel-link' ], $htmlParentheses );
2457 array $msgParams = [],
2460 $options = (array)$options;
2461 $options[] =
'withaccess';
2462 $tooltipTitle = $name;
2465 $skin = RequestContext::getMain()->getSkin();
2466 $isWatchlistExpiryEnabled = $skin->getConfig()->get(
'WatchlistExpiry' );
2467 if ( $name ===
'ca-unwatch' && $isWatchlistExpiryEnabled ) {
2468 $watchStore = MediaWikiServices::getInstance()->getWatchedItemStore();
2469 $watchedItem = $watchStore->getWatchedItem( $skin->getUser(),
2470 $skin->getRelevantTitle() );
2472 $diffInDays = $watchedItem->getExpiryInDays();
2474 if ( $diffInDays ) {
2475 $msgParams = [ $diffInDays ];
2477 $tooltipTitle =
'ca-unwatch-expiring';
2479 $tooltipTitle =
'ca-unwatch-expiring-hours';
2486 'title' => self::titleAttrib( $tooltipTitle, $options, $msgParams ),
2487 'accesskey' => self::accesskey( $name )
2489 if ( $attribs[
'title'] ===
false ) {
2490 unset( $attribs[
'title'] );
2492 if ( $attribs[
'accesskey'] ===
false ) {
2493 unset( $attribs[
'accesskey'] );
2505 public static function tooltip( $name, $options =
null ) {
2506 $tooltip = self::titleAttrib( $name, $options );
2507 if ( $tooltip ===
false ) {
2510 return Xml::expandAttributes( [
UserOptionsLookup $userOptionsLookup
$wgThumbUpright
Adjust width of upright images when parameter 'upright' is used This allows a nicer look for upright ...
$wgThumbLimits
Adjust thumbnails on image pages according to a user setting.
$wgDisableAnonTalk
Disable links to talk pages of anonymous users (IPs) in listings on special pages like page history,...
$wgSVGMaxSize
Don't scale a SVG larger than this.
$wgShowRollbackEditCount
The $wgShowRollbackEditCount variable is used to show how many edits can be rolled back.
$wgUploadMissingFileUrl
Point the upload link for missing files to an external URL, as with $wgUploadNavigationUrl.
$wgUploadNavigationUrl
Point the upload navigation link to an external URL Useful if you want to use a shared repository by ...
$wgResponsiveImages
Generate and use thumbnails suitable for screens with 1.5 and 2.0 pixel densities.
$wgEnableUploads
Allow users to upload files.
$wgMiserMode
Disable database-intensive features.
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.
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.
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 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 userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
static titleAttrib( $name, $options=null, array $msgParams=[])
Given the id of an interface element, constructs the appropriate title attribute from the system mess...
static accesskey( $name)
Given the id of an interface element, constructs the appropriate accesskey attribute from the system ...
static getRevisionDeletedClass(RevisionRecord $revisionRecord)
Returns css class of a deleted revision.
static formatAutocomments( $comment, $title=null, $local=false, $wikiId=null)
Converts autogenerated comments in edit summaries into section links.
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 makeCommentLink(LinkTarget $linkTarget, $text, $wikiId=null, $options=[])
Generates a link to the given LinkTarget.
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 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 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 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 makeThumbLink2(LinkTarget $title, $file, $frameParams=[], $handlerParams=[], $time=false, $query="", array $classes=[])
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 tooltipAndAccesskeyAttribs( $name, array $msgParams=[], $options=null)
Returns the attributes for the tooltip and access key.
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 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.
static guessSectionNameFromStrippedText( $text)
Like guessSectionNameFromWikiText(), but takes already-stripped text as input.
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 escapeRegexReplacement( $string)
Escape a string to make it suitable for inclusion in a preg_replace() replacement parameter.
Represents a page (or page fragment) title within MediaWiki.
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