27use Wikimedia\ScopedCallback;
381 # Placeholders for text injection by hooks (must be HTML)
382 # extensions should take care to _append_ to the present value
444 $this->page = $article->getPage();
445 $this->mTitle = $article->getTitle();
446 $this->context = $article->getContext();
448 $this->contentModel = $this->mTitle->getContentModel();
450 $handler = ContentHandler::getForModelID( $this->contentModel );
451 $this->contentFormat =
$handler->getDefaultFormat();
452 $this->editConflictHelperFactory = [ $this,
'newTextConflictHelper' ];
484 $this->mContextTitle =
$title;
495 if ( is_null( $this->mContextTitle ) ) {
498 __METHOD__ .
' called by ' .
wfGetAllCallers( 5 ) .
' with no title set.'
525 return $this->enableApiEditOverride ===
true ||
526 ContentHandler::getForModelID( $modelId )->supportsDirectEditing();
536 $this->enableApiEditOverride = $enableOverride;
560 if ( !Hooks::run(
'AlternateEdit', [ $this ] ) ) {
564 wfDebug( __METHOD__ .
": enter\n" );
566 $request = $this->context->getRequest();
568 if (
$request->getBool(
'redlink' ) && $this->mTitle->exists() ) {
569 $this->context->getOutput()->redirect( $this->mTitle->getFullURL() );
574 $this->firsttime =
false;
579 $this->preview =
true;
583 $this->formtype =
'save';
584 } elseif ( $this->preview ) {
585 $this->formtype =
'preview';
586 } elseif ( $this->
diff ) {
587 $this->formtype =
'diff';
588 }
else { #
First time through
589 $this->firsttime =
true;
591 $this->formtype =
'preview';
593 $this->formtype =
'initial';
599 wfDebug( __METHOD__ .
": User can't edit\n" );
602 DeferredUpdates::addCallableUpdate(
function () {
603 $this->context->getUser()->spreadAnyEditBlock();
611 $revision = $this->mArticle->getRevisionFetched();
615 && $revision->getContentModel() !== $this->contentModel
618 if ( $this->undidRev ) {
619 $undidRevObj = Revision::newFromId( $this->undidRev );
620 $prevRev = $undidRevObj ? $undidRevObj->getPrevious() :
null;
622 if ( !$this->undidRev
624 || $prevRev->getContentModel() !== $this->contentModel
629 'contentmodelediterror',
630 $revision->getContentModel(),
638 $this->isConflict =
false;
640 # Show applicable editing introductions
641 if ( $this->formtype ==
'initial' || $this->firsttime ) {
645 # Attempt submission here. This will check for edit conflicts,
646 # and redundantly check for locked database, blocked IPs, etc.
647 # that edit() already checked just in case someone tries to sneak
648 # in the back door with a hand-edited submission URL.
650 if (
'save' == $this->formtype ) {
651 $resultDetails =
null;
658 # First time through: get contents, set time for conflict
660 if (
'initial' == $this->formtype || $this->firsttime ) {
666 if ( !$this->mTitle->getArticleID() ) {
667 Hooks::run(
'EditFormPreloadText', [ &$this->textbox1, &$this->mTitle ] );
669 Hooks::run(
'EditFormInitialText', [ $this ] );
682 $user = $this->context->getUser();
683 $permErrors = $this->mTitle->getUserPermissionsErrors(
'edit', $user, $rigor );
684 # Can this title be created?
685 if ( !$this->mTitle->exists() ) {
686 $permErrors = array_merge(
689 $this->mTitle->getUserPermissionsErrors(
'create', $user, $rigor ),
694 # Ignore some permissions errors when a user is just previewing/viewing diffs
696 foreach ( $permErrors as $error ) {
697 if ( ( $this->preview || $this->
diff )
699 $error[0] ==
'blockedtext' ||
700 $error[0] ==
'autoblockedtext' ||
701 $error[0] ==
'systemblockedtext'
726 $out = $this->context->getOutput();
727 if ( $this->context->getRequest()->getBool(
'redlink' ) ) {
731 $out->redirect( $this->mTitle->getFullURL() );
737 # Use the normal message if there's nothing to display
738 if ( $this->firsttime && ( !$content || $content->isEmpty() ) ) {
739 $action = $this->mTitle->exists() ?
'edit' :
740 ( $this->mTitle->isTalkPage() ?
'createtalk' :
'createpage' );
746 $out->formatPermissionsErrorMessage( $permErrors,
'edit' )
756 $out = $this->context->getOutput();
757 Hooks::run(
'EditPage::showReadOnlyForm:initial', [ $this, &
$out ] );
759 $out->setRobotPolicy(
'noindex,nofollow' );
760 $out->setPageTitle( $this->context->msg(
762 $this->getContextTitle()->getPrefixedText()
765 $out->addHTML( $this->editFormPageTop );
766 $out->addHTML( $this->editFormTextTop );
768 if ( $errorMessage !==
'' ) {
769 $out->addWikiText( $errorMessage );
770 $out->addHTML(
"<hr />\n" );
773 # If the user made changes, preserve them when showing the markup
774 # (This happens when a user is blocked during edit, for instance)
775 if ( !$this->firsttime ) {
777 $out->addWikiMsg(
'viewyourtext' );
782 # Serialize using the default format if the content model is not supported
783 # (e.g. for an old revision with a different model)
786 $out->addWikiMsg(
'viewsourcetext' );
789 $out->addHTML( $this->editFormTextBeforeContent );
790 $this->
showTextbox( $text,
'wpTextbox1', [
'readonly' ] );
791 $out->addHTML( $this->editFormTextAfterContent );
795 $out->addModules(
'mediawiki.action.edit.collapsibleFooter' );
797 $out->addHTML( $this->editFormTextBottom );
798 if ( $this->mTitle->exists() ) {
799 $out->returnToMain(
null, $this->mTitle );
809 $config = $this->context->getConfig();
810 $previewOnOpenNamespaces = $config->get(
'PreviewOnOpenNamespaces' );
811 $request = $this->context->getRequest();
812 if ( $config->get(
'RawHtml' ) ) {
818 if (
$request->getVal(
'preview' ) ==
'yes' ) {
821 } elseif (
$request->getVal(
'preview' ) ==
'no' ) {
824 } elseif ( $this->section ==
'new' ) {
827 } elseif ( (
$request->getVal(
'preload' ) !==
null || $this->mTitle->exists() )
828 && $this->context->getUser()->getOption(
'previewonfirst' )
832 } elseif ( !$this->mTitle->exists()
833 && isset( $previewOnOpenNamespaces[$this->mTitle->getNamespace()] )
834 && $previewOnOpenNamespaces[$this->mTitle->getNamespace()]
850 if ( $this->mTitle->isUserConfigPage() ) {
851 $name = $this->mTitle->getSkinFromConfigSubpage();
852 $skins = array_merge(
853 array_keys( Skin::getSkinNames() ),
856 return !in_array( $name, $skins )
857 && in_array( strtolower( $name ), $skins );
871 $contentHandler = ContentHandler::getForTitle( $this->mTitle );
872 return $contentHandler->supportsSections();
881 # Section edit can come from either the form or a link
882 $this->section =
$request->getVal(
'wpSection',
$request->getVal(
'section' ) );
885 throw new ErrorPageError(
'sectioneditnotsupported-title',
'sectioneditnotsupported-text' );
888 $this->isNew = !$this->mTitle->exists() || $this->section ==
'new';
891 # These fields need to be checked for encoding.
892 # Also remove trailing whitespace, but don't remove _initial_
893 # whitespace from the text boxes. This may be significant formatting.
894 $this->textbox1 = rtrim(
$request->getText(
'wpTextbox1' ) );
895 if ( !
$request->getCheck(
'wpTextbox2' ) ) {
905 $this->unicodeCheck =
$request->getText(
'wpUnicodeCheck' );
907 $this->summary =
$request->getText(
'wpSummary' );
909 # If the summary consists of a heading, e.g. '==Foobar==', extract the title from the
910 # header syntax, e.g. 'Foobar'. This is mainly an issue when we are using wpSummary for
912 $this->summary = preg_replace(
'/^\s*=+\s*(.*?)\s*=+\s*$/',
'$1', $this->summary );
914 # Treat sectiontitle the same way as summary.
915 # Note that wpSectionTitle is not yet a part of the actual edit form, as wpSummary is
916 # currently doing double duty as both edit summary and section title. Right now this
917 # is just to allow API edits to work around this limitation, but this should be
918 # incorporated into the actual edit form when EditPage is rewritten (Bugs 18654, 26312).
919 $this->sectiontitle =
$request->getText(
'wpSectionTitle' );
920 $this->sectiontitle = preg_replace(
'/^\s*=+\s*(.*?)\s*=+\s*$/',
'$1', $this->sectiontitle );
922 $this->edittime =
$request->getVal(
'wpEdittime' );
923 $this->editRevId =
$request->getIntOrNull(
'editRevId' );
924 $this->starttime =
$request->getVal(
'wpStarttime' );
931 $this->scrolltop =
$request->getIntOrNull(
'wpScrolltop' );
933 if ( $this->textbox1 ===
'' &&
$request->getVal(
'wpTextbox1' ) ===
null ) {
937 $this->incompleteForm =
true;
945 $this->incompleteForm = ( !
$request->getVal(
'wpUltimateParam' )
946 && is_null( $this->edittime ) );
948 if ( $this->incompleteForm ) {
949 # If the form is incomplete, force to preview.
950 wfDebug( __METHOD__ .
": Form data appears to be incomplete\n" );
951 wfDebug(
"POST DATA: " . var_export( $_POST,
true ) .
"\n" );
952 $this->preview =
true;
954 $this->preview =
$request->getCheck(
'wpPreview' );
962 # Some browsers will not report any submit button
963 # if the user hits enter in the comment box.
964 # The unmarked state will be assumed to be a save,
965 # if the form seems otherwise complete.
966 wfDebug( __METHOD__ .
": Passed token check.\n" );
967 } elseif ( $this->
diff ) {
968 # Failed token check, but only requested "Show Changes".
969 wfDebug( __METHOD__ .
": Failed token check; Show Changes requested.\n" );
971 # Page might be a hack attempt posted from
972 # an external site. Preview instead of saving.
973 wfDebug( __METHOD__ .
": Failed token check; forcing preview\n" );
974 $this->preview =
true;
978 if ( !preg_match(
'/^\d{14}$/', $this->edittime ) ) {
979 $this->edittime =
null;
982 if ( !preg_match(
'/^\d{14}$/', $this->starttime ) ) {
983 $this->starttime =
null;
986 $this->recreate =
$request->getCheck(
'wpRecreate' );
988 $this->minoredit =
$request->getCheck(
'wpMinoredit' );
989 $this->watchthis =
$request->getCheck(
'wpWatchthis' );
991 $user = $this->context->getUser();
992 # Don't force edit summaries when a user is editing their own user or talk page
993 if ( ( $this->mTitle->mNamespace == NS_USER || $this->mTitle->mNamespace ==
NS_USER_TALK )
994 && $this->mTitle->getText() == $user->getName()
996 $this->allowBlankSummary =
true;
998 $this->allowBlankSummary =
$request->getBool(
'wpIgnoreBlankSummary' )
999 || !$user->getOption(
'forceeditsummary' );
1002 $this->autoSumm =
$request->getText(
'wpAutoSummary' );
1004 $this->allowBlankArticle =
$request->getBool(
'wpIgnoreBlankArticle' );
1005 $this->allowSelfRedirect =
$request->getBool(
'wpIgnoreSelfRedirect' );
1009 $this->changeTags = [];
1011 $this->changeTags = array_filter( array_map(
'trim', explode(
',',
1015 # Not a posted form? Start with nothing.
1016 wfDebug( __METHOD__ .
": Not a posted form.\n" );
1017 $this->textbox1 =
'';
1018 $this->summary =
'';
1019 $this->sectiontitle =
'';
1020 $this->edittime =
'';
1021 $this->editRevId =
null;
1023 $this->
edit =
false;
1024 $this->preview =
false;
1025 $this->
save =
false;
1026 $this->
diff =
false;
1027 $this->minoredit =
false;
1029 $this->watchthis =
$request->getBool(
'watchthis',
false );
1030 $this->recreate =
false;
1034 if ( $this->section ==
'new' &&
$request->getVal(
'preloadtitle' ) ) {
1035 $this->sectiontitle =
$request->getVal(
'preloadtitle' );
1037 $this->summary =
$request->getVal(
'preloadtitle' );
1038 } elseif ( $this->section !=
'new' &&
$request->getVal(
'summary' ) ) {
1039 $this->summary =
$request->getText(
'summary' );
1040 if ( $this->summary !==
'' ) {
1041 $this->hasPresetSummary =
true;
1045 if (
$request->getVal(
'minor' ) ) {
1046 $this->minoredit =
true;
1050 $this->oldid =
$request->getInt(
'oldid' );
1051 $this->parentRevId =
$request->getInt(
'parentRevId' );
1053 $this->bot =
$request->getBool(
'bot',
true );
1054 $this->nosummary =
$request->getBool(
'nosummary' );
1057 $this->contentModel =
$request->getText(
'model', $this->contentModel );
1059 $this->contentFormat =
$request->getText(
'format', $this->contentFormat );
1062 $handler = ContentHandler::getForModelID( $this->contentModel );
1065 'editpage-invalidcontentmodel-title',
1066 'editpage-invalidcontentmodel-text',
1071 if ( !
$handler->isSupportedFormat( $this->contentFormat ) ) {
1073 'editpage-notsupportedcontentformat-title',
1074 'editpage-notsupportedcontentformat-text',
1077 wfEscapeWikiText( ContentHandler::getLocalizedName( $this->contentModel ) )
1088 $this->editintro =
$request->getText(
'editintro',
1090 $this->section ===
'new' ?
'MediaWiki:addsection-editintro' :
'' );
1093 Hooks::run(
'EditPage::importFormData', [ $this,
$request ] );
1115 $this->edittime = $this->page->getTimestamp();
1116 $this->editRevId = $this->page->getLatest();
1118 $content = $this->
getContentObject(
false ); # TODO: track content
object?!
1119 if ( $content ===
false ) {
1122 $this->textbox1 = $this->
toEditText( $content );
1124 $user = $this->context->getUser();
1126 # Sort out the "watch" checkbox
1127 if ( $user->getOption(
'watchdefault' ) ) {
1129 $this->watchthis =
true;
1130 } elseif ( $user->getOption(
'watchcreations' ) && !$this->mTitle->exists() ) {
1132 $this->watchthis =
true;
1133 } elseif ( $user->isWatched( $this->mTitle ) ) {
1135 $this->watchthis =
true;
1137 if ( $user->getOption(
'minordefault' ) && !$this->isNew ) {
1138 $this->minoredit =
true;
1140 if ( $this->textbox1 ===
false ) {
1158 $user = $this->context->getUser();
1159 $request = $this->context->getRequest();
1162 if ( !$this->mTitle->exists() || $this->section ==
'new' ) {
1163 if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI && $this->section !=
'new' ) {
1164 # If this is a system message, get the default text.
1165 $msg = $this->mTitle->getDefaultMessageText();
1169 if ( $content ===
false ) {
1170 # If requested, preload some text.
1171 $preload =
$request->getVal(
'preload',
1173 $this->section ===
'new' ?
'MediaWiki:addsection-preload' :
'' );
1180 if ( $this->section !=
'' ) {
1183 $content = $orig ? $orig->getSection( $this->section ) :
null;
1186 $content = $def_content;
1189 $undoafter =
$request->getInt(
'undoafter' );
1190 $undo =
$request->getInt(
'undo' );
1192 if ( $undo > 0 && $undoafter > 0 ) {
1193 $undorev = Revision::newFromId( $undo );
1194 $oldrev = Revision::newFromId( $undoafter );
1196 # Sanity check, make sure it's the right page,
1197 # the revisions exist and they were not deleted.
1198 # Otherwise, $content will be left as-is.
1199 if ( !is_null( $undorev ) && !is_null( $oldrev ) &&
1200 !$undorev->isDeleted( Revision::DELETED_TEXT ) &&
1201 !$oldrev->isDeleted( Revision::DELETED_TEXT )
1203 $content = $this->page->getUndoContent( $undorev, $oldrev );
1205 if ( $content ===
false ) {
1206 # Warn the user that something went wrong
1207 $undoMsg =
'failure';
1209 $oldContent = $this->page->getContent( Revision::RAW );
1210 $popts = ParserOptions::newFromUserAndLang( $user,
$wgContLang );
1211 $newContent = $content->preSaveTransform( $this->mTitle, $user, $popts );
1212 if ( $newContent->getModel() !== $oldContent->getModel() ) {
1217 $this->contentModel = $newContent->getModel();
1218 $this->contentFormat = $oldrev->getContentFormat();
1221 if ( $newContent->equals( $oldContent ) ) {
1222 # Tell the user that the undo results in no change,
1223 # i.e. the revisions were already undone.
1224 $undoMsg =
'nochange';
1227 # Inform the user of our success and set an automatic edit summary
1228 $undoMsg =
'success';
1230 # If we just undid one rev, use an autosummary
1231 $firstrev = $oldrev->getNext();
1232 if ( $firstrev && $firstrev->getId() == $undo ) {
1233 $userText = $undorev->getUserText();
1234 if ( $userText ===
'' ) {
1235 $undoSummary = $this->context->msg(
1236 'undo-summary-username-hidden',
1238 )->inContentLanguage()->text();
1240 $undoSummary = $this->context->msg(
1244 )->inContentLanguage()->text();
1246 if ( $this->summary ===
'' ) {
1247 $this->summary = $undoSummary;
1249 $this->summary = $undoSummary . $this->context->msg(
'colon-separator' )
1252 $this->undidRev = $undo;
1254 $this->formtype =
'diff';
1264 $out = $this->context->getOutput();
1266 $class = ( $undoMsg ==
'success' ?
'' :
'error ' ) .
"mw-undo-{$undoMsg}";
1267 $this->editFormPageTop .=
$out->parse(
"<div class=\"{$class}\">" .
1268 $this->context->msg(
'undo-' . $undoMsg )->plain() .
'</div>',
true,
true );
1271 if ( $content ===
false ) {
1296 if ( $this->section ==
'new' ) {
1299 $revision = $this->mArticle->getRevisionFetched();
1300 if ( $revision ===
null ) {
1301 $handler = ContentHandler::getForModelID( $this->contentModel );
1302 return $handler->makeEmptyContent();
1304 $content = $revision->getContent( Revision::FOR_THIS_USER, $user );
1321 if ( $this->parentRevId ) {
1324 return $this->mArticle->getRevIdFetched();
1337 $rev = $this->page->getRevision();
1338 $content =
$rev ?
$rev->getContent( Revision::RAW ) :
null;
1340 if ( $content ===
false || $content ===
null ) {
1341 $handler = ContentHandler::getForModelID( $this->contentModel );
1342 return $handler->makeEmptyContent();
1343 } elseif ( !$this->undidRev ) {
1348 $logger = LoggerFactory::getInstance(
'editpage' );
1349 if ( $this->contentModel !==
$rev->getContentModel() ) {
1350 $logger->warning(
"Overriding content model from current edit {prev} to {new}", [
1351 'prev' => $this->contentModel,
1352 'new' =>
$rev->getContentModel(),
1353 'title' => $this->getTitle()->getPrefixedDBkey(),
1354 'method' => __METHOD__
1356 $this->contentModel =
$rev->getContentModel();
1361 if ( !$content->isSupportedFormat( $this->contentFormat ) ) {
1362 $logger->warning(
"Current revision content format unsupported. Overriding {prev} to {new}", [
1364 'prev' => $this->contentFormat,
1365 'new' =>
$rev->getContentFormat(),
1366 'title' => $this->getTitle()->getPrefixedDBkey(),
1367 'method' => __METHOD__
1369 $this->contentFormat =
$rev->getContentFormat();
1383 $this->mPreloadContent = $content;
1398 if ( !empty( $this->mPreloadContent ) ) {
1402 $handler = ContentHandler::getForModelID( $this->contentModel );
1404 if ( $preload ===
'' ) {
1405 return $handler->makeEmptyContent();
1408 $user = $this->context->getUser();
1409 $title = Title::newFromText( $preload );
1410 # Check for existence to avoid getting MediaWiki:Noarticletext
1411 if ( $title ===
null || !$title->exists() || !$title->userCan(
'read', $user ) ) {
1413 return $handler->makeEmptyContent();
1416 $page = WikiPage::factory( $title );
1420 if ( $title ===
null || !$title->exists() || !$title->userCan(
'read', $user ) ) {
1422 return $handler->makeEmptyContent();
1424 $page = WikiPage::factory( $title );
1427 $parserOptions = ParserOptions::newFromUser( $user );
1432 return $handler->makeEmptyContent();
1435 if ( $content->getModel() !==
$handler->getModelID() ) {
1436 $converted = $content->convert(
$handler->getModelID() );
1438 if ( !$converted ) {
1440 wfDebug(
"Attempt to preload incompatible content: " .
1441 "can't convert " . $content->getModel() .
1444 return $handler->makeEmptyContent();
1447 $content = $converted;
1450 return $content->preloadTransform( $title, $parserOptions,
$params );
1461 $token =
$request->getVal(
'wpEditToken' );
1462 $user = $this->context->getUser();
1463 $this->mTokenOk = $user->matchEditToken( $token );
1464 $this->mTokenOkExceptSuffix = $user->matchEditTokenNoSuffix( $token );
1483 $revisionId = $this->page->getLatest();
1484 $postEditKey = self::POST_EDIT_COOKIE_KEY_PREFIX . $revisionId;
1487 if ( $statusValue == self::AS_SUCCESS_NEW_ARTICLE ) {
1489 } elseif ( $this->oldid ) {
1493 $response = $this->context->getRequest()->response();
1494 $response->setCookie( $postEditKey, $val, time() + self::POST_EDIT_COOKIE_DURATION );
1504 # Allow bots to exempt some edits from bot flagging
1505 $bot = $this->context->getUser()->isAllowed(
'bot' ) &&
$this->bot;
1508 Hooks::run(
'EditPage::attemptSave:after', [ $this,
$status, $resultDetails ] );
1517 if ( $this->context->getRequest()->getText(
'mode' ) !==
'conflict' ) {
1538 if (
$status->value == self::AS_SUCCESS_UPDATE
1539 ||
$status->value == self::AS_SUCCESS_NEW_ARTICLE
1543 $this->didSave =
true;
1544 if ( !$resultDetails[
'nullEdit'] ) {
1549 $out = $this->context->getOutput();
1553 $request = $this->context->getRequest();
1554 $extraQueryRedirect =
$request->getVal(
'wpExtraQueryRedirect' );
1575 $out->addWikiText(
'<div class="error">' .
"\n" .
$status->getWikiText() .
'</div>' );
1579 $query = $resultDetails[
'redirect'] ?
'redirect=no' :
'';
1580 if ( $extraQueryRedirect ) {
1582 $query = $extraQueryRedirect;
1587 $anchor = isset( $resultDetails[
'sectionanchor'] ) ? $resultDetails[
'sectionanchor'] :
'';
1588 $out->redirect( $this->mTitle->getFullURL(
$query ) . $anchor );
1593 $sectionanchor = $resultDetails[
'sectionanchor'];
1597 'ArticleUpdateBeforeRedirect',
1598 [ $this->mArticle, &$sectionanchor, &$extraQuery ]
1601 if ( $resultDetails[
'redirect'] ) {
1602 if ( $extraQuery ==
'' ) {
1603 $extraQuery =
'redirect=no';
1605 $extraQuery =
'redirect=no&' . $extraQuery;
1608 if ( $extraQueryRedirect ) {
1609 if ( $extraQuery ===
'' ) {
1610 $extraQuery = $extraQueryRedirect;
1612 $extraQuery = $extraQuery .
'&' . $extraQueryRedirect;
1616 $out->redirect( $this->mTitle->getFullURL( $extraQuery ) . $sectionanchor );
1641 $permission = $this->mTitle->isTalkPage() ?
'createtalk' :
'createpage';
1652 $this->hookError =
'<div class="error">' .
"\n" .
$status->getWikiText() .
1669 if ( $this->hookError !=
'' ) {
1670 # ...or the hook could be expecting us to produce an error
1671 $status->fatal(
'hookaborted' );
1677 if ( !Hooks::run(
'EditFilterMergedContent',
1678 [ $this->context, $content,
$status, $this->summary,
1679 $user, $this->minoredit ] )
1681 # Error messages etc. could be handled within the hook...
1683 $status->fatal(
'hookaborted' );
1696 } elseif ( !
$status->isOK() ) {
1697 # ...or the hook could be expecting us to produce an error
1700 $status->fatal(
'hookaborted' );
1715 $errmsg =
$status->getWikiText(
1718 $this->context->getLanguage()
1721<
div class=
"errorbox">
1737 if ( $this->sectiontitle !==
'' ) {
1742 if ( $this->summary ===
'' ) {
1743 $cleanSectionTitle =
$wgParser->stripSectionName( $this->sectiontitle );
1744 return $this->context->msg(
'newsectionsummary' )
1745 ->rawParams( $cleanSectionTitle )->inContentLanguage()->text();
1747 } elseif ( $this->summary !==
'' ) {
1749 # This is a new section, so create a link to the new section
1750 # in the revision summary.
1751 $cleanSummary =
$wgParser->stripSectionName( $this->summary );
1752 return $this->context->msg(
'newsectionsummary' )
1753 ->rawParams( $cleanSummary )->inContentLanguage()->text();
1784 $user = $this->context->getUser();
1786 if ( !Hooks::run(
'EditPage::attemptSave', [ $this ] ) ) {
1787 wfDebug(
"Hook 'EditPage::attemptSave' aborted article saving\n" );
1788 $status->fatal(
'hookaborted' );
1793 if ( $this->unicodeCheck !== self::UNICODE_CHECK ) {
1794 $status->fatal(
'unicode-support-fail' );
1799 $request = $this->context->getRequest();
1800 $spam =
$request->getText(
'wpAntispam' );
1801 if ( $spam !==
'' ) {
1806 $this->mTitle->getPrefixedText() .
1807 '" submitted bogus field "' .
1811 $status->fatal(
'spamprotectionmatch',
false );
1817 # Construct Content object
1821 'content-failed-to-parse',
1822 $this->contentModel,
1823 $this->contentFormat,
1830 # Check image redirect
1831 if ( $this->mTitle->getNamespace() ==
NS_FILE &&
1832 $textbox_content->isRedirect() &&
1833 !$user->isAllowed(
'upload' )
1843 if ( $match ===
false && $this->section ==
'new' ) {
1844 # $wgSpamRegex is enforced on this new heading/summary because, unlike
1845 # regular summaries, it is added to the actual wikitext.
1846 if ( $this->sectiontitle !==
'' ) {
1847 # This branch is taken when the API is used with the 'sectiontitle' parameter.
1850 # This branch is taken when the "Add Topic" user interface is used, or the API
1851 # is used with the 'summary' parameter.
1855 if ( $match ===
false ) {
1858 if ( $match !==
false ) {
1859 $result[
'spam'] = $match;
1861 $pdbk = $this->mTitle->getPrefixedDBkey();
1862 $match = str_replace(
"\n",
'', $match );
1863 wfDebugLog(
'SpamRegex',
"$ip spam regex hit [[$pdbk]]: \"$match\"" );
1864 $status->fatal(
'spamprotectionmatch', $match );
1870 [ $this, $this->textbox1, $this->section, &$this->hookError, $this->summary ] )
1872 # Error messages etc. could be handled within the hook...
1873 $status->fatal(
'hookaborted' );
1876 } elseif ( $this->hookError !=
'' ) {
1877 # ...or the hook could be expecting us to produce an error
1878 $status->fatal(
'hookaborted' );
1883 if ( $user->isBlockedFrom( $this->mTitle,
false ) ) {
1886 $user->spreadAnyEditBlock();
1888 # Check block state against master, thus 'false'.
1889 $status->setResult(
false, self::AS_BLOCKED_PAGE_FOR_USER );
1893 $this->contentLength = strlen( $this->textbox1 );
1894 $config = $this->context->getConfig();
1895 $maxArticleSize = $config->get(
'MaxArticleSize' );
1896 if ( $this->contentLength > $maxArticleSize * 1024 ) {
1898 $this->tooBig =
true;
1899 $status->setResult(
false, self::AS_CONTENT_TOO_BIG );
1903 if ( !$user->isAllowed(
'edit' ) ) {
1904 if ( $user->isAnon() ) {
1905 $status->setResult(
false, self::AS_READ_ONLY_PAGE_ANON );
1908 $status->fatal(
'readonlytext' );
1914 $changingContentModel =
false;
1915 if ( $this->contentModel !== $this->mTitle->getContentModel() ) {
1916 if ( !$config->get(
'ContentHandlerUseDB' ) ) {
1917 $status->fatal(
'editpage-cannot-use-custom-model' );
1920 } elseif ( !$user->isAllowed(
'editcontentmodel' ) ) {
1921 $status->setResult(
false, self::AS_NO_CHANGE_CONTENT_MODEL );
1927 if ( !$titleWithNewContentModel->userCan(
'editcontentmodel', $user )
1928 || !$titleWithNewContentModel->userCan(
'edit', $user )
1930 $status->setResult(
false, self::AS_NO_CHANGE_CONTENT_MODEL );
1934 $changingContentModel =
true;
1935 $oldContentModel = $this->mTitle->getContentModel();
1938 if ( $this->changeTags ) {
1940 $this->changeTags, $user );
1941 if ( !$changeTagsStatus->isOK() ) {
1943 return $changeTagsStatus;
1948 $status->fatal(
'readonlytext' );
1952 if ( $user->pingLimiter() || $user->pingLimiter(
'linkpurge', 0 )
1953 || ( $changingContentModel && $user->pingLimiter(
'editcontentmodel' ) )
1955 $status->fatal(
'actionthrottledtext' );
1960 # If the article has been deleted while editing, don't save it without
1963 $status->setResult(
false, self::AS_ARTICLE_WAS_DELETED );
1967 # Load the page data from the master. If anything changes in the meantime,
1968 # we detect it by using page_latest like a token in a 1 try compare-and-swap.
1969 $this->page->loadPageData(
'fromdbmaster' );
1970 $new = !$this->page->exists();
1974 if ( !$this->mTitle->userCan(
'create', $user ) ) {
1975 $status->fatal(
'nocreatetext' );
1977 wfDebug( __METHOD__ .
": no create permission\n" );
1984 $defaultMessageText = $this->mTitle->getDefaultMessageText();
1985 if ( $this->mTitle->getNamespace() === NS_MEDIAWIKI && $defaultMessageText !==
false ) {
1986 $defaultText = $defaultMessageText;
1991 if ( !$this->allowBlankArticle && $this->textbox1 === $defaultText ) {
1992 $this->blankArticle =
true;
1993 $status->fatal(
'blankarticle' );
1994 $status->setResult(
false, self::AS_BLANK_ARTICLE );
2002 $content = $textbox_content;
2004 $result[
'sectionanchor'] =
'';
2005 if ( $this->section ==
'new' ) {
2006 if ( $this->sectiontitle !==
'' ) {
2008 $content = $content->addSectionHeader( $this->sectiontitle );
2009 } elseif ( $this->summary !==
'' ) {
2011 $content = $content->addSectionHeader( $this->summary );
2020 # Article exists. Check for edit conflict.
2022 $this->page->clear(); # Force reload of dates, etc.
2023 $timestamp = $this->page->getTimestamp();
2024 $latest = $this->page->getLatest();
2026 wfDebug(
"timestamp: {$timestamp}, edittime: {$this->edittime}\n" );
2029 if ( $timestamp != $this->edittime
2030 || ( $this->editRevId !==
null && $this->editRevId != $latest )
2032 $this->isConflict =
true;
2033 if ( $this->section ==
'new' ) {
2034 if ( $this->page->getUserText() == $user->getName() &&
2035 $this->page->getComment() == $this->newSectionSummary()
2041 .
": duplicate new section submission; trigger edit conflict!\n" );
2044 $this->isConflict =
false;
2045 wfDebug( __METHOD__ .
": conflict suppressed; new section\n" );
2047 } elseif ( $this->section ==
''
2048 && Revision::userWasLastToEdit(
2049 DB_MASTER, $this->mTitle->getArticleID(),
2050 $user->getId(), $this->edittime
2053 # Suppress edit conflict with self, except for section edits where merging is required.
2054 wfDebug( __METHOD__ .
": Suppressing edit conflict, same user.\n" );
2055 $this->isConflict =
false;
2060 if ( $this->sectiontitle !==
'' ) {
2068 if ( $this->isConflict ) {
2070 .
": conflict! getting section '{$this->section}' for time '{$this->edittime}'"
2071 .
" (id '{$this->editRevId}') (article time '{$timestamp}')\n" );
2074 if ( $this->editRevId !==
null ) {
2075 $content = $this->page->replaceSectionAtRev(
2082 $content = $this->page->replaceSectionContent(
2090 wfDebug( __METHOD__ .
": getting section '{$this->section}'\n" );
2091 $content = $this->page->replaceSectionContent(
2098 if ( is_null( $content ) ) {
2099 wfDebug( __METHOD__ .
": activating conflict; section replace failed.\n" );
2100 $this->isConflict =
true;
2101 $content = $textbox_content;
2102 } elseif ( $this->isConflict ) {
2106 $this->isConflict =
false;
2107 wfDebug( __METHOD__ .
": Suppressing edit conflict, successful merge.\n" );
2109 $this->section =
'';
2110 $this->textbox1 = ContentHandler::getContentText( $content );
2111 wfDebug( __METHOD__ .
": Keeping edit conflict, failed merge.\n" );
2115 if ( $this->isConflict ) {
2116 $status->setResult(
false, self::AS_CONFLICT_DETECTED );
2124 if ( $this->section ==
'new' ) {
2126 if ( !$this->allowBlankSummary && trim( $this->summary ) ==
'' ) {
2127 $this->missingSummary =
true;
2128 $status->fatal(
'missingsummary' );
2134 if ( $this->textbox1 ==
'' ) {
2135 $this->missingComment =
true;
2136 $status->fatal(
'missingcommenttext' );
2140 } elseif ( !$this->allowBlankSummary
2141 && !$content->equals( $this->getOriginalContent( $user ) )
2142 && !$content->isRedirect()
2143 && md5( $this->summary ) == $this->autoSumm
2145 $this->missingSummary =
true;
2146 $status->fatal(
'missingsummary' );
2152 $sectionanchor =
'';
2153 if ( $this->section ==
'new' ) {
2155 } elseif ( $this->section !=
'' ) {
2156 # Try to get a section anchor from the section source, redirect
2157 # to edited section if header found.
2158 # XXX: Might be better to integrate this into Article::replaceSectionAtRev
2159 # for duplicate heading checking and maybe parsing.
2160 $hasmatch = preg_match(
"/^ *([=]{1,6})(.*?)(\\1) *\\n/i", $this->textbox1,
$matches );
2161 # We can't deal with anchors, includes, html etc in the header for now,
2162 # headline would need to be parsed to improve this.
2163 if ( $hasmatch && strlen(
$matches[2] ) > 0 ) {
2167 $result[
'sectionanchor'] = $sectionanchor;
2173 $this->textbox1 = $this->
toEditText( $content );
2174 $this->section =
'';
2179 if ( !$this->allowSelfRedirect
2180 && $content->isRedirect()
2181 && $content->getRedirectTarget()->equals( $this->getTitle() )
2185 if ( !$currentTarget || !$currentTarget->equals( $this->getTitle() ) ) {
2186 $this->selfRedirect =
true;
2187 $status->fatal(
'selfredirect' );
2194 $this->contentLength = strlen( $this->
toEditText( $content ) );
2195 if ( $this->contentLength > $maxArticleSize * 1024 ) {
2196 $this->tooBig =
true;
2197 $status->setResult(
false, self::AS_MAX_ARTICLE_SIZE_EXCEEDED );
2203 ( ( $this->minoredit && !$this->isNew ) ?
EDIT_MINOR : 0 ) |
2206 $doEditStatus = $this->page->doEditContent(
2212 $content->getDefaultFormat(),
2217 if ( !$doEditStatus->isOK() ) {
2221 $errors = $doEditStatus->getErrorsArray();
2222 if ( in_array( $errors[0][0],
2223 [
'edit-gone-missing',
'edit-conflict',
'edit-already-exists' ] )
2225 $this->isConflict =
true;
2229 return $doEditStatus;
2232 $result[
'nullEdit'] = $doEditStatus->hasMessage(
'edit-no-change' );
2233 if ( $result[
'nullEdit'] ) {
2235 $user->pingLimiter(
'linkpurge' );
2237 $result[
'redirect'] = $content->isRedirect();
2242 if ( $changingContentModel ) {
2245 $new ?
false : $oldContentModel,
2261 $new = $oldModel ===
false;
2262 $log =
new ManualLogEntry(
'contentmodel', $new ?
'new' :
'change' );
2264 $log->setTarget( $this->mTitle );
2265 $log->setComment( $reason );
2266 $log->setParameters( [
2267 '4::oldmodel' => $oldModel,
2268 '5::newmodel' => $newModel
2270 $logid = $log->insert();
2271 $log->publish( $logid );
2278 $user = $this->context->getUser();
2279 if ( !$user->isLoggedIn() ) {
2286 DeferredUpdates::addCallableUpdate(
function () use ( $user, $title, $watch ) {
2310 $baseContent = $baseRevision ? $baseRevision->getContent() :
null;
2312 if ( is_null( $baseContent ) ) {
2317 $currentRevision = Revision::loadFromTitle( $db, $this->mTitle );
2318 $currentContent = $currentRevision ? $currentRevision->getContent() :
null;
2320 if ( is_null( $currentContent ) ) {
2324 $handler = ContentHandler::getForModelID( $baseContent->getModel() );
2326 $result =
$handler->merge3( $baseContent, $editContent, $currentContent );
2331 $this->parentRevId = $currentRevision->getId();
2344 if ( !$this->mBaseRevision ) {
2346 $this->mBaseRevision = $this->editRevId
2347 ? Revision::newFromId( $this->editRevId, Revision::READ_LATEST )
2348 : Revision::loadFromTimestamp( $db, $this->mTitle, $this->edittime );
2386 foreach ( $regexes as $regex ) {
2388 if ( preg_match( $regex, $text,
$matches ) ) {
2396 $out = $this->context->getOutput();
2398 $out->addModules(
'mediawiki.action.edit' );
2399 $out->addModuleStyles(
'mediawiki.action.edit.styles' );
2400 $out->addModuleStyles(
'mediawiki.editfont.styles' );
2402 $user = $this->context->getUser();
2403 if ( $user->getOption(
'showtoolbar' ) ) {
2408 $out->addModules(
'mediawiki.toolbar' );
2411 if ( $user->getOption(
'uselivepreview' ) ) {
2412 $out->addModules(
'mediawiki.action.edit.preview' );
2415 if ( $user->getOption(
'useeditwarning' ) ) {
2416 $out->addModules(
'mediawiki.action.edit.editWarning' );
2419 # Enabled article-related sidebar, toplinks, etc.
2420 $out->setArticleRelated(
true );
2423 if ( $this->isConflict ) {
2424 $msg =
'editconflict';
2425 } elseif ( $contextTitle->exists() && $this->section !=
'' ) {
2426 $msg = $this->section ==
'new' ?
'editingcomment' :
'editingsection';
2428 $msg = $contextTitle->exists()
2429 || ( $contextTitle->getNamespace() == NS_MEDIAWIKI
2430 && $contextTitle->getDefaultMessageText() !==
false
2436 # Use the title defined by DISPLAYTITLE magic word when present
2437 # NOTE: getDisplayTitle() returns HTML while getPrefixedText() returns plain text.
2438 # setPageTitle() treats the input as wikitext, which should be safe in either case.
2439 $displayTitle = isset( $this->mParserOutput ) ? $this->mParserOutput->getDisplayTitle() :
false;
2440 if ( $displayTitle ===
false ) {
2441 $displayTitle = $contextTitle->getPrefixedText();
2443 $out->setPageTitle( $this->context->msg( $msg, $displayTitle ) );
2445 $config = $this->context->getConfig();
2447 # Transmit the name of the message to JavaScript for live preview
2448 # Keep Resources.php/mediawiki.action.edit.preview in sync with the possible keys
2449 $out->addJsConfigVars( [
2450 'wgEditMessage' => $msg,
2451 'wgAjaxEditStash' => $config->get(
'AjaxEditStash' ),
2456 $out->addJsConfigVars(
2457 'wgEditSubmitButtonLabelPublish',
2458 $config->get(
'EditSubmitButtonLabelPublish' )
2466 if ( $this->suppressIntro ) {
2470 $out = $this->context->getOutput();
2471 $namespace = $this->mTitle->getNamespace();
2473 if ( $namespace == NS_MEDIAWIKI ) {
2474 # Show a warning if editing an interface message
2475 $out->wrapWikiMsg(
"<div class='mw-editinginterface'>\n$1\n</div>",
'editinginterface' );
2476 # If this is a default message (but not css, json, or js),
2477 # show a hint that it is translatable on translatewiki.net
2483 $defaultMessageText = $this->mTitle->getDefaultMessageText();
2484 if ( $defaultMessageText !==
false ) {
2485 $out->wrapWikiMsg(
"<div class='mw-translateinterface'>\n$1\n</div>",
2486 'translateinterface' );
2489 } elseif ( $namespace ==
NS_FILE ) {
2490 # Show a hint to shared repo
2492 if ( $file && !$file->isLocal() ) {
2493 $descUrl = $file->getDescriptionUrl();
2494 # there must be a description url to show a hint to shared repo
2496 if ( !$this->mTitle->exists() ) {
2497 $out->wrapWikiMsg(
"<div class=\"mw-sharedupload-desc-create\">\n$1\n</div>", [
2498 'sharedupload-desc-create', $file->getRepo()->getDisplayName(), $descUrl
2501 $out->wrapWikiMsg(
"<div class=\"mw-sharedupload-desc-edit\">\n$1\n</div>", [
2502 'sharedupload-desc-edit', $file->getRepo()->getDisplayName(), $descUrl
2509 # Show a warning message when someone creates/edits a user (talk) page but the user does not exist
2510 # Show log extract when the user is currently blocked
2511 if ( $namespace == NS_USER || $namespace ==
NS_USER_TALK ) {
2512 $username = explode(
'/', $this->mTitle->getText(), 2 )[0];
2517 $userExists = ( $user && $user->isLoggedIn() );
2518 if ( $userExists && $user->isHidden() && !$this->context->getUser()->isAllowed(
'hideuser' ) ) {
2521 $userExists =
false;
2524 if ( !$userExists && !$ip ) { #
User does not exist
2525 $out->wrapWikiMsg(
"<div class=\"mw-userpage-userdoesnotexist error\">\n$1\n</div>",
2528 # Show log extract if the user is currently blocked
2532 MWNamespace::getCanonicalName( NS_USER ) .
':' . $block->getTarget(),
2536 'showIfEmpty' =>
false,
2538 'blocked-notice-logextract',
2539 $user->getName() # Support GENDER in notice
2545 # Try to add a custom edit intro, or use the standard one if this is not possible.
2547 $helpLink =
wfExpandUrl( Skin::makeInternalOrExternalUrl(
2548 $this->context->msg(
'helppage' )->inContentLanguage()->text()
2550 if ( $this->context->getUser()->isLoggedIn() ) {
2553 "<div class=\"mw-newarticletext plainlinks\">\n$1\n</div>",
2562 "<div class=\"mw-newarticletextanon plainlinks\">\n$1\n</div>",
2564 'newarticletextanon',
2570 # Give a notice if the user is editing a deleted/moved page...
2571 if ( !$this->mTitle->exists() ) {
2578 'conds' => [
'log_action != ' .
$dbr->addQuotes(
'revision' ) ],
2579 'showIfEmpty' =>
false,
2580 'msgKey' => [
'recreate-moveddeleted-warn' ]
2592 if ( $this->editintro ) {
2593 $title = Title::newFromText( $this->editintro );
2594 if ( $title instanceof
Title && $title->
exists() && $title->userCan(
'read' ) ) {
2596 $this->context->getOutput()->addWikiTextTitleTidy(
2597 '<div class="mw-editintro">{{:' . $title->getFullText() .
'}}</div>',
2625 if ( $content ===
null || $content ===
false || is_string( $content ) ) {
2630 throw new MWException(
'This content model is not supported: ' . $content->getModel() );
2633 return $content->serialize( $this->contentFormat );
2653 if ( $text ===
false || $text ===
null ) {
2657 $content = ContentHandler::makeContent( $text, $this->
getTitle(),
2658 $this->contentModel, $this->contentFormat );
2661 throw new MWException(
'This content model is not supported: ' . $content->getModel() );
2676 # need to parse the preview early so that we know which templates are used,
2677 # otherwise users with "show preview after edit box" will get a blank list
2678 # we parse this near the beginning so that setHeaders can do the title
2679 # setting work instead of leaving it in getPreviewText
2680 $previewOutput =
'';
2681 if ( $this->formtype ==
'preview' ) {
2685 $out = $this->context->getOutput();
2689 Hooks::run(
'EditPage::showEditForm:initial', [ &$editPage, &
$out ] );
2696 if ( !$this->isConflict &&
2697 $this->section !=
'' &&
2702 $out->showErrorPage(
'sectioneditnotsupported-title',
'sectioneditnotsupported-text' );
2708 $out->addHTML( $this->editFormPageTop );
2710 $user = $this->context->getUser();
2711 if ( $user->getOption(
'previewontop' ) ) {
2715 $out->addHTML( $this->editFormTextTop );
2717 $showToolbar =
true;
2719 if ( $this->formtype ==
'save' ) {
2722 $showToolbar =
false;
2724 $out->wrapWikiMsg(
"<div class='error mw-deleted-while-editing'>\n$1\n</div>",
2725 'deletedwhileediting' );
2731 $out->addHTML( Html::openElement(
2734 'class' =>
'mw-editform',
2735 'id' => self::EDITFORM_ID,
2736 'name' => self::EDITFORM_ID,
2739 'enctype' =>
'multipart/form-data'
2743 if ( is_callable( $formCallback ) ) {
2744 wfWarn(
'The $formCallback parameter to ' . __METHOD__ .
'is deprecated' );
2745 call_user_func_array( $formCallback, [ &
$out ] );
2749 $out->addHTML( Html::hidden(
'wpUnicodeCheck', self::UNICODE_CHECK ) );
2753 Xml::openElement(
'div', [
'id' =>
'antispam-container',
'style' =>
'display: none;' ] )
2756 [
'for' =>
'wpAntispam' ],
2757 $this->context->msg(
'simpleantispam-label' )->parse()
2763 'name' =>
'wpAntispam',
2764 'id' =>
'wpAntispam',
2768 . Xml::closeElement(
'div' )
2773 Hooks::run(
'EditPage::showEditForm:fields', [ &$editPage, &
$out ] );
2779 $username = $this->lastDelete->user_name;
2780 $comment = CommentStore::getStore()
2781 ->getComment(
'log_comment', $this->lastDelete )->text;
2785 $key = $comment ===
''
2786 ?
'confirmrecreate-noreason'
2787 :
'confirmrecreate';
2789 '<div class="mw-confirm-recreate">' .
2790 $this->context->msg( $key,
$username,
"<nowiki>$comment</nowiki>" )->parse() .
2791 Xml::checkLabel( $this->context->msg(
'recreate' )->text(),
'wpRecreate',
'wpRecreate',
false,
2798 # When the summary is hidden, also hide them on preview/show changes
2799 if ( $this->nosummary ) {
2800 $out->addHTML( Html::hidden(
'nosummary',
true ) );
2803 # If a blank edit summary was previously provided, and the appropriate
2804 # user preference is active, pass a hidden tag as wpIgnoreBlankSummary. This will stop the
2805 # user being bounced back more than once in the event that a summary
2808 # For a bit more sophisticated detection of blank summaries, hash the
2809 # automatic one and pass that in the hidden field wpAutoSummary.
2810 if ( $this->missingSummary || ( $this->section ==
'new' && $this->nosummary ) ) {
2811 $out->addHTML( Html::hidden(
'wpIgnoreBlankSummary',
true ) );
2814 if ( $this->undidRev ) {
2815 $out->addHTML( Html::hidden(
'wpUndidRevision', $this->undidRev ) );
2818 if ( $this->selfRedirect ) {
2819 $out->addHTML( Html::hidden(
'wpIgnoreSelfRedirect',
true ) );
2822 if ( $this->hasPresetSummary ) {
2826 $this->autoSumm = md5(
'' );
2829 $autosumm = $this->autoSumm ? $this->autoSumm : md5( $this->summary );
2830 $out->addHTML( Html::hidden(
'wpAutoSummary', $autosumm ) );
2832 $out->addHTML( Html::hidden(
'oldid', $this->oldid ) );
2835 $out->addHTML( Html::hidden(
'format', $this->contentFormat ) );
2836 $out->addHTML( Html::hidden(
'model', $this->contentModel ) );
2840 if ( $this->section ==
'new' ) {
2845 $out->addHTML( $this->editFormTextBeforeContent );
2846 if ( $this->isConflict ) {
2852 $this->textbox1 = $this->
toEditText( $content );
2861 if ( !$this->mTitle->isUserConfigPage() && $showToolbar && $user->getOption(
'showtoolbar' ) ) {
2862 $out->addHTML( self::getEditToolbar( $this->mTitle ) );
2865 if ( $this->blankArticle ) {
2866 $out->addHTML( Html::hidden(
'wpIgnoreBlankArticle',
true ) );
2869 if ( $this->isConflict ) {
2874 $conflictTextBoxAttribs = [];
2876 $conflictTextBoxAttribs[
'style'] =
'display:none;';
2877 } elseif ( $this->isOldRev ) {
2878 $conflictTextBoxAttribs[
'class'] =
'mw-textarea-oldrev';
2887 $out->addHTML( $this->editFormTextAfterContent );
2897 $out->addHTML( $this->editFormTextAfterTools .
"\n" );
2901 $out->addHTML( Html::rawElement(
'div', [
'class' =>
'hiddencats' ],
2904 $out->addHTML( Html::rawElement(
'div', [
'class' =>
'limitreport' ],
2905 self::getPreviewLimitReport( $this->mParserOutput ) ) );
2907 $out->addModules(
'mediawiki.action.edit.collapsibleFooter' );
2909 if ( $this->isConflict ) {
2914 $msg = $this->context->msg(
2915 'content-failed-to-parse',
2916 $this->contentModel,
2917 $this->contentFormat,
2920 $out->addWikiText(
'<div class="error">' . $msg->text() .
'</div>' );
2925 if ( $this->isConflict ) {
2927 } elseif ( $this->preview ) {
2929 } elseif ( $this->
diff ) {
2934 $out->addHTML( Html::hidden(
'mode', $mode, [
'id' =>
'mw-edit-mode' ] ) );
2938 $out->addHTML( Html::hidden(
'wpUltimateParam',
true ) );
2939 $out->addHTML( $this->editFormTextBottom .
"\n</form>\n" );
2941 if ( !$user->getOption(
'previewontop' ) ) {
2955 $this->context, MediaWikiServices::getInstance()->getLinkRenderer()
2960 if ( $this->preview ) {
2962 } elseif ( $this->section !=
'' ) {
2966 return Html::rawElement(
'div', [
'class' =>
'templatesUsed' ],
2967 $templateListFormatter->format( $templates,
$type )
2978 preg_match(
"/^(=+)(.+)\\1\\s*(\n|$)/i", $text,
$matches );
2988 $out = $this->context->getOutput();
2989 $user = $this->context->getUser();
2990 if ( $this->isConflict ) {
2992 $this->editRevId = $this->page->getLatest();
2994 if ( $this->section !=
'' && $this->section !=
'new' ) {
2995 if ( !$this->summary && !$this->preview && !$this->
diff ) {
2997 if ( $sectionTitle !==
false ) {
2998 $this->summary =
"/* $sectionTitle */ ";
3005 if ( $this->missingComment ) {
3006 $out->wrapWikiMsg(
"<div id='mw-missingcommenttext'>\n$1\n</div>",
'missingcommenttext' );
3009 if ( $this->missingSummary && $this->section !=
'new' ) {
3011 "<div id='mw-missingsummary'>\n$1\n</div>",
3012 [
'missingsummary', $buttonLabel ]
3016 if ( $this->missingSummary && $this->section ==
'new' ) {
3018 "<div id='mw-missingcommentheader'>\n$1\n</div>",
3019 [
'missingcommentheader', $buttonLabel ]
3023 if ( $this->blankArticle ) {
3025 "<div id='mw-blankarticle'>\n$1\n</div>",
3026 [
'blankarticle', $buttonLabel ]
3030 if ( $this->selfRedirect ) {
3032 "<div id='mw-selfredirect'>\n$1\n</div>",
3033 [
'selfredirect', $buttonLabel ]
3037 if ( $this->hookError !==
'' ) {
3038 $out->addWikiText( $this->hookError );
3041 if ( $this->section !=
'new' ) {
3042 $revision = $this->mArticle->getRevisionFetched();
3046 if ( !$revision->userCan( Revision::DELETED_TEXT, $user ) ) {
3048 "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
3049 'rev-deleted-text-permission'
3051 } elseif ( $revision->isDeleted( Revision::DELETED_TEXT ) ) {
3053 "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
3054 'rev-deleted-text-view'
3058 if ( !$revision->isCurrent() ) {
3059 $this->mArticle->setOldSubtitle( $revision->getId() );
3060 $out->addWikiMsg(
'editingold' );
3061 $this->isOldRev =
true;
3063 } elseif ( $this->mTitle->exists() ) {
3066 $out->wrapWikiMsg(
"<div class='errorbox'>\n$1\n</div>\n",
3067 [
'missing-revision', $this->oldid ] );
3074 "<div id=\"mw-read-only-warning\">\n$1\n</div>",
3077 } elseif ( $user->isAnon() ) {
3078 if ( $this->formtype !=
'preview' ) {
3080 "<div id='mw-anon-edit-warning' class='warningbox'>\n$1\n</div>",
3081 [
'anoneditwarning',
3083 SpecialPage::getTitleFor(
'Userlogin' )->getFullURL( [
3084 'returnto' => $this->
getTitle()->getPrefixedDBkey()
3087 SpecialPage::getTitleFor(
'CreateAccount' )->getFullURL( [
3088 'returnto' => $this->
getTitle()->getPrefixedDBkey()
3093 $out->wrapWikiMsg(
"<div id=\"mw-anon-preview-warning\" class=\"warningbox\">\n$1</div>",
3094 'anonpreviewwarning'
3098 if ( $this->mTitle->isUserConfigPage() ) {
3099 # Check the skin exists
3102 "<div class='error' id='mw-userinvalidconfigtitle'>\n$1\n</div>",
3103 [
'userinvalidconfigtitle', $this->mTitle->getSkinFromConfigSubpage() ]
3106 if ( $this->
getTitle()->isSubpageOf( $user->getUserPage() ) ) {
3107 $isUserCssConfig = $this->mTitle->isUserCssConfigPage();
3108 $isUserJsonConfig = $this->mTitle->isUserJsonConfigPage();
3109 $isUserJsConfig = $this->mTitle->isUserJsConfigPage();
3111 $warning = $isUserCssConfig
3113 : ( $isUserJsonConfig ?
'userjsonispublic' :
'userjsispublic' );
3115 $out->wrapWikiMsg(
'<div class="mw-userconfigpublic">$1</div>', $warning );
3117 if ( $this->formtype !==
'preview' ) {
3118 $config = $this->context->getConfig();
3119 if ( $isUserCssConfig && $config->get(
'AllowUserCss' ) ) {
3121 "<div id='mw-usercssyoucanpreview'>\n$1\n</div>",
3122 [
'usercssyoucanpreview' ]
3124 } elseif ( $isUserJsonConfig ) {
3126 "<div id='mw-userjsonyoucanpreview'>\n$1\n</div>",
3127 [
'userjsonyoucanpreview' ]
3129 } elseif ( $isUserJsConfig && $config->get(
'AllowUserJs' ) ) {
3131 "<div id='mw-userjsyoucanpreview'>\n$1\n</div>",
3132 [
'userjsyoucanpreview' ]
3144 # Add header copyright warning
3156 $conf = $this->context->getConfig();
3157 $oldCommentSchema = $conf->get(
'CommentTableSchemaMigrationStage' ) ===
MIGRATION_OLD;
3161 return ( is_array( $inputAttrs ) ? $inputAttrs : [] ) + [
3162 'id' =>
'wpSummary',
3163 'name' =>
'wpSummary',
3164 'maxlength' => $oldCommentSchema ? 200 : CommentStore::COMMENT_CHARACTER_LIMIT,
3167 'spellcheck' =>
'true',
3181 $inputAttrs = OOUI\Element::configFromHtmlAttributes(
3190 $inputAttrs[
'inputId'] = $inputAttrs[
'id'];
3191 $inputAttrs[
'id'] =
'wpSummaryWidget';
3193 return new OOUI\FieldLayout(
3194 new OOUI\TextInputWidget( [
3196 'infusable' =>
true,
3199 'label' =>
new OOUI\HtmlSnippet( $labelText ),
3201 'id' =>
'wpSummaryLabel',
3202 'classes' => [ $this->missingSummary ?
'mw-summarymissed' :
'mw-summary' ],
3214 # Add a class if 'missingsummary' is triggered to allow styling of the summary line
3215 $summaryClass = $this->missingSummary ?
'mw-summarymissed' :
'mw-summary';
3216 if ( $isSubjectPreview ) {
3217 if ( $this->nosummary ) {
3221 if ( !$this->mShowSummaryField ) {
3226 $labelText = $this->context->msg( $isSubjectPreview ?
'subject' :
'summary' )->parse();
3230 [
'class' => $summaryClass ]
3244 if ( !
$summary || ( !$this->preview && !$this->
diff ) ) {
3250 if ( $isSubjectPreview ) {
3251 $summary = $this->context->msg(
'newsectionsummary' )
3253 ->inContentLanguage()->text();
3256 $message = $isSubjectPreview ?
'subject-preview' :
'summary-preview';
3258 $summary = $this->context->msg( $message )->parse()
3260 return Xml::tags(
'div', [
'class' =>
'mw-summary-preview' ],
$summary );
3264 $out = $this->context->getOutput();
3265 $out->addHTML( Html::hidden(
'wpSection', $this->section ) );
3266 $out->addHTML( Html::hidden(
'wpStarttime', $this->starttime ) );
3267 $out->addHTML( Html::hidden(
'wpEdittime', $this->edittime ) );
3268 $out->addHTML( Html::hidden(
'editRevId', $this->editRevId ) );
3269 $out->addHTML( Html::hidden(
'wpScrolltop', $this->scrolltop, [
'id' =>
'wpScrolltop' ] ) );
3285 $this->context->getOutput()->addHTML(
3287 Html::hidden(
"wpEditToken", $this->context->getUser()->getEditToken() ) .
3314 $attribs = [
'style' =>
'display:none;' ];
3317 $classes = $builder->getTextboxProtectionCSSClasses( $this->
getTitle() );
3319 # Is an old revision being edited?
3320 if ( $this->isOldRev ) {
3321 $classes[] =
'mw-textarea-oldrev';
3341 $this->
showTextbox( $this->textbox2,
'wpTextbox2', [
'tabindex' => 6,
'readonly' ] );
3346 $attribs = $builder->buildTextboxAttribs(
3349 $this->context->getUser(),
3353 $this->context->getOutput()->addHTML(
3354 Html::textarea( $name, $builder->addNewLineAtEnd( $text ),
$attribs )
3361 $classes[] =
'ontop';
3364 $attribs = [
'id' =>
'wikiPreview',
'class' => implode(
' ', $classes ) ];
3366 if ( $this->formtype !=
'preview' ) {
3367 $attribs[
'style'] =
'display: none;';
3370 $out = $this->context->getOutput();
3373 if ( $this->formtype ==
'preview' ) {
3377 $pageViewLang = $this->mTitle->getPageViewLanguage();
3378 $attribs = [
'lang' => $pageViewLang->getHtmlCode(),
'dir' => $pageViewLang->getDir(),
3379 'class' =>
'mw-content-' . $pageViewLang->getDir() ];
3383 $out->addHTML(
'</div>' );
3385 if ( $this->formtype ==
'diff' ) {
3389 $msg = $this->context->msg(
3390 'content-failed-to-parse',
3391 $this->contentModel,
3392 $this->contentFormat,
3395 $out->addWikiText(
'<div class="error">' . $msg->text() .
'</div>' );
3408 $this->mArticle->openShowCategory();
3410 # This hook seems slightly odd here, but makes things more
3411 # consistent for extensions.
3412 $out = $this->context->getOutput();
3413 Hooks::run(
'OutputPageBeforeHTML', [ &
$out, &$text ] );
3414 $out->addHTML( $text );
3416 $this->mArticle->closeShowCategory();
3430 $oldtitlemsg =
'currentrev';
3431 # if message does not exist, show diff against the preloaded default
3432 if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI && !$this->mTitle->exists() ) {
3433 $oldtext = $this->mTitle->getDefaultMessageText();
3434 if ( $oldtext !==
false ) {
3435 $oldtitlemsg =
'defaultmessagetext';
3445 if ( $this->editRevId !==
null ) {
3446 $newContent = $this->page->replaceSectionAtRev(
3447 $this->section, $textboxContent, $this->summary, $this->editRevId
3450 $newContent = $this->page->replaceSectionContent(
3451 $this->section, $textboxContent, $this->summary, $this->edittime
3455 if ( $newContent ) {
3456 Hooks::run(
'EditPageGetDiffContent', [ $this, &$newContent ] );
3458 $user = $this->context->getUser();
3459 $popts = ParserOptions::newFromUserAndLang( $user,
$wgContLang );
3460 $newContent = $newContent->preSaveTransform( $this->mTitle, $user, $popts );
3463 if ( ( $oldContent && !$oldContent->isEmpty() ) || ( $newContent && !$newContent->isEmpty() ) ) {
3464 $oldtitle = $this->context->msg( $oldtitlemsg )->parse();
3465 $newtitle = $this->context->msg(
'yourtext' )->parse();
3467 if ( !$oldContent ) {
3468 $oldContent = $newContent->getContentHandler()->makeEmptyContent();
3471 if ( !$newContent ) {
3472 $newContent = $oldContent->getContentHandler()->makeEmptyContent();
3475 $de = $oldContent->getContentHandler()->createDifferenceEngine( $this->context );
3476 $de->setContent( $oldContent, $newContent );
3478 $difftext = $de->getDiff( $oldtitle, $newtitle );
3479 $de->showDiffStyle();
3484 $this->context->getOutput()->addHTML(
'<div id="wikiDiff">' . $difftext .
'</div>' );
3491 $msg =
'editpage-head-copy-warn';
3492 if ( !$this->context->msg( $msg )->isDisabled() ) {
3493 $this->context->getOutput()->wrapWikiMsg(
"<div class='editpage-head-copywarn'>\n$1\n</div>",
3494 'editpage-head-copy-warn' );
3507 $msg =
'editpage-tos-summary';
3508 Hooks::run(
'EditPageTosSummary', [ $this->mTitle, &$msg ] );
3509 if ( !$this->context->msg( $msg )->isDisabled() ) {
3510 $out = $this->context->getOutput();
3511 $out->addHTML(
'<div class="mw-tos-summary">' );
3512 $out->addWikiMsg( $msg );
3513 $out->addHTML(
'</div>' );
3522 $this->context->getOutput()->addHTML(
'<div class="mw-editTools">' .
3523 $this->context->msg(
'edittools' )->inContentLanguage()->parse() .
3548 $copywarnMsg = [
'copyrightwarning',
3549 '[[' .
wfMessage(
'copyrightpage' )->inContentLanguage()->text() .
']]',
3552 $copywarnMsg = [
'copyrightwarning2',
3553 '[[' .
wfMessage(
'copyrightpage' )->inContentLanguage()->text() .
']]' ];
3556 Hooks::run(
'EditPageCopyrightWarning', [ $title, &$copywarnMsg ] );
3558 $msg = call_user_func_array(
'wfMessage', $copywarnMsg )->title( $title );
3560 $msg->inLanguage( $langcode );
3562 return "<div id=\"editpage-copywarn\">\n" .
3563 $msg->$format() .
"\n</div>";
3580 $limitReport = Html::rawElement(
'div', [
'class' =>
'mw-limitReportExplanation' ],
3581 wfMessage(
'limitreport-title' )->parseAsBlock()
3585 $limitReport .= Html::openElement(
'div', [
'class' =>
'preview-limit-report-wrapper' ] );
3587 $limitReport .= Html::openElement(
'table', [
3588 'class' =>
'preview-limit-report wikitable'
3590 Html::openElement(
'tbody' );
3592 foreach (
$output->getLimitReportData() as $key =>
$value ) {
3593 if ( Hooks::run(
'ParserLimitReportFormat',
3594 [ $key, &
$value, &$limitReport,
true,
true ]
3597 $valueMsg =
wfMessage( [
"$key-value-html",
"$key-value" ] );
3598 if ( !$valueMsg->exists() ) {
3601 if ( !$keyMsg->isDisabled() && !$valueMsg->isDisabled() ) {
3602 $limitReport .= Html::openElement(
'tr' ) .
3603 Html::rawElement(
'th',
null, $keyMsg->parse() ) .
3604 Html::rawElement(
'td',
null,
3607 Html::closeElement(
'tr' );
3612 $limitReport .= Html::closeElement(
'tbody' ) .
3613 Html::closeElement(
'table' ) .
3614 Html::closeElement(
'div' );
3616 return $limitReport;
3620 $out = $this->context->getOutput();
3621 $out->addHTML(
"<div class='editOptions'>\n" );
3623 if ( $this->section !=
'new' ) {
3630 [
'minor' => $this->minoredit,
'watch' => $this->watchthis ]
3632 $checkboxesHTML =
new OOUI\HorizontalLayout( [
'items' => $checkboxes ] );
3634 $out->addHTML(
"<div class='editCheckboxes'>" . $checkboxesHTML .
"</div>\n" );
3638 $out->addHTML( $this->editFormTextAfterWarn );
3640 $out->addHTML(
"<div class='editButtons'>\n" );
3645 $message = $this->context->msg(
'edithelppage' )->inContentLanguage()->text();
3646 $edithelpurl = Skin::makeInternalOrExternalUrl( $message );
3649 $this->context->msg(
'edithelp' )->text(),
3650 [
'target' =>
'helpwindow',
'href' => $edithelpurl ],
3653 $this->context->msg(
'word-separator' )->escaped() .
3654 $this->context->msg(
'newwindow' )->parse();
3656 $out->addHTML(
" <span class='cancelLink'>{$cancel}</span>\n" );
3657 $out->addHTML(
" <span class='editHelp'>{$edithelp}</span>\n" );
3658 $out->addHTML(
"</div><!-- editButtons -->\n" );
3660 Hooks::run(
'EditPage::showStandardInputs:options', [ $this,
$out, &
$tabindex ] );
3662 $out->addHTML(
"</div><!-- editOptions -->\n" );
3670 $out = $this->context->getOutput();
3673 if ( Hooks::run(
'EditPageBeforeConflictDiff', [ &$editPage, &
$out ] ) ) {
3689 if ( !$this->isConflict && $this->oldid > 0 ) {
3692 $cancelParams[
'redirect'] =
'no';
3695 return new OOUI\ButtonWidget( [
3696 'id' =>
'mw-editform-cancel',
3698 'label' =>
new OOUI\HtmlSnippet( $this->context->msg(
'cancel' )->parse() ),
3700 'infusable' =>
true,
3701 'flags' =>
'destructive',
3715 return $title->getLocalURL( [
'action' => $this->action ] );
3726 if ( $this->deletedSinceEdit !==
null ) {
3730 $this->deletedSinceEdit =
false;
3732 if ( !$this->mTitle->exists() && $this->mTitle->isDeletedQuick() ) {
3734 if ( $this->lastDelete ) {
3735 $deleteTime =
wfTimestamp( TS_MW, $this->lastDelete->log_timestamp );
3736 if ( $deleteTime > $this->starttime ) {
3737 $this->deletedSinceEdit =
true;
3750 $commentQuery = CommentStore::getStore()->getJoin(
'log_comment' );
3751 $actorQuery = ActorMigration::newMigration()->getJoin(
'log_user' );
3752 $data =
$dbr->selectRow(
3753 array_merge( [
'logging' ], $commentQuery[
'tables'], $actorQuery[
'tables'], [
'user' ] ),
3763 ] + $commentQuery[
'fields'] + $actorQuery[
'fields'],
3765 'log_namespace' => $this->mTitle->getNamespace(),
3766 'log_title' => $this->mTitle->getDBkey(),
3767 'log_type' =>
'delete',
3768 'log_action' =>
'delete',
3771 [
'LIMIT' => 1,
'ORDER BY' =>
'log_timestamp DESC' ],
3773 'user' => [
'JOIN',
'user_id=' . $actorQuery[
'fields'][
'log_user'] ],
3774 ] + $commentQuery[
'joins'] + $actorQuery[
'joins']
3777 if ( is_object( $data ) ) {
3779 $data->user_name = $this->context->msg(
'rev-deleted-user' )->escaped();
3783 $data->log_comment_text = $this->context->msg(
'rev-deleted-comment' )->escaped();
3784 $data->log_comment_data =
null;
3797 $out = $this->context->getOutput();
3798 $config = $this->context->getConfig();
3800 if ( $config->get(
'RawHtml' ) && !$this->mTokenOk ) {
3804 if ( $this->textbox1 !==
'' ) {
3808 $parsedNote =
$out->parse(
"<div class='previewnote'>" .
3809 $this->context->msg(
'session_fail_preview_html' )->text() .
"</div>",
3823 'AlternateEditPreview',
3824 [ $this, &$content, &$previewHTML, &$this->mParserOutput ] )
3826 return $previewHTML;
3829 # provide a anchor link to the editform
3830 $continueEditing =
'<span class="mw-continue-editing">' .
3831 '[[#' . self::EDITFORM_ID .
'|' .
3832 $this->context->getLanguage()->getArrow() .
' ' .
3833 $this->context->msg(
'continue-editing' )->text() .
']]</span>';
3834 if ( $this->mTriedSave && !$this->mTokenOk ) {
3835 if ( $this->mTokenOkExceptSuffix ) {
3836 $note = $this->context->msg(
'token_suffix_mismatch' )->plain();
3839 $note = $this->context->msg(
'session_fail_preview' )->plain();
3842 } elseif ( $this->incompleteForm ) {
3843 $note = $this->context->msg(
'edit_form_incomplete' )->plain();
3844 if ( $this->mTriedSave ) {
3848 $note = $this->context->msg(
'previewnote' )->plain() .
' ' . $continueEditing;
3851 # don't parse non-wikitext pages, show message about preview
3852 if ( $this->mTitle->isUserConfigPage() || $this->mTitle->isSiteConfigPage() ) {
3853 if ( $this->mTitle->isUserConfigPage() ) {
3855 } elseif ( $this->mTitle->isSiteConfigPage() ) {
3863 if ( $level ===
'user' && !$config->get(
'AllowUserCss' ) ) {
3868 if ( $level ===
'user' ) {
3873 if ( $level ===
'user' && !$config->get(
'AllowUserJs' ) ) {
3880 # Used messages to make sure grep find them:
3881 # Messages: usercsspreview, userjsonpreview, userjspreview,
3882 # sitecsspreview, sitejsonpreview, sitejspreview
3883 if ( $level && $format ) {
3884 $note =
"<div id='mw-{$level}{$format}preview'>" .
3885 $this->context->msg(
"{$level}{$format}preview" )->text() .
3886 ' ' . $continueEditing .
"</div>";
3890 # If we're adding a comment, we need to show the
3891 # summary as the headline
3892 if ( $this->section ===
"new" && $this->summary !==
"" ) {
3893 $content = $content->addSectionHeader( $this->summary );
3896 $hook_args = [ $this, &$content ];
3897 Hooks::run(
'EditPageGetPreviewContent', $hook_args );
3900 $parserOutput = $parserResult[
'parserOutput'];
3901 $previewHTML = $parserResult[
'html'];
3902 $this->mParserOutput = $parserOutput;
3903 $out->addParserOutputMetadata( $parserOutput );
3905 if ( count( $parserOutput->getWarnings() ) ) {
3906 $note .=
"\n\n" . implode(
"\n\n", $parserOutput->getWarnings() );
3910 $m = $this->context->msg(
3911 'content-failed-to-parse',
3912 $this->contentModel,
3913 $this->contentFormat,
3916 $note .=
"\n\n" . $m->parse();
3920 if ( $this->isConflict ) {
3921 $conflict =
'<h2 id="mw-previewconflict">'
3922 . $this->context->msg(
'previewconflict' )->escaped() .
"</h2>\n";
3924 $conflict =
'<hr />';
3927 $previewhead =
"<div class='previewnote'>\n" .
3928 '<h2 id="mw-previewheader">' . $this->context->msg(
'preview' )->escaped() .
"</h2>" .
3929 $out->parse( $note,
true,
true ) . $conflict .
"</div>\n";
3931 $pageViewLang = $this->mTitle->getPageViewLanguage();
3932 $attribs = [
'lang' => $pageViewLang->getHtmlCode(),
'dir' => $pageViewLang->getDir(),
3933 'class' =>
'mw-content-' . $pageViewLang->getDir() ];
3934 $previewHTML = Html::rawElement(
'div',
$attribs, $previewHTML );
3940 $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
3941 $stats->increment(
'edit.failures.' . $failureType );
3949 $parserOptions = $this->page->makeParserOptions( $this->context );
3950 $parserOptions->setIsPreview(
true );
3951 $parserOptions->setIsSectionPreview( !is_null( $this->section ) && $this->section !==
'' );
3952 $parserOptions->enableLimitReport();
3953 return $parserOptions;
3966 $user = $this->context->getUser();
3968 $pstContent = $content->
preSaveTransform( $this->mTitle, $user, $parserOptions );
3969 $scopedCallback = $parserOptions->setupFakeRevision(
3970 $this->mTitle, $pstContent, $user );
3971 $parserOutput = $pstContent->getParserOutput( $this->mTitle,
null, $parserOptions );
3972 ScopedCallback::consume( $scopedCallback );
3974 'parserOutput' => $parserOutput,
3975 'html' => $parserOutput->getText( [
3976 'enableSectionEditLinks' =>
false
3985 if ( $this->preview || $this->section !=
'' ) {
3987 if ( !isset( $this->mParserOutput ) ) {
3990 foreach ( $this->mParserOutput->getTemplates() as $ns =>
$template ) {
3991 foreach ( array_keys(
$template ) as $dbk ) {
3992 $templates[] = Title::makeTitle( $ns, $dbk );
3997 return $this->mTitle->getTemplateLinksFrom();
4013 $showSignature =
true;
4015 $showSignature = MWNamespace::wantSignatures( $title->getNamespace() );
4029 'id' =>
'mw-editbutton-bold',
4031 'close' =>
'\'\
'\'',
4032 'sample' =>
wfMessage(
'bold_sample' )->text(),
4033 'tip' =>
wfMessage(
'bold_tip' )->text(),
4036 'id' =>
'mw-editbutton-italic',
4039 'sample' =>
wfMessage(
'italic_sample' )->text(),
4040 'tip' =>
wfMessage(
'italic_tip' )->text(),
4043 'id' =>
'mw-editbutton-link',
4046 'sample' =>
wfMessage(
'link_sample' )->text(),
4047 'tip' =>
wfMessage(
'link_tip' )->text(),
4050 'id' =>
'mw-editbutton-extlink',
4053 'sample' =>
wfMessage(
'extlink_sample' )->text(),
4054 'tip' =>
wfMessage(
'extlink_tip' )->text(),
4057 'id' =>
'mw-editbutton-headline',
4060 'sample' =>
wfMessage(
'headline_sample' )->text(),
4061 'tip' =>
wfMessage(
'headline_tip' )->text(),
4063 $imagesAvailable ? [
4064 'id' =>
'mw-editbutton-image',
4067 'sample' =>
wfMessage(
'image_sample' )->text(),
4068 'tip' =>
wfMessage(
'image_tip' )->text(),
4070 $imagesAvailable ? [
4071 'id' =>
'mw-editbutton-media',
4074 'sample' =>
wfMessage(
'media_sample' )->text(),
4075 'tip' =>
wfMessage(
'media_tip' )->text(),
4078 'id' =>
'mw-editbutton-nowiki',
4079 'open' =>
"<nowiki>",
4080 'close' =>
"</nowiki>",
4081 'sample' =>
wfMessage(
'nowiki_sample' )->text(),
4082 'tip' =>
wfMessage(
'nowiki_tip' )->text(),
4085 'id' =>
'mw-editbutton-signature',
4086 'open' =>
wfMessage(
'sig-text',
'~~~~' )->inContentLanguage()->text(),
4089 'tip' =>
wfMessage(
'sig_tip' )->text(),
4092 'id' =>
'mw-editbutton-hr',
4093 'open' =>
"\n----\n",
4100 $script =
'mw.loader.using("mediawiki.toolbar", function () {';
4101 foreach ( $toolarray as $tool ) {
4120 $script .= Xml::encodeJsCall(
4121 'mw.toolbar.addButton',
4129 $toolbar =
'<div id="toolbar"></div>';
4131 if ( Hooks::run(
'EditPageBeforeEditToolbar', [ &$toolbar ] ) ) {
4161 $user = $this->context->getUser();
4163 if ( !$this->isNew && $user->isAllowed(
'minoredit' ) ) {
4164 $checkboxes[
'wpMinoredit'] = [
4165 'id' =>
'wpMinoredit',
4166 'label-message' =>
'minoredit',
4168 'tooltip' =>
'minoredit',
4169 'label-id' =>
'mw-editpage-minoredit',
4170 'legacy-name' =>
'minor',
4171 'default' => $checked[
'minor'],
4175 if ( $user->isLoggedIn() ) {
4176 $checkboxes[
'wpWatchthis'] = [
4177 'id' =>
'wpWatchthis',
4178 'label-message' =>
'watchthis',
4180 'tooltip' =>
'watch',
4181 'label-id' =>
'mw-editpage-watch',
4182 'legacy-name' =>
'watch',
4183 'default' => $checked[
'watch'],
4188 Hooks::run(
'EditPageGetCheckboxesDefinition', [ $editPage, &$checkboxes ] );
4207 foreach ( $checkboxesDef as $name =>
$options ) {
4212 if ( isset(
$options[
'tooltip'] ) ) {
4213 $accesskey = $this->context->msg(
"accesskey-{$options['tooltip']}" )->text();
4216 if ( isset(
$options[
'title-message'] ) ) {
4217 $title = $this->context->msg(
$options[
'title-message'] )->text();
4220 $checkboxes[ $legacyName ] =
new OOUI\FieldLayout(
4221 new OOUI\CheckboxInputWidget( [
4223 'accessKey' => $accesskey,
4228 'infusable' =>
true,
4231 'align' =>
'inline',
4232 'label' =>
new OOUI\HtmlSnippet( $this->context->msg(
$options[
'label-message'] )->parse() ),
4242 $legacyCheckboxes = [];
4243 if ( !$this->isNew ) {
4244 $legacyCheckboxes[
'minor'] =
'';
4246 $legacyCheckboxes[
'watch'] =
'';
4248 foreach ( $checkboxes as $name => $oouiLayout ) {
4253 Hooks::run(
'EditPageBeforeEditChecks', [ &$ep, &$legacyCheckboxes, &
$tabindex ],
'1.29' );
4255 foreach ( $legacyCheckboxes as $name =>
$html ) {
4256 if (
$html && !isset( $checkboxes[$name] ) ) {
4257 $checkboxes[
$name] =
new OOUI\Widget( [
'content' =>
new OOUI\HtmlSnippet(
$html ) ] );
4272 $this->context->getConfig()->get(
'EditSubmitButtonLabelPublish' );
4275 $newPage = !$this->mTitle->exists();
4277 if ( $labelAsPublish ) {
4278 $buttonLabelKey = $newPage ?
'publishpage' :
'publishchanges';
4280 $buttonLabelKey = $newPage ?
'savearticle' :
'savechanges';
4283 return $buttonLabelKey;
4298 $this->context->getConfig()->get(
'EditSubmitButtonLabelPublish' );
4301 $buttonTooltip = $labelAsPublish ?
'publish' :
'save';
4303 $buttons[
'save'] =
new OOUI\ButtonInputWidget( [
4306 'id' =>
'wpSaveWidget',
4307 'inputId' =>
'wpSave',
4309 'useInputTag' =>
true,
4310 'flags' => [
'progressive',
'primary' ],
4311 'label' => $buttonLabel,
4312 'infusable' =>
true,
4320 $buttons[
'preview'] =
new OOUI\ButtonInputWidget( [
4321 'name' =>
'wpPreview',
4323 'id' =>
'wpPreviewWidget',
4324 'inputId' =>
'wpPreview',
4326 'useInputTag' =>
true,
4327 'label' => $this->context->msg(
'showpreview' )->text(),
4328 'infusable' =>
true,
4336 $buttons[
'diff'] =
new OOUI\ButtonInputWidget( [
4339 'id' =>
'wpDiffWidget',
4340 'inputId' =>
'wpDiff',
4342 'useInputTag' =>
true,
4343 'label' => $this->context->msg(
'showdiff' )->text(),
4344 'infusable' =>
true,
4354 Hooks::run(
'EditPageBeforeEditButtons', [ &$editPage, &$buttons, &
$tabindex ] );
4364 $out = $this->context->getOutput();
4365 $out->prepareErrorPage( $this->context->msg(
'nosuchsectiontitle' ) );
4367 $res = $this->context->msg(
'nosuchsectiontext', $this->section )->parseAsBlock();
4371 Hooks::run(
'EditPageNoSuchSection', [ &$editPage, &
$res ] );
4374 $out->returnToMain(
false, $this->mTitle );
4385 if ( is_array( $match ) ) {
4386 $match = $this->context->getLanguage()->listToText( $match );
4388 $out = $this->context->getOutput();
4389 $out->prepareErrorPage( $this->context->msg(
'spamprotectiontitle' ) );
4391 $out->addHTML(
'<div id="spamprotected">' );
4392 $out->addWikiMsg(
'spamprotectiontext' );
4396 $out->addHTML(
'</div>' );
4398 $out->wrapWikiMsg(
'<h2>$1</h2>',
"yourdiff" );
4401 $out->wrapWikiMsg(
'<h2>$1</h2>',
"yourtext" );
4418 return rtrim(
$request->getText( $field ) );
4438 $out = $this->context->getOutput();
4439 $editNotices = $this->mTitle->getEditNotices( $this->oldid );
4440 if ( count( $editNotices ) ) {
4441 $out->addHTML( implode(
"\n", $editNotices ) );
4443 $msg = $this->context->msg(
'editnotice-notext' );
4444 if ( !$msg->isDisabled() ) {
4446 '<div class="mw-editnotice-notext">'
4447 . $msg->parseAsBlock()
4458 if ( $this->mTitle->isTalkPage() ) {
4459 $this->context->getOutput()->addWikiMsg(
'talkpagetext' );
4467 if ( $this->contentLength ===
false ) {
4468 $this->contentLength = strlen( $this->textbox1 );
4471 $out = $this->context->getOutput();
4472 $lang = $this->context->getLanguage();
4473 $maxArticleSize = $this->context->getConfig()->get(
'MaxArticleSize' );
4474 if ( $this->tooBig || $this->contentLength > $maxArticleSize * 1024 ) {
4475 $out->wrapWikiMsg(
"<div class='error' id='mw-edit-longpageerror'>\n$1\n</div>",
4478 $lang->formatNum( round( $this->contentLength / 1024, 3 ) ),
4479 $lang->formatNum( $maxArticleSize )
4483 if ( !$this->context->msg(
'longpage-hint' )->isDisabled() ) {
4484 $out->wrapWikiMsg(
"<div id='mw-edit-longpage-hint'>\n$1\n</div>",
4487 $lang->formatSize( strlen( $this->textbox1 ) ),
4488 strlen( $this->textbox1 )
4499 $out = $this->context->getOutput();
4500 if ( $this->mTitle->isProtected(
'edit' ) &&
4501 MWNamespace::getRestrictionLevels( $this->mTitle->getNamespace() ) !== [
'' ]
4503 # Is the title semi-protected?
4504 if ( $this->mTitle->isSemiProtected() ) {
4505 $noticeMsg =
'semiprotectedpagewarning';
4507 # Then it must be protected based on static groups (regular)
4508 $noticeMsg =
'protectedpagewarning';
4511 [
'lim' => 1,
'msgKey' => [ $noticeMsg ] ] );
4513 if ( $this->mTitle->isCascadeProtected() ) {
4514 # Is this page under cascading protection from some source pages?
4516 list( $cascadeSources, ) = $this->mTitle->getCascadeProtectionSources();
4517 $notice =
"<div class='mw-cascadeprotectedwarning'>\n$1\n";
4518 $cascadeSourcesCount = count( $cascadeSources );
4519 if ( $cascadeSourcesCount > 0 ) {
4520 # Explain, and list the titles responsible
4521 foreach ( $cascadeSources as
$page ) {
4522 $notice .=
'* [[:' .
$page->getPrefixedText() .
"]]\n";
4525 $notice .=
'</div>';
4526 $out->wrapWikiMsg( $notice, [
'cascadeprotectedwarning', $cascadeSourcesCount ] );
4528 if ( !$this->mTitle->exists() && $this->mTitle->getRestrictions(
'create' ) ) {
4531 'showIfEmpty' =>
false,
4532 'msgKey' => [
'titleprotectedwarning' ],
4533 'wrap' =>
"<div class=\"mw-titleprotectedwarning\">\n$1</div>" ] );
4583 $userAgent = $this->context->getRequest()->getHeader(
'User-Agent' );
4584 if ( $userAgent && preg_match(
'/MSIE|Edge/', $userAgent ) ) {
4586 return $wgParser->guessLegacySectionNameFromWikiText( $text );
4589 $name =
$wgParser->guessSectionNameFromWikiText( $text );
4592 return '#' . urlencode( mb_substr( $name, 1 ) );
4602 $this->editConflictHelperFactory = $factory;
4603 $this->editConflictHelper =
null;
4610 if ( !$this->editConflictHelper ) {
4611 $this->editConflictHelper = call_user_func(
4612 $this->editConflictHelperFactory,
4628 MediaWikiServices::getInstance()->getStatsdDataFactory(),
$wgSummarySpamRegex
Same as the above except for edit summaries.
$wgRightsText
If either $wgRightsUrl or $wgRightsPage is specified then this variable gives the text for the link.
$wgSpamRegex
Edits matching these regular expressions in body text will be recognised as spam and rejected automat...
$wgEnableUploads
Uploads have to be specially set up to be secure.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfReadOnly()
Check whether the wiki is in read-only mode.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
wfFindFile( $title, $options=[])
Find a file.
wfArrayDiff2( $a, $b)
Like array_diff( $a, $b ) except that it works with two-dimensional arrays.
wfReadOnlyReason()
Check if the site is in read-only mode and return the message if so.
wfGetAllCallers( $limit=3)
Return a string consisting of callers in the stack.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
if(! $wgRequest->checkUrlExtension()) if(isset($_SERVER[ 'PATH_INFO']) &&$_SERVER[ 'PATH_INFO'] !='') if(! $wgEnableAPI) $wgTitle
Class for viewing MediaWiki article and history.
static newFromTarget( $specificTarget, $vagueTarget=null, $fromMaster=false)
Given a target and the target's type, get an existing Block object if possible.
Special handling for category description pages, showing pages, subcategories and file that belong to...
The edit page/HTML interface (split from Article) The actual database and text munging is still in Ar...
getPreviewParserOptions()
Get parser options for a preview.
getActionURL(Title $title)
Returns the URL to use in the form's action attribute.
isOouiEnabled()
Check if the edit page is using OOUI controls.
safeUnicodeInput( $request, $field)
Filter an input field through a Unicode de-armoring process if it came from an old browser with known...
bool stdClass $lastDelete
showTextbox( $text, $name, $customAttribs=[])
attemptSave(&$resultDetails=false)
Attempt submission.
isSectionEditSupported()
Returns whether section editing is supported for the current page.
getCheckboxesWidget(&$tabindex, $checked)
Returns an array of checkboxes for the edit form, including 'minor' and 'watch' checkboxes and any ot...
updateWatchlist()
Register the change of watch status.
const AS_SELF_REDIRECT
Status: user tried to create self-redirect (redirect to the same article) and wpIgnoreSelfRedirect ==...
getOriginalContent(User $user)
Get the content of the wanted revision, without section extraction.
static getPreviewLimitReport( $output)
Get the Limit report for page previews.
null string $contentFormat
showCustomIntro()
Attempt to show a custom editing introduction, if supplied.
displayPermissionsError(array $permErrors)
Display a permissions error page, like OutputPage::showPermissionsErrorPage(), but with the following...
const AS_CANNOT_USE_CUSTOM_MODEL
Status: when changing the content model is disallowed due to $wgContentHandlerUseDB being false.
runPostMergeFilters(Content $content, Status $status, User $user)
Run hooks that can filter edits just before they get saved.
showPreview( $text)
Append preview output to OutputPage.
const AS_UNICODE_NOT_SUPPORTED
Status: edit rejected because browser doesn't support Unicode.
const AS_HOOK_ERROR_EXPECTED
Status: A hook function returned an error.
const AS_READ_ONLY_PAGE_ANON
Status: this anonymous user is not allowed to edit this page.
safeUnicodeOutput( $text)
Filter an output field through a Unicode armoring process if it is going to an old browser with known...
getCheckboxesDefinition( $checked)
Return an array of checkbox definitions.
showEditTools()
Inserts optional text shown below edit and upload forms.
isSupportedContentModel( $modelId)
Returns if the given content model is editable.
$editFormTextAfterContent
$editFormTextBeforeContent
__construct(Article $article)
getEditPermissionErrors( $rigor='secure')
showStandardInputs(&$tabindex=2)
toEditContent( $text)
Turns the given text into a Content object by unserializing it.
const POST_EDIT_COOKIE_KEY_PREFIX
Prefix of key for cookie used to pass post-edit state.
const AS_MAX_ARTICLE_SIZE_EXCEEDED
Status: article is too big (> $wgMaxArticleSize), after merging in the new section.
const AS_CONFLICT_DETECTED
Status: (non-resolvable) edit conflict.
addExplainConflictHeader(OutputPage $out)
getSummaryInputAttributes(array $inputAttrs=null)
Helper function for summary input functions, which returns the neccessary attributes for the input.
incrementEditFailureStats( $failureType)
setPostEditCookie( $statusValue)
Sets post-edit cookie indicating the user just saved a particular revision.
const AS_SPAM_ERROR
Status: summary contained spam according to one of the regexes in $wgSummarySpamRegex.
wasDeletedSinceLastEdit()
Check if a page was deleted while the user was editing it, before submit.
setEditConflictHelperFactory(callable $factory)
Set a factory function to create an EditConflictHelper.
string null $unicodeCheck
What the user submitted in the 'wpUnicodeCheck' field.
const AS_READ_ONLY_PAGE_LOGGED
Status: this logged in user is not allowed to edit this page.
callable $editConflictHelperFactory
Factory function to create an edit conflict helper.
isWrongCaseUserConfigPage()
Checks whether the user entered a skin name in uppercase, e.g.
initialiseForm()
Initialise form fields in the object Called on the first invocation, e.g.
bool $hasPresetSummary
Has a summary been preset using GET parameter &summary= ?
const AS_BLANK_ARTICLE
Status: user tried to create a blank page and wpIgnoreBlankArticle == false.
static matchSummarySpamRegex( $text)
Check given input text against $wgSummarySpamRegex, and return the text of the first match.
handleStatus(Status $status, $resultDetails)
Handle status, such as after attempt save.
importFormData(&$request)
This function collects the form data and uses it to populate various member variables.
static extractSectionTitle( $text)
Extract the section title from current section text, if any.
showTextbox1( $customAttribs=null, $textoverride=null)
Method to output wpTextbox1 The $textoverride method can be used by subclasses overriding showContent...
buildTextboxAttribs( $name, array $customAttribs, User $user)
showDiff()
Get a diff between the current contents of the edit box and the version of the page we're editing fro...
Revision bool null $mBaseRevision
const AS_PARSE_ERROR
Status: can't parse content.
noSuchSectionPage()
Creates a basic error page which informs the user that they have attempted to edit a nonexistent sect...
incrementResolvedConflicts()
Log when a page was successfully saved after the edit conflict view.
showConflict()
Show an edit conflict.
guessSectionName( $text)
Turns section name wikitext into anchors for use in HTTP redirects.
const AS_READ_ONLY_PAGE
Status: wiki is in readonly mode (wfReadOnly() == true)
setPreloadedContent(Content $content)
Use this method before edit() to preload some content into the edit box.
static getCopyrightWarning( $title, $format='plain', $langcode=null)
Get the copyright warning, by default returns wikitext.
getParentRevId()
Get the edit's parent revision ID.
tokenOk(&$request)
Make sure the form isn't faking a user's credentials.
makeTemplatesOnThisPageList(array $templates)
Wrapper around TemplatesOnThisPageFormatter to make a "templates on this page" list.
ParserOutput $mParserOutput
previewOnOpen()
Should we show a preview when the edit form is first shown?
displayPreviewArea( $previewOutput, $isOnTop=false)
doPreviewParse(Content $content)
Parse the page for a preview.
setApiEditOverride( $enableOverride)
Allow editing of content that supports API direct editing, but not general direct editing.
internalAttemptSave(&$result, $bot=false)
Attempt submission (no UI)
getSubmitButtonLabel()
Get the message key of the label for the button to save the page.
getSummaryInputWidget( $summary="", $labelText=null, $inputAttrs=null)
Builds a standard summary input with a label.
const AS_CONTENT_TOO_BIG
Status: Content too big (> $wgMaxArticleSize)
getCurrentContent()
Get the current content of the page.
addContentModelChangeLogEntry(User $user, $oldModel, $newModel, $reason)
const EDITFORM_ID
HTML id and name for the beginning of the edit form.
const AS_CHANGE_TAG_ERROR
Status: an error relating to change tagging.
string $editFormPageTop
Before even the preview.
const AS_BLOCKED_PAGE_FOR_USER
Status: User is blocked from editing this page.
const AS_NO_CHANGE_CONTENT_MODEL
Status: user tried to modify the content model, but is not allowed to do that ( User::isAllowed('edit...
getCopywarn()
Get the copyright warning.
const POST_EDIT_COOKIE_DURATION
Duration of PostEdit cookie, in seconds.
static matchSpamRegex( $text)
Check given input text against $wgSpamRegex, and return the text of the first match.
getContextTitle()
Get the context title object.
toEditText( $content)
Gets an editable textual representation of $content.
null Title $mContextTitle
bool $isOldRev
Whether an old revision is edited.
const AS_IMAGE_REDIRECT_LOGGED
Status: logged in user is not allowed to upload (User::isAllowed('upload') == false)
const AS_END
Status: WikiPage::doEdit() was unsuccessful.
const AS_ARTICLE_WAS_DELETED
Status: article was deleted while editing and param wpRecreate == false or form was not posted.
const AS_TEXTBOX_EMPTY
Status: user tried to create a new section without content.
bool $mTokenOkExceptSuffix
newSectionSummary(&$sectionanchor=null)
Return the summary to be used for a new section.
const AS_SUCCESS_UPDATE
Status: Article successfully updated.
bool $isNew
New page or new section.
showIntro()
Show all applicable editing introductions.
static getEditToolbar( $title=null)
Shows a bulletin board style toolbar for common editing functions.
const AS_IMAGE_REDIRECT_ANON
Status: anonymous user is not allowed to upload (User::isAllowed('upload') == false)
getContentObject( $def_content=null)
getEditButtons(&$tabindex)
Returns an array of html code of the following buttons: save, diff and preview.
edit()
This is the function that gets called for "action=edit".
newTextConflictHelper( $submitButtonLabel)
bool $enableApiEditOverride
Set in ApiEditPage, based on ContentHandler::allowsDirectApiEditing.
displayViewSourcePage(Content $content, $errorMessage='')
Display a read-only View Source page.
addPageProtectionWarningHeaders()
addLongPageWarningHeader()
const AS_NO_CREATE_PERMISSION
Status: user tried to create this page, but is not allowed to do that ( Title->userCan('create') == f...
addNewLineAtEnd( $wikitext)
importContentFormData(&$request)
Subpage overridable method for extracting the page content data from the posted form to be placed in ...
showHeaderCopyrightWarning()
Show the header copyright warning.
getSummaryPreview( $isSubjectPreview, $summary="")
const AS_SUCCESS_NEW_ARTICLE
Status: Article successfully created.
showSummaryInput( $isSubjectPreview, $summary="")
mergeChangesIntoContent(&$editContent)
Attempts to do 3-way merge of edit content with a base revision and current content,...
showTosSummary()
Give a chance for site and per-namespace customizations of terms of service summary link that might e...
const UNICODE_CHECK
Used for Unicode support checks.
getPreviewText()
Get the rendered text for previewing.
formatStatusErrors(Status $status)
Wrap status errors in an errorbox for increased visibility.
showContentForm()
Subpage overridable method for printing the form for page content editing By default this simply outp...
getPreloadedContent( $preload, $params=[])
Get the contents to be preloaded into the box, either set by an earlier setPreloadText() or by loadin...
static matchSpamRegexInternal( $text, $regexes)
TextConflictHelper null $editConflictHelper
showEditForm( $formCallback=null)
Send the edit form and related headers to OutputPage.
const AS_RATE_LIMITED
Status: rate limiter for action 'edit' was tripped.
const AS_HOOK_ERROR
Status: Article update aborted by a hook function.
setContextTitle( $title)
Set the context Title object.
spamPageWithContent( $match=false)
Show "your edit contains spam" page with your diff and text.
const AS_SUMMARY_NEEDED
Status: no edit summary given and the user has forceeditsummary set and the user is not editing in hi...
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...
static accesskey( $name)
Given the id of an interface element, constructs the appropriate accesskey attribute from the system ...
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 formatHiddenCategories( $hiddencats)
Returns HTML for the "hidden categories on this page" list.
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
Exception representing a failure to serialize or unserialize a content object.
Exception thrown when an unregistered content model is requested.
Class for creating log entries manually, to inject them into the database.
setPerformer(User $performer)
Set the user that performed the action being logged.
Helper for displaying edit conflicts in text content models to users.
getEditConflictMainTextBox( $customAttribs=[])
HTML to build the textbox1 on edit conflicts.
getEditFormHtmlAfterContent()
Content to go in the edit form after textbox1.
setContentFormat( $contentFormat)
setContentModel( $contentModel)
setTextboxes( $yourtext, $storedversion)
getEditFormHtmlBeforeContent()
Content to go in the edit form before textbox1.
Helps EditPage build textboxes.
This class should be covered by a general architecture document which does not exist as of January 20...
Show an error when a user tries to do something they do not have the necessary permissions for.
Variant of the Message class.
Show an error when the wiki is locked/read-only and the user tries to do something that requires writ...
static inDebugMode()
Determine whether debug mode was requested Order of priority is 1) request param, 2) cookie,...
static makeInlineScript( $script)
Returns an HTML script tag that runs given JS code after startup and base modules.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Handles formatting for the "templates used on this page" lists.
Show an error when the user hits a rate limit.
Represents a title within MediaWiki.
exists( $flags=0)
Check if page exists.
setContentModel( $model)
Set a proposed content model for the page for permissions checking.
Show an error when the user tries to do something whilst blocked.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
static isIP( $name)
Does the string match an anonymous IP address?
static doWatchOrUnwatch( $watch, Title $title, User $user)
Watch or unwatch a page.
Class representing a MediaWiki article and history.
getRedirectTarget()
If this page is a redirect, get its target.
getContent( $audience=Revision::FOR_PUBLIC, User $user=null)
Get the content of the current revision.
isRedirect()
Tests if the article content represents a redirect.
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
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
the array() calling protocol came about after MediaWiki 1.4rc1.
namespace being checked & $result
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place $output
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action or null $user:User who performed the tagging when the tagging is subsequent to the action or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, 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. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy: boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DeleteUnknownPreferences':Called by the cleanupPreferences.php maintenance script to build a WHERE clause with which to delete preferences that are not known about. This hook is used by extensions that have dynamically-named preferences that should not be deleted in the usual cleanup process. For example, the Gadgets extension creates preferences prefixed with 'gadget-', and so anything with that prefix is excluded from the deletion. &where:An array that will be passed as the $cond parameter to IDatabase::select() to determine what will be deleted from the user_properties table. $db:The IDatabase object, useful for accessing $db->buildLike() etc. 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
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
also included in $newHeader if any indicating whether we should show just the diff
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
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
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
null means default & $customAttribs
namespace and then decline to actually register it file or subcat img or subcat $title
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
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
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
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 $out
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
this hook is for auditing only or null if authentication failed before getting that far $username
Allows to change the fields on the form that will be generated $name
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
this hook is for auditing only $response
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
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
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
processing should stop and the error should be shown to the user * false
returning false will NOT prevent logging $e
const CONTENT_MODEL_JAVASCRIPT
Base interface for content objects.
preSaveTransform(Title $title, User $user, ParserOptions $parserOptions)
Returns a Content object with pre-save transformations applied (or this object if no transformations ...
serialize( $format=null)
Convenience method for serializing this Content object.
Interface for objects which can provide a MediaWiki context on request.
if(!isset( $args[0])) $lang