Index: trunk/phase3/includes/FileDeleteForm.php |
— | — | @@ -75,32 +75,9 @@ |
76 | 76 | } elseif ( $reason == 'other' ) { |
77 | 77 | $reason = $this->DeleteReason; |
78 | 78 | } |
79 | | - |
80 | | - $article = null; |
81 | | - if( $this->oldimage ) { |
82 | | - $status = $this->file->deleteOld( $this->oldimage, $reason, $suppress ); |
83 | | - if( $status->ok ) { |
84 | | - // Need to do a log item |
85 | | - $log = new LogPage( 'delete' ); |
86 | | - $logComment = wfMsgForContent( 'deletedrevision', $this->oldimage ); |
87 | | - if( trim( $reason ) != '' ) |
88 | | - $logComment .= ": {$reason}"; |
89 | | - $log->addEntry( 'delete', $this->title, $logComment ); |
90 | | - } |
91 | | - } else { |
92 | | - $status = $this->file->delete( $reason, $suppress ); |
93 | | - if( $status->ok ) { |
94 | | - // Need to delete the associated article |
95 | | - $article = new Article( $this->title ); |
96 | | - if( wfRunHooks('ArticleDelete', array(&$article, &$wgUser, &$reason)) ){ |
97 | | - if( $article->doDeleteArticle( $reason, $suppress ) ) |
98 | | - wfRunHooks('ArticleDeleteComplete', array(&$article, &$wgUser, $reason)); |
99 | | - } |
100 | | - } |
101 | | - } |
102 | | - if( $status->isGood() ) wfRunHooks('FileDeleteComplete', array( |
103 | | - &$this->file, &$this->oldimage, &$article, &$wgUser, &$reason)); |
104 | 79 | |
| 80 | + $status = self::doDelete( $this->title, $this->file, $this->oldimage, $reason, $suppress ); |
| 81 | + |
105 | 82 | if( !$status->isGood() ) |
106 | 83 | $wgOut->addWikiText( $status->getWikiText( 'filedeleteerror-short', 'filedeleteerror-long' ) ); |
107 | 84 | if( $status->ok ) { |
— | — | @@ -116,6 +93,35 @@ |
117 | 94 | $this->showForm(); |
118 | 95 | $this->showLogEntries(); |
119 | 96 | } |
| 97 | + |
| 98 | + public static function doDelete( &$title, &$file, &$oldimage, $reason, $suppress ) { |
| 99 | + $article = null; |
| 100 | + if( $oldimage ) { |
| 101 | + $status = $file->deleteOld( $oldimage, $reason, $suppress ); |
| 102 | + if( $status->ok ) { |
| 103 | + // Need to do a log item |
| 104 | + $log = new LogPage( 'delete' ); |
| 105 | + $logComment = wfMsgForContent( 'deletedrevision', $oldimage ); |
| 106 | + if( trim( $reason ) != '' ) |
| 107 | + $logComment .= ": {$reason}"; |
| 108 | + $log->addEntry( 'delete', $title, $logComment ); |
| 109 | + } |
| 110 | + } else { |
| 111 | + $status = $file->delete( $reason, $suppress ); |
| 112 | + if( $status->ok ) { |
| 113 | + // Need to delete the associated article |
| 114 | + $article = new Article( $title ); |
| 115 | + if( wfRunHooks('ArticleDelete', array(&$article, &$wgUser, &$reason)) ) { |
| 116 | + if( $article->doDeleteArticle( $reason, $suppress ) ) |
| 117 | + wfRunHooks('ArticleDeleteComplete', array(&$article, &$wgUser, $reason)); |
| 118 | + } |
| 119 | + } |
| 120 | + } |
| 121 | + if( $status->isGood() ) wfRunHooks('FileDeleteComplete', array( |
| 122 | + &$file, &$oldimage, &$article, &$wgUser, &$reason)); |
| 123 | + |
| 124 | + return $status; |
| 125 | + } |
120 | 126 | |
121 | 127 | /** |
122 | 128 | * Show the confirmation form |