Go to the documentation of this file.
84 public static function link(
88 wfWarn( __METHOD__ .
': Requires $target to be a LinkTarget object.', 2 );
89 return "<!-- ERROR -->$html";
92 if ( is_string(
$query ) ) {
94 wfDeprecated( __METHOD__ .
' with parameter $query as string (should be array)',
'1.20' );
98 $services = MediaWikiServices::getInstance();
102 if ( !isset(
$options[
'stubThreshold'] ) ) {
103 $defaultLinkRenderer =
$services->getLinkRenderer();
104 $options[
'stubThreshold'] = $defaultLinkRenderer->getStubThreshold();
107 ->createFromLegacyOptions(
$options );
112 if (
$html !==
null ) {
118 if ( in_array(
'known',
$options,
true ) ) {
122 if ( in_array(
'broken',
$options,
true ) ) {
126 if ( in_array(
'noclasses',
$options,
true ) ) {
169 $ret =
"<a class=\"mw-selflink selflink\">{$prefix}{$html}</a>{$trail}";
175 $html = htmlspecialchars( $nt->getPrefixedText() );
178 return "<a class=\"mw-selflink selflink\">{$prefix}{$html}{$inside}</a>{$trail}";
197 $name = MediaWikiServices::getInstance()->getContentLanguage()->
198 getFormattedNsText( $namespace );
203 return $context->msg(
'invalidtitle-unknownnamespace', $namespace,
$title )->text();
213 list(
$name, $subpage ) = MediaWikiServices::getInstance()->getSpecialPageFactory()->
214 resolveAlias( $target->
getDBkey() );
232 $basename = strrchr( $url,
'/' );
233 if ( $basename ===
false ) {
236 $basename = substr( $basename, 1 );
258 wfDebug(
"Hook LinkerMakeExternalImage changed the output of external image "
259 .
"with url {$url} and alt text {$alt} to {$img}\n",
true );
262 return Html::element(
'img',
309 $query =
"", $widthOption =
null
320 if (
$file && !
$file->allowInlineDisplay() ) {
321 wfDebug( __METHOD__ .
': ' .
$title->getPrefixedDBkey() .
" does not allow inline display\n" );
327 if ( !isset( $frameParams[
'align'] ) ) {
328 $frameParams[
'align'] =
'';
330 if ( !isset( $frameParams[
'alt'] ) ) {
331 $frameParams[
'alt'] =
'';
333 if ( !isset( $frameParams[
'title'] ) ) {
334 $frameParams[
'title'] =
'';
336 if ( !isset( $frameParams[
'class'] ) ) {
337 $frameParams[
'class'] =
'';
340 $prefix = $postfix =
'';
342 if ( $frameParams[
'align'] ==
'center' ) {
343 $prefix =
'<div class="center">';
345 $frameParams[
'align'] =
'none';
357 if ( isset( $frameParams[
'thumbnail'] )
358 || isset( $frameParams[
'manualthumb'] )
359 || isset( $frameParams[
'framed'] )
360 || isset( $frameParams[
'frameless'] )
365 if ( $widthOption ===
null || !isset(
$wgThumbLimits[$widthOption] ) ) {
370 if ( isset( $frameParams[
'upright'] ) && $frameParams[
'upright'] == 0 ) {
377 $prefWidth = isset( $frameParams[
'upright'] ) ?
378 round(
$wgThumbLimits[$widthOption] * $frameParams[
'upright'], -1 ) :
390 if ( isset( $frameParams[
'thumbnail'] ) || isset( $frameParams[
'manualthumb'] )
391 || isset( $frameParams[
'framed'] )
393 # Create a thumbnail. Alignment depends on the writing direction of
394 # the page content language (right-aligned for LTR languages,
395 # left-aligned for RTL languages)
396 # If a thumbnail width has not been provided, it is set
397 # to the default user option as specified in Language*.php
398 if ( $frameParams[
'align'] ==
'' ) {
399 $frameParams[
'align'] =
$parser->getTargetLanguage()->alignEnd();
406 if (
$file && isset( $frameParams[
'frameless'] ) ) {
407 $srcWidth =
$file->getWidth( $page );
408 # For "frameless" option: do not present an image bigger than the
409 # source (for bitmap-style images). This is the same behavior as the
410 # "thumb" option does it already.
417 # Create a resized image, without the additional thumbnail features
428 'alt' => $frameParams[
'alt'],
429 'title' => $frameParams[
'title'],
430 'valign' => $frameParams[
'valign'] ??
false,
431 'img-class' => $frameParams[
'class'] ];
432 if ( isset( $frameParams[
'border'] ) ) {
433 $params[
'img-class'] .= (
$params[
'img-class'] !==
'' ?
' ' :
'' ) .
'thumbborder';
439 if ( $frameParams[
'align'] !=
'' ) {
440 $s = Html::rawElement(
442 [
'class' =>
'float' . $frameParams[
'align'] ],
446 return str_replace(
"\n",
' ', $prefix .
$s . $postfix );
459 if ( isset( $frameParams[
'link-url'] ) && $frameParams[
'link-url'] !==
'' ) {
460 $mtoParams[
'custom-url-link'] = $frameParams[
'link-url'];
461 if ( isset( $frameParams[
'link-target'] ) ) {
462 $mtoParams[
'custom-target-link'] = $frameParams[
'link-target'];
465 $extLinkAttrs =
$parser->getExternalLinkAttribs( $frameParams[
'link-url'] );
466 foreach ( $extLinkAttrs
as $name => $val ) {
468 $mtoParams[
'parser-extlink-' .
$name] = $val;
471 } elseif ( isset( $frameParams[
'link-title'] ) && $frameParams[
'link-title'] !==
'' ) {
473 self::normaliseSpecialPage( $frameParams[
'link-title'] )
475 } elseif ( !empty( $frameParams[
'no-link'] ) ) {
478 $mtoParams[
'desc-link'] =
true;
479 $mtoParams[
'desc-query'] =
$query;
497 $align =
'right',
$params = [], $framed =
false, $manualthumb =
""
505 $frameParams[
'framed'] =
true;
507 if ( $manualthumb ) {
508 $frameParams[
'manualthumb'] = $manualthumb;
528 if ( !isset( $frameParams[
'align'] ) ) {
529 $frameParams[
'align'] =
'right';
531 if ( !isset( $frameParams[
'alt'] ) ) {
532 $frameParams[
'alt'] =
'';
534 if ( !isset( $frameParams[
'title'] ) ) {
535 $frameParams[
'title'] =
'';
537 if ( !isset( $frameParams[
'caption'] ) ) {
538 $frameParams[
'caption'] =
'';
543 $handlerParams[
'width'] = isset( $frameParams[
'upright'] ) ? 130 : 180;
547 $manualthumb =
false;
552 if ( isset( $frameParams[
'manualthumb'] ) ) {
553 # Use manually specified thumbnail
555 if ( $manual_title ) {
564 } elseif ( isset( $frameParams[
'framed'] ) ) {
569 # Do not present an image bigger than the source, for bitmap-style images
570 # This is a hack to maintain compatibility with arbitrary pre-1.10 behavior
571 $srcWidth =
$file->getWidth( $page );
579 $outerWidth = $thumb->getWidth() + 2;
585 # ThumbnailImage::toHtml() already adds page= onto the end of DjVu URLs
586 # So we don't need to pass it here in $query. However, the URL for the
587 # zoom icon still needs it, so we make a unique query for it. See T16771
593 && !isset( $frameParams[
'link-title'] )
594 && !isset( $frameParams[
'link-url'] )
595 && !isset( $frameParams[
'no-link'] ) ) {
596 $frameParams[
'link-url'] = $url;
599 $s =
"<div class=\"thumb t{$frameParams['align']}\">"
600 .
"<div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">";
605 } elseif ( !$thumb ) {
606 $s .=
wfMessage(
'thumbnail_error',
'' )->escaped();
609 if ( !$noscale && !$manualthumb ) {
613 'alt' => $frameParams[
'alt'],
614 'title' => $frameParams[
'title'],
615 'img-class' => ( isset( $frameParams[
'class'] ) && $frameParams[
'class'] !==
''
616 ? $frameParams[
'class'] .
' '
617 :
'' ) .
'thumbimage'
621 if ( isset( $frameParams[
'framed'] ) ) {
624 $zoomIcon = Html::rawElement(
'div', [
'class' =>
'magnify' ],
625 Html::rawElement(
'a', [
627 'class' =>
'internal',
632 $s .=
' <div class="thumbcaption">' . $zoomIcon . $frameParams[
'caption'] .
"</div></div></div>";
633 return str_replace(
"\n",
' ',
$s );
648 $hp15[
'width'] = round( $hp[
'width'] * 1.5 );
650 $hp20[
'width'] = $hp[
'width'] * 2;
651 if ( isset( $hp[
'height'] ) ) {
652 $hp15[
'height'] = round( $hp[
'height'] * 1.5 );
653 $hp20[
'height'] = $hp[
'height'] * 2;
656 $thumb15 =
$file->transform( $hp15 );
657 $thumb20 =
$file->transform( $hp20 );
658 if ( $thumb15 && !$thumb15->isError() && $thumb15->getUrl() !== $thumb->getUrl() ) {
659 $thumb->responsiveUrls[
'1.5'] = $thumb15->getUrl();
661 if ( $thumb20 && !$thumb20->isError() && $thumb20->getUrl() !== $thumb->getUrl() ) {
662 $thumb->responsiveUrls[
'2'] = $thumb20->getUrl();
680 $query =
'', $unused1 =
'', $unused2 =
'',
$time =
false
683 wfWarn( __METHOD__ .
': Requires $title to be a Title object.' );
684 return "<!-- ERROR -->" . htmlspecialchars( $label );
688 if ( $label ==
'' ) {
689 $label =
$title->getPrefixedText();
691 $encLabel = htmlspecialchars( $label );
705 [
'class' =>
'mw-redirect' ],
707 [
'known',
'noclasses' ]
713 return '<a href="' . htmlspecialchars( $href ) .
'" class="new" title="' .
714 htmlspecialchars(
$title->getPrefixedText(), ENT_QUOTES ) .
'">' .
731 $q =
'wpDestFile=' . $destFile->getPartialURL();
746 return $upload->getLocalURL( $q );
777 $url =
$file->getUrl();
798 wfDebug(
"Hook LinkerMakeMediaLinkFile changed the output of link "
799 .
"with url {$url} and text {$html} to {$ret}\n",
true );
818 $key = strtolower(
$name );
848 $class .=
" $linktype";
851 $class .=
" {$attribs['class']}";
856 $text = htmlspecialchars( $text );
862 $newRel = Parser::getExternalLinkRel( $url,
$title );
865 } elseif ( $newRel !==
'' ) {
867 $newRels = explode(
' ', $newRel );
868 $oldRels = explode(
' ',
$attribs[
'rel'] );
869 $combined = array_unique( array_merge( $newRels, $oldRels ) );
870 $attribs[
'rel'] = implode(
' ', $combined );
876 wfDebug(
"Hook LinkerMakeExternalLink changed the output of link "
877 .
"with url {$url} and text {$text} to {$link}\n",
true );
881 return Html::rawElement(
'a',
$attribs, $text );
892 public static function userLink( $userId, $userName, $altUserName =
false ) {
893 $classes =
'mw-userlink';
895 if ( $userId == 0 ) {
899 $classes .=
' mw-extuserlink';
900 } elseif ( $altUserName ===
false ) {
903 $classes .=
' mw-anonuserlink';
910 '<bdi>' . htmlspecialchars( $altUserName !==
false ? $altUserName : $userName ) .
'</bdi>';
913 ?
self::link( $page, $linkText, [
'class' => $classes ] )
914 : Html::rawElement(
'span', [
'class' => $classes ], $linkText );
932 $userId, $userText, $redContribsWhenNoEdits =
false, $flags = 0, $edits =
null,
933 $useParentheses =
true
938 $addEmailLink = $flags & self::TOOL_LINKS_EMAIL && $userId;
952 $attribs[
'class'] =
'mw-usertoollinks-contribs';
953 if ( $redContribsWhenNoEdits ) {
954 if ( intval( $edits ) === 0 && $edits !== 0 ) {
956 $edits =
$user->getEditCount();
958 if ( $edits === 0 ) {
966 if ( $blockable && $wgUser->isAllowed(
'block' ) ) {
970 if ( $addEmailLink && $wgUser->canSendEmail() ) {
974 Hooks::run(
'UserToolLinksEdit', [ $userId, $userText, &$items ] );
980 if ( $useParentheses ) {
981 return wfMessage(
'word-separator' )->escaped()
982 .
'<span class="mw-usertoollinks">'
983 .
wfMessage(
'parentheses' )->rawParams(
$wgLang->pipeList( $items ) )->escaped()
988 foreach ( $items
as $tool ) {
989 $tools[] = Html::rawElement(
'span', [], $tool );
991 return ' <span class="mw-usertoollinks mw-changeslist-links">' .
992 implode(
' ', $tools ) .
'</span>';
1005 $userId, $userText, $edits =
null, $useParentheses =
true
1018 $moreLinkAttribs[
'class'] =
'mw-usertoollinks-talk';
1021 wfMessage(
'talkpagelinktext' )->escaped(),
1034 $moreLinkAttribs[
'class'] =
'mw-usertoollinks-block';
1049 $moreLinkAttribs[
'class'] =
'mw-usertoollinks-mail';
1073 return '<span class="history-deleted">' .
$link .
'</span>';
1099 return ' <span class="history-deleted mw-userlink">' .
$link .
'</span>';
1123 $comment,
$title =
null, $local =
false, $wikiId =
null
1125 # Sanitize text a bit:
1126 $comment = str_replace(
"\n",
" ", $comment );
1127 # Allow HTML entities (for T15815)
1128 $comment = Sanitizer::escapeHtmlAllowEntities( $comment );
1130 # Render autocomments and make links:
1153 $comment,
$title =
null, $local =
false, $wikiId =
null
1161 $comment = preg_replace_callback(
1167 '!(?:(?<=(.)))?/\*\s*(.*?)\s*\*/(?:(?=(.)))?!',
1168 function ( $match )
use (
$title, $local, $wikiId, &$append ) {
1172 $match += [
'',
'',
'',
'' ];
1174 $pre = $match[1] !==
'';
1176 $post = $match[3] !==
'';
1180 'FormatAutocomments',
1184 if ( $comment ===
null ) {
1187 # Remove links that a user may have manually put in the autosummary
1188 # This could be improved by copying as much of Parser::stripSectionName as desired.
1197 $sectionText = str_replace(
'[[',
'[[',
$auto );
1199 $section = substr( Parser::guessSectionNameFromStrippedText(
$section ), 1 );
1206 if ( $sectionTitle ) {
1208 $sectionTitle,
$wgLang->getArrow() .
$wgLang->getDirMark() . $sectionText,
1209 $wikiId,
'noclasses'
1214 # written summary $presep autocomment (summary )
1215 $pre =
wfMessage(
'autocomment-prefix' )->inContentLanguage()->escaped();
1218 # autocomment $postsep written summary ( summary)
1219 $auto .=
wfMessage(
'colon-separator' )->inContentLanguage()->escaped();
1222 $auto =
'<span dir="auto"><span class="autocomment">' .
$auto .
'</span>';
1223 $append .=
'</span>';
1231 return $comment . $append;
1254 $comment,
$title =
null, $local =
false, $wikiId =
null
1256 return preg_replace_callback(
1259 \s*+ # ignore leading whitespace, the *+ quantifier disallows backtracking
1260 :? # ignore optional leading colon
1261 ([^\]|]+) # 1. link target; page names cannot include ] or |
1264 # Stop matching at ]] without relying on backtracking.
1268 ([^[]*) # 3. link trail (the text up until the next link)
1270 function ( $match )
use (
$title, $local, $wikiId ) {
1272 $medians .= preg_quote(
1273 MediaWikiServices::getInstance()->getContentLanguage()->getNsText(
NS_MEDIA ),
1277 $comment = $match[0];
1279 # fix up urlencoded title texts (copied from Parser::replaceInternalLinks)
1280 if ( strpos( $match[1],
'%' ) !==
false ) {
1282 rawurldecode( $match[1] ),
1283 [
'<' =>
'<',
'>' =>
'>' ]
1287 # Handle link renaming [[foo|text]] will show link as "text"
1288 if ( $match[2] !=
"" ) {
1295 if ( preg_match(
'/^' . $medians .
'(.*)$/i', $match[1], $submatch ) ) {
1296 # Media link; trail not supported.
1297 $linkRegexp =
'/\[\[(.*?)\]\]/';
1303 # Other kind of link
1304 # Make sure its target is non-empty
1305 if ( isset( $match[1][0] ) && $match[1][0] ==
':' ) {
1306 $match[1] = substr( $match[1], 1 );
1308 if ( $match[1] !==
false && $match[1] !==
'' ) {
1310 MediaWikiServices::getInstance()->getContentLanguage()->linkTrail(),
1314 $trail = $submatch[1];
1318 $linkRegexp =
'/\[\[(.*?)\]\]' . preg_quote( $trail,
'/' ) .
'/';
1326 if ( $target->getText() ==
'' && !$target->isExternal()
1329 $target =
$title->createFragmentTarget( $target->getFragment() );
1338 $comment = preg_replace(
1368 if ( $wikiId !==
null && !$linkTarget->
isExternal() ) {
1397 # :Foobar -- override special treatment of prefix (images, language links)
1398 # /Foobar -- convert to CurrentPage/Foobar
1399 # /Foobar/ -- convert to CurrentPage/Foobar, strip the initial and final / from text
1400 # ../ -- convert to CurrentPage, from CurrentPage/CurrentSubPage
1401 # ../Foobar -- convert to CurrentPage/Foobar,
1402 # (from CurrentPage/CurrentSubPage)
1403 # ../Foobar/ -- convert to CurrentPage/Foobar, use 'Foobar' as text
1404 # (from CurrentPage/CurrentSubPage)
1408 # Some namespaces don't allow subpages,
1409 # so only perform processing if subpages are allowed
1411 $hash = strpos( $target,
'#' );
1412 if ( $hash !==
false ) {
1413 $suffix = substr( $target, $hash );
1414 $target = substr( $target, 0, $hash );
1419 $target = trim( $target );
1420 # Look at the first character
1421 if ( $target !=
'' && $target[0] ===
'/' ) {
1422 # / at end means we don't want the slash to be shown
1424 $trailingSlashes = preg_match_all(
'%(/+)$%', $target, $m );
1425 if ( $trailingSlashes ) {
1426 $noslash = $target = substr( $target, 1, -strlen( $m[0][0] ) );
1428 $noslash = substr( $target, 1 );
1431 $ret = $contextTitle->getPrefixedText() .
'/' . trim( $noslash ) . $suffix;
1432 if ( $text ===
'' ) {
1433 $text = $target . $suffix;
1434 } #
this might be changed
for ugliness reasons
1436 # check for .. subpage backlinks
1438 $nodotdot = $target;
1439 while ( strncmp( $nodotdot,
"../", 3 ) == 0 ) {
1441 $nodotdot = substr( $nodotdot, 3 );
1443 if ( $dotdotcount > 0 ) {
1444 $exploded = explode(
'/', $contextTitle->getPrefixedText() );
1445 if (
count( $exploded ) > $dotdotcount ) { #
not allowed to go
below top level
page
1446 $ret = implode(
'/', array_slice( $exploded, 0, -$dotdotcount ) );
1447 # / at the end means don't show full path
1448 if ( substr( $nodotdot, -1, 1 ) ===
'/' ) {
1449 $nodotdot = rtrim( $nodotdot,
'/' );
1450 if ( $text ===
'' ) {
1451 $text = $nodotdot . $suffix;
1454 $nodotdot = trim( $nodotdot );
1455 if ( $nodotdot !=
'' ) {
1456 $ret .=
'/' . $nodotdot;
1481 $comment,
$title =
null, $local =
false, $wikiId =
null, $useParentheses =
true
1486 if ( $comment ==
'' || $comment ==
'*' ) {
1490 if ( $useParentheses ) {
1491 $formatted =
wfMessage(
'parentheses' )->rawParams( $formatted )->escaped();
1492 $classNames =
'comment';
1494 $classNames =
'comment comment--without-parentheses';
1496 return " <span class=\"$classNames\">$formatted</span>";
1511 $useParentheses =
true
1517 $block =
" <span class=\"comment\">" .
wfMessage(
'rev-deleted-comment' )->escaped() .
"</span>";
1520 $rev->getTitle(), $local,
null, $useParentheses );
1522 $block =
" <span class=\"comment\">" .
wfMessage(
'rev-deleted-comment' )->escaped() .
"</span>";
1525 return " <span class=\"history-deleted comment\">$block</span>";
1537 $stxt =
wfMessage(
'historyempty' )->escaped();
1539 $stxt =
wfMessage(
'nbytes' )->numParams( $size )->escaped();
1541 return "<span class=\"history-size mw-diff-bytes\">$stxt</span>";
1562 return "</li>\n" . str_repeat(
"</ul>\n</li>\n", $level > 0 ? $level : 0 );
1576 public static function tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex =
false ) {
1577 $classes =
"toclevel-$level";
1578 if ( $sectionIndex !==
false ) {
1579 $classes .=
" tocsection-$sectionIndex";
1584 return Html::openElement(
'li', [
'class' => $classes ] )
1585 . Html::rawElement(
'a',
1586 [
'href' =>
"#$anchor" ],
1587 Html::element(
'span', [
'class' =>
'tocnumber' ], $tocnumber )
1589 . Html::rawElement(
'span', [
'class' =>
'toctext' ], $tocline )
1616 wfDeprecated( __METHOD__ .
' with type other than Language for $lang',
'1.33' );
1622 return '<div id="toc" class="toc">'
1623 . Html::element(
'input', [
1624 'type' =>
'checkbox',
1626 'id' =>
'toctogglecheckbox',
1627 'class' =>
'toctogglecheckbox',
1628 'style' =>
'display:none',
1630 . Html::openElement(
'div', [
1631 'class' =>
'toctitle',
1632 'lang' =>
$lang->getHtmlCode(),
1633 'dir' =>
$lang->getDir(),
1636 .
'<span class="toctogglespan">'
1637 . Html::label(
'',
'toctogglecheckbox', [
1638 'class' =>
'toctogglelabel',
1643 .
"</ul>\n</div>\n";
1659 if (
$section[
'toclevel'] > $lastLevel ) {
1661 } elseif (
$section[
'toclevel'] < $lastLevel ) {
1663 $lastLevel -
$section[
'toclevel'] );
1694 $link, $fallbackAnchor =
false
1696 $anchorEscaped = htmlspecialchars( $anchor );
1698 if ( $fallbackAnchor !==
false && $fallbackAnchor !== $anchor ) {
1699 $fallbackAnchor = htmlspecialchars( $fallbackAnchor );
1700 $fallback =
"<span id=\"$fallbackAnchor\"></span>";
1702 return "<h$level$attribs"
1703 .
"$fallback<span class=\"mw-headline\" id=\"$anchorEscaped\">$html</span>"
1715 $regex = MediaWikiServices::getInstance()->getContentLanguage()->linkTrail();
1717 if ( $trail !==
'' && preg_match( $regex, $trail, $m ) ) {
1718 list( , $inside, $trail ) = $m;
1720 return [ $inside, $trail ];
1758 if ( in_array(
'verify',
$options,
true ) ) {
1760 if ( $editCount ===
false ) {
1767 if ( !in_array(
'noBrackets',
$options,
true ) ) {
1768 $inner =
$context->msg(
'brackets' )->rawParams( $inner )->escaped();
1771 if (
$context->getUser()->getBoolOption(
'showrollbackconfirmation' ) ) {
1772 $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
1773 $stats->increment(
'rollbackconfirmation.event.load' );
1774 $context->getOutput()->addModules(
'mediawiki.page.rollback.confirmation' );
1777 return '<span class="mw-rollback-link">' . $inner .
'</span>';
1808 [
'rev_user_text' =>
$revQuery[
'fields'][
'rev_user_text'],
'rev_deleted' ],
1810 [
'rev_page' =>
$rev->getTitle()->getArticleID() ],
1813 'USE INDEX' => [
'revision' =>
'page_timestamp' ],
1814 'ORDER BY' =>
'rev_timestamp DESC',
1822 foreach (
$res as $row ) {
1863 $disableRollbackEditCountSpecialPage = [
'Recentchanges',
'Watchlist' ];
1872 'action' =>
'rollback',
1873 'from' =>
$rev->getUserText(),
1874 'token' =>
$context->getUser()->getEditToken(
'rollback' ),
1878 'data-mw' =>
'interface',
1879 'title' =>
$context->msg(
'tooltip-rollback' )->text()
1882 $options = [
'known',
'noclasses' ];
1884 if (
$context->getRequest()->getBool(
'bot' ) ) {
1886 $query[
'hidediff'] =
'1';
1890 $disableRollbackEditCount =
false;
1892 foreach ( $disableRollbackEditCountSpecialPage
as $specialPage ) {
1894 $disableRollbackEditCount =
true;
1900 if ( !$disableRollbackEditCount
1904 if ( !is_numeric( $editCount ) ) {
1912 $html =
$context->msg(
'rollbacklinkcount' )->numParams( $editCount )->parse();
1932 if (
count( $hiddencats ) > 0 ) {
1933 # Construct the HTML
1934 $outText =
'<div class="mw-hiddenCategoriesExplanation">';
1935 $outText .=
wfMessage(
'hiddencategories' )->numParams(
count( $hiddencats ) )->parseAsBlock();
1936 $outText .=
"</div><ul>\n";
1938 foreach ( $hiddencats
as $titleObj ) {
1939 # If it's hidden, it must exist - no need to check with a LinkBatch
1941 .
self::link( $titleObj,
null, [], [],
'known' )
1944 $outText .=
'</ul>';
1966 $message =
wfMessage(
"tooltip-$name", $msgParams );
1967 if ( !$message->exists() ) {
1970 $tooltip = $message->text();
1971 # Compatibility: formerly some tooltips had [alt-.] hardcoded
1972 $tooltip = preg_replace(
"/ ?\[alt-.\]$/",
'', $tooltip );
1973 # Message equal to '-' means suppress it.
1974 if ( $tooltip ==
'-' ) {
1981 if ( in_array(
'nonexisting',
$options ) ) {
1982 $tooltip =
wfMessage(
'red-link-title', $tooltip ?:
'' )->text();
1984 if ( in_array(
'withaccess',
$options ) ) {
1986 if ( $accesskey !==
false ) {
1988 if ( $tooltip ===
false || $tooltip ===
'' ) {
1989 $tooltip =
wfMessage(
'brackets', $accesskey )->text();
1991 $tooltip .=
wfMessage(
'word-separator' )->text();
1992 $tooltip .=
wfMessage(
'brackets', $accesskey )->text();
2014 if ( isset( self::$accesskeycache[
$name] ) ) {
2015 return self::$accesskeycache[
$name];
2018 $message =
wfMessage(
"accesskey-$name" );
2020 if ( !$message->exists() ) {
2023 $accesskey = $message->plain();
2024 if ( $accesskey ===
'' || $accesskey ===
'-' ) {
2025 # @todo FIXME: Per standard MW behavior, a value of '-' means to suppress the
2026 # attribute, but this is broken for accesskey: that might be a useful
2032 self::$accesskeycache[
$name] = $accesskey;
2033 return self::$accesskeycache[
$name];
2050 $canHide =
$user->isAllowed(
'deleterevision' );
2051 if ( !$canHide && !(
$rev->getVisibility() &&
$user->isAllowed(
'deletedhistory' ) ) ) {
2058 if (
$rev->getId() ) {
2062 'type' =>
'revision',
2063 'target' =>
$title->getPrefixedDBkey(),
2064 'ids' =>
$rev->getId()
2070 'type' =>
'archive',
2071 'target' =>
$title->getPrefixedDBkey(),
2072 'ids' =>
$rev->getTimestamp()
2091 $msgKey = $delete ?
'rev-delundel' :
'rev-showdeleted';
2093 $tag = $restricted ?
'strong' :
'span';
2097 [
'class' =>
'mw-revdelundel-link' ],
2112 $msgKey = $delete ?
'rev-delundel' :
'rev-showdeleted';
2114 $htmlParentheses =
wfMessage(
'parentheses' )->rawParams(
$html )->escaped();
2115 return Xml::tags(
'span', [
'class' =>
'mw-revdelundel-link' ], $htmlParentheses );
2132 array $msgParams = [],
2142 if (
$attribs[
'title'] ===
false ) {
2145 if (
$attribs[
'accesskey'] ===
false ) {
2160 if ( $tooltip ===
false ) {
static getDefaultOption( $opt)
Get a given default option value.
static getImageLinkMTOParams( $frameParams, $query='', $parser=null)
Get the link parameters for MediaTransformOutput::toHtml() from given frame parameters supplied by th...
return true to allow those checks to and false if checking is done & $user
static newFromId( $id)
Static factory method for creation from a given user ID.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Marks HTML that shouldn't be escaped.
$wgThumbLimits
Adjust thumbnails on image pages according to a user setting.
static formatLinksInComment( $comment, $title=null, $local=false, $wikiId=null)
Formats wiki links and media links in text; all other wiki formatting is ignored.
Some internal bits split of from Skin.php.
const TOOL_LINKS_NOBLOCK
Flags for userToolLinks()
static userTalkLink( $userId, $userText)
static singleton()
Get a RepoGroup instance.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
static expandAttributes( $attribs)
Given an array of ('attributename' => 'value'), it generates the code to set the XML attributes : att...
processing should stop and the error should be shown to the user * false
static emailLink( $userId, $userText)
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
$wgResponsiveImages
Generate and use thumbnails suitable for screens with 1.5 and 2.0 pixel densities.
static revUserLink( $rev, $isPublic=false)
Generate a user link if the current user is allowed to view it.
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
if(!isset( $args[0])) $lang
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.
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
$wgSVGMaxSize
Don't scale a SVG larger than this.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could change
static userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null, $useParentheses=true)
Generate standard user tool links (talk, contributions, block link, etc.)
static getForeignURL( $wikiID, $page, $fragmentId=null)
Convenience to get a url to a page on a foreign wiki.
static fnamePart( $url)
Returns the filename part of an url.
static specialLink( $name, $key='')
Make a link to a special page given its name and, optionally, a message key from the link text.
static escapeRegexReplacement( $string)
Escape a string to make it suitable for inclusion in a preg_replace() replacement parameter.
static revComment(Revision $rev, $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 linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
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
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 processResponsiveImages( $file, $thumb, $hp)
Process responsive images: add 1.5x and 2x subimages to the thumbnail, where applicable.
if( $inline) $status value
if(! $wgRequest->checkUrlExtension()) if(isset( $_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] !='') $wgTitle
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
This document provides an overview of the usage of PageUpdater and that is
static tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex=false)
parameter level defines if we are on an indentation level
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
static formatHiddenCategories( $hiddencats)
Returns HTML for the "hidden categories on this page" list.
static tooltipAndAccesskeyAttribs( $name, array $msgParams=[], $options=null)
Returns the attributes for the tooltip and access key.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
null means default & $customAttribs
null for the 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
static tocList( $toc, $lang=null)
Wraps the TOC in a table and provides the hide/collapse javascript.
static getQueryInfo( $options=[])
Return the tables, fields, and join conditions to be selected to create a new revision object.
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
namespace and then decline to actually register it file or subcat img or subcat $title
static makeMediaLinkObj( $title, $html='', $time=false)
Create a direct link to a given uploaded file.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
static generateRollback( $rev, IContextSource $context=null, $options=[ 'verify'])
Generate a rollback link for a given revision.
static makeThumbLink2(Title $title, $file, $frameParams=[], $handlerParams=[], $time=false, $query="")
static getTitleValueFor( $name, $subpage=false, $fragment='')
Get a localised TitleValue object for a specified special page name.
static formatAutocomments( $comment, $title=null, $local=false, $wikiId=null)
Converts autogenerated comments in edit summaries into section links.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
static getRollbackEditCount( $rev, $verify)
This function will return the number of revisions which a rollback would revert and,...
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The below
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
static makeHeadline( $level, $attribs, $anchor, $html, $link, $fallbackAnchor=false)
Create a headline for content.
static makeThumbLinkObj(Title $title, $file, $label='', $alt='', $align='right', $params=[], $framed=false, $manualthumb="")
Make HTML for a thumbnail including image, border and caption.
static tocLineEnd()
End a Table Of Contents line.
wfGetLangObj( $langcode=false)
Return a Language object from $langcode.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
static hasSubpages( $index)
Does the namespace allow subpages?
wfCgiToArray( $query)
This is the logical opposite of wfArrayToCgi(): it accepts a query string as its argument and returns...
static revDeleteLinkDisabled( $delete=true)
Creates a dead (show/hide) link for deleting revisions/log entries.
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $parser
static makeExternalLink( $url, $text, $escape=true, $linktype='', $attribs=[], $title=null)
Make an external link.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
static revUserTools( $rev, $isPublic=false, $useParentheses=true)
Generate a user tool link cluster if the current user is allowed to view it.
static makeCommentLink(LinkTarget $linkTarget, $text, $wikiId=null, $options=[])
Generates a link to the given Title.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
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
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
static splitTrail( $trail)
Split a link trail, return the "inside" portion and the remainder of the trail as a two-element array...
static prettifyIP( $ip)
Prettify an IP for display to end users.
Allows to change the fields on the form that will be generated $name
$wgShowRollbackEditCount
The $wgShowRollbackEditCount variable is used to show how many edits can be rolled back.
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
static blockLink( $userId, $userText)
static normaliseSpecialPage(LinkTarget $target)
static getUserLinkTitle( $userName)
Get a target Title to link a username.
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 userToolLinksRedContribs( $userId, $userText, $edits=null, $useParentheses=true)
Alias for userToolLinks( $userId, $userText, true );.
static getRevDeleteLink(User $user, Revision $rev, Title $title)
Get a revision-deletion link, or disabled link, or nothing, depending on user permissions & the setti...
static tags( $element, $attribs, $contents)
Same as Xml::element(), but does not escape contents.
static generateTOC( $tree, $lang=null)
Generate a table of contents from a section tree.
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
static formatRevisionSize( $size)
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
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 exists( $index)
Returns whether the specified namespace exists.
static getMain()
Get the RequestContext object associated with the main request.
static newFromLinkTarget(LinkTarget $linkTarget, $forceClone='')
Returns a Title given a LinkTarget.
$wgUploadNavigationUrl
Point the upload navigation link to an external URL Useful if you want to use a shared repository by ...
static titleAttrib( $name, $options=null, array $msgParams=[])
Given the id of an interface element, constructs the appropriate title attribute from the system mess...
wfFindFile( $title, $options=[])
Find a file.
Interface for objects which can provide a MediaWiki context on request.
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...
see documentation in includes Linker php for Linker::makeImageLink & $handlerParams
static tooltip( $name, $options=null)
Returns raw bits of HTML, use titleAttrib()
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
Represents a title within MediaWiki.
$wgMiserMode
Disable database-intensive features.
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 $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
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
$wgThumbUpright
Adjust width of upright images when parameter 'upright' is used This allows a nicer look for upright ...
static tocUnindent( $level)
Finish one or more sublevels on the Table of Contents.
static makeMediaLinkFile(Title $title, $file, $html='')
Create a direct link to a given uploaded file.
static revDeleteLink( $query=[], $restricted=false, $delete=true)
Creates a (show/hide) link for deleting revisions/log entries.
$wgEnableUploads
Allow users to upload files.
usually copyright or history_copyright This message must be in HTML not wikitext & $link
static normalizeSubpageLink( $contextTitle, $target, &$text)
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
see documentation in includes Linker php for Linker::makeImageLink & $time
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response 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
$wgUploadMissingFileUrl
Point the upload link for missing files to an external URL, as with $wgUploadNavigationUrl.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
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 use $formDescriptor instead 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 "<
static accesskey( $name)
Given the id of an interface element, constructs the appropriate accesskey attribute from the system ...
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
static buildRollbackLink( $rev, IContextSource $context=null, $editCount=false)
Build a raw rollback link, useful for collections of "tool" links.
static isExternal( $username)
Tells whether the username is external or not.
static makeExternalImage( $url, $alt='')
Return the code for images which were added via external links, via Parser::maybeMakeExternalImage().
static getCanonicalName( $index)
Returns the canonical (English) name for a given index.
Internationalisation code.
static makeBrokenImageLinkObj( $title, $label='', $query='', $unused1='', $unused2='', $time=false)
Make a "broken" link to an image.
$wgDisableAnonTalk
Disable links to talk pages of anonymous users (IPs) in listings on special pages like page history,...