X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fpage%2FArticle.php;h=b49842874e757bfffd66f9d616dadf37c1ed221e;hp=e7a906d4bff97ee3c7cf5b212063fee00dc35f5f;hb=97a8fb78faa4ca2d9604140e5547f5deae5a2524;hpb=32f52cbacd760f8c1cb60345fe0310cbc8d7a4ec diff --git a/includes/page/Article.php b/includes/page/Article.php index e7a906d4bf..b49842874e 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -19,6 +19,7 @@ * * @file */ +use MediaWiki\MediaWikiServices; /** * Class for viewing MediaWiki article and history. @@ -494,7 +495,7 @@ class Article implements Page { $useParserCache = $this->mPage->shouldCheckParserCache( $parserOptions, $oldid ); wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); if ( $user->getStubThreshold() ) { - $this->getContext()->getStats()->increment( 'pcache_miss_stub' ); + MediaWikiServices::getInstance()->getStatsdDataFactory()->increment( 'pcache_miss_stub' ); } $this->showRedirectedFromHeader(); @@ -652,7 +653,17 @@ class Article implements Page { $this->showViewFooter(); $this->mPage->doViewUpdates( $user, $oldid ); - $outputPage->addModules( 'mediawiki.action.view.postEdit' ); + # Load the postEdit module if the user just saved this revision + # See also EditPage::setPostEditCookie + $request = $this->getContext()->getRequest(); + $cookieKey = EditPage::POST_EDIT_COOKIE_KEY_PREFIX . $this->getRevIdFetched(); + $postEdit = $request->getCookie( $cookieKey ); + if ( $postEdit ) { + # Clear the cookie. This also prevents caching of the response. + $request->response()->clearCookie( $cookieKey ); + $outputPage->addJsConfigVars( 'wgPostEdit', $postEdit ); + $outputPage->addModules( 'mediawiki.action.view.postEdit' ); + } } /** @@ -1132,7 +1143,7 @@ class Article implements Page { || $title->getNamespace() == NS_USER_TALK ) { $rootPart = explode( '/', $title->getText() )[0]; - $user = User::newFromName( $rootPart, false /* allow IP users*/ ); + $user = User::newFromName( $rootPart, false /* allow IP users */ ); $ip = User::isIP( $rootPart ); $block = Block::newFromTarget( $user, $user ); @@ -1680,74 +1691,127 @@ class Article implements Page { $suppress = ''; } $checkWatch = $user->getBoolOption( 'watchdeletion' ) || $user->isWatched( $title ); - $form = Html::openElement( 'form', [ 'method' => 'post', - 'action' => $title->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ] ) . - Html::openElement( 'fieldset', [ 'id' => 'mw-delete-table' ] ) . - Html::element( 'legend', null, wfMessage( 'delete-legend' )->text() ) . - Html::openElement( 'div', [ 'id' => 'mw-deleteconfirm-table' ] ) . - Html::openElement( 'div', [ 'id' => 'wpDeleteReasonListRow' ] ) . - Html::label( wfMessage( 'deletecomment' )->text(), 'wpDeleteReasonList' ) . - ' ' . - Xml::listDropDown( - 'wpDeleteReasonList', - wfMessage( 'deletereason-dropdown' )->inContentLanguage()->text(), - wfMessage( 'deletereasonotherlist' )->inContentLanguage()->text(), - '', - 'wpReasonDropDown', - 1 - ) . - Html::closeElement( 'div' ) . - Html::openElement( 'div', [ 'id' => 'wpDeleteReasonRow' ] ) . - Html::label( wfMessage( 'deleteotherreason' )->text(), 'wpReason' ) . - ' ' . - Html::input( 'wpReason', $reason, 'text', [ - 'size' => '60', - 'maxlength' => '255', - 'tabindex' => '2', - 'id' => 'wpReason', - 'class' => 'mw-ui-input-inline', - 'autofocus' - ] ) . - Html::closeElement( 'div' ); - - # Disallow watching if user is not logged in - if ( $user->isLoggedIn() ) { - $form .= - Xml::checkLabel( wfMessage( 'watchthis' )->text(), - 'wpWatch', 'wpWatch', $checkWatch, [ 'tabindex' => '3' ] ); - } - - $form .= - Html::openElement( 'div' ) . - $suppress . - Xml::submitButton( wfMessage( 'deletepage' )->text(), - [ - 'name' => 'wpConfirmB', - 'id' => 'wpConfirmB', - 'tabindex' => '5', - 'class' => $useMediaWikiUIEverywhere ? 'mw-ui-button mw-ui-destructive' : '', - ] - ) . - Html::closeElement( 'div' ) . - Html::closeElement( 'div' ) . - Xml::closeElement( 'fieldset' ) . - Html::hidden( - 'wpEditToken', - $user->getEditToken( [ 'delete', $title->getPrefixedText() ] ) - ) . - Xml::closeElement( 'form' ); - - if ( $user->isAllowed( 'editinterface' ) ) { - $link = Linker::linkKnown( - $ctx->msg( 'deletereason-dropdown' )->inContentLanguage()->getTitle(), - wfMessage( 'delete-edit-reasonlist' )->escaped(), - [], - [ 'action' => 'edit' ] - ); - $form .= '

' . $link . '

'; + + $outputPage->enableOOUI(); + + $options = []; + $options[] = [ + 'data' => 'other', + 'label' => $ctx->msg( 'deletereasonotherlist' )->inContentLanguage()->text(), + ]; + $list = $ctx->msg( 'deletereason-dropdown' )->inContentLanguage()->text(); + foreach ( explode( "\n", $list ) as $option ) { + $value = trim( $option ); + if ( $value == '' ) { + continue; + } elseif ( substr( $value, 0, 1 ) == '*' && substr( $value, 1, 1 ) != '*' ) { + $options[] = [ 'optgroup' => trim( substr( $value, 1 ) ) ]; + } elseif ( substr( $value, 0, 2 ) == '**' ) { + $options[] = [ 'data' => trim( substr( $value, 2 ) ) ]; + } else { + $options[] = [ 'data' => trim( $value ) ]; } + } + + $fields[] = new OOUI\FieldLayout( + new OOUI\DropdownInputWidget( [ + 'name' => 'wpDeleteReasonList', + 'inputId' => 'wpDeleteReasonList', + 'tabIndex' => 1, + 'infusable' => true, + 'value' => '', + 'options' => $options + ] ), + [ + 'label' => $ctx->msg( 'deletecomment' )->text(), + 'align' => 'top', + ] + ); + + $fields[] = new OOUI\FieldLayout( + new OOUI\TextInputWidget( [ + 'name' => 'wpReason', + 'inputId' => 'wpReason', + 'tabIndex' => 2, + 'maxLength' => 255, + 'infusable' => true, + 'value' => $reason, + 'autofocus' => true, + ] ), + [ + 'label' => $ctx->msg( 'deleteotherreason' )->text(), + 'align' => 'top', + ] + ); + + if ( $user->isLoggedIn() ) { + $fields[] = new OOUI\FieldLayout( + new OOUI\CheckboxInputWidget( [ + 'name' => 'wpWatch', + 'inputId' => 'wpWatch', + 'tabIndex' => 3, + 'selected' => $checkWatch, + ] ), + [ + 'label' => $ctx->msg( 'watchthis' )->text(), + 'align' => 'inline', + 'infusable' => true, + ] + ); + } - $outputPage->addHTML( $form ); + $fields[] = new OOUI\FieldLayout( + new OOUI\ButtonInputWidget( [ + 'name' => 'wpConfirmB', + 'inputId' => 'wpConfirmB', + 'tabIndex' => 5, + 'value' => $ctx->msg( 'deletepage' )->text(), + 'label' => $ctx->msg( 'deletepage' )->text(), + 'flags' => [ 'primary', 'destructive' ], + 'type' => 'submit', + ] ), + [ + 'align' => 'top', + ] + ); + + $fieldset = new OOUI\FieldsetLayout( [ + 'label' => $ctx->msg( 'delete-legend' )->text(), + 'id' => 'mw-delete-table', + 'items' => $fields, + ] ); + + $form = new OOUI\FormLayout( [ + 'method' => 'post', + 'action' => $title->getLocalURL( 'action=delete' ), + 'id' => 'deleteconfirm', + ] ); + $form->appendContent( + $fieldset, + new OOUI\HtmlSnippet( + Html::hidden( 'wpEditToken', $user->getEditToken( [ 'delete', $title->getPrefixedText() ] ) ) + ) + ); + + $outputPage->addHTML( + new OOUI\PanelLayout( [ + 'classes' => [ 'deletepage-wrapper' ], + 'expanded' => false, + 'padded' => true, + 'framed' => true, + 'content' => $form, + ] ) + ); + + if ( $user->isAllowed( 'editinterface' ) ) { + $link = Linker::linkKnown( + $ctx->msg( 'deletereason-dropdown' )->inContentLanguage()->getTitle(), + wfMessage( 'delete-edit-reasonlist' )->escaped(), + [], + [ 'action' => 'edit' ] + ); + $outputPage->addHTML( '

' . $link . '

' ); + } $deleteLogPage = new LogPage( 'delete' ); $outputPage->addHTML( Xml::element( 'h2', null, $deleteLogPage->getName()->text() ) ); @@ -2042,16 +2106,20 @@ class Article implements Page { /** * Call to WikiPage function for backwards compatibility. * @see WikiPage::doPurge + * @note In 1.28 (and only 1.28), this took a $flags parameter that + * controlled how much purging was done. */ - public function doPurge( $flags = WikiPage::PURGE_ALL ) { - return $this->mPage->doPurge( $flags ); + public function doPurge() { + return $this->mPage->doPurge(); } /** * Call to WikiPage function for backwards compatibility. * @see WikiPage::getLastPurgeTimestamp + * @deprecated since 1.29 */ public function getLastPurgeTimestamp() { + wfDeprecated( __METHOD__, '1.29' ); return $this->mPage->getLastPurgeTimestamp(); }