From: jenkins-bot Date: Wed, 12 Jul 2017 16:14:38 +0000 (+0000) Subject: Merge "Convert article delete to use OOUI" X-Git-Tag: 1.31.0-rc.0~2730 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=12601ff7d2796752404bfb331fccc41083d31f9f;hp=-c Merge "Convert article delete to use OOUI" --- 12601ff7d2796752404bfb331fccc41083d31f9f diff --combined includes/page/Article.php index dc4096c438,b49842874e..16328bcead --- a/includes/page/Article.php +++ b/includes/page/Article.php @@@ -214,6 -214,7 +214,6 @@@ class Article implements Page * @since 1.21 */ protected function getContentObject() { - if ( $this->mPage->getId() === 0 ) { # If this is a MediaWiki:x message, then load the messages # and return the message value for x. @@@ -568,8 -569,8 +568,8 @@@ $outputPage->setRevisionTimestamp( $this->mPage->getTimestamp() ); if ( !Hooks::run( 'ArticleContentViewCustom', - [ $this->fetchContentObject(), $this->getTitle(), $outputPage ] ) ) { - + [ $this->fetchContentObject(), $this->getTitle(), $outputPage ] ) + ) { # Allow extensions do their own custom view for certain pages $outputDone = true; } @@@ -979,8 -980,8 +979,8 @@@ } // Check for cached results - $key = wfMemcKey( 'unpatrollable-page', $title->getArticleID() ); - $cache = ObjectCache::getMainWANInstance(); + $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); + $key = $cache->makeKey( 'unpatrollable-page', $title->getArticleID() ); if ( $cache->get( $key ) ) { return false; } @@@ -1120,8 -1121,8 +1120,8 @@@ * @since 1.27 */ public static function purgePatrolFooterCache( $articleID ) { - $cache = ObjectCache::getMainWANInstance(); - $cache->delete( wfMemcKey( 'unpatrollable-page', $articleID ) ); + $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); + $cache->delete( $cache->makeKey( 'unpatrollable-page', $articleID ) ); } /** @@@ -1176,8 -1177,8 +1176,8 @@@ # Show delete and move logs if there were any such events. # The logging query can DOS the site when bots/crawlers cause 404 floods, # so be careful showing this. 404 pages must be cheap as they are hard to cache. - $cache = ObjectCache::getMainStashInstance(); - $key = wfMemcKey( 'page-recent-delete', md5( $title->getPrefixedText() ) ); + $cache = MediaWikiServices::getInstance()->getMainObjectStash(); + $key = $cache->makeKey( 'page-recent-delete', md5( $title->getPrefixedText() ) ); $loggedIn = $this->getContext()->getUser()->isLoggedIn(); if ( $loggedIn || $cache->get( $key ) ) { $logTypes = [ 'delete', 'move' ]; @@@ -1433,8 -1434,6 +1433,8 @@@ * @param bool $appendSubtitle [optional] * @param bool $forceKnown Should the image be shown as a bluelink regardless of existence? * @return string Containing HTML with redirect link + * + * @deprecated since 1.30 */ public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) { $lang = $this->getTitle()->getPageLanguage(); @@@ -1692,74 -1691,127 +1692,127 @@@ $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', + ] + ); - $outputPage->addHTML( $form ); + $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, + ] + ); + } + + $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() ) );