X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FFileDeleteForm.php;h=e31f9d218d0e40201915bc7dafef864aaa8a4086;hb=326d52f9613c5227d75f97361be6ec6ef78b214e;hp=c362ec05280c89e56a79734d2fb60fe5ebaf5f21;hpb=4e021bb8d4741d5af0f02942fe3c33a19e7fabca;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php
index c362ec0528..e31f9d218d 100644
--- a/includes/FileDeleteForm.php
+++ b/includes/FileDeleteForm.php
@@ -36,18 +36,18 @@ class FileDeleteForm {
private $title = null;
/**
- * @var File
+ * @var LocalFile
*/
private $file = null;
/**
- * @var File
+ * @var LocalFile
*/
private $oldfile = null;
private $oldimage = '';
/**
- * @param File $file File object we're deleting
+ * @param LocalFile $file File object we're deleting
*/
public function __construct( $file ) {
$this->title = $file->getTitle();
@@ -79,7 +79,9 @@ class FileDeleteForm {
$this->oldimage = $wgRequest->getText( 'oldimage', false );
$token = $wgRequest->getText( 'wpEditToken' );
# Flag to hide all contents of the archived revisions
- $suppress = $wgRequest->getCheck( 'wpSuppress' ) && $wgUser->isAllowed( 'suppressrevision' );
+ $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
+ $suppress = $wgRequest->getCheck( 'wpSuppress' ) &&
+ $permissionManager->userHasRight( $wgUser, 'suppressrevision' );
if ( $this->oldimage ) {
$this->oldfile = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName(
@@ -120,9 +122,10 @@ class FileDeleteForm {
if ( !$status->isGood() ) {
$wgOut->addHTML( '
' . $this->prepareMessage( 'filedeleteerror-short' ) . "
\n" );
- $wgOut->addWikiText( '' .
+ $wgOut->wrapWikiTextAsInterface(
+ 'error',
$status->getWikiText( 'filedeleteerror-short', 'filedeleteerror-long' )
- . '
' );
+ );
}
if ( $status->isOK() ) {
$wgOut->setPageTitle( wfMessage( 'actioncomplete' ) );
@@ -144,7 +147,7 @@ class FileDeleteForm {
* Really delete the file
*
* @param Title &$title
- * @param File &$file
+ * @param LocalFile &$file
* @param string &$oldimage Archive name
* @param string $reason Reason of the deletion
* @param bool $suppress Whether to mark all deleted versions as restricted
@@ -164,7 +167,7 @@ class FileDeleteForm {
if ( $oldimage ) {
$page = null;
$status = $file->deleteOld( $oldimage, $reason, $suppress, $user );
- if ( $status->ok ) {
+ if ( $status->isOK() ) {
// Need to do a log item
$logComment = wfMessage( 'deletedrevision', $oldimage )->inContentLanguage()->text();
if ( trim( $reason ) != '' ) {
@@ -178,7 +181,7 @@ class FileDeleteForm {
$logEntry->setPerformer( $user );
$logEntry->setTarget( $title );
$logEntry->setComment( $logComment );
- $logEntry->setTags( $tags );
+ $logEntry->addTags( $tags );
$logid = $logEntry->insert();
$logEntry->publish( $logid );
@@ -209,7 +212,7 @@ class FileDeleteForm {
$logEntry->setPerformer( $user );
$logEntry->setTarget( clone $title );
$logEntry->setComment( $reason );
- $logEntry->setTags( $tags );
+ $logEntry->addTags( $tags );
$logid = $logEntry->insert();
$dbw->onTransactionPreCommitOrIdle(
function () use ( $logEntry, $logid ) {
@@ -228,7 +231,6 @@ class FileDeleteForm {
$lbFactory->rollbackMasterChanges( __METHOD__ );
}
} else {
- // Done; nothing changed
$dbw->endAtomic( __METHOD__ );
}
}
@@ -245,9 +247,7 @@ class FileDeleteForm {
*/
private function showForm() {
global $wgOut, $wgUser, $wgRequest;
-
- $conf = RequestContext::getMain()->getConfig();
- $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD;
+ $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
$wgOut->addModules( 'mediawiki.action.delete.file' );
@@ -255,16 +255,18 @@ class FileDeleteForm {
$wgOut->enableOOUI();
+ $fields = [];
+
+ $fields[] = new OOUI\LabelWidget( [ 'label' => new OOUI\HtmlSnippet(
+ $this->prepareMessage( 'filedelete-intro' ) ) ]
+ );
+
$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',
@@ -282,13 +284,13 @@ class FileDeleteForm {
// 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).
+ // Unicode codepoints.
$fields[] = new OOUI\FieldLayout(
new OOUI\TextInputWidget( [
'name' => 'wpReason',
'inputId' => 'wpReason',
'tabIndex' => 2,
- 'maxLength' => $oldCommentSchema ? 255 : CommentStore::COMMENT_CHARACTER_LIMIT,
+ 'maxLength' => CommentStore::COMMENT_CHARACTER_LIMIT,
'infusable' => true,
'value' => $wgRequest->getText( 'wpReason' ),
'autofocus' => true,
@@ -299,7 +301,7 @@ class FileDeleteForm {
]
);
- if ( $wgUser->isAllowed( 'suppressrevision' ) ) {
+ if ( $permissionManager->userHasRight( $wgUser, 'suppressrevision' ) ) {
$fields[] = new OOUI\FieldLayout(
new OOUI\CheckboxInputWidget( [
'name' => 'wpSuppress',
@@ -373,7 +375,7 @@ class FileDeleteForm {
] )
);
- if ( $wgUser->isAllowed( 'editinterface' ) ) {
+ if ( $permissionManager->userHasRight( $wgUser, 'editinterface' ) ) {
$linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
$link = $linkRenderer->makeKnownLink(
$wgOut->msg( 'filedelete-reason-dropdown' )->inContentLanguage()->getTitle(),
@@ -449,9 +451,9 @@ class FileDeleteForm {
* value was provided, does it correspond to an
* existing, local, old version of this file?
*
- * @param File &$file
- * @param File &$oldfile
- * @param File $oldimage
+ * @param LocalFile &$file
+ * @param LocalFile &$oldfile
+ * @param LocalFile $oldimage
* @return bool
*/
public static function haveDeletableFile( &$file, &$oldfile, $oldimage ) {