diff options
author | jenkins-bot <jenkins-bot@gerrit.wikimedia.org> | 2018-08-01 17:23:24 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@wikimedia.org> | 2018-08-01 17:23:24 +0000 |
commit | 695d7c28fe7036e9988ce92908185ebc41238296 (patch) | |
tree | ce2d150ade3feacd58342b5f9201ed7bb9abb943 /includes/FileDeleteForm.php | |
parent | e143c40fee88922eb393a88f94e60afc439d1f49 (diff) | |
parent | 65a8e68ec07d7eed10d868f4338f29cbbcefa992 (diff) | |
download | mediawikicore-695d7c28fe7036e9988ce92908185ebc41238296.tar.gz mediawikicore-695d7c28fe7036e9988ce92908185ebc41238296.zip |
Merge "Convert file delete to use OOUI"
Diffstat (limited to 'includes/FileDeleteForm.php')
-rw-r--r-- | includes/FileDeleteForm.php | 219 |
1 files changed, 129 insertions, 90 deletions
diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index ce7503704924..c362ec05280c 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -79,7 +79,7 @@ class FileDeleteForm { $this->oldimage = $wgRequest->getText( 'oldimage', false ); $token = $wgRequest->getText( 'wpEditToken' ); # Flag to hide all contents of the archived revisions - $suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgUser->isAllowed( 'suppressrevision' ); + $suppress = $wgRequest->getCheck( 'wpSuppress' ) && $wgUser->isAllowed( 'suppressrevision' ); if ( $this->oldimage ) { $this->oldfile = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( @@ -249,101 +249,140 @@ class FileDeleteForm { $conf = RequestContext::getMain()->getConfig(); $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD; - if ( $wgUser->isAllowed( 'suppressrevision' ) ) { - $suppress = "<tr id=\"wpDeleteSuppressRow\"> - <td></td> - <td class='mw-input'><strong>" . - Xml::checkLabel( wfMessage( 'revdelete-suppress' )->text(), - 'wpSuppress', 'wpSuppress', false, [ 'tabindex' => '3' ] ) . - "</strong></td> - </tr>"; - } else { - $suppress = ''; - } - $wgOut->addModules( 'mediawiki.action.delete.file' ); $checkWatch = $wgUser->getBoolOption( 'watchdeletion' ) || $wgUser->isWatched( $this->title ); - $form = Xml::openElement( 'form', [ 'method' => 'post', 'action' => $this->getAction(), - 'id' => 'mw-img-deleteconfirm' ] ) . - Xml::openElement( 'fieldset' ) . - Xml::element( 'legend', null, wfMessage( 'filedelete-legend' )->text() ) . - Html::hidden( 'wpEditToken', $wgUser->getEditToken( $this->oldimage ) ) . - $this->prepareMessage( 'filedelete-intro' ) . - Xml::openElement( 'table', [ 'id' => 'mw-img-deleteconfirm-table' ] ) . - "<tr> - <td class='mw-label'>" . - Xml::label( wfMessage( 'filedelete-comment' )->text(), 'wpDeleteReasonList' ) . - "</td> - <td class='mw-input'>" . - Xml::listDropDown( - 'wpDeleteReasonList', - wfMessage( 'filedelete-reason-dropdown' )->inContentLanguage()->text(), - wfMessage( 'filedelete-reason-otherlist' )->inContentLanguage()->text(), - '', - 'wpReasonDropDown', - 1 - ) . - "</td> - </tr> - <tr> - <td class='mw-label'>" . - Xml::label( wfMessage( 'filedelete-otherreason' )->text(), 'wpReason' ) . - "</td> - <td class='mw-input'>" . - Xml::input( 'wpReason', 60, $wgRequest->getText( 'wpReason' ), [ - 'type' => 'text', - // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP - // (e.g. emojis) count for two each. This limit is overridden in JS to instead count - // Unicode codepoints (or 255 UTF-8 bytes for old schema). - 'maxlength' => $oldCommentSchema ? 255 : CommentStore::COMMENT_CHARACTER_LIMIT, - 'tabindex' => '2', - 'id' => 'wpReason' - ] ) . - "</td> - </tr> - {$suppress}"; + + $wgOut->enableOOUI(); + + $options = Xml::listDropDownOptions( + $wgOut->msg( 'filedelete-reason-dropdown' )->inContentLanguage()->text(), + [ 'other' => $wgOut->msg( 'filedelete-reason-otherlist' )->inContentLanguage()->text() ] + ); + $options = Xml::listDropDownOptionsOoui( $options ); + + $fields[] = new OOUI\LabelWidget( [ 'label' => new OOUI\HtmlSnippet( + $this->prepareMessage( 'filedelete-intro' ) ) ] + ); + + $fields[] = new OOUI\FieldLayout( + new OOUI\DropdownInputWidget( [ + 'name' => 'wpDeleteReasonList', + 'inputId' => 'wpDeleteReasonList', + 'tabIndex' => 1, + 'infusable' => true, + 'value' => '', + 'options' => $options, + ] ), + [ + 'label' => $wgOut->msg( 'filedelete-comment' )->text(), + 'align' => 'top', + ] + ); + + // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP + // (e.g. emojis) count for two each. This limit is overridden in JS to instead count + // Unicode codepoints (or 255 UTF-8 bytes for old schema). + $fields[] = new OOUI\FieldLayout( + new OOUI\TextInputWidget( [ + 'name' => 'wpReason', + 'inputId' => 'wpReason', + 'tabIndex' => 2, + 'maxLength' => $oldCommentSchema ? 255 : CommentStore::COMMENT_CHARACTER_LIMIT, + 'infusable' => true, + 'value' => $wgRequest->getText( 'wpReason' ), + 'autofocus' => true, + ] ), + [ + 'label' => $wgOut->msg( 'filedelete-otherreason' )->text(), + 'align' => 'top', + ] + ); + + if ( $wgUser->isAllowed( 'suppressrevision' ) ) { + $fields[] = new OOUI\FieldLayout( + new OOUI\CheckboxInputWidget( [ + 'name' => 'wpSuppress', + 'inputId' => 'wpSuppress', + 'tabIndex' => 3, + 'selected' => false, + ] ), + [ + 'label' => $wgOut->msg( 'revdelete-suppress' )->text(), + 'align' => 'inline', + 'infusable' => true, + ] + ); + } + if ( $wgUser->isLoggedIn() ) { - $form .= " - <tr> - <td></td> - <td class='mw-input'>" . - Xml::checkLabel( wfMessage( 'watchthis' )->text(), - 'wpWatch', 'wpWatch', $checkWatch, [ 'tabindex' => '3' ] ) . - "</td> - </tr>"; + $fields[] = new OOUI\FieldLayout( + new OOUI\CheckboxInputWidget( [ + 'name' => 'wpWatch', + 'inputId' => 'wpWatch', + 'tabIndex' => 3, + 'selected' => $checkWatch, + ] ), + [ + 'label' => $wgOut->msg( 'watchthis' )->text(), + 'align' => 'inline', + 'infusable' => true, + ] + ); } - $form .= " - <tr> - <td></td> - <td class='mw-submit'>" . - Xml::submitButton( - wfMessage( 'filedelete-submit' )->text(), - [ - 'name' => 'mw-filedelete-submit', - 'id' => 'mw-filedelete-submit', - 'tabindex' => '4' - ] - ) . - "</td> - </tr>" . - Xml::closeElement( 'table' ) . - Xml::closeElement( 'fieldset' ) . - Xml::closeElement( 'form' ); - - if ( $wgUser->isAllowed( 'editinterface' ) ) { - $title = wfMessage( 'filedelete-reason-dropdown' )->inContentLanguage()->getTitle(); - $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); - $link = $linkRenderer->makeKnownLink( - $title, - wfMessage( 'filedelete-edit-reasonlist' )->text(), - [], - [ 'action' => 'edit' ] - ); - $form .= '<p class="mw-filedelete-editreasons">' . $link . '</p>'; - } - $wgOut->addHTML( $form ); + $fields[] = new OOUI\FieldLayout( + new OOUI\ButtonInputWidget( [ + 'name' => 'mw-filedelete-submit', + 'inputId' => 'mw-filedelete-submit', + 'tabIndex' => 4, + 'value' => $wgOut->msg( 'filedelete-submit' )->text(), + 'label' => $wgOut->msg( 'filedelete-submit' )->text(), + 'flags' => [ 'primary', 'destructive' ], + 'type' => 'submit', + ] ), + [ + 'align' => 'top', + ] + ); + + $fieldset = new OOUI\FieldsetLayout( [ + 'label' => $wgOut->msg( 'filedelete-legend' )->text(), + 'items' => $fields, + ] ); + + $form = new OOUI\FormLayout( [ + 'method' => 'post', + 'action' => $this->getAction(), + 'id' => 'mw-img-deleteconfirm', + ] ); + $form->appendContent( + $fieldset, + new OOUI\HtmlSnippet( + Html::hidden( 'wpEditToken', $wgUser->getEditToken( $this->oldimage ) ) + ) + ); + + $wgOut->addHTML( + new OOUI\PanelLayout( [ + 'classes' => [ 'deletepage-wrapper' ], + 'expanded' => false, + 'padded' => true, + 'framed' => true, + 'content' => $form, + ] ) + ); + + if ( $wgUser->isAllowed( 'editinterface' ) ) { + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); + $link = $linkRenderer->makeKnownLink( + $wgOut->msg( 'filedelete-reason-dropdown' )->inContentLanguage()->getTitle(), + wfMessage( 'filedelete-edit-reasonlist' )->text(), + [], + [ 'action' => 'edit' ] + ); + $wgOut->addHTML( '<p class="mw-filedelete-editreasons">' . $link . '</p>' ); + } } /** |