X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FFileDeleteForm.php;h=c362ec05280c89e56a79734d2fb60fe5ebaf5f21;hb=3842fd20799f80116b3a32b601ec67e97b71bae8;hp=ce7503704924246e18ac17fa84f0b9736783d71e;hpb=ef970021795d220af007fd603e4813c1122bc8ef;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index ce75037049..c362ec0528 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 = " - - " . - Xml::checkLabel( wfMessage( 'revdelete-suppress' )->text(), - 'wpSuppress', 'wpSuppress', false, [ 'tabindex' => '3' ] ) . - " - "; - } 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' ] ) . - " - " . - Xml::label( wfMessage( 'filedelete-comment' )->text(), 'wpDeleteReasonList' ) . - " - " . - Xml::listDropDown( - 'wpDeleteReasonList', - wfMessage( 'filedelete-reason-dropdown' )->inContentLanguage()->text(), - wfMessage( 'filedelete-reason-otherlist' )->inContentLanguage()->text(), - '', - 'wpReasonDropDown', - 1 - ) . - " - - - " . - Xml::label( wfMessage( 'filedelete-otherreason' )->text(), 'wpReason' ) . - " - " . - 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' - ] ) . - " - - {$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 .= " - - - " . - Xml::checkLabel( wfMessage( 'watchthis' )->text(), - 'wpWatch', 'wpWatch', $checkWatch, [ 'tabindex' => '3' ] ) . - " - "; + $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 .= " - - - " . - Xml::submitButton( - wfMessage( 'filedelete-submit' )->text(), - [ - 'name' => 'mw-filedelete-submit', - 'id' => 'mw-filedelete-submit', - 'tabindex' => '4' - ] - ) . - " - " . - 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 .= '

' . $link . '

'; - } - $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( '

' . $link . '

' ); + } } /**