53 $services = MediaWikiServices::getInstance();
111 wfWarn( __METHOD__ .
': Requires $target to be a LinkTarget object.', 2 );
112 return "<!-- ERROR -->$html";
115 if ( is_string(
$query ) ) {
117 wfDeprecated( __METHOD__ .
' with parameter $query as string (should be array)',
'1.20' );
121 $services = MediaWikiServices::getInstance();
125 if ( !isset(
$options[
'stubThreshold'] ) ) {
126 $defaultLinkRenderer =
$services->getLinkRenderer();
127 $options[
'stubThreshold'] = $defaultLinkRenderer->getStubThreshold();
130 ->createFromLegacyOptions(
$options );
135 if (
$html !==
null ) {
140 if ( in_array(
'known',
$options,
true ) ) {
142 } elseif ( in_array(
'broken',
$options,
true ) ) {
144 } elseif ( in_array(
'noclasses',
$options,
true ) ) {
187 $ret =
"<a class=\"mw-selflink selflink\">{$prefix}{$html}</a>{$trail}";
188 if ( !Hooks::run(
'SelfLinkBegin', [ $nt, &
$html, &$trail, &$prefix, &
$ret ] ) ) {
193 $html = htmlspecialchars( $nt->getPrefixedText() );
196 return "<a class=\"mw-selflink selflink\">{$prefix}{$html}{$inside}</a>{$trail}";
213 if ( MWNamespace::exists( $namespace ) ) {
215 $name =
$context->msg(
'blanknamespace' )->text();
217 $name =
$wgContLang->getFormattedNsText( $namespace );
219 return $context->msg(
'invalidtitle-knownnamespace', $namespace, $name, $title )->text();
221 return $context->msg(
'invalidtitle-unknownnamespace', $namespace, $title )->text();
236 $ret = SpecialPage::getTitleValueFor( $name, $subpage, $target->
getFragment() );
252 $basename = strrchr( $url,
'/' );
253 if (
false === $basename ) {
256 $basename = substr( $basename, 1 );
276 $success = Hooks::run(
'LinkerMakeExternalImage', [ &$url, &$alt, &$img ] );
278 wfDebug(
"Hook LinkerMakeExternalImage changed the output of external image "
279 .
"with url {$url} and alt text {$alt} to {$img}\n",
true );
282 return Html::element(
'img',
326 $query =
"", $widthOption =
null
330 if ( !Hooks::run(
'ImageBeforeProduceHTML', [ &$dummy, &$title,
335 if ( $file && !$file->allowInlineDisplay() ) {
336 wfDebug( __METHOD__ .
': ' . $title->getPrefixedDBkey() .
" does not allow inline display\n" );
342 if ( !isset( $frameParams[
'align'] ) ) {
343 $frameParams[
'align'] =
'';
345 if ( !isset( $frameParams[
'alt'] ) ) {
346 $frameParams[
'alt'] =
'';
348 if ( !isset( $frameParams[
'title'] ) ) {
349 $frameParams[
'title'] =
'';
351 if ( !isset( $frameParams[
'class'] ) ) {
352 $frameParams[
'class'] =
'';
355 $prefix = $postfix =
'';
357 if (
'center' == $frameParams[
'align'] ) {
358 $prefix =
'<div class="center">';
360 $frameParams[
'align'] =
'none';
363 if ( isset(
$handlerParams[
'height'] ) && $file->isVectorized() ) {
372 if ( isset( $frameParams[
'thumbnail'] )
373 || isset( $frameParams[
'manualthumb'] )
374 || isset( $frameParams[
'framed'] )
375 || isset( $frameParams[
'frameless'] )
380 if ( $widthOption ===
null || !isset(
$wgThumbLimits[$widthOption] ) ) {
385 if ( isset( $frameParams[
'upright'] ) && $frameParams[
'upright'] == 0 ) {
392 $prefWidth = isset( $frameParams[
'upright'] ) ?
393 round(
$wgThumbLimits[$widthOption] * $frameParams[
'upright'], -1 ) :
399 $prefWidth <
$handlerParams[
'width'] || $file->isVectorized() ) ) {
405 if ( isset( $frameParams[
'thumbnail'] ) || isset( $frameParams[
'manualthumb'] )
406 || isset( $frameParams[
'framed'] )
408 # Create a thumbnail. Alignment depends on the writing direction of
409 # the page content language (right-aligned for LTR languages,
410 # left-aligned for RTL languages)
411 # If a thumbnail width has not been provided, it is set
412 # to the default user option as specified in Language*.php
413 if ( $frameParams[
'align'] ==
'' ) {
414 $frameParams[
'align'] =
$parser->getTargetLanguage()->alignEnd();
421 if ( $file && isset( $frameParams[
'frameless'] ) ) {
422 $srcWidth = $file->getWidth( $page );
423 # For "frameless" option: do not present an image bigger than the
424 # source (for bitmap-style images). This is the same behavior as the
425 # "thumb" option does it already.
426 if ( $srcWidth && !$file->mustRender() &&
$handlerParams[
'width'] > $srcWidth ) {
432 # Create a resized image, without the additional thumbnail features
443 'alt' => $frameParams[
'alt'],
444 'title' => $frameParams[
'title'],
445 'valign' => isset( $frameParams[
'valign'] ) ? $frameParams[
'valign'] :
false,
446 'img-class' => $frameParams[
'class'] ];
447 if ( isset( $frameParams[
'border'] ) ) {
448 $params[
'img-class'] .= (
$params[
'img-class'] !==
'' ?
' ' :
'' ) .
'thumbborder';
454 if ( $frameParams[
'align'] !=
'' ) {
455 $s =
"<div class=\"float{$frameParams['align']}\">{$s}</div>";
457 return str_replace(
"\n",
' ', $prefix .
$s . $postfix );
470 if ( isset( $frameParams[
'link-url'] ) && $frameParams[
'link-url'] !==
'' ) {
471 $mtoParams[
'custom-url-link'] = $frameParams[
'link-url'];
472 if ( isset( $frameParams[
'link-target'] ) ) {
473 $mtoParams[
'custom-target-link'] = $frameParams[
'link-target'];
476 $extLinkAttrs =
$parser->getExternalLinkAttribs( $frameParams[
'link-url'] );
477 foreach ( $extLinkAttrs as $name => $val ) {
479 $mtoParams[
'parser-extlink-' .
$name] = $val;
482 } elseif ( isset( $frameParams[
'link-title'] ) && $frameParams[
'link-title'] !==
'' ) {
483 $mtoParams[
'custom-title-link'] = Title::newFromLinkTarget(
484 self::normaliseSpecialPage( $frameParams[
'link-title'] )
486 } elseif ( !empty( $frameParams[
'no-link'] ) ) {
489 $mtoParams[
'desc-link'] =
true;
490 $mtoParams[
'desc-query'] =
$query;
508 $align =
'right',
$params = [], $framed =
false, $manualthumb =
""
516 $frameParams[
'framed'] =
true;
518 if ( $manualthumb ) {
519 $frameParams[
'manualthumb'] = $manualthumb;
536 $exists = $file && $file->exists();
539 if ( !isset( $frameParams[
'align'] ) ) {
540 $frameParams[
'align'] =
'right';
542 if ( !isset( $frameParams[
'alt'] ) ) {
543 $frameParams[
'alt'] =
'';
545 if ( !isset( $frameParams[
'title'] ) ) {
546 $frameParams[
'title'] =
'';
548 if ( !isset( $frameParams[
'caption'] ) ) {
549 $frameParams[
'caption'] =
'';
554 $handlerParams[
'width'] = isset( $frameParams[
'upright'] ) ? 130 : 180;
558 $manualthumb =
false;
563 if ( isset( $frameParams[
'manualthumb'] ) ) {
564 # Use manually specified thumbnail
565 $manual_title = Title::makeTitleSafe(
NS_FILE, $frameParams[
'manualthumb'] );
566 if ( $manual_title ) {
575 } elseif ( isset( $frameParams[
'framed'] ) ) {
580 # Do not present an image bigger than the source, for bitmap-style images
581 # This is a hack to maintain compatibility with arbitrary pre-1.10 behavior
582 $srcWidth = $file->getWidth( $page );
583 if ( $srcWidth && !$file->mustRender() &&
$handlerParams[
'width'] > $srcWidth ) {
590 $outerWidth = $thumb->getWidth() + 2;
596 # ThumbnailImage::toHtml() already adds page= onto the end of DjVu URLs
597 # So we don't need to pass it here in $query. However, the URL for the
598 # zoom icon still needs it, so we make a unique query for it. See T16771
599 $url = $title->getLocalURL(
$query );
604 && !isset( $frameParams[
'link-title'] )
605 && !isset( $frameParams[
'link-url'] )
606 && !isset( $frameParams[
'no-link'] ) ) {
607 $frameParams[
'link-url'] = $url;
610 $s =
"<div class=\"thumb t{$frameParams['align']}\">"
611 .
"<div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">";
616 } elseif ( !$thumb ) {
617 $s .=
wfMessage(
'thumbnail_error',
'' )->escaped();
620 if ( !$noscale && !$manualthumb ) {
624 'alt' => $frameParams[
'alt'],
625 'title' => $frameParams[
'title'],
626 'img-class' => ( isset( $frameParams[
'class'] ) && $frameParams[
'class'] !==
''
627 ? $frameParams[
'class'] .
' '
628 :
'' ) .
'thumbimage'
632 if ( isset( $frameParams[
'framed'] ) ) {
635 $zoomIcon = Html::rawElement(
'div', [
'class' =>
'magnify' ],
636 Html::rawElement(
'a', [
638 'class' =>
'internal',
643 $s .=
' <div class="thumbcaption">' . $zoomIcon . $frameParams[
'caption'] .
"</div></div></div>";
644 return str_replace(
"\n",
' ',
$s );
659 $hp15[
'width'] = round( $hp[
'width'] * 1.5 );
661 $hp20[
'width'] = $hp[
'width'] * 2;
662 if ( isset( $hp[
'height'] ) ) {
663 $hp15[
'height'] = round( $hp[
'height'] * 1.5 );
664 $hp20[
'height'] = $hp[
'height'] * 2;
667 $thumb15 = $file->transform( $hp15 );
668 $thumb20 = $file->transform( $hp20 );
669 if ( $thumb15 && !$thumb15->isError() && $thumb15->getUrl() !== $thumb->getUrl() ) {
670 $thumb->responsiveUrls[
'1.5'] = $thumb15->getUrl();
672 if ( $thumb20 && !$thumb20->isError() && $thumb20->getUrl() !== $thumb->getUrl() ) {
673 $thumb->responsiveUrls[
'2'] = $thumb20->getUrl();
691 $query =
'', $unused1 =
'', $unused2 =
'',
$time =
false
693 if ( !$title instanceof
Title ) {
694 wfWarn( __METHOD__ .
': Requires $title to be a Title object.' );
695 return "<!-- ERROR -->" . htmlspecialchars( $label );
699 if ( $label ==
'' ) {
700 $label = $title->getPrefixedText();
702 $encLabel = htmlspecialchars( $label );
716 [
'class' =>
'mw-redirect' ],
718 [
'known',
'noclasses' ]
724 return '<a href="' . htmlspecialchars( $href ) .
'" class="new" title="' .
725 htmlspecialchars( $title->getPrefixedText(), ENT_QUOTES ) .
'">' .
742 $q =
'wpDestFile=' . $destFile->getPartialURL();
752 $upload = SpecialPage::getTitleFor(
'Upload' );
753 return $upload->getLocalURL( $q );
784 if ( $file && $file->exists() ) {
785 $url = $file->getUrl();
792 $alt = $title->getText();
804 if ( !Hooks::run(
'LinkerMakeMediaLinkFile',
806 wfDebug(
"Hook LinkerMakeMediaLinkFile changed the output of link "
807 .
"with url {$url} and text {$html} to {$ret}\n",
true );
826 $key = strtolower( $name );
844 $linktype =
'',
$attribs = [], $title =
null
849 $class .=
" $linktype";
852 $class .=
" {$attribs['class']}";
857 $text = htmlspecialchars( $text );
863 $newRel = Parser::getExternalLinkRel( $url, $title );
866 } elseif ( $newRel !==
'' ) {
868 $newRels = explode(
' ', $newRel );
869 $oldRels = explode(
' ',
$attribs[
'rel'] );
870 $combined = array_unique( array_merge( $newRels, $oldRels ) );
871 $attribs[
'rel'] = implode(
' ', $combined );
874 $success = Hooks::run(
'LinkerMakeExternalLink',
877 wfDebug(
"Hook LinkerMakeExternalLink changed the output of link "
878 .
"with url {$url} and text {$text} to {$link}\n",
true );
882 return Html::rawElement(
'a',
$attribs, $text );
893 public static function userLink( $userId, $userName, $altUserName =
false ) {
894 $classes =
'mw-userlink';
896 if ( $userId == 0 ) {
900 $classes .=
' mw-extuserlink';
901 } elseif ( $altUserName ===
false ) {
902 $altUserName = IP::prettifyIP( $userName );
904 $classes .=
' mw-anonuserlink';
906 $page = Title::makeTitle( NS_USER, $userName );
911 '<bdi>' . htmlspecialchars( $altUserName !==
false ? $altUserName : $userName ) .
'</bdi>';
914 ?
self::link( $page, $linkText, [
'class' => $classes ] )
915 : Html::rawElement(
'span', [
'class' => $classes ], $linkText );
932 $userId, $userText, $redContribsWhenNoEdits =
false, $flags = 0, $edits =
null
937 $addEmailLink = $flags & self::TOOL_LINKS_EMAIL && $userId;
951 $attribs[
'class'] =
'mw-usertoollinks-contribs';
952 if ( $redContribsWhenNoEdits ) {
953 if ( intval( $edits ) === 0 && $edits !== 0 ) {
955 $edits = $user->getEditCount();
957 if ( $edits === 0 ) {
961 $contribsPage = SpecialPage::getTitleFor(
'Contributions', $userText );
965 if ( $blockable &&
$wgUser->isAllowed(
'block' ) ) {
969 if ( $addEmailLink &&
$wgUser->canSendEmail() ) {
973 Hooks::run(
'UserToolLinksEdit', [ $userId, $userText, &$items ] );
976 return wfMessage(
'word-separator' )->escaped()
977 .
'<span class="mw-usertoollinks">'
978 .
wfMessage(
'parentheses' )->rawParams(
$wgLang->pipeList( $items ) )->escaped()
1004 $userTalkPage = Title::makeTitle(
NS_USER_TALK, $userText );
1005 $moreLinkAttribs[
'class'] =
'mw-usertoollinks-talk';
1007 wfMessage(
'talkpagelinktext' )->escaped(),
1009 return $userTalkLink;
1019 $blockPage = SpecialPage::getTitleFor(
'Block', $userText );
1020 $moreLinkAttribs[
'class'] =
'mw-usertoollinks-block';
1033 $emailPage = SpecialPage::getTitleFor(
'Emailuser', $userText );
1034 $moreLinkAttribs[
'class'] =
'mw-usertoollinks-mail';
1049 if (
$rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) {
1051 } elseif (
$rev->userCan( Revision::DELETED_USER ) ) {
1053 $rev->getUserText( Revision::FOR_THIS_USER ) );
1057 if (
$rev->isDeleted( Revision::DELETED_USER ) ) {
1058 return '<span class="history-deleted">' .
$link .
'</span>';
1071 if (
$rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) {
1073 } elseif (
$rev->userCan( Revision::DELETED_USER ) ) {
1074 $userId =
$rev->getUser( Revision::FOR_THIS_USER );
1075 $userText =
$rev->getUserText( Revision::FOR_THIS_USER );
1081 if (
$rev->isDeleted( Revision::DELETED_USER ) ) {
1082 return ' <span class="history-deleted">' .
$link .
'</span>';
1110 $comment, $title =
null, $local =
false, $wikiId =
null
1112 # Sanitize text a bit:
1113 $comment = str_replace(
"\n",
" ", $comment );
1114 # Allow HTML entities (for T15815)
1115 $comment = Sanitizer::escapeHtmlAllowEntities( $comment );
1117 # Render autocomments and make links:
1142 $comment, $title =
null, $local =
false, $wikiId =
null
1150 $comment = preg_replace_callback(
1156 '!(?:(?<=(.)))?/\*\s*(.*?)\s*\*/(?:(?=(.)))?!',
1157 function ( $match ) use ( $title, $local, $wikiId, &$append ) {
1161 $match += [
'',
'',
'',
'' ];
1163 $pre = $match[1] !==
'';
1165 $post = $match[3] !==
'';
1169 'FormatAutocomments',
1170 [ &$comment,
$pre,
$auto, $post, $title, $local, $wikiId ]
1173 if ( $comment ===
null ) {
1177 # Remove links that a user may have manually put in the autosummary
1178 # This could be improved by copying as much of Parser::stripSectionName as desired.
1183 $section = substr( Parser::guessSectionNameFromStrippedText(
$section ), 1 );
1187 $sectionTitle = Title::makeTitleSafe( $title->getNamespace(),
1190 if ( $sectionTitle ) {
1197 # written summary $presep autocomment (summary )
1198 $pre =
wfMessage(
'autocomment-prefix' )->inContentLanguage()->escaped();
1201 # autocomment $postsep written summary ( summary)
1202 $auto .=
wfMessage(
'colon-separator' )->inContentLanguage()->escaped();
1204 $auto =
'<span class="autocomment">' .
$auto .
'</span>';
1206 .
'<span dir="auto">' .
$auto;
1207 $append .=
'</span>';
1213 return $comment . $append;
1235 $comment, $title =
null, $local =
false, $wikiId =
null
1237 return preg_replace_callback(
1240 :? # ignore optional leading colon
1241 ([^\]|]+) # 1. link target; page names cannot include ] or |
1244 # Stop matching at ]] without relying on backtracking.
1248 ([^[]*) # 3. link trail (the text up until the next link)
1250 function ( $match ) use ( $title, $local, $wikiId ) {
1253 $medians =
'(?:' . preg_quote( MWNamespace::getCanonicalName(
NS_MEDIA ),
'/' ) .
'|';
1256 $comment = $match[0];
1258 # fix up urlencoded title texts (copied from Parser::replaceInternalLinks)
1259 if ( strpos( $match[1],
'%' ) !==
false ) {
1261 rawurldecode( $match[1] ),
1262 [
'<' =>
'<',
'>' =>
'>' ]
1266 # Handle link renaming [[foo|text]] will show link as "text"
1267 if ( $match[2] !=
"" ) {
1274 if ( preg_match(
'/^' . $medians .
'(.*)$/i', $match[1], $submatch ) ) {
1275 # Media link; trail not supported.
1276 $linkRegexp =
'/\[\[(.*?)\]\]/';
1277 $title = Title::makeTitleSafe(
NS_FILE, $submatch[1] );
1282 # Other kind of link
1283 # Make sure its target is non-empty
1284 if ( isset( $match[1][0] ) && $match[1][0] ==
':' ) {
1285 $match[1] = substr( $match[1], 1 );
1287 if ( $match[1] !==
false && $match[1] !==
'' ) {
1288 if ( preg_match(
$wgContLang->linkTrail(), $match[3], $submatch ) ) {
1289 $trail = $submatch[1];
1293 $linkRegexp =
'/\[\[(.*?)\]\]' . preg_quote( $trail,
'/' ) .
'/';
1299 $target = Title::newFromText( $linkTarget );
1301 if ( $target->getText() ==
'' && !$target->isExternal()
1302 && !$local && $title
1304 $target = $title->createFragmentTarget( $target->getFragment() );
1313 $comment = preg_replace(
1343 if ( $wikiId !==
null && !$linkTarget->
isExternal() ) {
1349 : MWNamespace::getCanonicalName( $linkTarget->
getNamespace() ) .
':'
1372 # :Foobar -- override special treatment of prefix (images, language links)
1373 # /Foobar -- convert to CurrentPage/Foobar
1374 # /Foobar/ -- convert to CurrentPage/Foobar, strip the initial and final / from text
1375 # ../ -- convert to CurrentPage, from CurrentPage/CurrentSubPage
1376 # ../Foobar -- convert to CurrentPage/Foobar,
1377 # (from CurrentPage/CurrentSubPage)
1378 # ../Foobar/ -- convert to CurrentPage/Foobar, use 'Foobar' as text
1379 # (from CurrentPage/CurrentSubPage)
1381 $ret = $target; #
default return value is no change
1383 # Some namespaces don't allow subpages,
1384 # so only perform processing if subpages are allowed
1385 if ( $contextTitle && MWNamespace::hasSubpages( $contextTitle->getNamespace() ) ) {
1386 $hash = strpos( $target,
'#' );
1387 if ( $hash !==
false ) {
1388 $suffix = substr( $target, $hash );
1389 $target = substr( $target, 0, $hash );
1394 $target = trim( $target );
1395 # Look at the first character
1396 if ( $target !=
'' && $target[0] ===
'/' ) {
1397 # / at end means we don't want the slash to be shown
1399 $trailingSlashes = preg_match_all(
'%(/+)$%', $target, $m );
1400 if ( $trailingSlashes ) {
1401 $noslash = $target = substr( $target, 1, -strlen( $m[0][0] ) );
1403 $noslash = substr( $target, 1 );
1406 $ret = $contextTitle->getPrefixedText() .
'/' . trim( $noslash ) . $suffix;
1407 if ( $text ===
'' ) {
1408 $text = $target . $suffix;
1409 } #
this might be changed
for ugliness
reasons
1411 # check for .. subpage backlinks
1413 $nodotdot = $target;
1414 while ( strncmp( $nodotdot,
"../", 3 ) == 0 ) {
1416 $nodotdot = substr( $nodotdot, 3 );
1418 if ( $dotdotcount > 0 ) {
1419 $exploded = explode(
'/', $contextTitle->getPrefixedText() );
1420 if ( count( $exploded ) > $dotdotcount ) { # not allowed to go
below top level page
1421 $ret = implode(
'/', array_slice( $exploded, 0, -$dotdotcount ) );
1422 # / at the end means don't show full path
1423 if ( substr( $nodotdot, -1, 1 ) ===
'/' ) {
1424 $nodotdot = rtrim( $nodotdot,
'/' );
1425 if ( $text ===
'' ) {
1426 $text = $nodotdot . $suffix;
1429 $nodotdot = trim( $nodotdot );
1430 if ( $nodotdot !=
'' ) {
1431 $ret .=
'/' . $nodotdot;
1456 $comment, $title =
null, $local =
false, $wikiId =
null
1461 if ( $comment ==
'' || $comment ==
'*' ) {
1465 $formatted =
wfMessage(
'parentheses' )->rawParams( $formatted )->escaped();
1466 return " <span class=\"comment\">$formatted</span>";
1481 if (
$rev->getComment( Revision::RAW ) ==
"" ) {
1484 if (
$rev->isDeleted( Revision::DELETED_COMMENT ) && $isPublic ) {
1485 $block =
" <span class=\"comment\">" .
wfMessage(
'rev-deleted-comment' )->escaped() .
"</span>";
1486 } elseif (
$rev->userCan( Revision::DELETED_COMMENT ) ) {
1488 $rev->getTitle(), $local );
1490 $block =
" <span class=\"comment\">" .
wfMessage(
'rev-deleted-comment' )->escaped() .
"</span>";
1492 if (
$rev->isDeleted( Revision::DELETED_COMMENT ) ) {
1493 return " <span class=\"history-deleted\">$block</span>";
1505 $stxt =
wfMessage(
'historyempty' )->escaped();
1507 $stxt =
wfMessage(
'nbytes' )->numParams( $size )->escaped();
1508 $stxt =
wfMessage(
'parentheses' )->rawParams( $stxt )->escaped();
1510 return "<span class=\"history-size\">$stxt</span>";
1531 return "</li>\n" . str_repeat(
"</ul>\n</li>\n", $level > 0 ? $level : 0 );
1545 public static function tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex =
false ) {
1546 $classes =
"toclevel-$level";
1547 if ( $sectionIndex !==
false ) {
1548 $classes .=
" tocsection-$sectionIndex";
1553 return "\n" . Html::openElement(
'li', [
'class' => $classes ] )
1554 . Html::rawElement(
'a',
1555 [
'href' =>
"#$anchor" ],
1556 Html::element(
'span', [
'class' =>
'tocnumber' ], $tocnumber )
1558 . Html::rawElement(
'span', [
'class' =>
'toctext' ], $tocline )
1585 return '<div id="toc" class="toc">'
1586 . Html::openElement(
'div', [
1587 'class' =>
'toctitle',
1588 'lang' =>
$lang->getHtmlCode(),
1589 'dir' =>
$lang->getDir(),
1591 .
'<h2>' . $title .
"</h2></div>\n"
1593 .
"</ul>\n</div>\n";
1608 if (
$section[
'toclevel'] > $lastLevel ) {
1610 } elseif (
$section[
'toclevel'] < $lastLevel ) {
1612 $lastLevel -
$section[
'toclevel'] );
1643 $link, $fallbackAnchor =
false
1645 $anchorEscaped = htmlspecialchars( $anchor );
1647 if ( $fallbackAnchor !==
false && $fallbackAnchor !== $anchor ) {
1648 $fallbackAnchor = htmlspecialchars( $fallbackAnchor );
1649 $fallback =
"<span id=\"$fallbackAnchor\"></span>";
1651 $ret =
"<h$level$attribs"
1652 .
"$fallback<span class=\"mw-headline\" id=\"$anchorEscaped\">$html</span>"
1669 if ( $trail !==
'' ) {
1671 if ( preg_match( $regex, $trail, $m ) ) {
1676 return [ $inside, $trail ];
1714 if ( in_array(
'verify',
$options,
true ) ) {
1716 if ( $editCount ===
false ) {
1723 if ( !in_array(
'noBrackets',
$options,
true ) ) {
1724 $inner =
$context->msg(
'brackets' )->rawParams( $inner )->escaped();
1727 return '<span class="mw-rollback-link">' . $inner .
'</span>';
1758 [
'rev_user_text' =>
$revQuery[
'fields'][
'rev_user_text'],
'rev_deleted' ],
1760 [
'rev_page' =>
$rev->getTitle()->getArticleID() ],
1763 'USE INDEX' => [
'revision' =>
'page_timestamp' ],
1764 'ORDER BY' =>
'rev_timestamp DESC',
1772 foreach (
$res as $row ) {
1773 if (
$rev->getUserText( Revision::RAW ) != $row->rev_user_text ) {
1775 ( $row->rev_deleted & Revision::DELETED_TEXT
1776 || $row->rev_deleted & Revision::DELETED_USER
1813 $disableRollbackEditCountSpecialPage = [
'Recentchanges',
'Watchlist' ];
1819 $title =
$rev->getTitle();
1821 'action' =>
'rollback',
1822 'from' =>
$rev->getUserText(),
1823 'token' =>
$context->getUser()->getEditToken(
'rollback' ),
1826 'data-mw' =>
'interface',
1827 'title' =>
$context->msg(
'tooltip-rollback' )->text(),
1829 $options = [
'known',
'noclasses' ];
1831 if (
$context->getRequest()->getBool(
'bot' ) ) {
1833 $query[
'hidediff'] =
'1';
1836 $disableRollbackEditCount =
false;
1838 foreach ( $disableRollbackEditCountSpecialPage as $specialPage ) {
1839 if (
$context->getTitle()->isSpecial( $specialPage ) ) {
1840 $disableRollbackEditCount =
true;
1846 if ( !$disableRollbackEditCount
1850 if ( !is_numeric( $editCount ) ) {
1858 $html =
$context->msg(
'rollbacklinkcount' )->numParams( $editCount )->parse();
1898 if ( $more instanceof
Message ) {
1899 $more = $more->toString();
1904 MediaWikiServices::getInstance()->getLinkRenderer()
1906 return $formatter->format( $templates,
$type, $more );
1919 if ( count( $hiddencats ) > 0 ) {
1920 # Construct the HTML
1921 $outText =
'<div class="mw-hiddenCategoriesExplanation">';
1922 $outText .=
wfMessage(
'hiddencategories' )->numParams( count( $hiddencats ) )->parseAsBlock();
1923 $outText .=
"</div><ul>\n";
1925 foreach ( $hiddencats as $titleObj ) {
1926 # If it's hidden, it must exist - no need to check with a LinkBatch
1928 .
self::link( $titleObj,
null, [], [],
'known' )
1931 $outText .=
'</ul>';
1950 return htmlspecialchars(
$wgLang->formatSize( $size ) );
1970 $message =
wfMessage(
"tooltip-$name", $msgParams );
1971 if ( !$message->exists() ) {
1974 $tooltip = $message->text();
1975 # Compatibility: formerly some tooltips had [alt-.] hardcoded
1976 $tooltip = preg_replace(
"/ ?\[alt-.\]$/",
'', $tooltip );
1977 # Message equal to '-' means suppress it.
1978 if ( $tooltip ==
'-' ) {
1985 if ( in_array(
'nonexisting',
$options ) ) {
1986 $tooltip =
wfMessage(
'red-link-title', $tooltip ?:
'' )->
text();
1988 if ( in_array(
'withaccess',
$options ) ) {
1990 if ( $accesskey !==
false ) {
1992 if ( $tooltip ===
false || $tooltip ===
'' ) {
1993 $tooltip =
wfMessage(
'brackets', $accesskey )->text();
1995 $tooltip .=
wfMessage(
'word-separator' )->text();
1996 $tooltip .=
wfMessage(
'brackets', $accesskey )->text();
2018 if ( isset( self::$accesskeycache[$name] ) ) {
2019 return self::$accesskeycache[
$name];
2022 $message =
wfMessage(
"accesskey-$name" );
2024 if ( !$message->exists() ) {
2027 $accesskey = $message->plain();
2028 if ( $accesskey ===
'' || $accesskey ===
'-' ) {
2029 # @todo FIXME: Per standard MW behavior, a value of '-' means to suppress the
2030 # attribute, but this is broken for accesskey: that might be a useful
2036 self::$accesskeycache[
$name] = $accesskey;
2037 return self::$accesskeycache[
$name];
2054 $canHide = $user->isAllowed(
'deleterevision' );
2055 if ( !$canHide && !(
$rev->getVisibility() && $user->isAllowed(
'deletedhistory' ) ) ) {
2059 if ( !
$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
2062 if (
$rev->getId() ) {
2066 'type' =>
'revision',
2067 'target' => $title->getPrefixedDBkey(),
2068 'ids' =>
$rev->getId()
2074 'type' =>
'archive',
2075 'target' => $title->getPrefixedDBkey(),
2076 'ids' =>
$rev->getTimestamp()
2080 $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide );
2095 $sp = SpecialPage::getTitleFor(
'Revisiondelete' );
2096 $msgKey = $delete ?
'rev-delundel' :
'rev-showdeleted';
2098 $tag = $restricted ?
'strong' :
'span';
2102 [
'class' =>
'mw-revdelundel-link' ],
2117 $msgKey = $delete ?
'rev-delundel' :
'rev-showdeleted';
2119 $htmlParentheses =
wfMessage(
'parentheses' )->rawParams(
$html )->escaped();
2120 return Xml::tags(
'span', [
'class' =>
'mw-revdelundel-link' ], $htmlParentheses );
2137 array $msgParams = [],
2147 if (
$attribs[
'title'] ===
false ) {
2150 if (
$attribs[
'accesskey'] ===
false ) {
2165 if ( $tooltip ===
false ) {
2168 return Xml::expandAttributes( [
$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
Uploads have to be specially set up to be secure.
$wgMiserMode
Disable database-intensive features.
wfGetLangObj( $langcode=false)
Return a Language object from $langcode.
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.
wfFindFile( $title, $options=[])
Find a file.
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...
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
if(! $wgRequest->checkUrlExtension()) if(isset($_SERVER[ 'PATH_INFO']) &&$_SERVER[ 'PATH_INFO'] !='') if(! $wgEnableAPI) $wgTitle
static getUserLinkTitle( $userName)
Get a target Title to link a username.
static isExternal( $username)
Tells whether the username is external or not.
Marks HTML that shouldn't be escaped.
Some internal bits split of from Skin.php.
static tocList( $toc, $lang=false)
Wraps the TOC in a table and provides the hide/collapse javascript.
static generateRollback( $rev, IContextSource $context=null, $options=[ 'verify'])
Generate a rollback link for a given revision.
static makeMediaLinkFile(Title $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 makeThumbLink2(Title $title, $file, $frameParams=[], $handlerParams=[], $time=false, $query="")
static formatSize( $size)
static accesskey( $name)
Given the id of an interface element, constructs the appropriate accesskey attribute from the system ...
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 getLinkColour(LinkTarget $t, $threshold)
Return the CSS colour of a known link.
static makeImageLink(Parser $parser, Title $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 linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
static generateTOC( $tree, $lang=false)
Generate a table of contents from a section tree.
static makeExternalImage( $url, $alt='')
Return the code for images which were added via external links, via Parser::maybeMakeExternalImage().
static userToolLinksRedContribs( $userId, $userText, $edits=null)
Alias for userToolLinks( $userId, $userText, true );.
static buildRollbackLink( $rev, IContextSource $context=null, $editCount=false)
Build a raw rollback link, useful for collections of "tool" links.
static makeCommentLink(LinkTarget $linkTarget, $text, $wikiId=null, $options=[])
Generates a link to the given Title.
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 getRollbackEditCount( $rev, $verify)
This function will return the number of revisions which a rollback would revert and,...
static normalizeSubpageLink( $contextTitle, $target, &$text)
static revComment(Revision $rev, $local=false, $isPublic=false)
Wrap and format the given revision's comment block, if the current user is allowed to view it.
const TOOL_LINKS_NOBLOCK
Flags for userToolLinks()
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 revUserLink( $rev, $isPublic=false)
Generate a user link if the current user is allowed to view it.
static commentBlock( $comment, $title=null, $local=false, $wikiId=null)
Wrap a comment in standard punctuation and formatting if it's non-empty, otherwise return empty strin...
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
static revUserTools( $rev, $isPublic=false)
Generate a user tool link cluster if the current user is allowed to view it.
static emailLink( $userId, $userText)
static makeThumbLinkObj(Title $title, $file, $label='', $alt, $align='right', $params=[], $framed=false, $manualthumb="")
Make HTML for a thumbnail including image, border and caption.
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 userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null)
Generate standard user tool links (talk, contributions, block link, etc.)
static formatRevisionSize( $size)
static tooltip( $name, $options=null)
Returns raw bits of HTML, use titleAttrib()
static userTalkLink( $userId, $userText)
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 normaliseSpecialPage(LinkTarget $target)
static makeHeadline( $level, $attribs, $anchor, $html, $link, $fallbackAnchor=false)
Create a headline for content.
static formatTemplates( $templates, $preview=false, $section=false, $more=null)
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 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 makeBrokenImageLinkObj( $title, $label='', $query='', $unused1='', $unused2='', $time=false)
Make a "broken" link to an image.
static getRevDeleteLink(User $user, Revision $rev, Title $title)
Get a revision-deletion link, or disabled link, or nothing, depending on user permissions & the setti...
The Message class provides methods which fulfil two basic services:
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
static singleton()
Get a RepoGroup instance.
static getMain()
Get the RequestContext object associated with the main request.
static resolveAlias( $alias)
Given a special page name with a possible subpage, return an array where the first element is the spe...
static escapeRegexReplacement( $string)
Escape a string to make it suitable for inclusion in a preg_replace() replacement parameter.
Handles formatting for the "templates used on this page" lists.
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromId( $id)
Static factory method for creation from a given user ID.
static getDefaultOption( $opt)
Get a given default option value.
static getForeignURL( $wikiID, $page, $fragmentId=null)
Convenience to get a url to a page on a foreign wiki.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an and does all the work of translating among various forms such as plain database etc For and for historical reasons
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
the array() calling protocol came about after MediaWiki 1.4rc1.
do that in ParserLimitReportFormat instead $parser
see documentation in includes Linker php for Linker::makeImageLink & $time
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges use this to change the tables headers change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped $pre
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges use this to change the tables headers change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped true if there is text before this autocomment $auto
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template to be included in the link
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
null means default & $customAttribs
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place or wrap services the preferred way to define a new service is the $wgServiceWiringFiles array $services
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Allows to change the fields on the form that will be generated $name
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form before processing starts Return false to skip default processing and return $ret $linkRenderer
see documentation in includes Linker php for Linker::makeImageLink & $handlerParams
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
processing should stop and the error should be shown to the user * false
Interface for objects which can provide a MediaWiki context on request.
controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for MediaWiki still create a but requests to it are no ops and we always fall through to the database If the cache daemon can t be it should also disable itself fairly smoothly By $wgMemc is used but when it is $parserMemc or $messageMemc this is mentioned below
if(!isset( $args[0])) $lang