From: Bryan Tong Minh Date: Fri, 4 Apr 2008 12:16:50 +0000 (+0000) Subject: Moved file deletion code to a more abstract FileDeleteForm::doDelete X-Git-Tag: 1.31.0-rc.0~48624 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=a3aeb20e0f4d261ba1213835ea39b774c3709950;p=lhc%2Fweb%2Fwiklou.git Moved file deletion code to a more abstract FileDeleteForm::doDelete --- diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index 8d6fc9ae2a..e9a252fed8 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -75,31 +75,8 @@ class FileDeleteForm { } elseif ( $reason == 'other' ) { $reason = $this->DeleteReason; } - - $article = null; - if( $this->oldimage ) { - $status = $this->file->deleteOld( $this->oldimage, $reason, $suppress ); - if( $status->ok ) { - // Need to do a log item - $log = new LogPage( 'delete' ); - $logComment = wfMsgForContent( 'deletedrevision', $this->oldimage ); - if( trim( $reason ) != '' ) - $logComment .= ": {$reason}"; - $log->addEntry( 'delete', $this->title, $logComment ); - } - } else { - $status = $this->file->delete( $reason, $suppress ); - if( $status->ok ) { - // Need to delete the associated article - $article = new Article( $this->title ); - if( wfRunHooks('ArticleDelete', array(&$article, &$wgUser, &$reason)) ){ - if( $article->doDeleteArticle( $reason, $suppress ) ) - wfRunHooks('ArticleDeleteComplete', array(&$article, &$wgUser, $reason)); - } - } - } - if( $status->isGood() ) wfRunHooks('FileDeleteComplete', array( - &$this->file, &$this->oldimage, &$article, &$wgUser, &$reason)); + + $status = self::doDelete( $this->title, $this->file, $this->oldimage, $reason, $suppress ); if( !$status->isGood() ) $wgOut->addWikiText( $status->getWikiText( 'filedeleteerror-short', 'filedeleteerror-long' ) ); @@ -116,6 +93,35 @@ class FileDeleteForm { $this->showForm(); $this->showLogEntries(); } + + public static function doDelete( &$title, &$file, &$oldimage, $reason, $suppress ) { + $article = null; + if( $oldimage ) { + $status = $file->deleteOld( $oldimage, $reason, $suppress ); + if( $status->ok ) { + // Need to do a log item + $log = new LogPage( 'delete' ); + $logComment = wfMsgForContent( 'deletedrevision', $oldimage ); + if( trim( $reason ) != '' ) + $logComment .= ": {$reason}"; + $log->addEntry( 'delete', $title, $logComment ); + } + } else { + $status = $file->delete( $reason, $suppress ); + if( $status->ok ) { + // Need to delete the associated article + $article = new Article( $title ); + if( wfRunHooks('ArticleDelete', array(&$article, &$wgUser, &$reason)) ) { + if( $article->doDeleteArticle( $reason, $suppress ) ) + wfRunHooks('ArticleDeleteComplete', array(&$article, &$wgUser, $reason)); + } + } + } + if( $status->isGood() ) wfRunHooks('FileDeleteComplete', array( + &$file, &$oldimage, &$article, &$wgUser, &$reason)); + + return $status; + } /** * Show the confirmation form