371 # Placeholders for text injection by hooks (must be HTML)
372 # extensions should take care to _append_ to the present value
405 $this->mTitle = $article->
getTitle();
407 $this->contentModel = $this->mTitle->getContentModel();
410 $this->contentFormat =
$handler->getDefaultFormat();
434 $this->mContextTitle =
$title;
445 if ( is_null( $this->mContextTitle ) ) {
461 return $this->enableApiEditOverride ===
true ||
472 $this->enableApiEditOverride = $enableOverride;
493 if ( !
Hooks::run(
'AlternateEdit', [ $this ] ) ) {
497 wfDebug( __METHOD__ .
": enter\n" );
500 if ( $wgRequest->getBool(
'redlink' ) && $this->mTitle->exists() ) {
501 $wgOut->redirect( $this->mTitle->getFullURL() );
506 $this->firsttime =
false;
511 $this->preview =
true;
515 $this->formtype =
'save';
516 } elseif ( $this->preview ) {
517 $this->formtype =
'preview';
518 } elseif ( $this->diff ) {
519 $this->formtype =
'diff';
520 }
else { #
First time through
521 $this->firsttime =
true;
523 $this->formtype =
'preview';
525 $this->formtype =
'initial';
531 wfDebug( __METHOD__ .
": User can't edit\n" );
536 $user->spreadAnyEditBlock();
544 $revision = $this->mArticle->getRevisionFetched();
550 'contentmodelediterror',
551 $revision->getContentModel(),
558 $this->isConflict =
false;
560 $this->isCssJsSubpage = $this->mTitle->isCssJsSubpage();
561 $this->isCssSubpage = $this->mTitle->isCssSubpage();
562 $this->isJsSubpage = $this->mTitle->isJsSubpage();
566 # Show applicable editing introductions
567 if ( $this->formtype ==
'initial' || $this->firsttime ) {
571 # Attempt submission here. This will check for edit conflicts,
572 # and redundantly check for locked database, blocked IPs, etc.
573 # that edit() already checked just in case someone tries to sneak
574 # in the back door with a hand-edited submission URL.
576 if (
'save' == $this->formtype ) {
577 $resultDetails = null;
584 # First time through: get contents, set time for conflict
586 if (
'initial' == $this->formtype || $this->firsttime ) {
592 if ( !$this->mTitle->getArticleID() ) {
593 Hooks::run(
'EditFormPreloadText', [ &$this->textbox1, &$this->mTitle ] );
595 Hooks::run(
'EditFormInitialText', [ $this ] );
610 $permErrors = $this->mTitle->getUserPermissionsErrors(
'edit', $wgUser, $rigor );
611 # Can this title be created?
612 if ( !$this->mTitle->exists() ) {
613 $permErrors = array_merge(
616 $this->mTitle->getUserPermissionsErrors(
'create', $wgUser, $rigor ),
621 # Ignore some permissions errors when a user is just previewing/viewing diffs
623 foreach ( $permErrors
as $error ) {
624 if ( ( $this->preview || $this->diff )
625 && ( $error[0] ==
'blockedtext' || $error[0] ==
'autoblockedtext' )
651 if ( $wgRequest->getBool(
'redlink' ) ) {
655 $wgOut->redirect( $this->mTitle->getFullURL() );
661 # Use the normal message if there's nothing to display
663 $action = $this->mTitle->exists() ?
'edit' :
664 ( $this->mTitle->isTalkPage() ?
'createtalk' :
'createpage' );
670 $wgOut->formatPermissionsErrorMessage( $permErrors,
'edit' )
682 Hooks::run(
'EditPage::showReadOnlyForm:initial', [ $this, &$wgOut ] );
684 $wgOut->setRobotPolicy(
'noindex,nofollow' );
690 $wgOut->addHTML( $this->editFormPageTop );
691 $wgOut->addHTML( $this->editFormTextTop );
693 if ( $errorMessage !==
'' ) {
694 $wgOut->addWikiText( $errorMessage );
695 $wgOut->addHTML(
"<hr />\n" );
698 # If the user made changes, preserve them when showing the markup
699 # (This happens when a user is blocked during edit, for instance)
700 if ( !$this->firsttime ) {
702 $wgOut->addWikiMsg(
'viewyourtext' );
707 # Serialize using the default format if the content model is not supported
708 # (e.g. for an old revision with a different model)
711 $wgOut->addWikiMsg(
'viewsourcetext' );
714 $wgOut->addHTML( $this->editFormTextBeforeContent );
715 $this->
showTextbox( $text,
'wpTextbox1', [
'readonly' ] );
716 $wgOut->addHTML( $this->editFormTextAfterContent );
721 $wgOut->addModules(
'mediawiki.action.edit.collapsibleFooter' );
723 $wgOut->addHTML( $this->editFormTextBottom );
724 if ( $this->mTitle->exists() ) {
725 $wgOut->returnToMain( null, $this->mTitle );
736 if ( $wgRequest->getVal(
'preview' ) ==
'yes' ) {
739 } elseif ( $wgRequest->getVal(
'preview' ) ==
'no' ) {
742 } elseif ( $this->section ==
'new' ) {
745 } elseif ( ( $wgRequest->getVal(
'preload' ) !== null || $this->mTitle->exists() )
746 && $wgUser->getOption(
'previewonfirst' )
750 } elseif ( !$this->mTitle->exists()
751 && isset( $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()] )
752 && $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()]
768 if ( $this->mTitle->isCssJsSubpage() ) {
769 $name = $this->mTitle->getSkinFromCssJsSubpage();
770 $skins = array_merge(
774 return !in_array(
$name, $skins )
775 && in_array( strtolower(
$name ), $skins );
790 return $contentHandler->supportsSections();
801 # Section edit can come from either the form or a link
802 $this->section =
$request->getVal(
'wpSection',
$request->getVal(
'section' ) );
805 throw new ErrorPageError(
'sectioneditnotsupported-title',
'sectioneditnotsupported-text' );
808 $this->isNew = !$this->mTitle->exists() || $this->section ==
'new';
811 # These fields need to be checked for encoding.
812 # Also remove trailing whitespace, but don't remove _initial_
813 # whitespace from the text boxes. This may be significant formatting.
815 if ( !
$request->getCheck(
'wpTextbox2' ) ) {
825 # Truncate for whole multibyte characters
826 $this->summary = $wgContLang->truncate(
$request->getText(
'wpSummary' ), 255 );
828 # If the summary consists of a heading, e.g. '==Foobar==', extract the title from the
829 # header syntax, e.g. 'Foobar'. This is mainly an issue when we are using wpSummary for
831 $this->summary = preg_replace(
'/^\s*=+\s*(.*?)\s*=+\s*$/',
'$1', $this->summary );
833 # Treat sectiontitle the same way as summary.
834 # Note that wpSectionTitle is not yet a part of the actual edit form, as wpSummary is
835 # currently doing double duty as both edit summary and section title. Right now this
836 # is just to allow API edits to work around this limitation, but this should be
837 # incorporated into the actual edit form when EditPage is rewritten (Bugs 18654, 26312).
838 $this->sectiontitle = $wgContLang->truncate(
$request->getText(
'wpSectionTitle' ), 255 );
839 $this->sectiontitle = preg_replace(
'/^\s*=+\s*(.*?)\s*=+\s*$/',
'$1', $this->sectiontitle );
841 $this->edittime =
$request->getVal(
'wpEdittime' );
842 $this->starttime =
$request->getVal(
'wpStarttime' );
849 $this->scrolltop =
$request->getIntOrNull(
'wpScrolltop' );
851 if ( $this->textbox1 ===
'' &&
$request->getVal(
'wpTextbox1' ) === null ) {
855 $this->incompleteForm =
true;
863 $this->incompleteForm = ( !
$request->getVal(
'wpUltimateParam' )
864 && is_null( $this->edittime ) );
866 if ( $this->incompleteForm ) {
867 # If the form is incomplete, force to preview.
868 wfDebug( __METHOD__ .
": Form data appears to be incomplete\n" );
869 wfDebug(
"POST DATA: " . var_export( $_POST,
true ) .
"\n" );
870 $this->preview =
true;
872 $this->preview =
$request->getCheck(
'wpPreview' );
873 $this->diff =
$request->getCheck(
'wpDiff' );
880 # Some browsers will not report any submit button
881 # if the user hits enter in the comment box.
882 # The unmarked state will be assumed to be a save,
883 # if the form seems otherwise complete.
884 wfDebug( __METHOD__ .
": Passed token check.\n" );
885 } elseif ( $this->diff ) {
886 # Failed token check, but only requested "Show Changes".
887 wfDebug( __METHOD__ .
": Failed token check; Show Changes requested.\n" );
889 # Page might be a hack attempt posted from
890 # an external site. Preview instead of saving.
891 wfDebug( __METHOD__ .
": Failed token check; forcing preview\n" );
892 $this->preview =
true;
896 if ( !preg_match(
'/^\d{14}$/', $this->edittime ) ) {
897 $this->edittime = null;
900 if ( !preg_match(
'/^\d{14}$/', $this->starttime ) ) {
901 $this->starttime = null;
904 $this->recreate =
$request->getCheck(
'wpRecreate' );
906 $this->minoredit =
$request->getCheck(
'wpMinoredit' );
907 $this->watchthis =
$request->getCheck(
'wpWatchthis' );
909 # Don't force edit summaries when a user is editing their own user or talk page
911 && $this->mTitle->getText() == $wgUser->getName()
913 $this->allowBlankSummary =
true;
915 $this->allowBlankSummary =
$request->getBool(
'wpIgnoreBlankSummary' )
916 || !$wgUser->getOption(
'forceeditsummary' );
919 $this->autoSumm =
$request->getText(
'wpAutoSummary' );
921 $this->allowBlankArticle =
$request->getBool(
'wpIgnoreBlankArticle' );
922 $this->allowSelfRedirect =
$request->getBool(
'wpIgnoreSelfRedirect' );
926 $this->changeTags = [];
928 $this->changeTags = array_filter( array_map(
'trim', explode(
',',
932 # Not a posted form? Start with nothing.
933 wfDebug( __METHOD__ .
": Not a posted form.\n" );
934 $this->textbox1 =
'';
936 $this->sectiontitle =
'';
937 $this->edittime =
'';
940 $this->preview =
false;
943 $this->minoredit =
false;
945 $this->watchthis =
$request->getBool(
'watchthis',
false );
946 $this->recreate =
false;
950 if ( $this->section ==
'new' &&
$request->getVal(
'preloadtitle' ) ) {
951 $this->sectiontitle =
$request->getVal(
'preloadtitle' );
953 $this->summary =
$request->getVal(
'preloadtitle' );
954 } elseif ( $this->section !=
'new' &&
$request->getVal(
'summary' ) ) {
955 $this->summary =
$request->getText(
'summary' );
956 if ( $this->summary !==
'' ) {
957 $this->hasPresetSummary =
true;
961 if (
$request->getVal(
'minor' ) ) {
962 $this->minoredit =
true;
966 $this->oldid =
$request->getInt(
'oldid' );
967 $this->parentRevId =
$request->getInt(
'parentRevId' );
969 $this->bot =
$request->getBool(
'bot',
true );
970 $this->nosummary =
$request->getBool(
'nosummary' );
973 $this->contentModel =
$request->getText(
'model', $this->contentModel );
975 $this->contentFormat =
$request->getText(
'format', $this->contentFormat );
978 ->isSupportedFormat( $this->contentFormat )
981 'editpage-notsupportedcontentformat-title',
982 'editpage-notsupportedcontentformat-text',
996 $this->editintro =
$request->getText(
'editintro',
998 $this->section ===
'new' ?
'MediaWiki:addsection-editintro' :
'' );
1025 $this->edittime = $this->
page->getTimestamp();
1034 # Sort out the "watch" checkbox
1035 if ( $wgUser->getOption(
'watchdefault' ) ) {
1037 $this->watchthis =
true;
1038 } elseif ( $wgUser->getOption(
'watchcreations' ) && !$this->mTitle->exists() ) {
1040 $this->watchthis =
true;
1041 } elseif ( $wgUser->isWatched( $this->mTitle ) ) {
1043 $this->watchthis =
true;
1045 if ( $wgUser->getOption(
'minordefault' ) && !
$this->isNew ) {
1046 $this->minoredit =
true;
1048 if ( $this->textbox1 ===
false ) {
1068 if ( !$this->mTitle->exists() || $this->section ==
'new' ) {
1069 if ( $this->mTitle->getNamespace() ==
NS_MEDIAWIKI && $this->section !=
'new' ) {
1070 # If this is a system message, get the default text.
1071 $msg = $this->mTitle->getDefaultMessageText();
1076 # If requested, preload some text.
1077 $preload = $wgRequest->getVal(
'preload',
1079 $this->section ===
'new' ?
'MediaWiki:addsection-preload' :
'' );
1080 $params = $wgRequest->getArray(
'preloadparams', [] );
1086 if ( $this->section !=
'' ) {
1089 $content = $orig ? $orig->getSection( $this->section ) : null;
1095 $undoafter = $wgRequest->getInt(
'undoafter' );
1096 $undo = $wgRequest->getInt(
'undo' );
1098 if ( $undo > 0 && $undoafter > 0 ) {
1102 # Sanity check, make sure it's the right page,
1103 # the revisions exist and they were not deleted.
1104 # Otherwise, $content will be left as-is.
1105 if ( !is_null( $undorev ) && !is_null( $oldrev ) &&
1109 $content = $this->
page->getUndoContent( $undorev, $oldrev );
1112 # Warn the user that something went wrong
1113 $undoMsg =
'failure';
1117 $newContent =
$content->preSaveTransform( $this->mTitle, $wgUser, $popts );
1119 if ( $newContent->equals( $oldContent ) ) {
1120 # Tell the user that the undo results in no change,
1121 # i.e. the revisions were already undone.
1122 $undoMsg =
'nochange';
1125 # Inform the user of our success and set an automatic edit summary
1126 $undoMsg =
'success';
1128 # If we just undid one rev, use an autosummary
1129 $firstrev = $oldrev->getNext();
1130 if ( $firstrev && $firstrev->getId() == $undo ) {
1131 $userText = $undorev->getUserText();
1132 if ( $userText ===
'' ) {
1134 'undo-summary-username-hidden',
1136 )->inContentLanguage()->text();
1142 )->inContentLanguage()->text();
1144 if ( $this->summary ===
'' ) {
1145 $this->summary = $undoSummary;
1147 $this->summary = $undoSummary .
wfMessage(
'colon-separator' )
1150 $this->undidRev = $undo;
1152 $this->formtype =
'diff';
1163 $class = ( $undoMsg ==
'success' ?
'' :
'error ' ) .
"mw-undo-{$undoMsg}";
1164 $this->editFormPageTop .= $wgOut->parse(
"<div class=\"{$class}\">" .
1165 wfMessage(
'undo-' . $undoMsg )->plain() .
'</div>',
true,
true );
1193 if ( $this->section ==
'new' ) {
1196 $revision = $this->mArticle->getRevisionFetched();
1197 if ( $revision === null ) {
1198 if ( !$this->contentModel ) {
1199 $this->contentModel = $this->
getTitle()->getContentModel();
1203 return $handler->makeEmptyContent();
1222 if ( $this->parentRevId ) {
1225 return $this->mArticle->getRevIdFetched();
1242 if ( !$this->contentModel ) {
1243 $this->contentModel = $this->
getTitle()->getContentModel();
1247 return $handler->makeEmptyContent();
1249 # nasty side-effect, but needed for consistency
1250 $this->contentModel =
$rev->getContentModel();
1251 $this->contentFormat =
$rev->getContentFormat();
1282 if ( !empty( $this->mPreloadContent ) ) {
1288 if ( $preload ===
'' ) {
1289 return $handler->makeEmptyContent();
1293 # Check for existence to avoid getting MediaWiki:Noarticletext
1296 return $handler->makeEmptyContent();
1305 return $handler->makeEmptyContent();
1315 return $handler->makeEmptyContent();
1321 if ( !$converted ) {
1323 wfDebug(
"Attempt to preload incompatible content: " .
1324 "can't convert " .
$content->getModel() .
1327 return $handler->makeEmptyContent();
1345 $token =
$request->getVal(
'wpEditToken' );
1346 $this->mTokenOk = $wgUser->matchEditToken( $token );
1347 $this->mTokenOkExceptSuffix = $wgUser->matchEditTokenNoSuffix( $token );
1368 $revisionId = $this->
page->getLatest();
1369 $postEditKey = self::POST_EDIT_COOKIE_KEY_PREFIX . $revisionId;
1372 if ( $statusValue == self::AS_SUCCESS_NEW_ARTICLE ) {
1374 } elseif ( $this->oldid ) {
1379 $response->setCookie( $postEditKey, $val, time() + self::POST_EDIT_COOKIE_DURATION, [
1380 'httpOnly' =>
false,
1393 # Allow bots to exempt some edits from bot flagging
1397 Hooks::run(
'EditPage::attemptSave:after', [ $this,
$status, $resultDetails ] );
1418 if ( $status->value == self::AS_SUCCESS_UPDATE
1419 || $status->value == self::AS_SUCCESS_NEW_ARTICLE
1421 $this->didSave =
true;
1422 if ( !$resultDetails[
'nullEdit'] ) {
1430 $extraQueryRedirect =
$request->getVal(
'wpExtraQueryRedirect' );
1432 switch ( $status->value ) {
1433 case self::AS_HOOK_ERROR_EXPECTED:
1434 case self::AS_CONTENT_TOO_BIG:
1435 case self::AS_ARTICLE_WAS_DELETED:
1436 case self::AS_CONFLICT_DETECTED:
1437 case self::AS_SUMMARY_NEEDED:
1438 case self::AS_TEXTBOX_EMPTY:
1439 case self::AS_MAX_ARTICLE_SIZE_EXCEEDED:
1441 case self::AS_BLANK_ARTICLE:
1442 case self::AS_SELF_REDIRECT:
1445 case self::AS_HOOK_ERROR:
1448 case self::AS_CANNOT_USE_CUSTOM_MODEL:
1449 case self::AS_PARSE_ERROR:
1450 $wgOut->addWikiText(
'<div class="error">' . $status->
getWikiText() .
'</div>' );
1453 case self::AS_SUCCESS_NEW_ARTICLE:
1454 $query = $resultDetails[
'redirect'] ?
'redirect=no' :
'';
1455 if ( $extraQueryRedirect ) {
1457 $query = $extraQueryRedirect;
1462 $anchor = isset( $resultDetails[
'sectionanchor'] ) ? $resultDetails[
'sectionanchor'] :
'';
1463 $wgOut->redirect( $this->mTitle->getFullURL(
$query ) . $anchor );
1466 case self::AS_SUCCESS_UPDATE:
1468 $sectionanchor = $resultDetails[
'sectionanchor'];
1472 'ArticleUpdateBeforeRedirect',
1473 [ $this->mArticle, &$sectionanchor, &$extraQuery ]
1476 if ( $resultDetails[
'redirect'] ) {
1477 if ( $extraQuery ==
'' ) {
1478 $extraQuery =
'redirect=no';
1480 $extraQuery =
'redirect=no&' . $extraQuery;
1483 if ( $extraQueryRedirect ) {
1484 if ( $extraQuery ===
'' ) {
1485 $extraQuery = $extraQueryRedirect;
1487 $extraQuery = $extraQuery .
'&' . $extraQueryRedirect;
1491 $wgOut->redirect( $this->mTitle->getFullURL( $extraQuery ) . $sectionanchor );
1494 case self::AS_SPAM_ERROR:
1498 case self::AS_BLOCKED_PAGE_FOR_USER:
1501 case self::AS_IMAGE_REDIRECT_ANON:
1502 case self::AS_IMAGE_REDIRECT_LOGGED:
1505 case self::AS_READ_ONLY_PAGE_ANON:
1506 case self::AS_READ_ONLY_PAGE_LOGGED:
1509 case self::AS_READ_ONLY_PAGE:
1512 case self::AS_RATE_LIMITED:
1515 case self::AS_NO_CREATE_PERMISSION:
1516 $permission = $this->mTitle->isTalkPage() ?
'createtalk' :
'createpage';
1519 case self::AS_NO_CHANGE_CONTENT_MODEL:
1527 $this->hookError =
'<div class="error">' . $status->
getWikiText() .
1545 [ $this, $content, &$this->hookError, $this->summary ] )
1547 # Error messages etc. could be handled within the hook...
1548 $status->
fatal(
'hookaborted' );
1549 $status->value = self::AS_HOOK_ERROR;
1551 } elseif ( $this->hookError !=
'' ) {
1552 # ...or the hook could be expecting us to produce an error
1553 $status->
fatal(
'hookaborted' );
1554 $status->value = self::AS_HOOK_ERROR_EXPECTED;
1563 # Error messages etc. could be handled within the hook...
1564 if ( $status->isGood() ) {
1565 $status->
fatal(
'hookaborted' );
1571 $this->hookError = $status->getWikiText();
1574 if ( !$status->value ) {
1575 $status->value = self::AS_HOOK_ERROR;
1578 } elseif ( !$status->isOK() ) {
1579 # ...or the hook could be expecting us to produce an error
1581 $this->hookError = $status->getWikiText();
1582 $status->fatal(
'hookaborted' );
1583 $status->value = self::AS_HOOK_ERROR_EXPECTED;
1599 if ( $this->sectiontitle !==
'' ) {
1600 $sectionanchor = $wgParser->guessLegacySectionNameFromWikiText( $this->sectiontitle );
1604 if ( $this->summary ===
'' ) {
1605 $cleanSectionTitle = $wgParser->stripSectionName( $this->sectiontitle );
1607 ->rawParams( $cleanSectionTitle )->inContentLanguage()->text();
1609 } elseif ( $this->summary !==
'' ) {
1610 $sectionanchor = $wgParser->guessLegacySectionNameFromWikiText( $this->summary );
1611 # This is a new section, so create a link to the new section
1612 # in the revision summary.
1613 $cleanSummary = $wgParser->stripSectionName( $this->summary );
1615 ->rawParams( $cleanSummary )->inContentLanguage()->text();
1646 global $wgContentHandlerUseDB;
1650 if ( !
Hooks::run(
'EditPage::attemptSave', [ $this ] ) ) {
1651 wfDebug(
"Hook 'EditPage::attemptSave' aborted article saving\n" );
1652 $status->fatal(
'hookaborted' );
1653 $status->value = self::AS_HOOK_ERROR;
1657 $spam = $wgRequest->getText(
'wpAntispam' );
1658 if ( $spam !==
'' ) {
1661 $wgUser->getName() .
1663 $this->mTitle->getPrefixedText() .
1664 '" submitted bogus field "' .
1668 $status->fatal(
'spamprotectionmatch',
false );
1669 $status->value = self::AS_SPAM_ERROR;
1674 # Construct Content object
1678 'content-failed-to-parse',
1679 $this->contentModel,
1680 $this->contentFormat,
1683 $status->value = self::AS_PARSE_ERROR;
1687 # Check image redirect
1688 if ( $this->mTitle->getNamespace() ==
NS_FILE &&
1689 $textbox_content->isRedirect() &&
1690 !$wgUser->isAllowed(
'upload' )
1692 $code = $wgUser->isAnon() ? self::AS_IMAGE_REDIRECT_ANON : self::AS_IMAGE_REDIRECT_LOGGED;
1699 $match = self::matchSummarySpamRegex( $this->summary );
1700 if ( $match ===
false && $this->section ==
'new' ) {
1701 # $wgSpamRegex is enforced on this new heading/summary because, unlike
1702 # regular summaries, it is added to the actual wikitext.
1703 if ( $this->sectiontitle !==
'' ) {
1704 # This branch is taken when the API is used with the 'sectiontitle' parameter.
1705 $match = self::matchSpamRegex( $this->sectiontitle );
1707 # This branch is taken when the "Add Topic" user interface is used, or the API
1708 # is used with the 'summary' parameter.
1709 $match = self::matchSpamRegex( $this->summary );
1712 if ( $match ===
false ) {
1713 $match = self::matchSpamRegex( $this->textbox1 );
1715 if ( $match !==
false ) {
1717 $ip = $wgRequest->getIP();
1718 $pdbk = $this->mTitle->getPrefixedDBkey();
1719 $match = str_replace(
"\n",
'', $match );
1720 wfDebugLog(
'SpamRegex',
"$ip spam regex hit [[$pdbk]]: \"$match\"" );
1721 $status->fatal(
'spamprotectionmatch', $match );
1722 $status->value = self::AS_SPAM_ERROR;
1727 [ $this, $this->textbox1, $this->section, &$this->hookError, $this->summary ] )
1729 # Error messages etc. could be handled within the hook...
1730 $status->fatal(
'hookaborted' );
1731 $status->value = self::AS_HOOK_ERROR;
1733 } elseif ( $this->hookError !=
'' ) {
1734 # ...or the hook could be expecting us to produce an error
1735 $status->fatal(
'hookaborted' );
1736 $status->value = self::AS_HOOK_ERROR_EXPECTED;
1740 if ( $wgUser->isBlockedFrom( $this->mTitle,
false ) ) {
1743 $wgUser->spreadAnyEditBlock();
1745 # Check block state against master, thus 'false'.
1746 $status->setResult(
false, self::AS_BLOCKED_PAGE_FOR_USER );
1750 $this->kblength = (int)( strlen( $this->textbox1 ) / 1024 );
1751 if ( $this->kblength > $wgMaxArticleSize ) {
1753 $this->tooBig =
true;
1754 $status->setResult(
false, self::AS_CONTENT_TOO_BIG );
1758 if ( !$wgUser->isAllowed(
'edit' ) ) {
1759 if ( $wgUser->isAnon() ) {
1760 $status->setResult(
false, self::AS_READ_ONLY_PAGE_ANON );
1763 $status->fatal(
'readonlytext' );
1764 $status->value = self::AS_READ_ONLY_PAGE_LOGGED;
1769 $changingContentModel =
false;
1770 if ( $this->contentModel !== $this->mTitle->getContentModel() ) {
1771 if ( !$wgContentHandlerUseDB ) {
1772 $status->fatal(
'editpage-cannot-use-custom-model' );
1773 $status->value = self::AS_CANNOT_USE_CUSTOM_MODEL;
1775 } elseif ( !$wgUser->isAllowed(
'editcontentmodel' ) ) {
1776 $status->setResult(
false, self::AS_NO_CHANGE_CONTENT_MODEL );
1780 $changingContentModel =
true;
1781 $oldContentModel = $this->mTitle->getContentModel();
1784 if ( $this->changeTags ) {
1786 $this->changeTags, $wgUser );
1787 if ( !$changeTagsStatus->isOK() ) {
1788 $changeTagsStatus->value = self::AS_CHANGE_TAG_ERROR;
1789 return $changeTagsStatus;
1794 $status->fatal(
'readonlytext' );
1795 $status->value = self::AS_READ_ONLY_PAGE;
1798 if ( $wgUser->pingLimiter() || $wgUser->pingLimiter(
'linkpurge', 0 ) ) {
1799 $status->fatal(
'actionthrottledtext' );
1800 $status->value = self::AS_RATE_LIMITED;
1804 # If the article has been deleted while editing, don't save it without
1807 $status->setResult(
false, self::AS_ARTICLE_WAS_DELETED );
1811 # Load the page data from the master. If anything changes in the meantime,
1812 # we detect it by using page_latest like a token in a 1 try compare-and-swap.
1813 $this->
page->loadPageData(
'fromdbmaster' );
1814 $new = !$this->
page->exists();
1818 if ( !$this->mTitle->userCan(
'create', $wgUser ) ) {
1819 $status->fatal(
'nocreatetext' );
1820 $status->value = self::AS_NO_CREATE_PERMISSION;
1821 wfDebug( __METHOD__ .
": no create permission\n" );
1828 $defaultMessageText = $this->mTitle->getDefaultMessageText();
1829 if ( $this->mTitle->getNamespace() ===
NS_MEDIAWIKI && $defaultMessageText !==
false ) {
1830 $defaultText = $defaultMessageText;
1835 if ( !$this->allowBlankArticle && $this->textbox1 === $defaultText ) {
1836 $this->blankArticle =
true;
1837 $status->fatal(
'blankarticle' );
1838 $status->setResult(
false, self::AS_BLANK_ARTICLE );
1848 $result[
'sectionanchor'] =
'';
1849 if ( $this->section ==
'new' ) {
1850 if ( $this->sectiontitle !==
'' ) {
1853 } elseif ( $this->summary !==
'' ) {
1860 $status->value = self::AS_SUCCESS_NEW_ARTICLE;
1864 # Article exists. Check for edit conflict.
1866 $this->
page->clear(); # Force reload
of dates,
etc.
1869 wfDebug(
"timestamp: {$timestamp}, edittime: {$this->edittime}\n" );
1872 $this->isConflict =
true;
1873 if ( $this->section ==
'new' ) {
1874 if ( $this->
page->getUserText() == $wgUser->getName() &&
1881 .
": duplicate new section submission; trigger edit conflict!\n" );
1884 $this->isConflict =
false;
1885 wfDebug( __METHOD__ .
": conflict suppressed; new section\n" );
1887 } elseif ( $this->section ==
''
1889 DB_MASTER, $this->mTitle->getArticleID(),
1893 # Suppress edit conflict with self, except for section edits where merging is required.
1894 wfDebug( __METHOD__ .
": Suppressing edit conflict, same user.\n" );
1895 $this->isConflict =
false;
1900 if ( $this->sectiontitle !==
'' ) {
1908 if ( $this->isConflict ) {
1910 .
": conflict! getting section '{$this->section}' for time '{$this->edittime}'"
1911 .
" (article time '{$timestamp}')\n" );
1920 wfDebug( __METHOD__ .
": getting section '{$this->section}'\n" );
1929 wfDebug( __METHOD__ .
": activating conflict; section replace failed.\n" );
1930 $this->isConflict =
true;
1932 } elseif ( $this->isConflict ) {
1936 $this->isConflict =
false;
1937 wfDebug( __METHOD__ .
": Suppressing edit conflict, successful merge.\n" );
1939 $this->section =
'';
1941 wfDebug( __METHOD__ .
": Keeping edit conflict, failed merge.\n" );
1945 if ( $this->isConflict ) {
1946 $status->setResult(
false, self::AS_CONFLICT_DETECTED );
1954 if ( $this->section ==
'new' ) {
1956 if ( !$this->allowBlankSummary && trim( $this->summary ) ==
'' ) {
1957 $this->missingSummary =
true;
1958 $status->fatal(
'missingsummary' );
1959 $status->value = self::AS_SUMMARY_NEEDED;
1964 if ( $this->textbox1 ==
'' ) {
1965 $this->missingComment =
true;
1966 $status->fatal(
'missingcommenttext' );
1967 $status->value = self::AS_TEXTBOX_EMPTY;
1970 } elseif ( !$this->allowBlankSummary
1971 && !
$content->equals( $this->getOriginalContent( $wgUser ) )
1975 $this->missingSummary =
true;
1976 $status->fatal(
'missingsummary' );
1977 $status->value = self::AS_SUMMARY_NEEDED;
1982 $sectionanchor =
'';
1983 if ( $this->section ==
'new' ) {
1985 } elseif ( $this->section !=
'' ) {
1986 # Try to get a section anchor from the section source, redirect
1987 # to edited section if header found.
1988 # XXX: Might be better to integrate this into Article::replaceSectionAtRev
1989 # for duplicate heading checking and maybe parsing.
1990 $hasmatch = preg_match(
"/^ *([=]{1,6})(.*?)(\\1) *\\n/i", $this->textbox1,
$matches );
1991 # We can't deal with anchors, includes, html etc in the header for now,
1992 # headline would need to be parsed to improve this.
1993 if ( $hasmatch && strlen(
$matches[2] ) > 0 ) {
1994 $sectionanchor = $wgParser->guessLegacySectionNameFromWikiText(
$matches[2] );
1997 $result[
'sectionanchor'] = $sectionanchor;
2004 $this->section =
'';
2006 $status->value = self::AS_SUCCESS_UPDATE;
2009 if ( !$this->allowSelfRedirect
2015 if ( !$currentTarget || !$currentTarget->equals( $this->getTitle() ) ) {
2016 $this->selfRedirect =
true;
2017 $status->fatal(
'selfredirect' );
2018 $status->value = self::AS_SELF_REDIRECT;
2025 if ( $this->kblength > $wgMaxArticleSize ) {
2026 $this->tooBig =
true;
2027 $status->setResult(
false, self::AS_MAX_ARTICLE_SIZE_EXCEEDED );
2033 ( ( $this->minoredit && !$this->isNew ) ?
EDIT_MINOR : 0 ) |
2036 $doEditStatus = $this->
page->doEditContent(
2046 if ( !$doEditStatus->isOK() ) {
2050 $errors = $doEditStatus->getErrorsArray();
2051 if ( in_array( $errors[0][0],
2052 [
'edit-gone-missing',
'edit-conflict',
'edit-already-exists' ] )
2054 $this->isConflict =
true;
2056 $doEditStatus->value = self::AS_END;
2058 return $doEditStatus;
2061 $result[
'nullEdit'] = $doEditStatus->hasMessage(
'edit-no-change' );
2064 $wgUser->pingLimiter(
'linkpurge' );
2071 if ( $changingContentModel ) {
2074 $new ?
false : $oldContentModel,
2075 $this->contentModel,
2090 $new = $oldModel ===
false;
2091 $log =
new ManualLogEntry(
'contentmodel', $new ?
'new' :
'change' );
2092 $log->setPerformer( $user );
2093 $log->setTarget( $this->mTitle );
2094 $log->setComment( $reason );
2095 $log->setParameters( [
2096 '4::oldmodel' => $oldModel,
2097 '5::newmodel' => $newModel
2099 $logid = $log->insert();
2100 $log->publish( $logid );
2109 if ( !$wgUser->isLoggedIn() ) {
2142 $baseContent = $baseRevision ? $baseRevision->getContent() : null;
2144 if ( is_null( $baseContent ) ) {
2150 $currentContent = $currentRevision ? $currentRevision->getContent() : null;
2152 if ( is_null( $currentContent ) ) {
2158 $result =
$handler->merge3( $baseContent, $editContent, $currentContent );
2163 $this->parentRevId = $currentRevision->getId();
2176 if ( !$this->mBaseRevision ) {
2179 $db, $this->mTitle, $this->edittime );
2194 $regexes = (
array)$wgSpamRegex;
2195 return self::matchSpamRegexInternal( $text, $regexes );
2206 global $wgSummarySpamRegex;
2207 $regexes = (
array)$wgSummarySpamRegex;
2208 return self::matchSpamRegexInternal( $text, $regexes );
2217 foreach ( $regexes
as $regex ) {
2219 if ( preg_match( $regex, $text,
$matches ) ) {
2229 $wgOut->addModules(
'mediawiki.action.edit' );
2230 $wgOut->addModuleStyles(
'mediawiki.action.edit.styles' );
2232 if ( $wgUser->getOption(
'showtoolbar' ) ) {
2237 $wgOut->addModules(
'mediawiki.toolbar' );
2240 if ( $wgUser->getOption(
'uselivepreview' ) ) {
2241 $wgOut->addModules(
'mediawiki.action.edit.preview' );
2244 if ( $wgUser->getOption(
'useeditwarning' ) ) {
2245 $wgOut->addModules(
'mediawiki.action.edit.editWarning' );
2248 if ( $wgAjaxEditStash ) {
2249 $wgOut->addModules(
'mediawiki.action.edit.stash' );
2252 # Enabled article-related sidebar, toplinks, etc.
2253 $wgOut->setArticleRelated(
true );
2256 if ( $this->isConflict ) {
2257 $msg =
'editconflict';
2258 } elseif ( $contextTitle->exists() && $this->section !=
'' ) {
2259 $msg = $this->section ==
'new' ?
'editingcomment' :
'editingsection';
2261 $msg = $contextTitle->exists()
2263 && $contextTitle->getDefaultMessageText() !==
false
2269 # Use the title defined by DISPLAYTITLE magic word when present
2270 # NOTE: getDisplayTitle() returns HTML while getPrefixedText() returns plain text.
2271 # setPageTitle() treats the input as wikitext, which should be safe in either case.
2272 $displayTitle = isset( $this->mParserOutput ) ? $this->mParserOutput->getDisplayTitle() :
false;
2273 if ( $displayTitle ===
false ) {
2274 $displayTitle = $contextTitle->getPrefixedText();
2276 $wgOut->setPageTitle(
wfMessage( $msg, $displayTitle ) );
2277 # Transmit the name of the message to JavaScript for live preview
2278 # Keep Resources.php/mediawiki.action.edit.preview in sync with the possible keys
2279 $wgOut->addJsConfigVars(
'wgEditMessage', $msg );
2287 if ( $this->suppressIntro ) {
2291 $namespace = $this->mTitle->getNamespace();
2294 # Show a warning if editing an interface message
2295 $wgOut->wrapWikiMsg(
"<div class='mw-editinginterface'>\n$1\n</div>",
'editinginterface' );
2296 # If this is a default message (but not css or js),
2297 # show a hint that it is translatable on translatewiki.net
2301 $defaultMessageText = $this->mTitle->getDefaultMessageText();
2302 if ( $defaultMessageText !==
false ) {
2303 $wgOut->wrapWikiMsg(
"<div class='mw-translateinterface'>\n$1\n</div>",
2304 'translateinterface' );
2307 } elseif ( $namespace ==
NS_FILE ) {
2308 # Show a hint to shared repo
2310 if ( $file && !$file->isLocal() ) {
2311 $descUrl = $file->getDescriptionUrl();
2312 # there must be a description url to show a hint to shared repo
2314 if ( !$this->mTitle->exists() ) {
2315 $wgOut->wrapWikiMsg(
"<div class=\"mw-sharedupload-desc-create\">\n$1\n</div>", [
2316 'sharedupload-desc-create', $file->getRepo()->getDisplayName(), $descUrl
2319 $wgOut->wrapWikiMsg(
"<div class=\"mw-sharedupload-desc-edit\">\n$1\n</div>", [
2320 'sharedupload-desc-edit', $file->getRepo()->getDisplayName(), $descUrl
2327 # Show a warning message when someone creates/edits a user (talk) page but the user does not exist
2328 # Show log extract when the user is currently blocked
2330 $username = explode(
'/', $this->mTitle->getText(), 2 )[0];
2334 if ( !( $user && $user->isLoggedIn() ) && !$ip ) { #
User does not exist
2335 $wgOut->wrapWikiMsg(
"<div class=\"mw-userpage-userdoesnotexist error\">\n$1\n</div>",
2338 # Show log extract if the user is currently blocked
2346 'showIfEmpty' =>
false,
2348 'blocked-notice-logextract',
2349 $user->getName() # Support GENDER
in notice
2355 # Try to add a custom edit intro, or use the standard one if this is not possible.
2360 if ( $wgUser->isLoggedIn() ) {
2361 $wgOut->wrapWikiMsg(
2363 "<div class=\"mw-newarticletext plainlinks\">\n$1\n</div>",
2370 $wgOut->wrapWikiMsg(
2372 "<div class=\"mw-newarticletextanon plainlinks\">\n$1\n</div>",
2374 'newarticletextanon',
2380 # Give a notice if the user is editing a deleted/moved page...
2381 if ( !$this->mTitle->exists() ) {
2386 'conds' => [
"log_action != 'revision'" ],
2387 'showIfEmpty' =>
false,
2388 'msgKey' => [
'recreate-moveddeleted-warn' ]
2400 if ( $this->editintro ) {
2405 $wgOut->addWikiTextTitleTidy(
2406 '<div class="mw-editintro">{{:' .
$title->getFullText() .
'}}</div>',
2439 throw new MWException(
'This content model is not supported: '
2443 return $content->serialize( $this->contentFormat );
2463 if ( $text ===
false || $text === null ) {
2468 $this->contentModel, $this->contentFormat );
2471 throw new MWException(
'This content model is not supported: '
2489 # need to parse the preview early so that we know which templates are used,
2490 # otherwise users with "show preview after edit box" will get a blank list
2491 # we parse this near the beginning so that setHeaders can do the title
2492 # setting work instead of leaving it in getPreviewText
2493 $previewOutput =
'';
2494 if ( $this->formtype ==
'preview' ) {
2498 Hooks::run(
'EditPage::showEditForm:initial', [ &$this, &$wgOut ] );
2506 $wgOut->addHTML( $this->editFormPageTop );
2508 if ( $wgUser->getOption(
'previewontop' ) ) {
2512 $wgOut->addHTML( $this->editFormTextTop );
2514 $showToolbar =
true;
2516 if ( $this->formtype ==
'save' ) {
2519 $showToolbar =
false;
2521 $wgOut->wrapWikiMsg(
"<div class='error mw-deleted-while-editing'>\n$1\n</div>",
2522 'deletedwhileediting' );
2531 'id' => self::EDITFORM_ID,
2532 'name' => self::EDITFORM_ID,
2535 'enctype' =>
'multipart/form-data'
2539 if ( is_callable( $formCallback ) ) {
2540 wfWarn(
'The $formCallback parameter to ' . __METHOD__ .
'is deprecated' );
2541 call_user_func_array( $formCallback, [ &$wgOut ] );
2546 Xml::openElement(
'div', [
'id' =>
'antispam-container',
'style' =>
'display: none;' ] )
2549 [
'for' =>
'wpAntispam' ],
2550 wfMessage(
'simpleantispam-label' )->parse()
2556 'name' =>
'wpAntispam',
2557 'id' =>
'wpAntispam',
2564 Hooks::run(
'EditPage::showEditForm:fields', [ &$this, &$wgOut ] );
2570 $username = $this->lastDelete->user_name;
2571 $comment = $this->lastDelete->log_comment;
2576 ?
'confirmrecreate-noreason'
2577 :
'confirmrecreate';
2579 '<div class="mw-confirm-recreate">' .
2588 # When the summary is hidden, also hide them on preview/show changes
2589 if ( $this->nosummary ) {
2593 # If a blank edit summary was previously provided, and the appropriate
2594 # user preference is active, pass a hidden tag as wpIgnoreBlankSummary. This will stop the
2595 # user being bounced back more than once in the event that a summary
2598 # For a bit more sophisticated detection of blank summaries, hash the
2599 # automatic one and pass that in the hidden field wpAutoSummary.
2600 if ( $this->missingSummary || ( $this->section ==
'new' && $this->nosummary ) ) {
2601 $wgOut->addHTML(
Html::hidden(
'wpIgnoreBlankSummary',
true ) );
2604 if ( $this->undidRev ) {
2605 $wgOut->addHTML(
Html::hidden(
'wpUndidRevision', $this->undidRev ) );
2608 if ( $this->selfRedirect ) {
2609 $wgOut->addHTML(
Html::hidden(
'wpIgnoreSelfRedirect',
true ) );
2612 if ( $this->hasPresetSummary ) {
2616 $this->autoSumm = md5(
'' );
2619 $autosumm = $this->autoSumm ? $this->autoSumm : md5( $this->summary );
2620 $wgOut->addHTML(
Html::hidden(
'wpAutoSummary', $autosumm ) );
2622 $wgOut->addHTML(
Html::hidden(
'oldid', $this->oldid ) );
2625 $wgOut->addHTML(
Html::hidden(
'format', $this->contentFormat ) );
2626 $wgOut->addHTML(
Html::hidden(
'model', $this->contentModel ) );
2628 if ( $this->section ==
'new' ) {
2633 $wgOut->addHTML( $this->editFormTextBeforeContent );
2635 if ( !$this->isCssJsSubpage && $showToolbar && $wgUser->getOption(
'showtoolbar' ) ) {
2639 if ( $this->blankArticle ) {
2640 $wgOut->addHTML(
Html::hidden(
'wpIgnoreBlankArticle',
true ) );
2643 if ( $this->isConflict ) {
2658 $wgOut->addHTML( $this->editFormTextAfterContent );
2668 $wgOut->addHTML( $this->editFormTextAfterTools .
"\n" );
2677 self::getPreviewLimitReport( $this->mParserOutput ) ) );
2679 $wgOut->addModules(
'mediawiki.action.edit.collapsibleFooter' );
2681 if ( $this->isConflict ) {
2687 'content-failed-to-parse',
2688 $this->contentModel,
2689 $this->contentFormat,
2692 $wgOut->addWikiText(
'<div class="error">' . $msg->text() .
'</div>' );
2698 $wgOut->addHTML(
Html::hidden(
'wpUltimateParam',
true ) );
2699 $wgOut->addHTML( $this->editFormTextBottom .
"\n</form>\n" );
2701 if ( !$wgUser->getOption(
'previewontop' ) ) {
2714 preg_match(
"/^(=+)(.+)\\1\\s*(\n|$)/i", $text,
$matches );
2717 return $wgParser->stripSectionName( trim(
$matches[2] ) );
2730 if ( $this->mTitle->isTalkPage() ) {
2731 $wgOut->addWikiMsg(
'talkpagetext' );
2735 $editNotices = $this->mTitle->getEditNotices( $this->oldid );
2736 if ( count( $editNotices ) ) {
2737 $wgOut->addHTML( implode(
"\n", $editNotices ) );
2739 $msg =
wfMessage(
'editnotice-notext' );
2740 if ( !$msg->isDisabled() ) {
2742 '<div class="mw-editnotice-notext">'
2743 . $msg->parseAsBlock()
2749 if ( $this->isConflict ) {
2750 $wgOut->wrapWikiMsg(
"<div class='mw-explainconflict'>\n$1\n</div>",
'explainconflict' );
2751 $this->edittime = $this->
page->getTimestamp();
2757 $wgOut->showErrorPage(
'sectioneditnotsupported-title',
'sectioneditnotsupported-text' );
2761 if ( $this->section !=
'' && $this->section !=
'new' ) {
2762 if ( !$this->summary && !$this->preview && !$this->diff ) {
2763 $sectionTitle = self::extractSectionTitle( $this->textbox1 );
2764 if ( $sectionTitle !==
false ) {
2765 $this->summary =
"/* $sectionTitle */ ";
2770 if ( $this->missingComment ) {
2771 $wgOut->wrapWikiMsg(
"<div id='mw-missingcommenttext'>\n$1\n</div>",
'missingcommenttext' );
2774 if ( $this->missingSummary && $this->section !=
'new' ) {
2775 $wgOut->wrapWikiMsg(
"<div id='mw-missingsummary'>\n$1\n</div>",
'missingsummary' );
2778 if ( $this->missingSummary && $this->section ==
'new' ) {
2779 $wgOut->wrapWikiMsg(
"<div id='mw-missingcommentheader'>\n$1\n</div>",
'missingcommentheader' );
2782 if ( $this->blankArticle ) {
2783 $wgOut->wrapWikiMsg(
"<div id='mw-blankarticle'>\n$1\n</div>",
'blankarticle' );
2786 if ( $this->selfRedirect ) {
2787 $wgOut->wrapWikiMsg(
"<div id='mw-selfredirect'>\n$1\n</div>",
'selfredirect' );
2790 if ( $this->hookError !==
'' ) {
2791 $wgOut->addWikiText( $this->hookError );
2795 $wgOut->addWikiMsg(
'nonunicodebrowser' );
2798 if ( $this->section !=
'new' ) {
2799 $revision = $this->mArticle->getRevisionFetched();
2804 $wgOut->wrapWikiMsg(
2805 "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
2806 'rev-deleted-text-permission'
2809 $wgOut->wrapWikiMsg(
2810 "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
2811 'rev-deleted-text-view'
2815 if ( !$revision->isCurrent() ) {
2816 $this->mArticle->setOldSubtitle( $revision->getId() );
2817 $wgOut->addWikiMsg(
'editingold' );
2819 } elseif ( $this->mTitle->exists() ) {
2822 $wgOut->wrapWikiMsg(
"<div class='errorbox'>\n$1\n</div>\n",
2823 [
'missing-revision', $this->oldid ] );
2829 $wgOut->wrapWikiMsg(
2830 "<div id=\"mw-read-only-warning\">\n$1\n</div>",
2833 } elseif ( $wgUser->isAnon() ) {
2834 if ( $this->formtype !=
'preview' ) {
2835 $wgOut->wrapWikiMsg(
2836 "<div id='mw-anon-edit-warning' class='warningbox'>\n$1\n</div>",
2837 [
'anoneditwarning',
2839 '{{fullurl:Special:UserLogin|returnto={{FULLPAGENAMEE}}}}',
2841 '{{fullurl:Special:CreateAccount|returnto={{FULLPAGENAMEE}}}}' ]
2844 $wgOut->wrapWikiMsg(
"<div id=\"mw-anon-preview-warning\" class=\"warningbox\">\n$1</div>",
2845 'anonpreviewwarning'
2849 if ( $this->isCssJsSubpage ) {
2850 # Check the skin exists
2852 $wgOut->wrapWikiMsg(
2853 "<div class='error' id='mw-userinvalidcssjstitle'>\n$1\n</div>",
2854 [
'userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage() ]
2857 if ( $this->
getTitle()->isSubpageOf( $wgUser->getUserPage() ) ) {
2858 if ( $this->formtype !==
'preview' ) {
2859 if ( $this->isCssSubpage && $wgAllowUserCss ) {
2860 $wgOut->wrapWikiMsg(
2861 "<div id='mw-usercssyoucanpreview'>\n$1\n</div>",
2862 [
'usercssyoucanpreview' ]
2866 if ( $this->isJsSubpage && $wgAllowUserJs ) {
2867 $wgOut->wrapWikiMsg(
2868 "<div id='mw-userjsyoucanpreview'>\n$1\n</div>",
2869 [
'userjsyoucanpreview' ]
2877 if ( $this->mTitle->isProtected(
'edit' ) &&
2880 # Is the title semi-protected?
2881 if ( $this->mTitle->isSemiProtected() ) {
2882 $noticeMsg =
'semiprotectedpagewarning';
2884 # Then it must be protected based on static groups (regular)
2885 $noticeMsg =
'protectedpagewarning';
2888 [
'lim' => 1,
'msgKey' => [ $noticeMsg ] ] );
2890 if ( $this->mTitle->isCascadeProtected() ) {
2891 # Is this page under cascading protection from some source pages?
2893 list( $cascadeSources, ) = $this->mTitle->getCascadeProtectionSources();
2894 $notice =
"<div class='mw-cascadeprotectedwarning'>\n$1\n";
2895 $cascadeSourcesCount = count( $cascadeSources );
2896 if ( $cascadeSourcesCount > 0 ) {
2897 # Explain, and list the titles responsible
2898 foreach ( $cascadeSources
as $page ) {
2899 $notice .=
'* [[:' . $page->getPrefixedText() .
"]]\n";
2902 $notice .=
'</div>';
2903 $wgOut->wrapWikiMsg( $notice, [
'cascadeprotectedwarning', $cascadeSourcesCount ] );
2905 if ( !$this->mTitle->exists() && $this->mTitle->getRestrictions(
'create' ) ) {
2908 'showIfEmpty' =>
false,
2909 'msgKey' => [
'titleprotectedwarning' ],
2910 'wrap' =>
"<div class=\"mw-titleprotectedwarning\">\n$1</div>" ] );
2913 if ( $this->kblength ===
false ) {
2914 $this->kblength = (int)( strlen( $this->textbox1 ) / 1024 );
2917 if ( $this->tooBig || $this->kblength > $wgMaxArticleSize ) {
2918 $wgOut->wrapWikiMsg(
"<div class='error' id='mw-edit-longpageerror'>\n$1\n</div>",
2921 $wgLang->formatNum( $this->kblength ),
2922 $wgLang->formatNum( $wgMaxArticleSize )
2926 if ( !
wfMessage(
'longpage-hint' )->isDisabled() ) {
2927 $wgOut->wrapWikiMsg(
"<div id='mw-edit-longpage-hint'>\n$1\n</div>",
2930 $wgLang->formatSize( strlen( $this->textbox1 ) ),
2931 strlen( $this->textbox1 )
2936 # Add header copyright warning
2957 $inputAttrs = null, $spanLabelAttrs = null
2960 $inputAttrs = ( is_array( $inputAttrs ) ? $inputAttrs : [] ) + [
2961 'id' =>
'wpSummary',
2962 'maxlength' =>
'200',
2965 'spellcheck' =>
'true',
2968 $spanLabelAttrs = ( is_array( $spanLabelAttrs ) ? $spanLabelAttrs : [] ) + [
2969 'class' => $this->missingSummary ?
'mw-summarymissed' :
'mw-summary',
2970 'id' =>
"wpSummaryLabel"
2977 $inputAttrs[
'id'] ? [
'for' => $inputAttrs[
'id'] ] : null,
2980 $label =
Xml::tags(
'span', $spanLabelAttrs, $label );
2985 return [ $label, $input ];
2996 # Add a class if 'missingsummary' is triggered to allow styling of the summary line
2997 $summaryClass = $this->missingSummary ?
'mw-summarymissed' :
'mw-summary';
2998 if ( $isSubjectPreview ) {
2999 if ( $this->nosummary ) {
3003 if ( !$this->mShowSummaryField ) {
3008 $labelText =
wfMessage( $isSubjectPreview ?
'subject' :
'summary' )->parse();
3012 [
'class' => $summaryClass ],
3015 $wgOut->addHTML(
"{$label} {$input}" );
3028 if ( !
$summary || ( !$this->preview && !$this->diff ) ) {
3034 if ( $isSubjectPreview ) {
3036 ->inContentLanguage()->text();
3039 $message = $isSubjectPreview ?
'subject-preview' :
'summary-preview';
3048 $section = htmlspecialchars( $this->section );
3049 $wgOut->addHTML( <<<HTML
3050 <input
type=
'hidden' value=
"{$section}" name=
"wpSection"/>
3051 <input
type=
'hidden' value=
"{$this->starttime}" name=
"wpStarttime" />
3052 <input
type=
'hidden' value=
"{$this->edittime}" name=
"wpEdittime" />
3053 <input
type=
'hidden' value=
"{$this->scrolltop}" name=
"wpScrolltop" id=
"wpScrolltop" />
3076 $wgOut->addHTML(
"\n" .
Html::hidden(
"wpEditToken", $wgUser->getEditToken() ) .
"\n" );
3101 $attribs = [
'style' =>
'display:none;' ];
3104 if ( $this->mTitle->isProtected(
'edit' ) &&
3107 # Is the title semi-protected?
3108 if ( $this->mTitle->isSemiProtected() ) {
3109 $classes[] =
'mw-textarea-sprotected';
3111 # Then it must be protected based on static groups (regular)
3112 $classes[] =
'mw-textarea-protected';
3114 # Is the title cascade-protected?
3115 if ( $this->mTitle->isCascadeProtected() ) {
3116 $classes[] =
'mw-textarea-cprotected';
3126 if ( count( $classes ) ) {
3127 if ( isset(
$attribs[
'class'] ) ) {
3130 $attribs[
'class'] = implode(
' ', $classes );
3135 $textoverride !== null ? $textoverride : $this->textbox1,
3142 $this->
showTextbox( $this->textbox2,
'wpTextbox2', [
'tabindex' => 6,
'readonly' ] );
3149 if ( strval( $wikitext ) !==
'' ) {
3160 'cols' => $wgUser->getIntOption(
'cols' ),
3161 'rows' => $wgUser->getIntOption(
'rows' ),
3167 $pageLang = $this->mTitle->getPageLanguage();
3168 $attribs[
'lang'] = $pageLang->getHtmlCode();
3169 $attribs[
'dir'] = $pageLang->getDir();
3178 $classes[] =
'ontop';
3181 $attribs = [
'id' =>
'wikiPreview',
'class' => implode(
' ', $classes ) ];
3183 if ( $this->formtype !=
'preview' ) {
3184 $attribs[
'style'] =
'display: none;';
3189 if ( $this->formtype ==
'preview' ) {
3193 $pageViewLang = $this->mTitle->getPageViewLanguage();
3194 $attribs = [
'lang' => $pageViewLang->getHtmlCode(),
'dir' => $pageViewLang->getDir(),
3195 'class' =>
'mw-content-' . $pageViewLang->getDir() ];
3199 $wgOut->addHTML(
'</div>' );
3201 if ( $this->formtype ==
'diff' ) {
3206 'content-failed-to-parse',
3207 $this->contentModel,
3208 $this->contentFormat,
3211 $wgOut->addWikiText(
'<div class="error">' . $msg->text() .
'</div>' );
3224 if ( $this->mTitle->getNamespace() ==
NS_CATEGORY ) {
3225 $this->mArticle->openShowCategory();
3227 # This hook seems slightly odd here, but makes things more
3228 # consistent for extensions.
3229 Hooks::run(
'OutputPageBeforeHTML', [ &$wgOut, &$text ] );
3230 $wgOut->addHTML( $text );
3231 if ( $this->mTitle->getNamespace() ==
NS_CATEGORY ) {
3232 $this->mArticle->closeShowCategory();
3246 $oldtitlemsg =
'currentrev';
3247 # if message does not exist, show diff against the preloaded default
3248 if ( $this->mTitle->getNamespace() ==
NS_MEDIAWIKI && !$this->mTitle->exists() ) {
3249 $oldtext = $this->mTitle->getDefaultMessageText();
3250 if ( $oldtext !==
false ) {
3251 $oldtitlemsg =
'defaultmessagetext';
3262 $newContent = $this->
page->replaceSectionContent(
3263 $this->section, $textboxContent,
3264 $this->summary, $this->edittime );
3266 if ( $newContent ) {
3268 Hooks::run(
'EditPageGetDiffContent', [ $this, &$newContent ] );
3271 $newContent = $newContent->preSaveTransform( $this->mTitle, $wgUser, $popts );
3274 if ( ( $oldContent && !$oldContent->isEmpty() ) || ( $newContent && !$newContent->isEmpty() ) ) {
3275 $oldtitle =
wfMessage( $oldtitlemsg )->parse();
3276 $newtitle =
wfMessage(
'yourtext' )->parse();
3278 if ( !$oldContent ) {
3279 $oldContent = $newContent->getContentHandler()->makeEmptyContent();
3282 if ( !$newContent ) {
3283 $newContent = $oldContent->getContentHandler()->makeEmptyContent();
3286 $de = $oldContent->getContentHandler()->createDifferenceEngine( $this->mArticle->getContext() );
3287 $de->setContent( $oldContent, $newContent );
3289 $difftext = $de->getDiff( $oldtitle, $newtitle );
3290 $de->showDiffStyle();
3295 $wgOut->addHTML(
'<div id="wikiDiff">' . $difftext .
'</div>' );
3302 $msg =
'editpage-head-copy-warn';
3303 if ( !
wfMessage( $msg )->isDisabled() ) {
3305 $wgOut->wrapWikiMsg(
"<div class='editpage-head-copywarn'>\n$1\n</div>",
3306 'editpage-head-copy-warn' );
3319 $msg =
'editpage-tos-summary';
3320 Hooks::run(
'EditPageTosSummary', [ $this->mTitle, &$msg ] );
3321 if ( !
wfMessage( $msg )->isDisabled() ) {
3323 $wgOut->addHTML(
'<div class="mw-tos-summary">' );
3324 $wgOut->addWikiMsg( $msg );
3325 $wgOut->addHTML(
'</div>' );
3331 $wgOut->addHTML(
'<div class="mw-editTools">' .
3332 wfMessage(
'edittools' )->inContentLanguage()->parse() .
3343 return self::getCopyrightWarning( $this->mTitle );
3355 if ( $wgRightsText ) {
3356 $copywarnMsg = [
'copyrightwarning',
3357 '[[' .
wfMessage(
'copyrightpage' )->inContentLanguage()->text() .
']]',
3360 $copywarnMsg = [
'copyrightwarning2',
3361 '[[' .
wfMessage(
'copyrightpage' )->inContentLanguage()->text() .
']]' ];
3366 return "<div id=\"editpage-copywarn\">\n" .
3367 call_user_func_array(
'wfMessage', $copywarnMsg )->$format() .
"\n</div>";
3382 $limitReport =
Html::rawElement(
'div', [
'class' =>
'mw-limitReportExplanation' ],
3383 wfMessage(
'limitreport-title' )->parseAsBlock()
3387 $limitReport .=
Html::openElement(
'div', [
'class' =>
'preview-limit-report-wrapper' ] );
3390 'class' =>
'preview-limit-report wikitable'
3396 [ $key, &
$value, &$limitReport,
true,
true ]
3399 $valueMsg =
wfMessage( [
"$key-value-html",
"$key-value" ] );
3400 if ( !$valueMsg->exists() ) {
3403 if ( !$keyMsg->isDisabled() && !$valueMsg->isDisabled() ) {
3416 return $limitReport;
3421 $wgOut->addHTML(
"<div class='editOptions'>\n" );
3423 if ( $this->section !=
'new' ) {
3429 [
'minor' => $this->minoredit,
'watch' => $this->watchthis ] );
3430 $wgOut->addHTML(
"<div class='editCheckboxes'>" . implode( $checkboxes,
"\n" ) .
"</div>\n" );
3434 $wgOut->addHTML( $this->editFormTextAfterWarn );
3436 $wgOut->addHTML(
"<div class='editButtons'>\n" );
3440 if ( $cancel !==
'' ) {
3442 [
'class' =>
'mw-editButtons-pipe-separator' ],
3446 $message =
wfMessage(
'edithelppage' )->inContentLanguage()->text();
3449 'target' =>
'helpwindow',
3450 'href' => $edithelpurl,
3453 $attrs, [
'mw-ui-quiet' ] ) .
3454 wfMessage(
'word-separator' )->escaped() .
3457 $wgOut->addHTML(
" <span class='cancelLink'>{$cancel}</span>\n" );
3458 $wgOut->addHTML(
" <span class='editHelp'>{$edithelp}</span>\n" );
3459 $wgOut->addHTML(
"</div><!-- editButtons -->\n" );
3463 $wgOut->addHTML(
"</div><!-- editOptions -->\n" );
3473 if (
Hooks::run(
'EditPageBeforeConflictDiff', [ &$this, &$wgOut ] ) ) {
3474 $stats = $wgOut->getContext()->getStats();
3475 $stats->increment(
'edit.failures.conflict' );
3477 $wgOut->wrapWikiMsg(
'<h2>$1</h2>',
"yourdiff" );
3483 $de =
$handler->createDifferenceEngine( $this->mArticle->getContext() );
3484 $de->setContent( $content2, $content1 );
3490 $wgOut->wrapWikiMsg(
'<h2>$1</h2>',
"yourtext" );
3500 if ( !$this->isConflict && $this->oldid > 0 ) {
3503 $attrs = [
'id' =>
'mw-editform-cancel' ];
3534 if ( $this->deletedSinceEdit !== null ) {
3538 $this->deletedSinceEdit =
false;
3540 if ( !$this->mTitle->exists() && $this->mTitle->isDeletedQuick() ) {
3542 if ( $this->lastDelete ) {
3544 if ( $deleteTime > $this->starttime ) {
3545 $this->deletedSinceEdit =
true;
3558 $data =
$dbr->selectRow(
3559 [
'logging',
'user' ],
3572 'log_namespace' => $this->mTitle->getNamespace(),
3573 'log_title' => $this->mTitle->getDBkey(),
3574 'log_type' =>
'delete',
3575 'log_action' =>
'delete',
3579 [
'LIMIT' => 1,
'ORDER BY' =>
'log_timestamp DESC' ]
3582 if ( is_object( $data ) ) {
3584 $data->user_name =
wfMessage(
'rev-deleted-user' )->escaped();
3588 $data->log_comment =
wfMessage(
'rev-deleted-comment' )->escaped();
3604 $stats = $wgOut->getContext()->getStats();
3606 if ( $wgRawHtml && !$this->mTokenOk ) {
3610 if ( $this->textbox1 !==
'' ) {
3614 $parsedNote = $wgOut->parse(
"<div class='previewnote'>" .
3615 wfMessage(
'session_fail_preview_html' )->
text() .
"</div>",
true,
true );
3617 $stats->increment(
'edit.failures.session_loss' );
3628 'AlternateEditPreview',
3629 [ $this, &
$content, &$previewHTML, &$this->mParserOutput ] )
3631 return $previewHTML;
3634 # provide a anchor link to the editform
3635 $continueEditing =
'<span class="mw-continue-editing">' .
3636 '[[#' . self::EDITFORM_ID .
'|' . $wgLang->getArrow() .
' ' .
3637 wfMessage(
'continue-editing' )->text() .
']]</span>';
3638 if ( $this->mTriedSave && !$this->mTokenOk ) {
3639 if ( $this->mTokenOkExceptSuffix ) {
3640 $note =
wfMessage(
'token_suffix_mismatch' )->plain();
3641 $stats->increment(
'edit.failures.bad_token' );
3643 $note =
wfMessage(
'session_fail_preview' )->plain();
3644 $stats->increment(
'edit.failures.session_loss' );
3646 } elseif ( $this->incompleteForm ) {
3647 $note =
wfMessage(
'edit_form_incomplete' )->plain();
3648 if ( $this->mTriedSave ) {
3649 $stats->increment(
'edit.failures.incomplete_form' );
3652 $note =
wfMessage(
'previewnote' )->plain() .
' ' . $continueEditing;
3655 $parserOptions = $this->
page->makeParserOptions( $this->mArticle->getContext() );
3656 $parserOptions->setIsPreview(
true );
3657 $parserOptions->setIsSectionPreview( !is_null( $this->section ) && $this->section !==
'' );
3659 # don't parse non-wikitext pages, show message about preview
3660 if ( $this->mTitle->isCssJsSubpage() || $this->mTitle->isCssOrJsPage() ) {
3661 if ( $this->mTitle->isCssJsSubpage() ) {
3663 } elseif ( $this->mTitle->isCssOrJsPage() ) {
3671 if ( $level ===
'user' && !$wgAllowUserCss ) {
3676 if ( $level ===
'user' && !$wgAllowUserJs ) {
3683 # Used messages to make sure grep find them:
3684 # Messages: usercsspreview, userjspreview, sitecsspreview, sitejspreview
3685 if ( $level && $format ) {
3686 $note =
"<div id='mw-{$level}{$format}preview'>" .
3687 wfMessage(
"{$level}{$format}preview" )->text() .
3688 ' ' . $continueEditing .
"</div>";
3692 # If we're adding a comment, we need to show the
3693 # summary as the headline
3694 if ( $this->section ===
"new" && $this->summary !==
"" ) {
3700 Hooks::run(
'EditPageGetPreviewContent', $hook_args );
3702 $parserOptions->enableLimitReport();
3704 # For CSS/JS pages, we should have called the ShowRawCssJs hook here.
3705 # But it's now deprecated, so never mind
3707 $pstContent =
$content->preSaveTransform( $this->mTitle, $wgUser, $parserOptions );
3708 $scopedCallback = $parserOptions->setupFakeRevision(
3709 $this->mTitle, $pstContent, $wgUser );
3710 $parserOutput = $pstContent->getParserOutput( $this->mTitle, null, $parserOptions );
3712 # Try to stash the edit for the final submission step
3713 # @todo: different date format preferences cause cache misses
3725 $note .=
"\n\n" . implode(
"\n\n",
$parserOutput->getWarnings() );
3731 'content-failed-to-parse',
3732 $this->contentModel,
3733 $this->contentFormat,
3736 $note .=
"\n\n" . $m->parse();
3740 if ( $this->isConflict ) {
3741 $conflict =
'<h2 id="mw-previewconflict">'
3742 .
wfMessage(
'previewconflict' )->escaped() .
"</h2>\n";
3744 $conflict =
'<hr />';
3747 $previewhead =
"<div class='previewnote'>\n" .
3748 '<h2 id="mw-previewheader">' .
wfMessage(
'preview' )->escaped() .
"</h2>" .
3749 $wgOut->parse( $note,
true,
true ) . $conflict .
"</div>\n";
3751 $pageViewLang = $this->mTitle->getPageViewLanguage();
3752 $attribs = [
'lang' => $pageViewLang->getHtmlCode(),
'dir' => $pageViewLang->getDir(),
3753 'class' =>
'mw-content-' . $pageViewLang->getDir() ];
3763 if ( $this->preview || $this->section !=
'' ) {
3765 if ( !isset( $this->mParserOutput ) ) {
3768 foreach ( $this->mParserOutput->getTemplates()
as $ns =>
$template ) {
3775 return $this->mTitle->getTemplateLinksFrom();
3790 $imagesAvailable = $wgEnableUploads || count( $wgForeignFileRepos );
3791 $showSignature =
true;
3807 'id' =>
'mw-editbutton-bold',
3809 'close' =>
'\'\
'\'',
3810 'sample' =>
wfMessage(
'bold_sample' )->text(),
3811 'tip' =>
wfMessage(
'bold_tip' )->text(),
3814 'id' =>
'mw-editbutton-italic',
3817 'sample' =>
wfMessage(
'italic_sample' )->text(),
3818 'tip' =>
wfMessage(
'italic_tip' )->text(),
3821 'id' =>
'mw-editbutton-link',
3824 'sample' =>
wfMessage(
'link_sample' )->text(),
3825 'tip' =>
wfMessage(
'link_tip' )->text(),
3828 'id' =>
'mw-editbutton-extlink',
3831 'sample' =>
wfMessage(
'extlink_sample' )->text(),
3832 'tip' =>
wfMessage(
'extlink_tip' )->text(),
3835 'id' =>
'mw-editbutton-headline',
3838 'sample' =>
wfMessage(
'headline_sample' )->text(),
3839 'tip' =>
wfMessage(
'headline_tip' )->text(),
3841 $imagesAvailable ? [
3842 'id' =>
'mw-editbutton-image',
3843 'open' =>
'[[' . $wgContLang->getNsText(
NS_FILE ) .
':',
3845 'sample' =>
wfMessage(
'image_sample' )->text(),
3846 'tip' =>
wfMessage(
'image_tip' )->text(),
3848 $imagesAvailable ? [
3849 'id' =>
'mw-editbutton-media',
3850 'open' =>
'[[' . $wgContLang->getNsText(
NS_MEDIA ) .
':',
3852 'sample' =>
wfMessage(
'media_sample' )->text(),
3853 'tip' =>
wfMessage(
'media_tip' )->text(),
3856 'id' =>
'mw-editbutton-nowiki',
3857 'open' =>
"<nowiki>",
3858 'close' =>
"</nowiki>",
3859 'sample' =>
wfMessage(
'nowiki_sample' )->text(),
3860 'tip' =>
wfMessage(
'nowiki_tip' )->text(),
3863 'id' =>
'mw-editbutton-signature',
3867 'tip' =>
wfMessage(
'sig_tip' )->text(),
3870 'id' =>
'mw-editbutton-hr',
3871 'open' =>
"\n----\n",
3878 $script =
'mw.loader.using("mediawiki.toolbar", function () {';
3879 foreach ( $toolarray
as $tool ) {
3899 'mw.toolbar.addButton',
3908 $toolbar =
'<div id="toolbar"></div>';
3910 Hooks::run(
'EditPageBeforeEditToolbar', [ &$toolbar ] );
3931 if ( !$this->isNew ) {
3932 $checkboxes[
'minor'] =
'';
3933 $minorLabel =
wfMessage(
'minoredit' )->parse();
3934 if ( $wgUser->isAllowed(
'minoredit' ) ) {
3937 'accesskey' =>
wfMessage(
'accesskey-minoredit' )->text(),
3938 'id' =>
'wpMinoredit',
3942 " <label for='wpMinoredit' id='mw-editpage-minoredit'" .
3944 ">{$minorLabel}</label>";
3946 if ( $wgUseMediaWikiUIEverywhere ) {
3947 $checkboxes[
'minor'] =
Html::openElement(
'div', [
'class' =>
'mw-ui-checkbox' ] ) .
3951 $checkboxes[
'minor'] = $minorEditHtml;
3956 $watchLabel =
wfMessage(
'watchthis' )->parse();
3957 $checkboxes[
'watch'] =
'';
3958 if ( $wgUser->isLoggedIn() ) {
3961 'accesskey' =>
wfMessage(
'accesskey-watch' )->text(),
3962 'id' =>
'wpWatchthis',
3966 " <label for='wpWatchthis' id='mw-editpage-watch'" .
3968 ">{$watchLabel}</label>";
3969 if ( $wgUseMediaWikiUIEverywhere ) {
3970 $checkboxes[
'watch'] =
Html::openElement(
'div', [
'class' =>
'mw-ui-checkbox' ] ) .
3974 $checkboxes[
'watch'] = $watchThisHtml;
3998 $attribs, [
'mw-ui-constructive' ] );
4002 'id' =>
'wpPreview',
4003 'name' =>
'wpPreview',
4008 $buttons[
'live'] =
'';
4029 $wgOut->prepareErrorPage(
wfMessage(
'nosuchsectiontitle' ) );
4031 $res =
wfMessage(
'nosuchsectiontext', $this->section )->parseAsBlock();
4033 $wgOut->addHTML(
$res );
4035 $wgOut->returnToMain(
false, $this->mTitle );
4047 if ( is_array( $match ) ) {
4048 $match = $wgLang->listToText( $match );
4050 $wgOut->prepareErrorPage(
wfMessage(
'spamprotectiontitle' ) );
4052 $wgOut->addHTML(
'<div id="spamprotected">' );
4053 $wgOut->addWikiMsg(
'spamprotectiontext' );
4057 $wgOut->addHTML(
'</div>' );
4059 $wgOut->wrapWikiMsg(
'<h2>$1</h2>',
"yourdiff" );
4062 $wgOut->wrapWikiMsg(
'<h2>$1</h2>',
"yourtext" );
4065 $wgOut->addReturnTo( $this->
getContextTitle(), [
'action' =>
'edit' ] );
4077 $currentbrowser = $wgRequest->getHeader(
'User-Agent' );
4078 if ( $currentbrowser ===
false ) {
4083 foreach ( $wgBrowserBlackList
as $browser ) {
4084 if ( preg_match( $browser, $currentbrowser ) ) {
4100 $text = rtrim(
$request->getText( $field ) );
4101 return $request->getBool(
'safemode' )
4115 $codedText = $wgContLang->recodeForEdit( $text );
4135 $invalue = strtr( $invalue, [
"&#x" =>
"�" ] );
4140 $valueLength = strlen( $invalue );
4141 for ( $i = 0; $i < $valueLength; $i++ ) {
4142 $bytevalue = ord( $invalue[$i] );
4143 if ( $bytevalue <= 0x7F ) {
4146 } elseif ( $bytevalue <= 0xBF ) {
4147 $working = $working << 6;
4148 $working += ( $bytevalue & 0x3F );
4150 if ( $bytesleft <= 0 ) {
4151 $result .=
"&#x" . strtoupper( dechex( $working ) ) .
";";
4153 } elseif ( $bytevalue <= 0xDF ) {
4154 $working = $bytevalue & 0x1F;
4156 } elseif ( $bytevalue <= 0xEF ) {
4157 $working = $bytevalue & 0x0F;
4160 $working = $bytevalue & 0x07;
4177 $valueLength = strlen( $invalue );
4178 for ( $i = 0; $i < $valueLength; $i++ ) {
4179 if ( ( substr( $invalue, $i, 3 ) ==
"&#x" ) && ( $invalue[$i + 3] !=
'0' ) ) {
4183 $hexstring .= $invalue[$i];
4185 }
while ( ctype_xdigit( $invalue[$i] ) && ( $i < strlen( $invalue ) ) );
4190 if ( ( substr( $invalue, $i, 1 ) ==
";" ) && ( strlen( $hexstring ) <= 6 ) ) {
4191 $codepoint = hexdec( $hexstring );
4194 $result .=
"&#x" . $hexstring . substr( $invalue, $i, 1 );
4197 $result .= substr( $invalue, $i, 1 );
4201 return strtr(
$result, [
"�" =>
"&#x" ] );
static newFromName($name, $validate= 'valid')
Static factory method for creation from username.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
displayPermissionsError(array $permErrors)
Display a permissions error page, like OutputPage::showPermissionsErrorPage(), but with the following...
makeSafe($invalue)
A number of web browsers are known to corrupt non-ASCII characters in a UTF-8 text editing environmen...
static closeElement($element)
Returns "$element>".
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
const AS_READ_ONLY_PAGE_ANON
Status: this anonymous user is not allowed to edit this page.
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
$wgMaxArticleSize
Maximum article size in kilobytes.
the array() calling protocol came about after MediaWiki 1.4rc1.
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
static linkKnown($target, $html=null, $customAttribs=[], $query=[], $options=[ 'known', 'noclasses'])
Identical to link(), except $options defaults to 'known'.
magic word the default is to use $key to get the and $key value or $key value text $key value html to format the value $key
$editFormTextAfterContent
showContentForm()
Subpage overridable method for printing the form for page content editing By default this simply outp...
getPreviewText()
Get the rendered text for previewing.
serialize($format=null)
Convenience method for serializing this Content object.
static element($element, $attribs=null, $contents= '', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
handleStatus(Status $status, $resultDetails)
Handle status, such as after attempt save.
per default it will return the text for text based content
Show an error when the wiki is locked/read-only and the user tries to do something that requires writ...
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
const AS_ARTICLE_WAS_DELETED
Status: article was deleted while editing and param wpRecreate == false or form was not posted...
const AS_HOOK_ERROR
Status: Article update aborted by a hook function.
static getForModelID($modelId)
Returns the ContentHandler singleton for the given model ID.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
safeUnicodeInput($request, $field)
Filter an input field through a Unicode de-armoring process if it came from an old browser with known...
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
showHeaderCopyrightWarning()
Show the header copyright warning.
getPage()
Get the WikiPage object of this instance.
getWikiText($shortContext=false, $longContext=false, $lang=null)
Get the error list as a wikitext formatted list.
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
database rows
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
showTosSummary()
Give a chance for site and per-namespace customizations of terms of service summary link that might e...
The edit page/HTML interface (split from Article) The actual database and text munging is still in Ar...
static hidden($name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
setContextTitle($title)
Set the context Title object.
const AS_SUMMARY_NEEDED
Status: no edit summary given and the user has forceeditsummary set and the user is not editing in hi...
const AS_HOOK_ERROR_EXPECTED
Status: A hook function returned an error.
getEditButtons(&$tabindex)
Returns an array of html code of the following buttons: save, diff, preview and live.
$wgAllowUserCss
Allow user Cascading Style Sheets (CSS)? This enables a lot of neat customizations, but may increase security risk to users and server load.
static newFromUserAndLang(User $user, Language $lang)
Get a ParserOptions object from a given user and language.
Class for viewing MediaWiki article and history.
null for the local wiki Added in
static getSkinNames()
Fetch the set of available skins.
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
null string $contentFormat
const AS_BLOCKED_PAGE_FOR_USER
Status: User is blocked from editing this page.
setPostEditCookie($statusValue)
Sets post-edit cookie indicating the user just saved a particular revision.
const AS_NO_CREATE_PERMISSION
Status: user tried to create this page, but is not allowed to do that ( Title->userCan('create') == f...
static getPreviewLimitReport($output)
Get the Limit report for page previews.
spamPageWithContent($match=false)
Show "your edit contains spam" page with your diff and text.
it s the revision text itself In either if gzip is the revision text is gzipped $flags
static getCopyrightWarning($title, $format= 'plain')
Get the copyright warning, by default returns wikitext.
static check($name, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox.
const POST_EDIT_COOKIE_DURATION
Duration of PostEdit cookie, in seconds.
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
this hook is for auditing only $response
internalAttemptSave(&$result, $bot=false)
Attempt submission (no UI)
bool stdClass $lastDelete
Represents a title within MediaWiki.
when a variable name is used in a it is silently declared as a new local masking the global
wfExpandUrl($url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
static newFromUser($user)
Get a ParserOptions object from a given user.
edit()
This is the function that gets called for "action=edit".
getContextTitle()
Get the context title object.
getContentObject($def_content=null)
mergeChangesIntoContent(&$editContent)
Attempts to do 3-way merge of edit content with a base revision and current content, in case of edit conflict, in whichever way appropriate for the content type.
static getRestrictionLevels($index, User $user=null)
Determine which restriction levels it makes sense to use in a namespace, optionally filtered by a use...
static tooltipAndAccesskeyAttribs($name, array $msgParams=[])
Returns the attributes for the tooltip and access key.
null string $contentModel
getEditPermissionErrors($rigor= 'secure')
isRedirect()
Tests if the article content represents a redirect.
null Title $mContextTitle
wfArrayDiff2($a, $b)
Like array_diff( $a, $b ) except that it works with two-dimensional arrays.
static formatTemplates($templates, $preview=false, $section=false, $more=null)
Returns HTML for the "templates used on this page" list.
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
static showLogExtract(&$out, $types=[], $page= '', $user= '', $param=[])
Show log extract.
static matchSummarySpamRegex($text)
Check given input text against $wgSummarySpamRegex, and return the text of the first match...
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 index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message.Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item.Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page.Return false to stop further processing of the tag $reader:XMLReader object &$pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision.Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag.Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload.Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports.&$fullInterwikiPrefix:Interwiki prefix, may contain colons.&$pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable.Can be used to lazy-load the import sources list.&$importSources:The value of $wgImportSources.Modify as necessary.See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page.$context:IContextSource object &$pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect.&$title:Title object for the current page &$request:WebRequest &$ignoreRedirect:boolean to skip redirect check &$target:Title/string of redirect target &$article:Article object 'InternalParseBeforeLinks':during Parser's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InternalParseBeforeSanitize':during Parser's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings.Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not.Return true without providing an interwiki to continue interwiki search.$prefix:interwiki prefix we are looking for.&$iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user's email has been invalidated successfully.$user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification.Callee may modify $url and $query, URL will be constructed as $url.$query &$url:URL to index.php &$query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) &$article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() &$ip:IP being check &$result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from &$allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn't match your organization.$addr:The e-mail address entered by the user &$result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user &$result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we're looking for a messages file for &$file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED!Use $magicWords in a file listed in $wgExtensionMessagesFiles instead.Use this to define synonyms of magic words depending of the language &$magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces.Do not use this hook to add namespaces.Use CanonicalNamespaces for that.&$namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED!Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead.Use to define aliases of special pages names depending of the language &$specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names.&$names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page's language links.This is called in various places to allow extensions to define the effective language links for a page.$title:The page's Title.&$links:Associative array mapping language codes to prefixed links of the form"language:title".&$linkFlags:Associative array mapping prefixed links to arrays of flags.Currently unused, but planned to provide support for marking individual language links in the UI, e.g.for featured articles. 'LanguageSelector':Hook to change the language selector available on a page.$out:The output page.$cssClassName:CSS class name of the language selector. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts.Return false to skip default processing and return $ret.See documentation for Linker::link() for details on the expected meanings of parameters.$skin:the Skin object $target:the Title that the link is pointing to &$html:the contents that the< a > tag should have(raw HTML) $result
const AS_CONTENT_TOO_BIG
Status: Content too big (> $wgMaxArticleSize)
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping $template
safeUnicodeOutput($text)
Filter an output field through a Unicode armoring process if it is going to an old browser with known...
static addCallableUpdate($callable, $type=self::POSTSEND)
Add a callable update.
$wgEnableUploads
Uploads have to be specially set up to be secure.
bool $isWrongCaseCssJsPage
attemptSave(&$resultDetails=false)
Attempt submission.
showIntro()
Show all applicable editing introductions.
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
null means default & $customAttribs
static getLocalizedName($name, Language $lang=null)
Returns the localized name for a given content model.
static closeElement($element)
Shortcut to close an XML element.
wfDebugLog($logGroup, $text, $dest= 'all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not...
getContent($audience=Revision::FOR_PUBLIC, User $user=null)
Get the content of the current revision.
static openElement($element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
getParentRevId()
Get the edit's parent revision ID.
isWrongCaseCssJsPage()
Checks whether the user entered a skin name in uppercase, e.g.
wfEscapeWikiText($text)
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc.
wfReadOnly()
Check whether the wiki is in read-only mode.
static getMain()
Static methods.
static textarea($name, $value= '', array $attribs=[])
Convenience function to produce a
static getCanonicalName($index)
Returns the canonical (English) name for a given index.
const AS_SPAM_ERROR
Status: summary contained spam according to one of the regexes in $wgSummarySpamRegex.
An error page which can definitely be safely rendered using the OutputPage.
static titleAttrib($name, $options=null, array $msgParams=[])
Given the id of an interface element, constructs the appropriate title attribute from the system mess...
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 etc
wfWarn($msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
in this case you re responsible for computing and outputting the entire conflict i the difference between revisions and your text headers and sections and Diff & $tabindex
getActionURL(Title $title)
Returns the URL to use in the form's action attribute.
static newFromTarget($specificTarget, $vagueTarget=null, $fromMaster=false)
Given a target and the target's type, get an existing Block object if possible.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context $parserOutput
displayViewSourcePage(Content $content, $errorMessage= '')
Display a read-only View Source page.
const AS_CANNOT_USE_CUSTOM_MODEL
Status: when changing the content model is disallowed due to $wgContentHandlerUseDB being false...
static runLegacyHooks($event, $args=[], $warn=null)
Call a legacy hook that uses text instead of Content objects.
getLocalURL($query= '', $query2=false)
Get a URL with no fragment or server name (relative URL) from a Title object.
static loadFromTimestamp($db, $title, $timestamp)
Load the revision for the given title with the given timestamp.
setPreloadedContent(Content $content)
Use this method before edit() to preload some content into the edit box.
static getContentText(Content $content=null)
Convenience function for getting flat text from a Content object.
const AS_SUCCESS_UPDATE
Status: Article successfully updated.
$wgAllowUserJs
Allow user Javascript page? This enables a lot of neat customizations, but may increase security risk...
const AS_READ_ONLY_PAGE
Status: wiki is in readonly mode (wfReadOnly() == true)
static openElement($element, $attribs=null)
This opens an XML element.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
Base interface for content objects.
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 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 unsetoffset-wrap String Wrap the message in html(usually something like"<
const AS_NO_CHANGE_CONTENT_MODEL
Status: user tried to modify the content model, but is not allowed to do that ( User::isAllowed('edit...
addContentModelChangeLogEntry(User $user, $oldModel, $newModel, $reason)
getTitle()
Get the title object of the article.
initialiseForm()
Initialise form fields in the object Called on the first invocation, e.g.
wasDeletedSinceLastEdit()
Check if a page was deleted while the user was editing it, before submit.
toEditText($content)
Gets an editable textual representation of $content.
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 save
fatal($message)
Add an error and set OK to false, indicating that the operation as a whole was fatal.
isSectionEditSupported()
Returns whether section editing is supported for the current page.
static isIP($name)
Does the string match an anonymous IPv4 address?
getSummaryInput($summary="", $labelText=null, $inputAttrs=null, $spanLabelAttrs=null)
Standard summary input and label (wgSummary), abstracted so EditPage subclasses may reorganize the fo...
showTextbox($text, $name, $customAttribs=[])
getPreloadedContent($preload, $params=[])
Get the contents to be preloaded into the box, either set by an earlier setPreloadText() or by loadin...
$wgUseMediaWikiUIEverywhere
Temporary variable that applies MediaWiki UI wherever it can be supported.
static makeInlineScript($script)
Construct an inline script tag with given JS code.
namespace and then decline to actually register it file or subcat img or subcat $title
showDiff()
Get a diff between the current contents of the edit box and the version of the page we're editing fro...
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
bool $isNew
New page or new section.
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
unmakeSafe($invalue)
Reverse the previously applied transliteration of non-ASCII characters back to UTF-8.
previewOnOpen()
Should we show a preview when the edit form is first shown?
static loadFromTitle($db, $title, $id=0)
Load either the current, or a specified, revision that's attached to a given page.
const EDITFORM_ID
HTML id and name for the beginning of the edit form.
getCopywarn()
Get the copyright warning.
showTextbox1($customAttribs=null, $textoverride=null)
Method to output wpTextbox1 The $textoverride method can be used by subclasses overriding showContent...
static makeContent($text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
const AS_SUCCESS_NEW_ARTICLE
Status: Article successfully created.
Show an error when the user tries to do something whilst blocked.
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
const AS_IMAGE_REDIRECT_LOGGED
Status: logged in user is not allowed to upload (User::isAllowed('upload') == false) ...
static matchSpamRegexInternal($text, $regexes)
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
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
static extractSectionTitle($text)
Extract the section title from current section text, if any.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
const AS_END
Status: WikiPage::doEdit() was unsuccessful.
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
CONTENT_MODEL_JAVASCRIPT
Uploads have to be specially set up to be secure.
importFormData(&$request)
This function collects the form data and uses it to populate various member variables.
noSuchSectionPage()
Creates a basic error page which informs the user that they have attempted to edit a nonexistent sect...
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object & $output
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
static newFromId($id, $flags=0)
Load a page revision from a given revision ID number.
ParserOutput $mParserOutput
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
this hook is for auditing only or null if authentication failed before getting that far $username
static inDebugMode()
Determine whether debug mode was requested Order of priority is 1) request param, 2) cookie...
bool $enableApiEditOverride
Set in ApiEditPage, based on ContentHandler::allowsDirectApiEditing.
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN type
static tags($element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
getCheckboxes(&$tabindex, $checked)
Returns an array of html code of the following checkboxes: minor and watch.
static submitButton($contents, array $attrs, array $modifiers=[])
Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enab...
Class for creating log entries manually, to inject them into the database.
error also a ContextSource you ll probably need to make sure the header is varied on $request
wfReadOnlyReason()
Check if the site is in read-only mode and return the message if so.
showCustomIntro()
Attempt to show a custom editing introduction, if supplied.
static matchSpamRegex($text)
Check given input text against $wgSpamRegex, and return the text of the first match.
importContentFormData(&$request)
Subpage overridable method for extracting the page content data from the posted form to be placed in ...
displayPreviewArea($previewOutput, $isOnTop=false)
newSectionSummary(&$sectionanchor=null)
Return the summary to be used for a new section.
const AS_RATE_LIMITED
Status: rate limiter for action 'edit' was tripped.
static formatHiddenCategories($hiddencats)
Returns HTML for the "hidden categories on this page" list.
Variant of the Message class.
runPostMergeFilters(Content $content, Status $status, User $user)
Run hooks that can filter edits just before they get saved.
const AS_MAX_ARTICLE_SIZE_EXCEEDED
Status: article is too big (> $wgMaxArticleSize), after merging in the new section.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content $content
getCurrentContent()
Get the current content of the page.
updateWatchlist()
Register the change of watch status.
static buttonAttributes(array $attrs, array $modifiers=[])
Modifies a set of attributes meant for button elements and apply a set of default attributes when $wg...
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 name
const AS_IMAGE_REDIRECT_ANON
Status: anonymous user is not allowed to upload (User::isAllowed('upload') == false) ...
showStandardInputs(&$tabindex=2)
static stashEditFromPreview(Page $page, Content $content, Content $pstContent, ParserOutput $pOut, ParserOptions $pstOpts, ParserOptions $pOpts, $timestamp)
Attempt to cache PST content and corresponding parser output in passing.
const AS_TEXTBOX_EMPTY
Status: user tried to create a new section without content.
Show an error when a user tries to do something they do not have the necessary permissions for...
getRedirectTarget()
If this page is a redirect, get its target.
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
checkUnicodeCompliantBrowser()
Check if the browser is on a blacklist of user-agents known to mangle UTF-8 data on form submission...
showConflict()
Show an edit conflict.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
bool $hasPresetSummary
Has a summary been preset using GET parameter &summary= ?
static consume(ScopedCallback &$sc=null)
Trigger a scoped callback and destroy it.
setApiEditOverride($enableOverride)
Allow editing of content that supports API direct editing, but not general direct editing...
static makeInternalOrExternalUrl($name)
If url string starts with http, consider as external URL, else internal.
const POST_EDIT_COOKIE_KEY_PREFIX
Prefix of key for cookie used to pass post-edit state.
static checkLabel($label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
const AS_BLANK_ARTICLE
Status: user tried to create a blank page and wpIgnoreBlankArticle == false.
codepointToUtf8($codepoint)
Return UTF-8 sequence for a given Unicode code point.
bool $mTokenOkExceptSuffix
if(!$wgRequest->checkUrlExtension()) if(!$wgEnableAPI) $wgTitle
const AS_CONFLICT_DETECTED
Status: (non-resolvable) edit conflict.
static linkButton($contents, array $attrs, array $modifiers=[])
Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enab...
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
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 userWasLastToEdit($db, $pageId, $userId, $since)
Check if no edits were made by other users since the time a user started editing the page...
getOriginalContent(User $user)
Get the content of the wanted revision, without section extraction.
static encodeJsCall($name, $args, $pretty=false)
Create a call to a JavaScript function.
static doWatchOrUnwatch($watch, Title $title, User $user)
Watch or unwatch a page.
const AS_READ_ONLY_PAGE_LOGGED
Status: this logged in user is not allowed to edit this page.
const AS_PARSE_ERROR
Status: can't parse content.
const AS_SELF_REDIRECT
Status: user tried to create self-redirect (redirect to the same article) and wpIgnoreSelfRedirect ==...
isSupportedContentModel($modelId)
Returns if the given content model is editable.
static element($element, $attribs=[], $contents= '')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
$editFormTextBeforeContent
showPreview($text)
Append preview output to $wgOut.
wfFindFile($title, $options=[])
Find a file.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk page
if(is_null($wgLocalTZoffset)) if(!$wgDBerrorLogTZ) $wgRequest
Show an error when the user hits a rate limit.
static getEditToolbar($title=null)
Shows a bulletin board style toolbar for common editing functions.
showSummaryInput($isSubjectPreview, $summary="")
toEditContent($text)
Turns the given text into a Content object by unserializing it.
showEditForm($formCallback=null)
Send the edit form and related headers to $wgOut.
static & makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
static newGood($value=null)
Factory function for good results.
Exception representing a failure to serialize or unserialize a content object.
tokenOk(&$request)
Make sure the form isn't faking a user's credentials.
string $editFormPageTop
Before even the preview.
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
getSummaryPreview($isSubjectPreview, $summary="")
const AS_CHANGE_TAG_ERROR
Status: an error relating to change tagging.
$wgBrowserBlackList
Browser Blacklist for unicode non compliant browsers.
static wantSignatures($index)
Might pages in this namespace require the use of the Signature button on the edit toolbar...
__construct(Article $article)
Allows to change the fields on the form that will be generated $name