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 ) {
117 if ( in_array(
'known',
$options,
true ) ) {
119 } elseif ( in_array(
'broken',
$options,
true ) ) {
121 } elseif ( in_array(
'noclasses',
$options,
true ) ) {
164 $ret =
"<a class=\"mw-selflink selflink\">{$prefix}{$html}</a>{$trail}";
165 if ( !Hooks::run(
'SelfLinkBegin', [ $nt, &
$html, &$trail, &$prefix, &
$ret ] ) ) {
170 $html = htmlspecialchars( $nt->getPrefixedText() );
173 return "<a class=\"mw-selflink selflink\">{$prefix}{$html}{$inside}</a>{$trail}";
188 if ( MWNamespace::exists( $namespace ) ) {
192 $name = MediaWikiServices::getInstance()->getContentLanguage()->
193 getFormattedNsText( $namespace );
197 return $context->msg(
'invalidtitle-unknownnamespace', $namespace,
$title )->text();
208 list(
$name, $subpage ) = MediaWikiServices::getInstance()->getSpecialPageFactory()->
209 resolveAlias( $target->
getDBkey() );
229 $basename = strrchr( $url,
'/' );
230 if (
false === $basename ) {
233 $basename = substr( $basename, 1 );
253 $success = Hooks::run(
'LinkerMakeExternalImage', [ &$url, &$alt, &$img ] );
255 wfDebug(
"Hook LinkerMakeExternalImage changed the output of external image "
256 .
"with url {$url} and alt text {$alt} to {$img}\n",
true );
259 return Html::element(
'img',
303 $query =
"", $widthOption =
null
307 if ( !Hooks::run(
'ImageBeforeProduceHTML', [ &$dummy, &
$title,
314 if ( $file && !$file->allowInlineDisplay() ) {
315 wfDebug( __METHOD__ .
': ' .
$title->getPrefixedDBkey() .
" does not allow inline display\n" );
321 if ( !isset( $frameParams[
'align'] ) ) {
322 $frameParams[
'align'] =
'';
324 if ( !isset( $frameParams[
'alt'] ) ) {
325 $frameParams[
'alt'] =
'';
327 if ( !isset( $frameParams[
'title'] ) ) {
328 $frameParams[
'title'] =
'';
330 if ( !isset( $frameParams[
'class'] ) ) {
331 $frameParams[
'class'] =
'';
334 $prefix = $postfix =
'';
336 if (
'center' == $frameParams[
'align'] ) {
337 $prefix =
'<div class="center">';
339 $frameParams[
'align'] =
'none';
342 if ( isset(
$handlerParams[
'height'] ) && $file->isVectorized() ) {
351 if ( isset( $frameParams[
'thumbnail'] )
352 || isset( $frameParams[
'manualthumb'] )
353 || isset( $frameParams[
'framed'] )
354 || isset( $frameParams[
'frameless'] )
359 if ( $widthOption ===
null || !isset(
$wgThumbLimits[$widthOption] ) ) {
364 if ( isset( $frameParams[
'upright'] ) && $frameParams[
'upright'] == 0 ) {
371 $prefWidth = isset( $frameParams[
'upright'] ) ?
372 round(
$wgThumbLimits[$widthOption] * $frameParams[
'upright'], -1 ) :
378 $prefWidth <
$handlerParams[
'width'] || $file->isVectorized() ) ) {
384 if ( isset( $frameParams[
'thumbnail'] ) || isset( $frameParams[
'manualthumb'] )
385 || isset( $frameParams[
'framed'] )
387 # Create a thumbnail. Alignment depends on the writing direction of
388 # the page content language (right-aligned for LTR languages,
389 # left-aligned for RTL languages)
390 # If a thumbnail width has not been provided, it is set
391 # to the default user option as specified in Language*.php
392 if ( $frameParams[
'align'] ==
'' ) {
393 $frameParams[
'align'] =
$parser->getTargetLanguage()->alignEnd();
400 if ( $file && isset( $frameParams[
'frameless'] ) ) {
401 $srcWidth = $file->getWidth( $page );
402 # For "frameless" option: do not present an image bigger than the
403 # source (for bitmap-style images). This is the same behavior as the
404 # "thumb" option does it already.
405 if ( $srcWidth && !$file->mustRender() &&
$handlerParams[
'width'] > $srcWidth ) {
411 # Create a resized image, without the additional thumbnail features
422 'alt' => $frameParams[
'alt'],
423 'title' => $frameParams[
'title'],
424 'valign' => $frameParams[
'valign'] ??
false,
425 'img-class' => $frameParams[
'class'] ];
426 if ( isset( $frameParams[
'border'] ) ) {
427 $params[
'img-class'] .= (
$params[
'img-class'] !==
'' ?
' ' :
'' ) .
'thumbborder';
433 if ( $frameParams[
'align'] !=
'' ) {
434 $s = Html::rawElement(
436 [
'class' =>
'float' . $frameParams[
'align'] ],
440 return str_replace(
"\n",
' ', $prefix .
$s . $postfix );
453 if ( isset( $frameParams[
'link-url'] ) && $frameParams[
'link-url'] !==
'' ) {
454 $mtoParams[
'custom-url-link'] = $frameParams[
'link-url'];
455 if ( isset( $frameParams[
'link-target'] ) ) {
456 $mtoParams[
'custom-target-link'] = $frameParams[
'link-target'];
459 $extLinkAttrs =
$parser->getExternalLinkAttribs( $frameParams[
'link-url'] );
460 foreach ( $extLinkAttrs
as $name => $val ) {
462 $mtoParams[
'parser-extlink-' .
$name] = $val;
465 } elseif ( isset( $frameParams[
'link-title'] ) && $frameParams[
'link-title'] !==
'' ) {
466 $mtoParams[
'custom-title-link'] = Title::newFromLinkTarget(
467 self::normaliseSpecialPage( $frameParams[
'link-title'] )
469 } elseif ( !empty( $frameParams[
'no-link'] ) ) {
472 $mtoParams[
'desc-link'] =
true;
473 $mtoParams[
'desc-query'] =
$query;
491 $align =
'right',
$params = [], $framed =
false, $manualthumb =
""
499 $frameParams[
'framed'] =
true;
501 if ( $manualthumb ) {
502 $frameParams[
'manualthumb'] = $manualthumb;
519 $exists = $file && $file->exists();
522 if ( !isset( $frameParams[
'align'] ) ) {
523 $frameParams[
'align'] =
'right';
525 if ( !isset( $frameParams[
'alt'] ) ) {
526 $frameParams[
'alt'] =
'';
528 if ( !isset( $frameParams[
'title'] ) ) {
529 $frameParams[
'title'] =
'';
531 if ( !isset( $frameParams[
'caption'] ) ) {
532 $frameParams[
'caption'] =
'';
537 $handlerParams[
'width'] = isset( $frameParams[
'upright'] ) ? 130 : 180;
541 $manualthumb =
false;
546 if ( isset( $frameParams[
'manualthumb'] ) ) {
547 # Use manually specified thumbnail
548 $manual_title = Title::makeTitleSafe(
NS_FILE, $frameParams[
'manualthumb'] );
549 if ( $manual_title ) {
558 } elseif ( isset( $frameParams[
'framed'] ) ) {
563 # Do not present an image bigger than the source, for bitmap-style images
564 # This is a hack to maintain compatibility with arbitrary pre-1.10 behavior
565 $srcWidth = $file->getWidth( $page );
566 if ( $srcWidth && !$file->mustRender() &&
$handlerParams[
'width'] > $srcWidth ) {
573 $outerWidth = $thumb->getWidth() + 2;
579 # ThumbnailImage::toHtml() already adds page= onto the end of DjVu URLs
580 # So we don't need to pass it here in $query. However, the URL for the
581 # zoom icon still needs it, so we make a unique query for it. See T16771
587 && !isset( $frameParams[
'link-title'] )
588 && !isset( $frameParams[
'link-url'] )
589 && !isset( $frameParams[
'no-link'] ) ) {
590 $frameParams[
'link-url'] = $url;
593 $s =
"<div class=\"thumb t{$frameParams['align']}\">"
594 .
"<div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">";
599 } elseif ( !$thumb ) {
600 $s .=
wfMessage(
'thumbnail_error',
'' )->escaped();
603 if ( !$noscale && !$manualthumb ) {
607 'alt' => $frameParams[
'alt'],
608 'title' => $frameParams[
'title'],
609 'img-class' => ( isset( $frameParams[
'class'] ) && $frameParams[
'class'] !==
''
610 ? $frameParams[
'class'] .
' '
611 :
'' ) .
'thumbimage'
615 if ( isset( $frameParams[
'framed'] ) ) {
618 $zoomIcon = Html::rawElement(
'div', [
'class' =>
'magnify' ],
619 Html::rawElement(
'a', [
621 'class' =>
'internal',
626 $s .=
' <div class="thumbcaption">' . $zoomIcon . $frameParams[
'caption'] .
"</div></div></div>";
627 return str_replace(
"\n",
' ',
$s );
642 $hp15[
'width'] = round( $hp[
'width'] * 1.5 );
644 $hp20[
'width'] = $hp[
'width'] * 2;
645 if ( isset( $hp[
'height'] ) ) {
646 $hp15[
'height'] = round( $hp[
'height'] * 1.5 );
647 $hp20[
'height'] = $hp[
'height'] * 2;
650 $thumb15 = $file->transform( $hp15 );
651 $thumb20 = $file->transform( $hp20 );
652 if ( $thumb15 && !$thumb15->isError() && $thumb15->getUrl() !== $thumb->getUrl() ) {
653 $thumb->responsiveUrls[
'1.5'] = $thumb15->getUrl();
655 if ( $thumb20 && !$thumb20->isError() && $thumb20->getUrl() !== $thumb->getUrl() ) {
656 $thumb->responsiveUrls[
'2'] = $thumb20->getUrl();
674 $query =
'', $unused1 =
'', $unused2 =
'',
$time =
false
677 wfWarn( __METHOD__ .
': Requires $title to be a Title object.' );
678 return "<!-- ERROR -->" . htmlspecialchars( $label );
682 if ( $label ==
'' ) {
683 $label =
$title->getPrefixedText();
685 $encLabel = htmlspecialchars( $label );
699 [
'class' =>
'mw-redirect' ],
701 [
'known',
'noclasses' ]
707 return '<a href="' . htmlspecialchars( $href ) .
'" class="new" title="' .
708 htmlspecialchars(
$title->getPrefixedText(), ENT_QUOTES ) .
'">' .
725 $q =
'wpDestFile=' . $destFile->getPartialURL();
735 $upload = SpecialPage::getTitleFor(
'Upload' );
736 return $upload->getLocalURL( $q );
767 if ( $file && $file->exists() ) {
768 $url = $file->getUrl();
787 if ( !Hooks::run(
'LinkerMakeMediaLinkFile',
789 wfDebug(
"Hook LinkerMakeMediaLinkFile changed the output of link "
790 .
"with url {$url} and text {$html} to {$ret}\n",
true );
809 $key = strtolower(
$name );
827 $linktype =
'',
$attribs = [], $title =
null
832 $class .=
" $linktype";
835 $class .=
" {$attribs['class']}";
840 $text = htmlspecialchars( $text );
846 $newRel = Parser::getExternalLinkRel( $url,
$title );
849 } elseif ( $newRel !==
'' ) {
851 $newRels = explode(
' ', $newRel );
852 $oldRels = explode(
' ',
$attribs[
'rel'] );
853 $combined = array_unique( array_merge( $newRels, $oldRels ) );
854 $attribs[
'rel'] = implode(
' ', $combined );
857 $success = Hooks::run(
'LinkerMakeExternalLink',
860 wfDebug(
"Hook LinkerMakeExternalLink changed the output of link "
861 .
"with url {$url} and text {$text} to {$link}\n",
true );
865 return Html::rawElement(
'a',
$attribs, $text );
876 public static function userLink( $userId, $userName, $altUserName =
false ) {
877 $classes =
'mw-userlink';
879 if ( $userId == 0 ) {
883 $classes .=
' mw-extuserlink';
884 } elseif ( $altUserName ===
false ) {
885 $altUserName = IP::prettifyIP( $userName );
887 $classes .=
' mw-anonuserlink';
889 $page = Title::makeTitle(
NS_USER, $userName );
894 '<bdi>' . htmlspecialchars( $altUserName !==
false ? $altUserName : $userName ) .
'</bdi>';
897 ?
self::link( $page, $linkText, [
'class' => $classes ] )
898 : Html::rawElement(
'span', [
'class' => $classes ], $linkText );
915 $userId, $userText, $redContribsWhenNoEdits =
false, $flags = 0, $edits =
null
920 $addEmailLink = $flags & self::TOOL_LINKS_EMAIL && $userId;
934 $attribs[
'class'] =
'mw-usertoollinks-contribs';
935 if ( $redContribsWhenNoEdits ) {
936 if ( intval( $edits ) === 0 && $edits !== 0 ) {
938 $edits =
$user->getEditCount();
940 if ( $edits === 0 ) {
944 $contribsPage = SpecialPage::getTitleFor(
'Contributions', $userText );
948 if ( $blockable && $wgUser->isAllowed(
'block' ) ) {
952 if ( $addEmailLink && $wgUser->canSendEmail() ) {
956 Hooks::run(
'UserToolLinksEdit', [ $userId, $userText, &$items ] );
959 return wfMessage(
'word-separator' )->escaped()
960 .
'<span class="mw-usertoollinks">'
961 .
wfMessage(
'parentheses' )->rawParams(
$wgLang->pipeList( $items ) )->escaped()
987 $userTalkPage = Title::makeTitle(
NS_USER_TALK, $userText );
988 $moreLinkAttribs[
'class'] =
'mw-usertoollinks-talk';
990 wfMessage(
'talkpagelinktext' )->escaped(),
992 return $userTalkLink;
1002 $blockPage = SpecialPage::getTitleFor(
'Block', $userText );
1003 $moreLinkAttribs[
'class'] =
'mw-usertoollinks-block';
1016 $emailPage = SpecialPage::getTitleFor(
'Emailuser', $userText );
1017 $moreLinkAttribs[
'class'] =
'mw-usertoollinks-mail';
1041 return '<span class="history-deleted">' .
$link .
'</span>';
1065 return ' <span class="history-deleted">' .
$link .
'</span>';
1089 $comment, $title =
null, $local =
false, $wikiId =
null
1091 # Sanitize text a bit:
1092 $comment = str_replace(
"\n",
" ", $comment );
1093 # Allow HTML entities (for T15815)
1094 $comment = Sanitizer::escapeHtmlAllowEntities( $comment );
1096 # Render autocomments and make links:
1121 $comment, $title =
null, $local =
false, $wikiId =
null
1129 $comment = preg_replace_callback(
1135 '!(?:(?<=(.)))?/\*\s*(.*?)\s*\*/(?:(?=(.)))?!',
1136 function ( $match )
use (
$title, $local, $wikiId, &$append ) {
1140 $match += [
'',
'',
'',
'' ];
1142 $pre = $match[1] !==
'';
1144 $post = $match[3] !==
'';
1148 'FormatAutocomments',
1152 if ( $comment ===
null ) {
1156 # Remove links that a user may have manually put in the autosummary
1157 # This could be improved by copying as much of Parser::stripSectionName as desired.
1162 $section = substr( Parser::guessSectionNameFromStrippedText(
$section ), 1 );
1166 $sectionTitle = Title::makeTitleSafe(
$title->getNamespace(),
1169 if ( $sectionTitle ) {
1176 # written summary $presep autocomment (summary )
1177 $pre =
wfMessage(
'autocomment-prefix' )->inContentLanguage()->escaped();
1180 # autocomment $postsep written summary ( summary)
1181 $auto .=
wfMessage(
'colon-separator' )->inContentLanguage()->escaped();
1183 $auto =
'<span class="autocomment">' .
$auto .
'</span>';
1185 .
'<span dir="auto">' .
$auto;
1186 $append .=
'</span>';
1192 return $comment . $append;
1215 $comment, $title =
null, $local =
false, $wikiId =
null
1217 return preg_replace_callback(
1220 \s*+ # ignore leading whitespace, the *+ quantifier disallows backtracking
1221 :? # ignore optional leading colon
1222 ([^\]|]+) # 1. link target; page names cannot include ] or |
1225 # Stop matching at ]] without relying on backtracking.
1229 ([^[]*) # 3. link trail (the text up until the next link)
1231 function ( $match )
use (
$title, $local, $wikiId ) {
1232 $medians =
'(?:' . preg_quote( MWNamespace::getCanonicalName(
NS_MEDIA ),
'/' ) .
'|';
1233 $medians .= preg_quote(
1234 MediaWikiServices::getInstance()->getContentLanguage()->getNsText(
NS_MEDIA ),
1238 $comment = $match[0];
1240 # fix up urlencoded title texts (copied from Parser::replaceInternalLinks)
1241 if ( strpos( $match[1],
'%' ) !==
false ) {
1243 rawurldecode( $match[1] ),
1244 [
'<' =>
'<',
'>' =>
'>' ]
1248 # Handle link renaming [[foo|text]] will show link as "text"
1249 if ( $match[2] !=
"" ) {
1256 if ( preg_match(
'/^' . $medians .
'(.*)$/i', $match[1], $submatch ) ) {
1257 # Media link; trail not supported.
1258 $linkRegexp =
'/\[\[(.*?)\]\]/';
1264 # Other kind of link
1265 # Make sure its target is non-empty
1266 if ( isset( $match[1][0] ) && $match[1][0] ==
':' ) {
1267 $match[1] = substr( $match[1], 1 );
1269 if ( $match[1] !==
false && $match[1] !==
'' ) {
1271 MediaWikiServices::getInstance()->getContentLanguage()->linkTrail(),
1275 $trail = $submatch[1];
1279 $linkRegexp =
'/\[\[(.*?)\]\]' . preg_quote( $trail,
'/' ) .
'/';
1285 $target = Title::newFromText( $linkTarget );
1287 if ( $target->getText() ==
'' && !$target->isExternal()
1290 $target =
$title->createFragmentTarget( $target->getFragment() );
1299 $comment = preg_replace(
1329 if ( $wikiId !==
null && !$linkTarget->
isExternal() ) {
1335 : MWNamespace::getCanonicalName( $linkTarget->
getNamespace() ) .
':'
1358 # :Foobar -- override special treatment of prefix (images, language links)
1359 # /Foobar -- convert to CurrentPage/Foobar
1360 # /Foobar/ -- convert to CurrentPage/Foobar, strip the initial and final / from text
1361 # ../ -- convert to CurrentPage, from CurrentPage/CurrentSubPage
1362 # ../Foobar -- convert to CurrentPage/Foobar,
1363 # (from CurrentPage/CurrentSubPage)
1364 # ../Foobar/ -- convert to CurrentPage/Foobar, use 'Foobar' as text
1365 # (from CurrentPage/CurrentSubPage)
1369 # Some namespaces don't allow subpages,
1370 # so only perform processing if subpages are allowed
1371 if ( $contextTitle && MWNamespace::hasSubpages( $contextTitle->getNamespace() ) ) {
1372 $hash = strpos( $target,
'#' );
1373 if ( $hash !==
false ) {
1374 $suffix = substr( $target, $hash );
1375 $target = substr( $target, 0, $hash );
1380 $target = trim( $target );
1381 # Look at the first character
1382 if ( $target !=
'' && $target[0] ===
'/' ) {
1383 # / at end means we don't want the slash to be shown
1385 $trailingSlashes = preg_match_all(
'%(/+)$%', $target, $m );
1386 if ( $trailingSlashes ) {
1387 $noslash = $target = substr( $target, 1, -strlen( $m[0][0] ) );
1389 $noslash = substr( $target, 1 );
1392 $ret = $contextTitle->getPrefixedText() .
'/' . trim( $noslash ) . $suffix;
1393 if ( $text ===
'' ) {
1394 $text = $target . $suffix;
1395 } #
this might be changed
for ugliness reasons
1397 # check for .. subpage backlinks
1399 $nodotdot = $target;
1400 while ( strncmp( $nodotdot,
"../", 3 ) == 0 ) {
1402 $nodotdot = substr( $nodotdot, 3 );
1404 if ( $dotdotcount > 0 ) {
1405 $exploded = explode(
'/', $contextTitle->getPrefixedText() );
1406 if ( count( $exploded ) > $dotdotcount ) { # not allowed to go
below top level
page
1407 $ret = implode(
'/', array_slice( $exploded, 0, -$dotdotcount ) );
1408 # / at the end means don't show full path
1409 if ( substr( $nodotdot, -1, 1 ) ===
'/' ) {
1410 $nodotdot = rtrim( $nodotdot,
'/' );
1411 if ( $text ===
'' ) {
1412 $text = $nodotdot . $suffix;
1415 $nodotdot = trim( $nodotdot );
1416 if ( $nodotdot !=
'' ) {
1417 $ret .=
'/' . $nodotdot;
1442 $comment, $title =
null, $local =
false, $wikiId =
null
1447 if ( $comment ==
'' || $comment ==
'*' ) {
1451 $formatted =
wfMessage(
'parentheses' )->rawParams( $formatted )->escaped();
1452 return " <span class=\"comment\">$formatted</span>";
1471 $block =
" <span class=\"comment\">" .
wfMessage(
'rev-deleted-comment' )->escaped() .
"</span>";
1474 $rev->getTitle(), $local );
1476 $block =
" <span class=\"comment\">" .
wfMessage(
'rev-deleted-comment' )->escaped() .
"</span>";
1479 return " <span class=\"history-deleted\">$block</span>";
1491 $stxt =
wfMessage(
'historyempty' )->escaped();
1493 $stxt =
wfMessage(
'nbytes' )->numParams( $size )->escaped();
1494 $stxt =
wfMessage(
'parentheses' )->rawParams( $stxt )->escaped();
1496 return "<span class=\"history-size\">$stxt</span>";
1517 return "</li>\n" . str_repeat(
"</ul>\n</li>\n", $level > 0 ? $level : 0 );
1531 public static function tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex =
false ) {
1532 $classes =
"toclevel-$level";
1533 if ( $sectionIndex !==
false ) {
1534 $classes .=
" tocsection-$sectionIndex";
1539 return Html::openElement(
'li', [
'class' => $classes ] )
1540 . Html::rawElement(
'a',
1541 [
'href' =>
"#$anchor" ],
1542 Html::element(
'span', [
'class' =>
'tocnumber' ], $tocnumber )
1544 . Html::rawElement(
'span', [
'class' =>
'toctext' ], $tocline )
1571 return '<div id="toc" class="toc">'
1572 . Html::element(
'input', [
1573 'type' =>
'checkbox',
1575 'id' =>
'toctogglecheckbox',
1576 'class' =>
'toctogglecheckbox',
1577 'style' =>
'display:none',
1579 . Html::openElement(
'div', [
1580 'class' =>
'toctitle',
1581 'lang' =>
$lang->getHtmlCode(),
1582 'dir' =>
$lang->getDir(),
1585 .
'<span class="toctogglespan">'
1586 . Html::label(
'',
'toctogglecheckbox', [
1587 'class' =>
'toctogglelabel',
1592 .
"</ul>\n</div>\n";
1607 if (
$section[
'toclevel'] > $lastLevel ) {
1609 } elseif (
$section[
'toclevel'] < $lastLevel ) {
1611 $lastLevel -
$section[
'toclevel'] );
1642 $link, $fallbackAnchor =
false
1644 $anchorEscaped = htmlspecialchars( $anchor );
1646 if ( $fallbackAnchor !==
false && $fallbackAnchor !== $anchor ) {
1647 $fallbackAnchor = htmlspecialchars( $fallbackAnchor );
1648 $fallback =
"<span id=\"$fallbackAnchor\"></span>";
1650 $ret =
"<h$level$attribs"
1651 .
"$fallback<span class=\"mw-headline\" id=\"$anchorEscaped\">$html</span>"
1665 $regex = MediaWikiServices::getInstance()->getContentLanguage()->linkTrail();
1667 if ( $trail !==
'' ) {
1669 if ( preg_match( $regex, $trail, $m ) ) {
1674 return [ $inside, $trail ];
1708 $context = RequestContext::getMain();
1712 if ( in_array(
'verify',
$options,
true ) ) {
1714 if ( $editCount ===
false ) {
1721 if ( !in_array(
'noBrackets',
$options,
true ) ) {
1722 $inner =
$context->msg(
'brackets' )->rawParams( $inner )->escaped();
1725 return '<span class="mw-rollback-link">' . $inner .
'</span>';
1756 [
'rev_user_text' =>
$revQuery[
'fields'][
'rev_user_text'],
'rev_deleted' ],
1758 [
'rev_page' =>
$rev->getTitle()->getArticleID() ],
1761 'USE INDEX' => [
'revision' =>
'page_timestamp' ],
1762 'ORDER BY' =>
'rev_timestamp DESC',
1770 foreach (
$res as $row ) {
1811 $disableRollbackEditCountSpecialPage = [
'Recentchanges',
'Watchlist' ];
1814 $context = RequestContext::getMain();
1819 'action' =>
'rollback',
1820 'from' =>
$rev->getUserText(),
1821 'token' =>
$context->getUser()->getEditToken(
'rollback' ),
1824 'data-mw' =>
'interface',
1825 'title' =>
$context->msg(
'tooltip-rollback' )->text(),
1827 $options = [
'known',
'noclasses' ];
1829 if (
$context->getRequest()->getBool(
'bot' ) ) {
1831 $query[
'hidediff'] =
'1';
1834 $disableRollbackEditCount =
false;
1836 foreach ( $disableRollbackEditCountSpecialPage
as $specialPage ) {
1838 $disableRollbackEditCount =
true;
1844 if ( !$disableRollbackEditCount
1848 if ( !is_numeric( $editCount ) ) {
1856 $html =
$context->msg(
'rollbacklinkcount' )->numParams( $editCount )->parse();
1896 if ( $more instanceof
Message ) {
1897 $more = $more->toString();
1901 RequestContext::getMain(),
1902 MediaWikiServices::getInstance()->getLinkRenderer()
1904 return $formatter->format( $templates,
$type, $more );
1917 if ( count( $hiddencats ) > 0 ) {
1918 # Construct the HTML
1919 $outText =
'<div class="mw-hiddenCategoriesExplanation">';
1920 $outText .=
wfMessage(
'hiddencategories' )->numParams( count( $hiddencats ) )->parseAsBlock();
1921 $outText .=
"</div><ul>\n";
1923 foreach ( $hiddencats
as $titleObj ) {
1924 # If it's hidden, it must exist - no need to check with a LinkBatch
1926 .
self::link( $titleObj,
null, [], [],
'known' )
1929 $outText .=
'</ul>';
1948 return htmlspecialchars(
$wgLang->formatSize( $size ) );
1968 $message =
wfMessage(
"tooltip-$name", $msgParams );
1969 if ( !$message->exists() ) {
1972 $tooltip = $message->text();
1973 # Compatibility: formerly some tooltips had [alt-.] hardcoded
1974 $tooltip = preg_replace(
"/ ?\[alt-.\]$/",
'', $tooltip );
1975 # Message equal to '-' means suppress it.
1976 if ( $tooltip ==
'-' ) {
1983 if ( in_array(
'nonexisting',
$options ) ) {
1984 $tooltip =
wfMessage(
'red-link-title', $tooltip ?:
'' )->
text();
1986 if ( in_array(
'withaccess',
$options ) ) {
1988 if ( $accesskey !==
false ) {
1990 if ( $tooltip ===
false || $tooltip ===
'' ) {
1991 $tooltip =
wfMessage(
'brackets', $accesskey )->text();
1993 $tooltip .=
wfMessage(
'word-separator' )->text();
1994 $tooltip .=
wfMessage(
'brackets', $accesskey )->text();
2016 if ( isset( self::$accesskeycache[
$name] ) ) {
2017 return self::$accesskeycache[
$name];
2020 $message =
wfMessage(
"accesskey-$name" );
2022 if ( !$message->exists() ) {
2025 $accesskey = $message->plain();
2026 if ( $accesskey ===
'' || $accesskey ===
'-' ) {
2027 # @todo FIXME: Per standard MW behavior, a value of '-' means to suppress the
2028 # attribute, but this is broken for accesskey: that might be a useful
2034 self::$accesskeycache[
$name] = $accesskey;
2035 return self::$accesskeycache[
$name];
2052 $canHide =
$user->isAllowed(
'deleterevision' );
2053 if ( !$canHide && !(
$rev->getVisibility() &&
$user->isAllowed(
'deletedhistory' ) ) ) {
2060 if (
$rev->getId() ) {
2064 'type' =>
'revision',
2065 'target' =>
$title->getPrefixedDBkey(),
2066 'ids' =>
$rev->getId()
2072 'type' =>
'archive',
2073 'target' =>
$title->getPrefixedDBkey(),
2074 'ids' =>
$rev->getTimestamp()
2093 $sp = SpecialPage::getTitleFor(
'Revisiondelete' );
2094 $msgKey = $delete ?
'rev-delundel' :
'rev-showdeleted';
2096 $tag = $restricted ?
'strong' :
'span';
2100 [
'class' =>
'mw-revdelundel-link' ],
2115 $msgKey = $delete ?
'rev-delundel' :
'rev-showdeleted';
2117 $htmlParentheses =
wfMessage(
'parentheses' )->rawParams(
$html )->escaped();
2118 return Xml::tags(
'span', [
'class' =>
'mw-revdelundel-link' ], $htmlParentheses );
2135 array $msgParams = [],
2145 if (
$attribs[
'title'] ===
false ) {
2148 if (
$attribs[
'accesskey'] ===
false ) {
2163 if ( $tooltip ===
false ) {
2166 return Xml::expandAttributes( [
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
See &</td >< td > &Fill in a specific reason below(for example, citing particular pages that were vandalized).</td >< td >
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
$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.
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'] !='') $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 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 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 makeThumbLinkObj(Title $title, $file, $label='', $alt='', $align='right', $params=[], $framed=false, $manualthumb="")
Make HTML for a thumbnail including image, border and caption.
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 getQueryInfo( $options=[])
Return the tables, fields, and join conditions to be selected to create a new revision object.
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 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
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
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $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
namespace and then decline to actually register it file or subcat img or subcat $title
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
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
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 "<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
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
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
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
Interface for objects which can provide a MediaWiki context on request.
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))
This document provides an overview of the usage of PageUpdater and that is
if(!isset( $args[0])) $lang