375 # Placeholders for text injection by hooks (must be HTML)
376 # extensions should take care to _append_ to the present value
417 $this->mTitle = $article->
getTitle();
420 $this->contentModel = $this->mTitle->getContentModel();
423 $this->contentFormat =
$handler->getDefaultFormat();
455 $this->mContextTitle =
$title;
466 if ( is_null( $this->mContextTitle ) ) {
482 return $this->enableApiEditOverride ===
true ||
493 $this->enableApiEditOverride = $enableOverride;
514 if ( !
Hooks::run(
'AlternateEdit', [ $this ] ) ) {
518 wfDebug( __METHOD__ .
": enter\n" );
521 if ( $wgRequest->getBool(
'redlink' ) && $this->mTitle->exists() ) {
522 $wgOut->redirect( $this->mTitle->getFullURL() );
527 $this->firsttime =
false;
532 $this->preview =
true;
536 $this->formtype =
'save';
537 } elseif ( $this->preview ) {
538 $this->formtype =
'preview';
539 } elseif ( $this->
diff ) {
540 $this->formtype =
'diff';
541 }
else { #
First time through
542 $this->firsttime =
true;
544 $this->formtype =
'preview';
546 $this->formtype =
'initial';
552 wfDebug( __METHOD__ .
": User can't edit\n" );
557 $user->spreadAnyEditBlock();
565 $revision = $this->mArticle->getRevisionFetched();
572 if ( $this->undidRev ) {
574 $prevRev = $undidRevObj ? $undidRevObj->getPrevious() : null;
576 if ( !$this->undidRev
583 'contentmodelediterror',
584 $revision->getContentModel(),
592 $this->isConflict =
false;
594 $this->isCssJsSubpage = $this->mTitle->isCssJsSubpage();
595 $this->isCssSubpage = $this->mTitle->isCssSubpage();
596 $this->isJsSubpage = $this->mTitle->isJsSubpage();
600 # Show applicable editing introductions
601 if ( $this->formtype ==
'initial' || $this->firsttime ) {
605 # Attempt submission here. This will check for edit conflicts,
606 # and redundantly check for locked database, blocked IPs, etc.
607 # that edit() already checked just in case someone tries to sneak
608 # in the back door with a hand-edited submission URL.
610 if (
'save' == $this->formtype ) {
611 $resultDetails = null;
618 # First time through: get contents, set time for conflict
620 if (
'initial' == $this->formtype || $this->firsttime ) {
626 if ( !$this->mTitle->getArticleID() ) {
627 Hooks::run(
'EditFormPreloadText', [ &$this->textbox1, &$this->mTitle ] );
629 Hooks::run(
'EditFormInitialText', [ $this ] );
644 $permErrors = $this->mTitle->getUserPermissionsErrors(
'edit', $wgUser, $rigor );
645 # Can this title be created?
646 if ( !$this->mTitle->exists() ) {
647 $permErrors = array_merge(
650 $this->mTitle->getUserPermissionsErrors(
'create', $wgUser, $rigor ),
655 # Ignore some permissions errors when a user is just previewing/viewing diffs
657 foreach ( $permErrors
as $error ) {
658 if ( ( $this->preview || $this->
diff )
659 && ( $error[0] ==
'blockedtext' || $error[0] ==
'autoblockedtext' )
685 if ( $wgRequest->getBool(
'redlink' ) ) {
689 $wgOut->redirect( $this->mTitle->getFullURL() );
695 # Use the normal message if there's nothing to display
697 $action = $this->mTitle->exists() ?
'edit' :
698 ( $this->mTitle->isTalkPage() ?
'createtalk' :
'createpage' );
704 $wgOut->formatPermissionsErrorMessage( $permErrors,
'edit' )
716 Hooks::run(
'EditPage::showReadOnlyForm:initial', [ $this, &$wgOut ] );
718 $wgOut->setRobotPolicy(
'noindex,nofollow' );
719 $wgOut->setPageTitle( $this->context->msg(
721 $this->getContextTitle()->getPrefixedText()
724 $wgOut->addHTML( $this->editFormPageTop );
725 $wgOut->addHTML( $this->editFormTextTop );
727 if ( $errorMessage !==
'' ) {
728 $wgOut->addWikiText( $errorMessage );
729 $wgOut->addHTML(
"<hr />\n" );
732 # If the user made changes, preserve them when showing the markup
733 # (This happens when a user is blocked during edit, for instance)
734 if ( !$this->firsttime ) {
736 $wgOut->addWikiMsg(
'viewyourtext' );
741 # Serialize using the default format if the content model is not supported
742 # (e.g. for an old revision with a different model)
745 $wgOut->addWikiMsg(
'viewsourcetext' );
748 $wgOut->addHTML( $this->editFormTextBeforeContent );
749 $this->
showTextbox( $text,
'wpTextbox1', [
'readonly' ] );
750 $wgOut->addHTML( $this->editFormTextAfterContent );
754 $wgOut->addModules(
'mediawiki.action.edit.collapsibleFooter' );
756 $wgOut->addHTML( $this->editFormTextBottom );
757 if ( $this->mTitle->exists() ) {
758 $wgOut->returnToMain( null, $this->mTitle );
769 if ( $wgRequest->getVal(
'preview' ) ==
'yes' ) {
772 } elseif ( $wgRequest->getVal(
'preview' ) ==
'no' ) {
775 } elseif ( $this->section ==
'new' ) {
778 } elseif ( ( $wgRequest->getVal(
'preload' ) !== null || $this->mTitle->exists() )
779 && $wgUser->getOption(
'previewonfirst' )
783 } elseif ( !$this->mTitle->exists()
784 && isset( $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()] )
785 && $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()]
801 if ( $this->mTitle->isCssJsSubpage() ) {
802 $name = $this->mTitle->getSkinFromCssJsSubpage();
803 $skins = array_merge(
807 return !in_array(
$name, $skins )
808 && in_array( strtolower(
$name ), $skins );
823 return $contentHandler->supportsSections();
834 # Section edit can come from either the form or a link
835 $this->section =
$request->getVal(
'wpSection',
$request->getVal(
'section' ) );
838 throw new ErrorPageError(
'sectioneditnotsupported-title',
'sectioneditnotsupported-text' );
841 $this->isNew = !$this->mTitle->exists() || $this->section ==
'new';
844 # These fields need to be checked for encoding.
845 # Also remove trailing whitespace, but don't remove _initial_
846 # whitespace from the text boxes. This may be significant formatting.
848 if ( !
$request->getCheck(
'wpTextbox2' ) ) {
858 # Truncate for whole multibyte characters
859 $this->summary = $wgContLang->truncate(
$request->getText(
'wpSummary' ), 255 );
861 # If the summary consists of a heading, e.g. '==Foobar==', extract the title from the
862 # header syntax, e.g. 'Foobar'. This is mainly an issue when we are using wpSummary for
864 $this->summary = preg_replace(
'/^\s*=+\s*(.*?)\s*=+\s*$/',
'$1', $this->summary );
866 # Treat sectiontitle the same way as summary.
867 # Note that wpSectionTitle is not yet a part of the actual edit form, as wpSummary is
868 # currently doing double duty as both edit summary and section title. Right now this
869 # is just to allow API edits to work around this limitation, but this should be
870 # incorporated into the actual edit form when EditPage is rewritten (Bugs 18654, 26312).
871 $this->sectiontitle = $wgContLang->truncate(
$request->getText(
'wpSectionTitle' ), 255 );
872 $this->sectiontitle = preg_replace(
'/^\s*=+\s*(.*?)\s*=+\s*$/',
'$1', $this->sectiontitle );
874 $this->edittime =
$request->getVal(
'wpEdittime' );
875 $this->editRevId =
$request->getIntOrNull(
'editRevId' );
876 $this->starttime =
$request->getVal(
'wpStarttime' );
883 $this->scrolltop =
$request->getIntOrNull(
'wpScrolltop' );
885 if ( $this->textbox1 ===
'' &&
$request->getVal(
'wpTextbox1' ) === null ) {
889 $this->incompleteForm =
true;
897 $this->incompleteForm = ( !
$request->getVal(
'wpUltimateParam' )
898 && is_null( $this->edittime ) );
900 if ( $this->incompleteForm ) {
901 # If the form is incomplete, force to preview.
902 wfDebug( __METHOD__ .
": Form data appears to be incomplete\n" );
903 wfDebug(
"POST DATA: " . var_export( $_POST,
true ) .
"\n" );
904 $this->preview =
true;
906 $this->preview =
$request->getCheck(
'wpPreview' );
914 # Some browsers will not report any submit button
915 # if the user hits enter in the comment box.
916 # The unmarked state will be assumed to be a save,
917 # if the form seems otherwise complete.
918 wfDebug( __METHOD__ .
": Passed token check.\n" );
919 } elseif ( $this->
diff ) {
920 # Failed token check, but only requested "Show Changes".
921 wfDebug( __METHOD__ .
": Failed token check; Show Changes requested.\n" );
923 # Page might be a hack attempt posted from
924 # an external site. Preview instead of saving.
925 wfDebug( __METHOD__ .
": Failed token check; forcing preview\n" );
926 $this->preview =
true;
930 if ( !preg_match(
'/^\d{14}$/', $this->edittime ) ) {
931 $this->edittime = null;
934 if ( !preg_match(
'/^\d{14}$/', $this->starttime ) ) {
935 $this->starttime = null;
938 $this->recreate =
$request->getCheck(
'wpRecreate' );
940 $this->minoredit =
$request->getCheck(
'wpMinoredit' );
941 $this->watchthis =
$request->getCheck(
'wpWatchthis' );
943 # Don't force edit summaries when a user is editing their own user or talk page
945 && $this->mTitle->getText() == $wgUser->getName()
947 $this->allowBlankSummary =
true;
949 $this->allowBlankSummary =
$request->getBool(
'wpIgnoreBlankSummary' )
950 || !$wgUser->getOption(
'forceeditsummary' );
953 $this->autoSumm =
$request->getText(
'wpAutoSummary' );
955 $this->allowBlankArticle =
$request->getBool(
'wpIgnoreBlankArticle' );
956 $this->allowSelfRedirect =
$request->getBool(
'wpIgnoreSelfRedirect' );
960 $this->changeTags = [];
962 $this->changeTags = array_filter( array_map(
'trim', explode(
',',
966 # Not a posted form? Start with nothing.
967 wfDebug( __METHOD__ .
": Not a posted form.\n" );
968 $this->textbox1 =
'';
970 $this->sectiontitle =
'';
971 $this->edittime =
'';
972 $this->editRevId = null;
975 $this->preview =
false;
978 $this->minoredit =
false;
980 $this->watchthis =
$request->getBool(
'watchthis',
false );
981 $this->recreate =
false;
985 if ( $this->section ==
'new' &&
$request->getVal(
'preloadtitle' ) ) {
986 $this->sectiontitle =
$request->getVal(
'preloadtitle' );
988 $this->summary =
$request->getVal(
'preloadtitle' );
989 } elseif ( $this->section !=
'new' &&
$request->getVal(
'summary' ) ) {
990 $this->summary =
$request->getText(
'summary' );
991 if ( $this->summary !==
'' ) {
992 $this->hasPresetSummary =
true;
996 if (
$request->getVal(
'minor' ) ) {
997 $this->minoredit =
true;
1001 $this->oldid =
$request->getInt(
'oldid' );
1002 $this->parentRevId =
$request->getInt(
'parentRevId' );
1004 $this->bot =
$request->getBool(
'bot',
true );
1005 $this->nosummary =
$request->getBool(
'nosummary' );
1008 $this->contentModel =
$request->getText(
'model', $this->contentModel );
1010 $this->contentFormat =
$request->getText(
'format', $this->contentFormat );
1016 'editpage-invalidcontentmodel-title',
1017 'editpage-invalidcontentmodel-text',
1018 [ $this->contentModel ]
1022 if ( !
$handler->isSupportedFormat( $this->contentFormat ) ) {
1024 'editpage-notsupportedcontentformat-title',
1025 'editpage-notsupportedcontentformat-text',
1036 $this->editintro =
$request->getText(
'editintro',
1038 $this->section ===
'new' ?
'MediaWiki:addsection-editintro' :
'' );
1065 $this->edittime = $this->
page->getTimestamp();
1066 $this->editRevId = $this->
page->getLatest();
1075 # Sort out the "watch" checkbox
1076 if ( $wgUser->getOption(
'watchdefault' ) ) {
1078 $this->watchthis =
true;
1079 } elseif ( $wgUser->getOption(
'watchcreations' ) && !$this->mTitle->exists() ) {
1081 $this->watchthis =
true;
1082 } elseif ( $wgUser->isWatched( $this->mTitle ) ) {
1084 $this->watchthis =
true;
1086 if ( $wgUser->getOption(
'minordefault' ) && !
$this->isNew ) {
1087 $this->minoredit =
true;
1089 if ( $this->textbox1 ===
false ) {
1109 if ( !$this->mTitle->exists() || $this->section ==
'new' ) {
1110 if ( $this->mTitle->getNamespace() ==
NS_MEDIAWIKI && $this->section !=
'new' ) {
1111 # If this is a system message, get the default text.
1112 $msg = $this->mTitle->getDefaultMessageText();
1117 # If requested, preload some text.
1118 $preload = $wgRequest->getVal(
'preload',
1120 $this->section ===
'new' ?
'MediaWiki:addsection-preload' :
'' );
1121 $params = $wgRequest->getArray(
'preloadparams', [] );
1127 if ( $this->section !=
'' ) {
1130 $content = $orig ? $orig->getSection( $this->section ) : null;
1136 $undoafter = $wgRequest->getInt(
'undoafter' );
1137 $undo = $wgRequest->getInt(
'undo' );
1139 if ( $undo > 0 && $undoafter > 0 ) {
1143 # Sanity check, make sure it's the right page,
1144 # the revisions exist and they were not deleted.
1145 # Otherwise, $content will be left as-is.
1146 if ( !is_null( $undorev ) && !is_null( $oldrev ) &&
1150 $content = $this->
page->getUndoContent( $undorev, $oldrev );
1153 # Warn the user that something went wrong
1154 $undoMsg =
'failure';
1158 $newContent =
$content->preSaveTransform( $this->mTitle, $wgUser, $popts );
1159 if ( $newContent->getModel() !== $oldContent->getModel() ) {
1164 $this->contentModel = $newContent->getModel();
1165 $this->contentFormat = $oldrev->getContentFormat();
1168 if ( $newContent->equals( $oldContent ) ) {
1169 # Tell the user that the undo results in no change,
1170 # i.e. the revisions were already undone.
1171 $undoMsg =
'nochange';
1174 # Inform the user of our success and set an automatic edit summary
1175 $undoMsg =
'success';
1177 # If we just undid one rev, use an autosummary
1178 $firstrev = $oldrev->getNext();
1179 if ( $firstrev && $firstrev->getId() == $undo ) {
1180 $userText = $undorev->getUserText();
1181 if ( $userText ===
'' ) {
1182 $undoSummary = $this->context->msg(
1183 'undo-summary-username-hidden',
1185 )->inContentLanguage()->text();
1187 $undoSummary = $this->context->msg(
1191 )->inContentLanguage()->text();
1193 if ( $this->summary ===
'' ) {
1194 $this->summary = $undoSummary;
1196 $this->summary = $undoSummary . $this->context->msg(
'colon-separator' )
1199 $this->undidRev = $undo;
1201 $this->formtype =
'diff';
1212 $class = ( $undoMsg ==
'success' ?
'' :
'error ' ) .
"mw-undo-{$undoMsg}";
1213 $this->editFormPageTop .= $wgOut->parse(
"<div class=\"{$class}\">" .
1214 $this->context->msg(
'undo-' . $undoMsg )->plain() .
'</div>',
true,
true );
1242 if ( $this->section ==
'new' ) {
1245 $revision = $this->mArticle->getRevisionFetched();
1246 if ( $revision === null ) {
1247 if ( !$this->contentModel ) {
1248 $this->contentModel = $this->
getTitle()->getContentModel();
1252 return $handler->makeEmptyContent();
1271 if ( $this->parentRevId ) {
1274 return $this->mArticle->getRevIdFetched();
1291 if ( !$this->contentModel ) {
1292 $this->contentModel = $this->
getTitle()->getContentModel();
1296 return $handler->makeEmptyContent();
1297 } elseif ( !$this->undidRev ) {
1302 $logger = LoggerFactory::getInstance(
'editpage' );
1303 if ( $this->contentModel !==
$rev->getContentModel() ) {
1304 $logger->warning(
"Overriding content model from current edit {prev} to {new}", [
1305 'prev' => $this->contentModel,
1306 'new' =>
$rev->getContentModel(),
1307 'title' => $this->
getTitle()->getPrefixedDBkey(),
1308 'method' => __METHOD__
1310 $this->contentModel =
$rev->getContentModel();
1315 if ( !
$content->isSupportedFormat( $this->contentFormat ) ) {
1316 $logger->warning(
"Current revision content format unsupported. Overriding {prev} to {new}", [
1318 'prev' => $this->contentFormat,
1319 'new' =>
$rev->getContentFormat(),
1320 'title' => $this->
getTitle()->getPrefixedDBkey(),
1321 'method' => __METHOD__
1323 $this->contentFormat =
$rev->getContentFormat();
1354 if ( !empty( $this->mPreloadContent ) ) {
1360 if ( $preload ===
'' ) {
1361 return $handler->makeEmptyContent();
1365 # Check for existence to avoid getting MediaWiki:Noarticletext
1368 return $handler->makeEmptyContent();
1377 return $handler->makeEmptyContent();
1387 return $handler->makeEmptyContent();
1393 if ( !$converted ) {
1395 wfDebug(
"Attempt to preload incompatible content: " .
1396 "can't convert " .
$content->getModel() .
1399 return $handler->makeEmptyContent();
1417 $token =
$request->getVal(
'wpEditToken' );
1418 $this->mTokenOk = $wgUser->matchEditToken( $token );
1419 $this->mTokenOkExceptSuffix = $wgUser->matchEditTokenNoSuffix( $token );
1440 $revisionId = $this->
page->getLatest();
1441 $postEditKey = self::POST_EDIT_COOKIE_KEY_PREFIX . $revisionId;
1444 if ( $statusValue == self::AS_SUCCESS_NEW_ARTICLE ) {
1446 } elseif ( $this->oldid ) {
1451 $response->setCookie( $postEditKey, $val, time() + self::POST_EDIT_COOKIE_DURATION, [
1452 'httpOnly' =>
false,
1465 # Allow bots to exempt some edits from bot flagging
1469 Hooks::run(
'EditPage::attemptSave:after', [ $this,
$status, $resultDetails ] );
1490 if ( $status->value == self::AS_SUCCESS_UPDATE
1491 || $status->value == self::AS_SUCCESS_NEW_ARTICLE
1493 $this->didSave =
true;
1494 if ( !$resultDetails[
'nullEdit'] ) {
1502 $extraQueryRedirect =
$request->getVal(
'wpExtraQueryRedirect' );
1504 switch ( $status->value ) {
1505 case self::AS_HOOK_ERROR_EXPECTED:
1506 case self::AS_CONTENT_TOO_BIG:
1507 case self::AS_ARTICLE_WAS_DELETED:
1508 case self::AS_CONFLICT_DETECTED:
1509 case self::AS_SUMMARY_NEEDED:
1510 case self::AS_TEXTBOX_EMPTY:
1511 case self::AS_MAX_ARTICLE_SIZE_EXCEEDED:
1513 case self::AS_BLANK_ARTICLE:
1514 case self::AS_SELF_REDIRECT:
1517 case self::AS_HOOK_ERROR:
1520 case self::AS_CANNOT_USE_CUSTOM_MODEL:
1521 case self::AS_PARSE_ERROR:
1522 $wgOut->addWikiText(
'<div class="error">' .
"\n" . $status->
getWikiText() .
'</div>' );
1525 case self::AS_SUCCESS_NEW_ARTICLE:
1526 $query = $resultDetails[
'redirect'] ?
'redirect=no' :
'';
1527 if ( $extraQueryRedirect ) {
1529 $query = $extraQueryRedirect;
1534 $anchor = isset( $resultDetails[
'sectionanchor'] ) ? $resultDetails[
'sectionanchor'] :
'';
1535 $wgOut->redirect( $this->mTitle->getFullURL(
$query ) . $anchor );
1538 case self::AS_SUCCESS_UPDATE:
1540 $sectionanchor = $resultDetails[
'sectionanchor'];
1544 'ArticleUpdateBeforeRedirect',
1545 [ $this->mArticle, &$sectionanchor, &$extraQuery ]
1548 if ( $resultDetails[
'redirect'] ) {
1549 if ( $extraQuery ==
'' ) {
1550 $extraQuery =
'redirect=no';
1552 $extraQuery =
'redirect=no&' . $extraQuery;
1555 if ( $extraQueryRedirect ) {
1556 if ( $extraQuery ===
'' ) {
1557 $extraQuery = $extraQueryRedirect;
1559 $extraQuery = $extraQuery .
'&' . $extraQueryRedirect;
1563 $wgOut->redirect( $this->mTitle->getFullURL( $extraQuery ) . $sectionanchor );
1566 case self::AS_SPAM_ERROR:
1570 case self::AS_BLOCKED_PAGE_FOR_USER:
1573 case self::AS_IMAGE_REDIRECT_ANON:
1574 case self::AS_IMAGE_REDIRECT_LOGGED:
1577 case self::AS_READ_ONLY_PAGE_ANON:
1578 case self::AS_READ_ONLY_PAGE_LOGGED:
1581 case self::AS_READ_ONLY_PAGE:
1584 case self::AS_RATE_LIMITED:
1587 case self::AS_NO_CREATE_PERMISSION:
1588 $permission = $this->mTitle->isTalkPage() ?
'createtalk' :
'createpage';
1591 case self::AS_NO_CHANGE_CONTENT_MODEL:
1599 $this->hookError =
'<div class="error">' .
"\n" . $status->
getWikiText() .
1617 [ $this, $content, &$this->hookError, $this->summary ],
1620 # Error messages etc. could be handled within the hook...
1621 $status->
fatal(
'hookaborted' );
1622 $status->value = self::AS_HOOK_ERROR;
1624 } elseif ( $this->hookError !=
'' ) {
1625 # ...or the hook could be expecting us to produce an error
1626 $status->
fatal(
'hookaborted' );
1627 $status->value = self::AS_HOOK_ERROR_EXPECTED;
1636 # Error messages etc. could be handled within the hook...
1637 if ( $status->isGood() ) {
1638 $status->
fatal(
'hookaborted' );
1644 $this->hookError = $status->getWikiText();
1647 if ( !$status->value ) {
1648 $status->value = self::AS_HOOK_ERROR;
1651 } elseif ( !$status->isOK() ) {
1652 # ...or the hook could be expecting us to produce an error
1654 $this->hookError = $status->getWikiText();
1655 $status->fatal(
'hookaborted' );
1656 $status->value = self::AS_HOOK_ERROR_EXPECTED;
1672 if ( $this->sectiontitle !==
'' ) {
1673 $sectionanchor = $wgParser->guessLegacySectionNameFromWikiText( $this->sectiontitle );
1677 if ( $this->summary ===
'' ) {
1678 $cleanSectionTitle = $wgParser->stripSectionName( $this->sectiontitle );
1679 return $this->context->msg(
'newsectionsummary' )
1680 ->rawParams( $cleanSectionTitle )->inContentLanguage()->text();
1682 } elseif ( $this->summary !==
'' ) {
1683 $sectionanchor = $wgParser->guessLegacySectionNameFromWikiText( $this->summary );
1684 # This is a new section, so create a link to the new section
1685 # in the revision summary.
1686 $cleanSummary = $wgParser->stripSectionName( $this->summary );
1687 return $this->context->msg(
'newsectionsummary' )
1688 ->rawParams( $cleanSummary )->inContentLanguage()->text();
1719 global $wgContentHandlerUseDB;
1723 if ( !
Hooks::run(
'EditPage::attemptSave', [ $this ] ) ) {
1724 wfDebug(
"Hook 'EditPage::attemptSave' aborted article saving\n" );
1725 $status->fatal(
'hookaborted' );
1726 $status->value = self::AS_HOOK_ERROR;
1730 $spam = $wgRequest->getText(
'wpAntispam' );
1731 if ( $spam !==
'' ) {
1734 $wgUser->getName() .
1736 $this->mTitle->getPrefixedText() .
1737 '" submitted bogus field "' .
1741 $status->fatal(
'spamprotectionmatch',
false );
1742 $status->value = self::AS_SPAM_ERROR;
1747 # Construct Content object
1751 'content-failed-to-parse',
1752 $this->contentModel,
1753 $this->contentFormat,
1756 $status->value = self::AS_PARSE_ERROR;
1760 # Check image redirect
1761 if ( $this->mTitle->getNamespace() ==
NS_FILE &&
1762 $textbox_content->isRedirect() &&
1763 !$wgUser->isAllowed(
'upload' )
1765 $code = $wgUser->isAnon() ? self::AS_IMAGE_REDIRECT_ANON : self::AS_IMAGE_REDIRECT_LOGGED;
1772 $match = self::matchSummarySpamRegex( $this->summary );
1773 if ( $match ===
false && $this->section ==
'new' ) {
1774 # $wgSpamRegex is enforced on this new heading/summary because, unlike
1775 # regular summaries, it is added to the actual wikitext.
1776 if ( $this->sectiontitle !==
'' ) {
1777 # This branch is taken when the API is used with the 'sectiontitle' parameter.
1778 $match = self::matchSpamRegex( $this->sectiontitle );
1780 # This branch is taken when the "Add Topic" user interface is used, or the API
1781 # is used with the 'summary' parameter.
1782 $match = self::matchSpamRegex( $this->summary );
1785 if ( $match ===
false ) {
1786 $match = self::matchSpamRegex( $this->textbox1 );
1788 if ( $match !==
false ) {
1790 $ip = $wgRequest->getIP();
1791 $pdbk = $this->mTitle->getPrefixedDBkey();
1792 $match = str_replace(
"\n",
'', $match );
1793 wfDebugLog(
'SpamRegex',
"$ip spam regex hit [[$pdbk]]: \"$match\"" );
1794 $status->fatal(
'spamprotectionmatch', $match );
1795 $status->value = self::AS_SPAM_ERROR;
1800 [ $this, $this->textbox1, $this->section, &$this->hookError, $this->summary ] )
1802 # Error messages etc. could be handled within the hook...
1803 $status->fatal(
'hookaborted' );
1804 $status->value = self::AS_HOOK_ERROR;
1806 } elseif ( $this->hookError !=
'' ) {
1807 # ...or the hook could be expecting us to produce an error
1808 $status->fatal(
'hookaborted' );
1809 $status->value = self::AS_HOOK_ERROR_EXPECTED;
1813 if ( $wgUser->isBlockedFrom( $this->mTitle,
false ) ) {
1816 $wgUser->spreadAnyEditBlock();
1818 # Check block state against master, thus 'false'.
1819 $status->setResult(
false, self::AS_BLOCKED_PAGE_FOR_USER );
1823 $this->contentLength = strlen( $this->textbox1 );
1824 if ( $this->contentLength > $wgMaxArticleSize * 1024 ) {
1826 $this->tooBig =
true;
1827 $status->setResult(
false, self::AS_CONTENT_TOO_BIG );
1831 if ( !$wgUser->isAllowed(
'edit' ) ) {
1832 if ( $wgUser->isAnon() ) {
1833 $status->setResult(
false, self::AS_READ_ONLY_PAGE_ANON );
1836 $status->fatal(
'readonlytext' );
1837 $status->value = self::AS_READ_ONLY_PAGE_LOGGED;
1842 $changingContentModel =
false;
1843 if ( $this->contentModel !== $this->mTitle->getContentModel() ) {
1844 if ( !$wgContentHandlerUseDB ) {
1845 $status->fatal(
'editpage-cannot-use-custom-model' );
1846 $status->value = self::AS_CANNOT_USE_CUSTOM_MODEL;
1848 } elseif ( !$wgUser->isAllowed(
'editcontentmodel' ) ) {
1849 $status->setResult(
false, self::AS_NO_CHANGE_CONTENT_MODEL );
1855 if ( !$titleWithNewContentModel->userCan(
'editcontentmodel', $wgUser )
1856 || !$titleWithNewContentModel->userCan(
'edit', $wgUser )
1858 $status->setResult(
false, self::AS_NO_CHANGE_CONTENT_MODEL );
1862 $changingContentModel =
true;
1863 $oldContentModel = $this->mTitle->getContentModel();
1866 if ( $this->changeTags ) {
1868 $this->changeTags, $wgUser );
1869 if ( !$changeTagsStatus->isOK() ) {
1870 $changeTagsStatus->value = self::AS_CHANGE_TAG_ERROR;
1871 return $changeTagsStatus;
1876 $status->fatal(
'readonlytext' );
1877 $status->value = self::AS_READ_ONLY_PAGE;
1880 if ( $wgUser->pingLimiter() || $wgUser->pingLimiter(
'linkpurge', 0 )
1881 || ( $changingContentModel && $wgUser->pingLimiter(
'editcontentmodel' ) )
1883 $status->fatal(
'actionthrottledtext' );
1884 $status->value = self::AS_RATE_LIMITED;
1888 # If the article has been deleted while editing, don't save it without
1891 $status->setResult(
false, self::AS_ARTICLE_WAS_DELETED );
1895 # Load the page data from the master. If anything changes in the meantime,
1896 # we detect it by using page_latest like a token in a 1 try compare-and-swap.
1897 $this->
page->loadPageData(
'fromdbmaster' );
1898 $new = !$this->
page->exists();
1902 if ( !$this->mTitle->userCan(
'create', $wgUser ) ) {
1903 $status->fatal(
'nocreatetext' );
1904 $status->value = self::AS_NO_CREATE_PERMISSION;
1905 wfDebug( __METHOD__ .
": no create permission\n" );
1912 $defaultMessageText = $this->mTitle->getDefaultMessageText();
1913 if ( $this->mTitle->getNamespace() ===
NS_MEDIAWIKI && $defaultMessageText !==
false ) {
1914 $defaultText = $defaultMessageText;
1919 if ( !$this->allowBlankArticle && $this->textbox1 === $defaultText ) {
1920 $this->blankArticle =
true;
1921 $status->fatal(
'blankarticle' );
1922 $status->setResult(
false, self::AS_BLANK_ARTICLE );
1932 $result[
'sectionanchor'] =
'';
1933 if ( $this->section ==
'new' ) {
1934 if ( $this->sectiontitle !==
'' ) {
1937 } elseif ( $this->summary !==
'' ) {
1944 $status->value = self::AS_SUCCESS_NEW_ARTICLE;
1948 # Article exists. Check for edit conflict.
1950 $this->
page->clear(); # Force reload
of dates,
etc.
1952 $latest = $this->
page->getLatest();
1954 wfDebug(
"timestamp: {$timestamp}, edittime: {$this->edittime}\n" );
1958 || ( $this->editRevId !== null && $this->editRevId != $latest )
1960 $this->isConflict =
true;
1961 if ( $this->section ==
'new' ) {
1962 if ( $this->
page->getUserText() == $wgUser->getName() &&
1969 .
": duplicate new section submission; trigger edit conflict!\n" );
1972 $this->isConflict =
false;
1973 wfDebug( __METHOD__ .
": conflict suppressed; new section\n" );
1975 } elseif ( $this->section ==
''
1977 DB_MASTER, $this->mTitle->getArticleID(),
1981 # Suppress edit conflict with self, except for section edits where merging is required.
1982 wfDebug( __METHOD__ .
": Suppressing edit conflict, same user.\n" );
1983 $this->isConflict =
false;
1988 if ( $this->sectiontitle !==
'' ) {
1996 if ( $this->isConflict ) {
1998 .
": conflict! getting section '{$this->section}' for time '{$this->edittime}'"
1999 .
" (id '{$this->editRevId}') (article time '{$timestamp}')\n" );
2002 if ( $this->editRevId !== null ) {
2018 wfDebug( __METHOD__ .
": getting section '{$this->section}'\n" );
2027 wfDebug( __METHOD__ .
": activating conflict; section replace failed.\n" );
2028 $this->isConflict =
true;
2030 } elseif ( $this->isConflict ) {
2034 $this->isConflict =
false;
2035 wfDebug( __METHOD__ .
": Suppressing edit conflict, successful merge.\n" );
2037 $this->section =
'';
2039 wfDebug( __METHOD__ .
": Keeping edit conflict, failed merge.\n" );
2043 if ( $this->isConflict ) {
2044 $status->setResult(
false, self::AS_CONFLICT_DETECTED );
2052 if ( $this->section ==
'new' ) {
2054 if ( !$this->allowBlankSummary && trim( $this->summary ) ==
'' ) {
2055 $this->missingSummary =
true;
2056 $status->fatal(
'missingsummary' );
2057 $status->value = self::AS_SUMMARY_NEEDED;
2062 if ( $this->textbox1 ==
'' ) {
2063 $this->missingComment =
true;
2064 $status->fatal(
'missingcommenttext' );
2065 $status->value = self::AS_TEXTBOX_EMPTY;
2068 } elseif ( !$this->allowBlankSummary
2069 && !
$content->equals( $this->getOriginalContent( $wgUser ) )
2073 $this->missingSummary =
true;
2074 $status->fatal(
'missingsummary' );
2075 $status->value = self::AS_SUMMARY_NEEDED;
2080 $sectionanchor =
'';
2081 if ( $this->section ==
'new' ) {
2083 } elseif ( $this->section !=
'' ) {
2084 # Try to get a section anchor from the section source, redirect
2085 # to edited section if header found.
2086 # XXX: Might be better to integrate this into Article::replaceSectionAtRev
2087 # for duplicate heading checking and maybe parsing.
2088 $hasmatch = preg_match(
"/^ *([=]{1,6})(.*?)(\\1) *\\n/i", $this->textbox1,
$matches );
2089 # We can't deal with anchors, includes, html etc in the header for now,
2090 # headline would need to be parsed to improve this.
2091 if ( $hasmatch && strlen(
$matches[2] ) > 0 ) {
2092 $sectionanchor = $wgParser->guessLegacySectionNameFromWikiText(
$matches[2] );
2095 $result[
'sectionanchor'] = $sectionanchor;
2102 $this->section =
'';
2104 $status->value = self::AS_SUCCESS_UPDATE;
2107 if ( !$this->allowSelfRedirect
2113 if ( !$currentTarget || !$currentTarget->equals( $this->getTitle() ) ) {
2114 $this->selfRedirect =
true;
2115 $status->fatal(
'selfredirect' );
2116 $status->value = self::AS_SELF_REDIRECT;
2123 if ( $this->contentLength > $wgMaxArticleSize * 1024 ) {
2124 $this->tooBig =
true;
2125 $status->setResult(
false, self::AS_MAX_ARTICLE_SIZE_EXCEEDED );
2131 ( ( $this->minoredit && !$this->isNew ) ?
EDIT_MINOR : 0 ) |
2134 $doEditStatus = $this->
page->doEditContent(
2144 if ( !$doEditStatus->isOK() ) {
2148 $errors = $doEditStatus->getErrorsArray();
2149 if ( in_array( $errors[0][0],
2150 [
'edit-gone-missing',
'edit-conflict',
'edit-already-exists' ] )
2152 $this->isConflict =
true;
2154 $doEditStatus->value = self::AS_END;
2156 return $doEditStatus;
2159 $result[
'nullEdit'] = $doEditStatus->hasMessage(
'edit-no-change' );
2162 $wgUser->pingLimiter(
'linkpurge' );
2169 if ( $changingContentModel ) {
2172 $new ?
false : $oldContentModel,
2173 $this->contentModel,
2188 $new = $oldModel ===
false;
2189 $log =
new ManualLogEntry(
'contentmodel', $new ?
'new' :
'change' );
2190 $log->setPerformer( $user );
2191 $log->setTarget( $this->mTitle );
2192 $log->setComment( $reason );
2193 $log->setParameters( [
2194 '4::oldmodel' => $oldModel,
2195 '5::newmodel' => $newModel
2197 $logid = $log->insert();
2198 $log->publish( $logid );
2207 if ( !$wgUser->isLoggedIn() ) {
2240 $baseContent = $baseRevision ? $baseRevision->getContent() : null;
2242 if ( is_null( $baseContent ) ) {
2248 $currentContent = $currentRevision ? $currentRevision->getContent() : null;
2250 if ( is_null( $currentContent ) ) {
2256 $result =
$handler->merge3( $baseContent, $editContent, $currentContent );
2261 $this->parentRevId = $currentRevision->getId();
2274 if ( !$this->mBaseRevision ) {
2276 $this->mBaseRevision = $this->editRevId
2293 $regexes = (
array)$wgSpamRegex;
2294 return self::matchSpamRegexInternal( $text, $regexes );
2305 global $wgSummarySpamRegex;
2306 $regexes = (
array)$wgSummarySpamRegex;
2307 return self::matchSpamRegexInternal( $text, $regexes );
2316 foreach ( $regexes
as $regex ) {
2318 if ( preg_match( $regex, $text,
$matches ) ) {
2328 $wgOut->addModules(
'mediawiki.action.edit' );
2329 $wgOut->addModuleStyles(
'mediawiki.action.edit.styles' );
2331 if ( $wgUser->getOption(
'showtoolbar' ) ) {
2336 $wgOut->addModules(
'mediawiki.toolbar' );
2339 if ( $wgUser->getOption(
'uselivepreview' ) ) {
2340 $wgOut->addModules(
'mediawiki.action.edit.preview' );
2343 if ( $wgUser->getOption(
'useeditwarning' ) ) {
2344 $wgOut->addModules(
'mediawiki.action.edit.editWarning' );
2347 # Enabled article-related sidebar, toplinks, etc.
2348 $wgOut->setArticleRelated(
true );
2351 if ( $this->isConflict ) {
2352 $msg =
'editconflict';
2353 } elseif ( $contextTitle->exists() && $this->section !=
'' ) {
2354 $msg = $this->section ==
'new' ?
'editingcomment' :
'editingsection';
2356 $msg = $contextTitle->exists()
2358 && $contextTitle->getDefaultMessageText() !==
false
2364 # Use the title defined by DISPLAYTITLE magic word when present
2365 # NOTE: getDisplayTitle() returns HTML while getPrefixedText() returns plain text.
2366 # setPageTitle() treats the input as wikitext, which should be safe in either case.
2367 $displayTitle = isset( $this->mParserOutput ) ? $this->mParserOutput->getDisplayTitle() :
false;
2368 if ( $displayTitle ===
false ) {
2369 $displayTitle = $contextTitle->getPrefixedText();
2371 $wgOut->setPageTitle( $this->context->msg( $msg, $displayTitle ) );
2372 # Transmit the name of the message to JavaScript for live preview
2373 # Keep Resources.php/mediawiki.action.edit.preview in sync with the possible keys
2374 $wgOut->addJsConfigVars( [
2375 'wgEditMessage' => $msg,
2376 'wgAjaxEditStash' => $wgAjaxEditStash,
2385 if ( $this->suppressIntro ) {
2389 $namespace = $this->mTitle->getNamespace();
2392 # Show a warning if editing an interface message
2393 $wgOut->wrapWikiMsg(
"<div class='mw-editinginterface'>\n$1\n</div>",
'editinginterface' );
2394 # If this is a default message (but not css or js),
2395 # show a hint that it is translatable on translatewiki.net
2399 $defaultMessageText = $this->mTitle->getDefaultMessageText();
2400 if ( $defaultMessageText !==
false ) {
2401 $wgOut->wrapWikiMsg(
"<div class='mw-translateinterface'>\n$1\n</div>",
2402 'translateinterface' );
2405 } elseif ( $namespace ==
NS_FILE ) {
2406 # Show a hint to shared repo
2408 if ( $file && !$file->isLocal() ) {
2409 $descUrl = $file->getDescriptionUrl();
2410 # there must be a description url to show a hint to shared repo
2412 if ( !$this->mTitle->exists() ) {
2413 $wgOut->wrapWikiMsg(
"<div class=\"mw-sharedupload-desc-create\">\n$1\n</div>", [
2414 'sharedupload-desc-create', $file->getRepo()->getDisplayName(), $descUrl
2417 $wgOut->wrapWikiMsg(
"<div class=\"mw-sharedupload-desc-edit\">\n$1\n</div>", [
2418 'sharedupload-desc-edit', $file->getRepo()->getDisplayName(), $descUrl
2425 # Show a warning message when someone creates/edits a user (talk) page but the user does not exist
2426 # Show log extract when the user is currently blocked
2428 $username = explode(
'/', $this->mTitle->getText(), 2 )[0];
2432 if ( !( $user && $user->isLoggedIn() ) && !$ip ) { #
User does
not exist
2433 $wgOut->wrapWikiMsg(
"<div class=\"mw-userpage-userdoesnotexist error\">\n$1\n</div>",
2436 # Show log extract if the user is currently blocked
2444 'showIfEmpty' =>
false,
2446 'blocked-notice-logextract',
2447 $user->getName() # Support GENDER
in notice
2453 # Try to add a custom edit intro, or use the standard one if this is not possible.
2456 $this->context->msg(
'helppage' )->inContentLanguage()->text()
2458 if ( $wgUser->isLoggedIn() ) {
2459 $wgOut->wrapWikiMsg(
2461 "<div class=\"mw-newarticletext plainlinks\">\n$1\n</div>",
2468 $wgOut->wrapWikiMsg(
2470 "<div class=\"mw-newarticletextanon plainlinks\">\n$1\n</div>",
2472 'newarticletextanon',
2478 # Give a notice if the user is editing a deleted/moved page...
2479 if ( !$this->mTitle->exists() ) {
2484 'conds' => [
"log_action != 'revision'" ],
2485 'showIfEmpty' =>
false,
2486 'msgKey' => [
'recreate-moveddeleted-warn' ]
2498 if ( $this->editintro ) {
2503 $wgOut->addWikiTextTitleTidy(
2504 '<div class="mw-editintro">{{:' .
$title->getFullText() .
'}}</div>',
2540 return $content->serialize( $this->contentFormat );
2560 if ( $text ===
false || $text === null ) {
2565 $this->contentModel, $this->contentFormat );
2585 # need to parse the preview early so that we know which templates are used,
2586 # otherwise users with "show preview after edit box" will get a blank list
2587 # we parse this near the beginning so that setHeaders can do the title
2588 # setting work instead of leaving it in getPreviewText
2589 $previewOutput =
'';
2590 if ( $this->formtype ==
'preview' ) {
2594 Hooks::run(
'EditPage::showEditForm:initial', [ &$this, &$wgOut ] );
2602 $wgOut->addHTML( $this->editFormPageTop );
2604 if ( $wgUser->getOption(
'previewontop' ) ) {
2608 $wgOut->addHTML( $this->editFormTextTop );
2610 $showToolbar =
true;
2612 if ( $this->formtype ==
'save' ) {
2615 $showToolbar =
false;
2617 $wgOut->wrapWikiMsg(
"<div class='error mw-deleted-while-editing'>\n$1\n</div>",
2618 'deletedwhileediting' );
2627 'id' => self::EDITFORM_ID,
2628 'name' => self::EDITFORM_ID,
2631 'enctype' =>
'multipart/form-data'
2635 if ( is_callable( $formCallback ) ) {
2636 wfWarn(
'The $formCallback parameter to ' . __METHOD__ .
'is deprecated' );
2637 call_user_func_array( $formCallback, [ &$wgOut ] );
2642 Xml::openElement(
'div', [
'id' =>
'antispam-container',
'style' =>
'display: none;' ] )
2645 [
'for' =>
'wpAntispam' ],
2646 $this->context->msg(
'simpleantispam-label' )->parse()
2652 'name' =>
'wpAntispam',
2653 'id' =>
'wpAntispam',
2660 Hooks::run(
'EditPage::showEditForm:fields', [ &$this, &$wgOut ] );
2666 $username = $this->lastDelete->user_name;
2667 $comment = $this->lastDelete->log_comment;
2672 ?
'confirmrecreate-noreason'
2673 :
'confirmrecreate';
2675 '<div class="mw-confirm-recreate">' .
2676 $this->context->msg( $key,
$username,
"<nowiki>$comment</nowiki>" )->parse() .
2677 Xml::checkLabel( $this->context->msg(
'recreate' )->text(),
'wpRecreate',
'wpRecreate',
false,
2684 # When the summary is hidden, also hide them on preview/show changes
2685 if ( $this->nosummary ) {
2689 # If a blank edit summary was previously provided, and the appropriate
2690 # user preference is active, pass a hidden tag as wpIgnoreBlankSummary. This will stop the
2691 # user being bounced back more than once in the event that a summary
2694 # For a bit more sophisticated detection of blank summaries, hash the
2695 # automatic one and pass that in the hidden field wpAutoSummary.
2696 if ( $this->missingSummary || ( $this->section ==
'new' && $this->nosummary ) ) {
2697 $wgOut->addHTML(
Html::hidden(
'wpIgnoreBlankSummary',
true ) );
2700 if ( $this->undidRev ) {
2701 $wgOut->addHTML(
Html::hidden(
'wpUndidRevision', $this->undidRev ) );
2704 if ( $this->selfRedirect ) {
2705 $wgOut->addHTML(
Html::hidden(
'wpIgnoreSelfRedirect',
true ) );
2708 if ( $this->hasPresetSummary ) {
2712 $this->autoSumm = md5(
'' );
2715 $autosumm = $this->autoSumm ? $this->autoSumm : md5( $this->summary );
2716 $wgOut->addHTML(
Html::hidden(
'wpAutoSummary', $autosumm ) );
2718 $wgOut->addHTML(
Html::hidden(
'oldid', $this->oldid ) );
2721 $wgOut->addHTML(
Html::hidden(
'format', $this->contentFormat ) );
2722 $wgOut->addHTML(
Html::hidden(
'model', $this->contentModel ) );
2724 if ( $this->section ==
'new' ) {
2729 $wgOut->addHTML( $this->editFormTextBeforeContent );
2731 if ( !$this->isCssJsSubpage && $showToolbar && $wgUser->getOption(
'showtoolbar' ) ) {
2735 if ( $this->blankArticle ) {
2736 $wgOut->addHTML(
Html::hidden(
'wpIgnoreBlankArticle',
true ) );
2739 if ( $this->isConflict ) {
2754 $wgOut->addHTML( $this->editFormTextAfterContent );
2764 $wgOut->addHTML( $this->editFormTextAfterTools .
"\n" );
2772 self::getPreviewLimitReport( $this->mParserOutput ) ) );
2774 $wgOut->addModules(
'mediawiki.action.edit.collapsibleFooter' );
2776 if ( $this->isConflict ) {
2781 $msg = $this->context->msg(
2782 'content-failed-to-parse',
2783 $this->contentModel,
2784 $this->contentFormat,
2787 $wgOut->addWikiText(
'<div class="error">' . $msg->text() .
'</div>' );
2792 if ( $this->isConflict ) {
2794 } elseif ( $this->preview ) {
2796 } elseif ( $this->
diff ) {
2801 $wgOut->addHTML(
Html::hidden(
'mode', $mode, [
'id' =>
'mw-edit-mode' ] ) );
2805 $wgOut->addHTML(
Html::hidden(
'wpUltimateParam',
true ) );
2806 $wgOut->addHTML( $this->editFormTextBottom .
"\n</form>\n" );
2808 if ( !$wgUser->getOption(
'previewontop' ) ) {
2823 $this->context, MediaWikiServices::getInstance()->getLinkRenderer()
2828 if ( $this->preview ) {
2830 } elseif ( $this->section !=
'' ) {
2835 $templateListFormatter->format( $templates,
$type )
2847 preg_match(
"/^(=+)(.+)\\1\\s*(\n|$)/i", $text,
$matches );
2850 return $wgParser->stripSectionName( trim(
$matches[2] ) );
2863 if ( $this->mTitle->isTalkPage() ) {
2864 $wgOut->addWikiMsg(
'talkpagetext' );
2868 $editNotices = $this->mTitle->getEditNotices( $this->oldid );
2869 if ( count( $editNotices ) ) {
2870 $wgOut->addHTML( implode(
"\n", $editNotices ) );
2872 $msg = $this->context->msg(
'editnotice-notext' );
2873 if ( !$msg->isDisabled() ) {
2875 '<div class="mw-editnotice-notext">'
2876 . $msg->parseAsBlock()
2882 if ( $this->isConflict ) {
2883 $wgOut->wrapWikiMsg(
"<div class='mw-explainconflict'>\n$1\n</div>",
'explainconflict' );
2884 $this->editRevId = $this->
page->getLatest();
2890 $wgOut->showErrorPage(
'sectioneditnotsupported-title',
'sectioneditnotsupported-text' );
2894 if ( $this->section !=
'' && $this->section !=
'new' ) {
2895 if ( !$this->summary && !$this->preview && !$this->
diff ) {
2896 $sectionTitle = self::extractSectionTitle( $this->textbox1 );
2897 if ( $sectionTitle !==
false ) {
2898 $this->summary =
"/* $sectionTitle */ ";
2903 if ( $this->missingComment ) {
2904 $wgOut->wrapWikiMsg(
"<div id='mw-missingcommenttext'>\n$1\n</div>",
'missingcommenttext' );
2907 if ( $this->missingSummary && $this->section !=
'new' ) {
2908 $wgOut->wrapWikiMsg(
"<div id='mw-missingsummary'>\n$1\n</div>",
'missingsummary' );
2911 if ( $this->missingSummary && $this->section ==
'new' ) {
2912 $wgOut->wrapWikiMsg(
"<div id='mw-missingcommentheader'>\n$1\n</div>",
'missingcommentheader' );
2915 if ( $this->blankArticle ) {
2916 $wgOut->wrapWikiMsg(
"<div id='mw-blankarticle'>\n$1\n</div>",
'blankarticle' );
2919 if ( $this->selfRedirect ) {
2920 $wgOut->wrapWikiMsg(
"<div id='mw-selfredirect'>\n$1\n</div>",
'selfredirect' );
2923 if ( $this->hookError !==
'' ) {
2924 $wgOut->addWikiText( $this->hookError );
2928 $wgOut->addWikiMsg(
'nonunicodebrowser' );
2931 if ( $this->section !=
'new' ) {
2932 $revision = $this->mArticle->getRevisionFetched();
2937 $wgOut->wrapWikiMsg(
2938 "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
2939 'rev-deleted-text-permission'
2942 $wgOut->wrapWikiMsg(
2943 "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
2944 'rev-deleted-text-view'
2948 if ( !$revision->isCurrent() ) {
2949 $this->mArticle->setOldSubtitle( $revision->getId() );
2950 $wgOut->addWikiMsg(
'editingold' );
2952 } elseif ( $this->mTitle->exists() ) {
2955 $wgOut->wrapWikiMsg(
"<div class='errorbox'>\n$1\n</div>\n",
2956 [
'missing-revision', $this->oldid ] );
2962 $wgOut->wrapWikiMsg(
2963 "<div id=\"mw-read-only-warning\">\n$1\n</div>",
2966 } elseif ( $wgUser->isAnon() ) {
2967 if ( $this->formtype !=
'preview' ) {
2968 $wgOut->wrapWikiMsg(
2969 "<div id='mw-anon-edit-warning' class='warningbox'>\n$1\n</div>",
2970 [
'anoneditwarning',
2973 'returnto' => $this->
getTitle()->getPrefixedDBkey()
2977 'returnto' => $this->
getTitle()->getPrefixedDBkey()
2982 $wgOut->wrapWikiMsg(
"<div id=\"mw-anon-preview-warning\" class=\"warningbox\">\n$1</div>",
2983 'anonpreviewwarning'
2987 if ( $this->isCssJsSubpage ) {
2988 # Check the skin exists
2990 $wgOut->wrapWikiMsg(
2991 "<div class='error' id='mw-userinvalidcssjstitle'>\n$1\n</div>",
2992 [
'userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage() ]
2995 if ( $this->
getTitle()->isSubpageOf( $wgUser->getUserPage() ) ) {
2996 $wgOut->wrapWikiMsg(
'<div class="mw-usercssjspublic">$1</div>',
2997 $this->isCssSubpage ?
'usercssispublic' :
'userjsispublic'
2999 if ( $this->formtype !==
'preview' ) {
3000 if ( $this->isCssSubpage && $wgAllowUserCss ) {
3001 $wgOut->wrapWikiMsg(
3002 "<div id='mw-usercssyoucanpreview'>\n$1\n</div>",
3003 [
'usercssyoucanpreview' ]
3007 if ( $this->isJsSubpage && $wgAllowUserJs ) {
3008 $wgOut->wrapWikiMsg(
3009 "<div id='mw-userjsyoucanpreview'>\n$1\n</div>",
3010 [
'userjsyoucanpreview' ]
3018 if ( $this->mTitle->isProtected(
'edit' ) &&
3021 # Is the title semi-protected?
3022 if ( $this->mTitle->isSemiProtected() ) {
3023 $noticeMsg =
'semiprotectedpagewarning';
3025 # Then it must be protected based on static groups (regular)
3026 $noticeMsg =
'protectedpagewarning';
3029 [
'lim' => 1,
'msgKey' => [ $noticeMsg ] ] );
3031 if ( $this->mTitle->isCascadeProtected() ) {
3032 # Is this page under cascading protection from some source pages?
3034 list( $cascadeSources, ) = $this->mTitle->getCascadeProtectionSources();
3035 $notice =
"<div class='mw-cascadeprotectedwarning'>\n$1\n";
3036 $cascadeSourcesCount = count( $cascadeSources );
3037 if ( $cascadeSourcesCount > 0 ) {
3038 # Explain, and list the titles responsible
3039 foreach ( $cascadeSources
as $page ) {
3040 $notice .=
'* [[:' . $page->getPrefixedText() .
"]]\n";
3043 $notice .=
'</div>';
3044 $wgOut->wrapWikiMsg( $notice, [
'cascadeprotectedwarning', $cascadeSourcesCount ] );
3046 if ( !$this->mTitle->exists() && $this->mTitle->getRestrictions(
'create' ) ) {
3049 'showIfEmpty' =>
false,
3050 'msgKey' => [
'titleprotectedwarning' ],
3051 'wrap' =>
"<div class=\"mw-titleprotectedwarning\">\n$1</div>" ] );
3054 if ( $this->contentLength ===
false ) {
3055 $this->contentLength = strlen( $this->textbox1 );
3058 if ( $this->tooBig || $this->contentLength > $wgMaxArticleSize * 1024 ) {
3059 $wgOut->wrapWikiMsg(
"<div class='error' id='mw-edit-longpageerror'>\n$1\n</div>",
3062 $wgLang->formatNum( round( $this->contentLength / 1024, 3 ) ),
3063 $wgLang->formatNum( $wgMaxArticleSize )
3067 if ( !$this->context->msg(
'longpage-hint' )->isDisabled() ) {
3068 $wgOut->wrapWikiMsg(
"<div id='mw-edit-longpage-hint'>\n$1\n</div>",
3071 $wgLang->formatSize( strlen( $this->textbox1 ) ),
3072 strlen( $this->textbox1 )
3077 # Add header copyright warning
3098 $inputAttrs = null, $spanLabelAttrs = null
3101 $inputAttrs = ( is_array( $inputAttrs ) ? $inputAttrs : [] ) + [
3102 'id' =>
'wpSummary',
3103 'maxlength' =>
'200',
3106 'spellcheck' =>
'true',
3109 $spanLabelAttrs = ( is_array( $spanLabelAttrs ) ? $spanLabelAttrs : [] ) + [
3110 'class' => $this->missingSummary ?
'mw-summarymissed' :
'mw-summary',
3111 'id' =>
"wpSummaryLabel"
3118 $inputAttrs[
'id'] ? [
'for' => $inputAttrs[
'id'] ] : null,
3121 $label =
Xml::tags(
'span', $spanLabelAttrs, $label );
3126 return [ $label, $input ];
3137 # Add a class if 'missingsummary' is triggered to allow styling of the summary line
3138 $summaryClass = $this->missingSummary ?
'mw-summarymissed' :
'mw-summary';
3139 if ( $isSubjectPreview ) {
3140 if ( $this->nosummary ) {
3144 if ( !$this->mShowSummaryField ) {
3148 $labelText = $this->context->msg( $isSubjectPreview ?
'subject' :
'summary' )->parse();
3152 [
'class' => $summaryClass ],
3155 $wgOut->addHTML(
"{$label} {$input}" );
3168 if ( !
$summary || ( !$this->preview && !$this->
diff ) ) {
3174 if ( $isSubjectPreview ) {
3175 $summary = $this->context->msg(
'newsectionsummary' )
3176 ->rawParams( $wgParser->stripSectionName(
$summary ) )
3177 ->inContentLanguage()->text();
3180 $message = $isSubjectPreview ?
'subject-preview' :
'summary-preview';
3182 $summary = $this->context->msg( $message )->parse()
3189 $section = htmlspecialchars( $this->section );
3190 $wgOut->addHTML( <<<HTML
3191 <input
type=
'hidden' value=
"{$section}" name=
"wpSection"/>
3192 <input
type=
'hidden' value=
"{$this->starttime}" name=
"wpStarttime" />
3193 <input
type=
'hidden' value=
"{$this->edittime}" name=
"wpEdittime" />
3194 <input
type=
'hidden' value=
"{$this->editRevId}" name=
"editRevId" />
3195 <input
type=
'hidden' value=
"{$this->scrolltop}" name=
"wpScrolltop" id=
"wpScrolltop" />
3218 $wgOut->addHTML(
"\n" .
Html::hidden(
"wpEditToken", $wgUser->getEditToken() ) .
"\n" );
3243 $attribs = [
'style' =>
'display:none;' ];
3246 if ( $this->mTitle->isProtected(
'edit' ) &&
3249 # Is the title semi-protected?
3250 if ( $this->mTitle->isSemiProtected() ) {
3251 $classes[] =
'mw-textarea-sprotected';
3253 # Then it must be protected based on static groups (regular)
3254 $classes[] =
'mw-textarea-protected';
3256 # Is the title cascade-protected?
3257 if ( $this->mTitle->isCascadeProtected() ) {
3258 $classes[] =
'mw-textarea-cprotected';
3268 if ( count( $classes ) ) {
3269 if ( isset(
$attribs[
'class'] ) ) {
3272 $attribs[
'class'] = implode(
' ', $classes );
3277 $textoverride !== null ? $textoverride : $this->textbox1,
3284 $this->
showTextbox( $this->textbox2,
'wpTextbox2', [
'tabindex' => 6,
'readonly' ] );
3291 if ( strval( $wikitext ) !==
'' ) {
3302 'cols' => $wgUser->getIntOption(
'cols' ),
3303 'rows' => $wgUser->getIntOption(
'rows' ),
3314 $class =
'mw-editfont-' . $wgUser->getOption(
'editfont' );
3316 if ( isset(
$attribs[
'class'] ) ) {
3317 if ( is_string(
$attribs[
'class'] ) ) {
3319 } elseif ( is_array(
$attribs[
'class'] ) ) {
3326 $pageLang = $this->mTitle->getPageLanguage();
3327 $attribs[
'lang'] = $pageLang->getHtmlCode();
3328 $attribs[
'dir'] = $pageLang->getDir();
3337 $classes[] =
'ontop';
3340 $attribs = [
'id' =>
'wikiPreview',
'class' => implode(
' ', $classes ) ];
3342 if ( $this->formtype !=
'preview' ) {
3343 $attribs[
'style'] =
'display: none;';
3348 if ( $this->formtype ==
'preview' ) {
3352 $pageViewLang = $this->mTitle->getPageViewLanguage();
3353 $attribs = [
'lang' => $pageViewLang->getHtmlCode(),
'dir' => $pageViewLang->getDir(),
3354 'class' =>
'mw-content-' . $pageViewLang->getDir() ];
3358 $wgOut->addHTML(
'</div>' );
3360 if ( $this->formtype ==
'diff' ) {
3364 $msg = $this->context->msg(
3365 'content-failed-to-parse',
3366 $this->contentModel,
3367 $this->contentFormat,
3370 $wgOut->addWikiText(
'<div class="error">' . $msg->text() .
'</div>' );
3383 if ( $this->mTitle->getNamespace() ==
NS_CATEGORY ) {
3384 $this->mArticle->openShowCategory();
3386 # This hook seems slightly odd here, but makes things more
3387 # consistent for extensions.
3388 Hooks::run(
'OutputPageBeforeHTML', [ &$wgOut, &$text ] );
3389 $wgOut->addHTML( $text );
3390 if ( $this->mTitle->getNamespace() ==
NS_CATEGORY ) {
3391 $this->mArticle->closeShowCategory();
3405 $oldtitlemsg =
'currentrev';
3406 # if message does not exist, show diff against the preloaded default
3407 if ( $this->mTitle->getNamespace() ==
NS_MEDIAWIKI && !$this->mTitle->exists() ) {
3408 $oldtext = $this->mTitle->getDefaultMessageText();
3409 if ( $oldtext !==
false ) {
3410 $oldtitlemsg =
'defaultmessagetext';
3420 if ( $this->editRevId !== null ) {
3421 $newContent = $this->
page->replaceSectionAtRev(
3422 $this->section, $textboxContent, $this->summary, $this->editRevId
3425 $newContent = $this->
page->replaceSectionContent(
3426 $this->section, $textboxContent, $this->summary, $this->edittime
3430 if ( $newContent ) {
3432 Hooks::run(
'EditPageGetDiffContent', [ $this, &$newContent ] );
3435 $newContent = $newContent->preSaveTransform( $this->mTitle, $wgUser, $popts );
3438 if ( ( $oldContent && !$oldContent->isEmpty() ) || ( $newContent && !$newContent->isEmpty() ) ) {
3439 $oldtitle = $this->context->msg( $oldtitlemsg )->parse();
3440 $newtitle = $this->context->msg(
'yourtext' )->parse();
3442 if ( !$oldContent ) {
3443 $oldContent = $newContent->getContentHandler()->makeEmptyContent();
3446 if ( !$newContent ) {
3447 $newContent = $oldContent->getContentHandler()->makeEmptyContent();
3450 $de = $oldContent->getContentHandler()->createDifferenceEngine( $this->mArticle->getContext() );
3451 $de->setContent( $oldContent, $newContent );
3453 $difftext = $de->getDiff( $oldtitle, $newtitle );
3454 $de->showDiffStyle();
3459 $wgOut->addHTML(
'<div id="wikiDiff">' . $difftext .
'</div>' );
3466 $msg =
'editpage-head-copy-warn';
3467 if ( !$this->context->msg( $msg )->isDisabled() ) {
3469 $wgOut->wrapWikiMsg(
"<div class='editpage-head-copywarn'>\n$1\n</div>",
3470 'editpage-head-copy-warn' );
3483 $msg =
'editpage-tos-summary';
3484 Hooks::run(
'EditPageTosSummary', [ $this->mTitle, &$msg ] );
3485 if ( !$this->context->msg( $msg )->isDisabled() ) {
3487 $wgOut->addHTML(
'<div class="mw-tos-summary">' );
3488 $wgOut->addWikiMsg( $msg );
3489 $wgOut->addHTML(
'</div>' );
3495 $wgOut->addHTML(
'<div class="mw-editTools">' .
3496 $this->context->msg(
'edittools' )->inContentLanguage()->parse() .
3507 return self::getCopyrightWarning( $this->mTitle );
3519 if ( $wgRightsText ) {
3520 $copywarnMsg = [
'copyrightwarning',
3521 '[[' .
wfMessage(
'copyrightpage' )->inContentLanguage()->text() .
']]',
3524 $copywarnMsg = [
'copyrightwarning2',
3525 '[[' .
wfMessage(
'copyrightpage' )->inContentLanguage()->text() .
']]' ];
3530 $msg = call_user_func_array(
'wfMessage', $copywarnMsg )->title(
$title );
3532 $msg->inLanguage( $langcode );
3534 return "<div id=\"editpage-copywarn\">\n" .
3535 $msg->$format() .
"\n</div>";
3550 $limitReport =
Html::rawElement(
'div', [
'class' =>
'mw-limitReportExplanation' ],
3551 wfMessage(
'limitreport-title' )->parseAsBlock()
3555 $limitReport .=
Html::openElement(
'div', [
'class' =>
'preview-limit-report-wrapper' ] );
3558 'class' =>
'preview-limit-report wikitable'
3564 [ $key, &
$value, &$limitReport,
true,
true ]
3567 $valueMsg =
wfMessage( [
"$key-value-html",
"$key-value" ] );
3568 if ( !$valueMsg->exists() ) {
3571 if ( !$keyMsg->isDisabled() && !$valueMsg->isDisabled() ) {
3584 return $limitReport;
3589 $wgOut->addHTML(
"<div class='editOptions'>\n" );
3591 if ( $this->section !=
'new' ) {
3597 [
'minor' => $this->minoredit,
'watch' => $this->watchthis ] );
3598 $wgOut->addHTML(
"<div class='editCheckboxes'>" . implode( $checkboxes,
"\n" ) .
"</div>\n" );
3602 $wgOut->addHTML( $this->editFormTextAfterWarn );
3604 $wgOut->addHTML(
"<div class='editButtons'>\n" );
3608 if ( $cancel !==
'' ) {
3610 [
'class' =>
'mw-editButtons-pipe-separator' ],
3611 $this->context->msg(
'pipe-separator' )->text() );
3614 $message = $this->context->msg(
'edithelppage' )->inContentLanguage()->text();
3617 'target' =>
'helpwindow',
3618 'href' => $edithelpurl,
3621 $attrs, [
'mw-ui-quiet' ] ) .
3622 $this->context->msg(
'word-separator' )->escaped() .
3623 $this->context->msg(
'newwindow' )->parse();
3625 $wgOut->addHTML(
" <span class='cancelLink'>{$cancel}</span>\n" );
3626 $wgOut->addHTML(
" <span class='editHelp'>{$edithelp}</span>\n" );
3627 $wgOut->addHTML(
"</div><!-- editButtons -->\n" );
3631 $wgOut->addHTML(
"</div><!-- editOptions -->\n" );
3641 if (
Hooks::run(
'EditPageBeforeConflictDiff', [ &$this, &$wgOut ] ) ) {
3642 $stats = $wgOut->getContext()->getStats();
3643 $stats->increment(
'edit.failures.conflict' );
3646 $this->mTitle->getNamespace() >=
NS_MAIN &&
3649 $stats->increment(
'edit.failures.conflict.byNamespaceId.' . $this->mTitle->getNamespace() );
3652 $wgOut->wrapWikiMsg(
'<h2>$1</h2>',
"yourdiff" );
3658 $de =
$handler->createDifferenceEngine( $this->mArticle->getContext() );
3659 $de->setContent( $content2, $content1 );
3661 $this->context->msg(
'yourtext' )->parse(),
3662 $this->context->msg(
'storedversion' )->text()
3665 $wgOut->wrapWikiMsg(
'<h2>$1</h2>',
"yourtext" );
3675 if ( !$this->isConflict && $this->oldid > 0 ) {
3678 $cancelParams[
'redirect'] =
'no';
3680 $attrs = [
'id' =>
'mw-editform-cancel' ];
3684 $this->context->msg(
'cancel' )->parse(),
3700 return $title->
getLocalURL( [
'action' => $this->action ] );
3711 if ( $this->deletedSinceEdit !== null ) {
3715 $this->deletedSinceEdit =
false;
3717 if ( !$this->mTitle->exists() && $this->mTitle->isDeletedQuick() ) {
3719 if ( $this->lastDelete ) {
3721 if ( $deleteTime > $this->starttime ) {
3722 $this->deletedSinceEdit =
true;
3735 $data =
$dbr->selectRow(
3736 [
'logging',
'user' ],
3749 'log_namespace' => $this->mTitle->getNamespace(),
3750 'log_title' => $this->mTitle->getDBkey(),
3751 'log_type' =>
'delete',
3752 'log_action' =>
'delete',
3756 [
'LIMIT' => 1,
'ORDER BY' =>
'log_timestamp DESC' ]
3759 if ( is_object( $data ) ) {
3761 $data->user_name = $this->context->msg(
'rev-deleted-user' )->escaped();
3765 $data->log_comment = $this->context->msg(
'rev-deleted-comment' )->escaped();
3781 $stats = $wgOut->getContext()->getStats();
3783 if ( $wgRawHtml && !$this->mTokenOk ) {
3787 if ( $this->textbox1 !==
'' ) {
3791 $parsedNote = $wgOut->parse(
"<div class='previewnote'>" .
3792 $this->context->msg(
'session_fail_preview_html' )->text() .
"</div>",
3795 $stats->increment(
'edit.failures.session_loss' );
3806 'AlternateEditPreview',
3807 [ $this, &
$content, &$previewHTML, &$this->mParserOutput ] )
3809 return $previewHTML;
3812 # provide a anchor link to the editform
3813 $continueEditing =
'<span class="mw-continue-editing">' .
3814 '[[#' . self::EDITFORM_ID .
'|' . $wgLang->getArrow() .
' ' .
3815 $this->context->msg(
'continue-editing' )->text() .
']]</span>';
3816 if ( $this->mTriedSave && !$this->mTokenOk ) {
3817 if ( $this->mTokenOkExceptSuffix ) {
3818 $note = $this->context->msg(
'token_suffix_mismatch' )->plain();
3819 $stats->increment(
'edit.failures.bad_token' );
3821 $note = $this->context->msg(
'session_fail_preview' )->plain();
3822 $stats->increment(
'edit.failures.session_loss' );
3824 } elseif ( $this->incompleteForm ) {
3825 $note = $this->context->msg(
'edit_form_incomplete' )->plain();
3826 if ( $this->mTriedSave ) {
3827 $stats->increment(
'edit.failures.incomplete_form' );
3830 $note = $this->context->msg(
'previewnote' )->plain() .
' ' . $continueEditing;
3833 # don't parse non-wikitext pages, show message about preview
3834 if ( $this->mTitle->isCssJsSubpage() || $this->mTitle->isCssOrJsPage() ) {
3835 if ( $this->mTitle->isCssJsSubpage() ) {
3837 } elseif ( $this->mTitle->isCssOrJsPage() ) {
3845 if ( $level ===
'user' && !$wgAllowUserCss ) {
3850 if ( $level ===
'user' && !$wgAllowUserJs ) {
3857 # Used messages to make sure grep find them:
3858 # Messages: usercsspreview, userjspreview, sitecsspreview, sitejspreview
3859 if ( $level && $format ) {
3860 $note =
"<div id='mw-{$level}{$format}preview'>" .
3861 $this->context->msg(
"{$level}{$format}preview" )->text() .
3862 ' ' . $continueEditing .
"</div>";
3866 # If we're adding a comment, we need to show the
3867 # summary as the headline
3868 if ( $this->section ===
"new" && $this->summary !==
"" ) {
3874 Hooks::run(
'EditPageGetPreviewContent', $hook_args );
3878 $previewHTML = $parserResult[
'html'];
3883 $note .=
"\n\n" . implode(
"\n\n",
$parserOutput->getWarnings() );
3887 $m = $this->context->msg(
3888 'content-failed-to-parse',
3889 $this->contentModel,
3890 $this->contentFormat,
3893 $note .=
"\n\n" . $m->parse();
3897 if ( $this->isConflict ) {
3898 $conflict =
'<h2 id="mw-previewconflict">'
3899 . $this->context->msg(
'previewconflict' )->escaped() .
"</h2>\n";
3901 $conflict =
'<hr />';
3904 $previewhead =
"<div class='previewnote'>\n" .
3905 '<h2 id="mw-previewheader">' . $this->context->msg(
'preview' )->escaped() .
"</h2>" .
3906 $wgOut->parse( $note,
true,
true ) . $conflict .
"</div>\n";
3908 $pageViewLang = $this->mTitle->getPageViewLanguage();
3909 $attribs = [
'lang' => $pageViewLang->getHtmlCode(),
'dir' => $pageViewLang->getDir(),
3910 'class' =>
'mw-content-' . $pageViewLang->getDir() ];
3921 $parserOptions = $this->
page->makeParserOptions( $this->mArticle->getContext() );
3922 $parserOptions->setIsPreview(
true );
3923 $parserOptions->setIsSectionPreview( !is_null( $this->section ) && $this->section !==
'' );
3924 $parserOptions->enableLimitReport();
3925 return $parserOptions;
3940 $pstContent = $content->
preSaveTransform( $this->mTitle, $wgUser, $parserOptions );
3941 $scopedCallback = $parserOptions->setupFakeRevision(
3942 $this->mTitle, $pstContent, $wgUser );
3943 $parserOutput = $pstContent->getParserOutput( $this->mTitle, null, $parserOptions );
3944 ScopedCallback::consume( $scopedCallback );
3955 if ( $this->preview || $this->section !=
'' ) {
3957 if ( !isset( $this->mParserOutput ) ) {
3960 foreach ( $this->mParserOutput->getTemplates()
as $ns =>
$template ) {
3967 return $this->mTitle->getTemplateLinksFrom();
3982 $imagesAvailable = $wgEnableUploads || count( $wgForeignFileRepos );
3983 $showSignature =
true;
3999 'id' =>
'mw-editbutton-bold',
4001 'close' =>
'\'\
'\'',
4002 'sample' =>
wfMessage(
'bold_sample' )->text(),
4003 'tip' =>
wfMessage(
'bold_tip' )->text(),
4006 'id' =>
'mw-editbutton-italic',
4009 'sample' =>
wfMessage(
'italic_sample' )->text(),
4010 'tip' =>
wfMessage(
'italic_tip' )->text(),
4013 'id' =>
'mw-editbutton-link',
4016 'sample' =>
wfMessage(
'link_sample' )->text(),
4017 'tip' =>
wfMessage(
'link_tip' )->text(),
4020 'id' =>
'mw-editbutton-extlink',
4023 'sample' =>
wfMessage(
'extlink_sample' )->text(),
4024 'tip' =>
wfMessage(
'extlink_tip' )->text(),
4027 'id' =>
'mw-editbutton-headline',
4030 'sample' =>
wfMessage(
'headline_sample' )->text(),
4031 'tip' =>
wfMessage(
'headline_tip' )->text(),
4033 $imagesAvailable ? [
4034 'id' =>
'mw-editbutton-image',
4035 'open' =>
'[[' . $wgContLang->getNsText(
NS_FILE ) .
':',
4037 'sample' =>
wfMessage(
'image_sample' )->text(),
4038 'tip' =>
wfMessage(
'image_tip' )->text(),
4040 $imagesAvailable ? [
4041 'id' =>
'mw-editbutton-media',
4042 'open' =>
'[[' . $wgContLang->getNsText(
NS_MEDIA ) .
':',
4044 'sample' =>
wfMessage(
'media_sample' )->text(),
4045 'tip' =>
wfMessage(
'media_tip' )->text(),
4048 'id' =>
'mw-editbutton-nowiki',
4049 'open' =>
"<nowiki>",
4050 'close' =>
"</nowiki>",
4051 'sample' =>
wfMessage(
'nowiki_sample' )->text(),
4052 'tip' =>
wfMessage(
'nowiki_tip' )->text(),
4055 'id' =>
'mw-editbutton-signature',
4056 'open' =>
wfMessage(
'sig-text',
'~~~~' )->inContentLanguage()->text(),
4059 'tip' =>
wfMessage(
'sig_tip' )->text(),
4062 'id' =>
'mw-editbutton-hr',
4063 'open' =>
"\n----\n",
4070 $script =
'mw.loader.using("mediawiki.toolbar", function () {';
4071 foreach ( $toolarray
as $tool ) {
4091 'mw.toolbar.addButton',
4100 $toolbar =
'<div id="toolbar"></div>';
4102 Hooks::run(
'EditPageBeforeEditToolbar', [ &$toolbar ] );
4123 if ( !$this->isNew ) {
4124 $checkboxes[
'minor'] =
'';
4125 $minorLabel = $this->context->msg(
'minoredit' )->parse();
4126 if ( $wgUser->isAllowed(
'minoredit' ) ) {
4129 'accesskey' => $this->context->msg(
'accesskey-minoredit' )->text(),
4130 'id' =>
'wpMinoredit',
4134 " <label for='wpMinoredit' id='mw-editpage-minoredit'" .
4136 ">{$minorLabel}</label>";
4138 if ( $wgUseMediaWikiUIEverywhere ) {
4139 $checkboxes[
'minor'] =
Html::openElement(
'div', [
'class' =>
'mw-ui-checkbox' ] ) .
4143 $checkboxes[
'minor'] = $minorEditHtml;
4148 $watchLabel = $this->context->msg(
'watchthis' )->parse();
4149 $checkboxes[
'watch'] =
'';
4150 if ( $wgUser->isLoggedIn() ) {
4153 'accesskey' => $this->context->msg(
'accesskey-watch' )->text(),
4154 'id' =>
'wpWatchthis',
4158 " <label for='wpWatchthis' id='mw-editpage-watch'" .
4160 ">{$watchLabel}</label>";
4161 if ( $wgUseMediaWikiUIEverywhere ) {
4162 $checkboxes[
'watch'] =
Html::openElement(
'div', [
'class' =>
'mw-ui-checkbox' ] ) .
4166 $checkboxes[
'watch'] = $watchThisHtml;
4185 $this->mArticle->getContext()->getConfig()->get(
'EditSubmitButtonLabelPublish' );
4188 if ( $labelAsPublish ) {
4189 $buttonLabelKey = !$this->mTitle->exists() ?
'publishpage' :
'publishchanges';
4191 $buttonLabelKey = !$this->mTitle->exists() ?
'savearticle' :
'savechanges';
4193 $buttonLabel = $this->context->msg( $buttonLabelKey )->text();
4203 'id' =>
'wpPreview',
4204 'name' =>
'wpPreview',
4207 $buttons[
'preview'] =
Html::submitButton( $this->context->msg(
'showpreview' )->text(),
4209 $buttons[
'live'] =
'';
4230 $wgOut->prepareErrorPage( $this->context->msg(
'nosuchsectiontitle' ) );
4232 $res = $this->context->msg(
'nosuchsectiontext', $this->section )->parseAsBlock();
4234 $wgOut->addHTML(
$res );
4236 $wgOut->returnToMain(
false, $this->mTitle );
4248 if ( is_array( $match ) ) {
4249 $match = $wgLang->listToText( $match );
4251 $wgOut->prepareErrorPage( $this->context->msg(
'spamprotectiontitle' ) );
4253 $wgOut->addHTML(
'<div id="spamprotected">' );
4254 $wgOut->addWikiMsg(
'spamprotectiontext' );
4258 $wgOut->addHTML(
'</div>' );
4260 $wgOut->wrapWikiMsg(
'<h2>$1</h2>',
"yourdiff" );
4263 $wgOut->wrapWikiMsg(
'<h2>$1</h2>',
"yourtext" );
4266 $wgOut->addReturnTo( $this->
getContextTitle(), [
'action' =>
'edit' ] );
4278 $currentbrowser = $wgRequest->getHeader(
'User-Agent' );
4279 if ( $currentbrowser ===
false ) {
4284 foreach ( $wgBrowserBlackList
as $browser ) {
4285 if ( preg_match( $browser, $currentbrowser ) ) {
4301 $text = rtrim(
$request->getText( $field ) );
4302 return $request->getBool(
'safemode' )
4334 $invalue = strtr( $invalue, [
"&#x" =>
"�" ] );
4339 $valueLength = strlen( $invalue );
4340 for ( $i = 0; $i < $valueLength; $i++ ) {
4341 $bytevalue = ord( $invalue[$i] );
4342 if ( $bytevalue <= 0x7F ) {
4345 } elseif ( $bytevalue <= 0xBF ) {
4346 $working = $working << 6;
4347 $working += ( $bytevalue & 0x3F );
4349 if ( $bytesleft <= 0 ) {
4350 $result .=
"&#x" . strtoupper( dechex( $working ) ) .
";";
4352 } elseif ( $bytevalue <= 0xDF ) {
4353 $working = $bytevalue & 0x1F;
4355 } elseif ( $bytevalue <= 0xEF ) {
4356 $working = $bytevalue & 0x0F;
4359 $working = $bytevalue & 0x07;
4376 $valueLength = strlen( $invalue );
4377 for ( $i = 0; $i < $valueLength; $i++ ) {
4378 if ( ( substr( $invalue, $i, 3 ) ==
"&#x" ) && ( $invalue[$i + 3] !=
'0' ) ) {
4382 $hexstring .= $invalue[$i];
4384 }
while ( ctype_xdigit( $invalue[$i] ) && ( $i < strlen( $invalue ) ) );
4389 if ( ( substr( $invalue, $i, 1 ) ==
";" ) && ( strlen( $hexstring ) <= 6 ) ) {
4390 $codepoint = hexdec( $hexstring );
4393 $result .=
"&#x" . $hexstring . substr( $invalue, $i, 1 );
4396 $result .= substr( $invalue, $i, 1 );
4400 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
$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.
processing should stop and the error should be shown to the user * false
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...
static getTitleFor($name, $subpage=false, $fragment= '')
Get a localised Title object for a specified special page name If you don't need a full Title object...
Handles formatting for the "templates used on this page" lists.
if(!$wgDBerrorLogTZ) $wgRequest
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...
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.
also included in $newHeader if any indicating whether we should show just the diff
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.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
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 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
null means default & $customAttribs
internalAttemptSave(&$result, $bot=false)
Attempt submission (no UI)
bool stdClass $lastDelete
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.
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':DEPRECATED!Use HtmlPageLinkRendererBegin instead.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...
$wgEnableUploads
Uploads have to be specially set up to be secure.
getContext()
Gets the context this Article is executed in.
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 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 true
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...
fatal($message)
Add an error and set OK to false, indicating that the operation as a whole was fatal.
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 getCopyrightWarning($title, $format= 'plain', $langcode=null)
Get the copyright warning, by default returns wikitext.
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.
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock()-offset Set to overwrite offset parameter in $wgRequest set to ''to unsetoffset-wrap String Wrap the message in html(usually something like"<
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...
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.
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.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
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
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
isSectionEditSupported()
Returns whether section editing is supported for the current page.
static isIP($name)
Does the string match an anonymous IP 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
static linkKnown($target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
static newGood($value=null)
Factory function for good results.
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.
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.
getPreviewParserOptions()
Get parser options for a preview.
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
makeTemplatesOnThisPageList(array $templates)
Wrapper around TemplatesOnThisPageFormatter to make a "templates on this page" list.
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 to manipulate or replace but no entry for that model exists in $wgContentHandlers if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive false for true for descending in case the handler function wants to provide a converted Content object Note that $result getContentModel() must return $toModel. 'CustomEditor'$rcid is used in generating this variable which contains information about the new such as the revision s whether the revision was marked as a minor edit or not
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
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.
doPreviewParse(Content $content)
Parse the page for a preview.
static submitButton($contents, array $attrs, array $modifiers=[])
Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enab...
Exception thrown when an unregistered content model is requested.
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)
preSaveTransform(Title $title, User $user, ParserOptions $parserOptions)
Returns a Content object with pre-save transformations applied (or this object if no transformations ...
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= ?
MediaWiki Logger LoggerFactory implements a PSR[0] compatible message logging system Named Psr Log LoggerInterface instances can be obtained from the MediaWiki Logger LoggerFactory::getInstance() static method.MediaWiki\Logger\LoggerFactory expects a class implementing the MediaWiki\Logger\Spi interface to act as a factory for new Psr\Log\LoggerInterface instances.The"Spi"in MediaWiki\Logger\Spi stands for"service provider interface".An SPI is an API intended to be implemented or extended by a third party.This software design pattern is intended to enable framework extension and replaceable components.It is specifically used in the MediaWiki\Logger\LoggerFactory service to allow alternate PSR-3 logging implementations to be easily integrated with MediaWiki.The service provider interface allows the backend logging library to be implemented in multiple ways.The $wgMWLoggerDefaultSpi global provides the classname of the default MediaWiki\Logger\Spi implementation to be loaded at runtime.This can either be the name of a class implementing the MediaWiki\Logger\Spi with a zero argument const ructor or a callable that will return an MediaWiki\Logger\Spi instance.Alternately the MediaWiki\Logger\LoggerFactory MediaWiki Logger LoggerFactory
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.
static addCallableUpdate($callable, $stage=self::POSTSEND, IDatabase $dbw=null)
Add a callable update.
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
Show an error when the user hits a rate limit.
static getEditToolbar($title=null)
Shows a bulletin board style toolbar for common editing functions.
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 my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
static makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
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.
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.
getSummaryPreview($isSubjectPreview, $summary="")
const AS_CHANGE_TAG_ERROR
Status: an error relating to change tagging.
static runLegacyHooks($event, $args=[], $deprecatedVersion=null)
Call a legacy hook that uses text instead of Content objects.
$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)
setContentModel($model)
Set a proposed content model for the page for permissions checking.
Allows to change the fields on the form that will be generated $name