Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -1481,6 +1481,7 @@ |
1482 | 1482 | 'filedelete-reason-dropdown', |
1483 | 1483 | 'filedelete-edit-reasonlist', |
1484 | 1484 | 'filedelete-maintenance', |
| 1485 | + 'filedelete-maintenance-title', |
1485 | 1486 | ), |
1486 | 1487 | 'mimesearch' => array( |
1487 | 1488 | 'mimesearch', |
Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -874,7 +874,7 @@ |
875 | 875 | $file: reference to the deleted file |
876 | 876 | $oldimage: in case of the deletion of an old image, the name of the old file |
877 | 877 | $article: in case all revisions of the file are deleted a reference to the |
878 | | - article associated with the file. |
| 878 | + WikiFilePage associated with the file. |
879 | 879 | $user: user who performed the deletion |
880 | 880 | $reason: reason |
881 | 881 | |
Index: trunk/phase3/includes/ImagePage.php |
— | — | @@ -789,19 +789,15 @@ |
790 | 790 | */ |
791 | 791 | public function delete() { |
792 | 792 | global $wgUploadMaintenance; |
793 | | - if ( $wgUploadMaintenance && $this->getTitle() && $this->getTitle()->getNamespace() == NS_FILE ) { |
794 | | - global $wgOut; |
795 | | - $wgOut->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n", array( 'filedelete-maintenance' ) ); |
796 | | - return; |
797 | | - } |
798 | 793 | |
799 | | - $this->loadFile(); |
800 | | - if ( !$this->mPage->getFile()->exists() || !$this->mPage->getFile()->isLocal() || $this->mPage->getFile()->getRedirected() ) { |
| 794 | + $file = $this->mPage->getFile(); |
| 795 | + if ( !$file->exists() || !$file->isLocal() || $file->getRedirected() ) { |
801 | 796 | // Standard article deletion |
802 | 797 | parent::delete(); |
803 | 798 | return; |
804 | 799 | } |
805 | | - $deleter = new FileDeleteForm( $this->mPage->getFile() ); |
| 800 | + |
| 801 | + $deleter = new FileDeleteForm( $file ); |
806 | 802 | $deleter->execute(); |
807 | 803 | } |
808 | 804 | |
Index: trunk/phase3/includes/FileDeleteForm.php |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | * pending authentication, confirmation, etc. |
41 | 41 | */ |
42 | 42 | public function execute() { |
43 | | - global $wgOut, $wgRequest, $wgUser; |
| 43 | + global $wgOut, $wgRequest, $wgUser, $wgUploadMaintenance; |
44 | 44 | |
45 | 45 | $permissionErrors = $this->title->getUserPermissionsErrors( 'delete', $wgUser ); |
46 | 46 | if ( count( $permissionErrors ) ) { |
— | — | @@ -50,6 +50,10 @@ |
51 | 51 | throw new ReadOnlyError; |
52 | 52 | } |
53 | 53 | |
| 54 | + if ( $wgUploadMaintenance ) { |
| 55 | + throw new ErrorPageError( 'filedelete-maintenance-title', 'filedelete-maintenance' ); |
| 56 | + } |
| 57 | + |
54 | 58 | $this->setHeaders(); |
55 | 59 | |
56 | 60 | $this->oldimage = $wgRequest->getText( 'oldimage', false ); |
— | — | @@ -81,7 +85,7 @@ |
82 | 86 | $reason = $deleteReasonList; |
83 | 87 | } |
84 | 88 | |
85 | | - $status = self::doDelete( $this->title, $this->file, $this->oldimage, $reason, $suppress ); |
| 89 | + $status = self::doDelete( $this->title, $this->file, $this->oldimage, $reason, $suppress, $wgUser ); |
86 | 90 | |
87 | 91 | if( !$status->isGood() ) { |
88 | 92 | $wgOut->addHTML( '<h2>' . $this->prepareMessage( 'filedeleteerror-short' ) . "</h2>\n" ); |
— | — | @@ -95,6 +99,12 @@ |
96 | 100 | // Return to the main page if we just deleted all versions of the |
97 | 101 | // file, otherwise go back to the description page |
98 | 102 | $wgOut->addReturnTo( $this->oldimage ? $this->title : Title::newMainPage() ); |
| 103 | + |
| 104 | + if ( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) { |
| 105 | + WatchAction::doWatch( $title, $wgUser ); |
| 106 | + } elseif ( $this->title->userIsWatching() ) { |
| 107 | + WatchAction::doUnwatch( $title, $wgUser ); |
| 108 | + } |
99 | 109 | } |
100 | 110 | return; |
101 | 111 | } |
— | — | @@ -111,13 +121,16 @@ |
112 | 122 | * @param $oldimage String: archive name |
113 | 123 | * @param $reason String: reason of the deletion |
114 | 124 | * @param $suppress Boolean: whether to mark all deleted versions as restricted |
| 125 | + * @param $user User object performing the request |
115 | 126 | */ |
116 | | - public static function doDelete( &$title, &$file, &$oldimage, $reason, $suppress ) { |
117 | | - global $wgUser; |
118 | | - $article = null; |
119 | | - $status = Status::newFatal( 'error' ); |
| 127 | + public static function doDelete( &$title, &$file, &$oldimage, $reason, $suppress, User $user = null ) { |
| 128 | + if ( $user === null ) { |
| 129 | + global $wgUser; |
| 130 | + $user = $wgUser; |
| 131 | + } |
120 | 132 | |
121 | 133 | if( $oldimage ) { |
| 134 | + $page = null; |
122 | 135 | $status = $file->deleteOld( $oldimage, $reason, $suppress ); |
123 | 136 | if( $status->ok ) { |
124 | 137 | // Need to do a log item |
— | — | @@ -129,18 +142,14 @@ |
130 | 143 | $log->addEntry( 'delete', $title, $logComment ); |
131 | 144 | } |
132 | 145 | } else { |
| 146 | + $status = Status::newFatal( 'error' ); |
133 | 147 | $id = $title->getArticleID( Title::GAID_FOR_UPDATE ); |
134 | | - $article = new Article( $title ); |
| 148 | + $page = WikiPage::factory( $title ); |
135 | 149 | $dbw = wfGetDB( DB_MASTER ); |
136 | 150 | try { |
137 | 151 | // delete the associated article first |
138 | | - if( $article->doDeleteArticle( $reason, $suppress, $id, false ) ) { |
139 | | - global $wgRequest; |
140 | | - if ( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) { |
141 | | - WatchAction::doWatch( $title, $wgUser ); |
142 | | - } elseif ( $title->userIsWatching() ) { |
143 | | - WatchAction::doUnwatch( $title, $wgUser ); |
144 | | - } |
| 152 | + $error = ''; |
| 153 | + if ( $page->doDeleteArticle( $reason, $suppress, $id, false, $error, $user ) ) { |
145 | 154 | $status = $file->delete( $reason, $suppress ); |
146 | 155 | if( $status->ok ) { |
147 | 156 | $dbw->commit(); |
— | — | @@ -154,9 +163,11 @@ |
155 | 164 | throw $e; |
156 | 165 | } |
157 | 166 | } |
158 | | - if( $status->isGood() ) |
159 | | - wfRunHooks('FileDeleteComplete', array( &$file, &$oldimage, &$article, &$wgUser, &$reason)); |
160 | 167 | |
| 168 | + if ( $status->isGood() ) { |
| 169 | + wfRunHooks( 'FileDeleteComplete', array( &$file, &$oldimage, &$page, &$user, &$reason ) ); |
| 170 | + } |
| 171 | + |
161 | 172 | return $status; |
162 | 173 | } |
163 | 174 | |
Index: trunk/phase3/languages/messages/MessagesQqq.php |
— | — | @@ -2015,30 +2015,32 @@ |
2016 | 2016 | {{Identical|Revert}}', |
2017 | 2017 | |
2018 | 2018 | # File deletion |
2019 | | -'filedelete-legend' => '{{Identical|Delete}}', |
2020 | | -'filedelete-intro-old' => 'Message displayed when you try to delete a version of a file. |
| 2019 | +'filedelete-legend' => '{{Identical|Delete}}', |
| 2020 | +'filedelete-intro-old' => 'Message displayed when you try to delete a version of a file. |
2021 | 2021 | * $1 is the name of the media |
2022 | 2022 | * $2 is a date |
2023 | 2023 | * $3 is a hour |
2024 | 2024 | * $4 is a URL and must follow square bracket: [$4', |
2025 | | -'filedelete-comment' => '{{Identical|Reason}}', |
2026 | | -'filedelete-submit' => 'Delete button when deleting a file for admins |
| 2025 | +'filedelete-comment' => '{{Identical|Reason}}', |
| 2026 | +'filedelete-submit' => 'Delete button when deleting a file for admins |
2027 | 2027 | |
2028 | 2028 | {{Identical|Delete}}', |
2029 | | -'filedelete-success-old' => 'Message displayed when you succeed in deleting a version of a file. |
| 2029 | +'filedelete-success-old' => 'Message displayed when you succeed in deleting a version of a file. |
2030 | 2030 | * $1 is the name of the media |
2031 | 2031 | * $2 is a date |
2032 | 2032 | * $3 is a hour', |
2033 | | -'filedelete-otherreason' => 'Message used when deleting a file. This is the description field for "Other/additional reason" for deletion. |
| 2033 | +'filedelete-otherreason' => 'Message used when deleting a file. This is the description field for "Other/additional reason" for deletion. |
2034 | 2034 | |
2035 | 2035 | {{Identical|Other/additional reason}}', |
2036 | | -'filedelete-reason-otherlist' => 'Message used as default in the dropdown menu in the form for deleting a file. Keeping this message selected assumes that a reason for deletion is specified in the field below. |
| 2036 | +'filedelete-reason-otherlist' => 'Message used as default in the dropdown menu in the form for deleting a file. Keeping this message selected assumes that a reason for deletion is specified in the field below. |
2037 | 2037 | |
2038 | 2038 | {{Identical|Other reason}}', |
2039 | | -'filedelete-reason-dropdown' => 'Predefined reasons for deleting a file that can be selected in a drop down list. Entries prefixed with one asterisk ("*") are group headers and cannot be selected. Entries prefixed with two asterisks can be selected as reason for deletion.', |
2040 | | -'filedelete-edit-reasonlist' => 'Shown beneath the file deletion form on the right side. It is a link to [[MediaWiki:Filedelete-reason-dropdown]]. |
| 2039 | +'filedelete-reason-dropdown' => 'Predefined reasons for deleting a file that can be selected in a drop down list. Entries prefixed with one asterisk ("*") are group headers and cannot be selected. Entries prefixed with two asterisks can be selected as reason for deletion.', |
| 2040 | +'filedelete-edit-reasonlist' => 'Shown beneath the file deletion form on the right side. It is a link to [[MediaWiki:Filedelete-reason-dropdown]]. |
2041 | 2041 | |
2042 | 2042 | {{Identical|Edit delete reasons}}', |
| 2043 | +'filedelete-maintenance' => 'Content of the error page when $wgUploadMaintenance is set to true.', |
| 2044 | +'filedelete-maintenance-title' => 'Title of the error page when $wgUploadMaintenance is set to true.', |
2043 | 2045 | |
2044 | 2046 | # MIME search |
2045 | 2047 | 'mimesearch' => 'Title of [[Special:MIMESearch]].', |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -2365,23 +2365,24 @@ |
2366 | 2366 | 'filerevert-badversion' => 'There is no previous local version of this file with the provided timestamp.', |
2367 | 2367 | |
2368 | 2368 | # File deletion |
2369 | | -'filedelete' => 'Delete $1', |
2370 | | -'filedelete-legend' => 'Delete file', |
2371 | | -'filedelete-intro' => "You are about to delete the file '''[[Media:$1|$1]]''' along with all of its history.", |
2372 | | -'filedelete-intro-old' => "You are deleting the version of '''[[Media:$1|$1]]''' as of [$4 $3, $2].", |
2373 | | -'filedelete-comment' => 'Reason:', |
2374 | | -'filedelete-submit' => 'Delete', |
2375 | | -'filedelete-success' => "'''$1''' has been deleted.", |
2376 | | -'filedelete-success-old' => "The version of '''[[Media:$1|$1]]''' as of $3, $2 has been deleted.", |
2377 | | -'filedelete-nofile' => "'''$1''' does not exist.", |
2378 | | -'filedelete-nofile-old' => "There is no archived version of '''$1''' with the specified attributes.", |
2379 | | -'filedelete-otherreason' => 'Other/additional reason:', |
2380 | | -'filedelete-reason-otherlist' => 'Other reason', |
2381 | | -'filedelete-reason-dropdown' => '*Common delete reasons |
| 2369 | +'filedelete' => 'Delete $1', |
| 2370 | +'filedelete-legend' => 'Delete file', |
| 2371 | +'filedelete-intro' => "You are about to delete the file '''[[Media:$1|$1]]''' along with all of its history.", |
| 2372 | +'filedelete-intro-old' => "You are deleting the version of '''[[Media:$1|$1]]''' as of [$4 $3, $2].", |
| 2373 | +'filedelete-comment' => 'Reason:', |
| 2374 | +'filedelete-submit' => 'Delete', |
| 2375 | +'filedelete-success' => "'''$1''' has been deleted.", |
| 2376 | +'filedelete-success-old' => "The version of '''[[Media:$1|$1]]''' as of $3, $2 has been deleted.", |
| 2377 | +'filedelete-nofile' => "'''$1''' does not exist.", |
| 2378 | +'filedelete-nofile-old' => "There is no archived version of '''$1''' with the specified attributes.", |
| 2379 | +'filedelete-otherreason' => 'Other/additional reason:', |
| 2380 | +'filedelete-reason-otherlist' => 'Other reason', |
| 2381 | +'filedelete-reason-dropdown' => '*Common delete reasons |
2382 | 2382 | ** Copyright violation |
2383 | 2383 | ** Duplicated file', |
2384 | | -'filedelete-edit-reasonlist' => 'Edit delete reasons', |
2385 | | -'filedelete-maintenance' => 'Deletion and restoration of files temporarily disabled during maintenance.', |
| 2384 | +'filedelete-edit-reasonlist' => 'Edit delete reasons', |
| 2385 | +'filedelete-maintenance' => 'Deletion and restoration of files temporarily disabled during maintenance.', |
| 2386 | +'filedelete-maintenance-title' => 'Cannot delete file', |
2386 | 2387 | |
2387 | 2388 | # MIME search |
2388 | 2389 | 'mimesearch' => 'MIME search', |