Index: trunk/extensions/DeleteBatch/DeleteBatch.body.php |
— | — | @@ -47,13 +47,13 @@ |
48 | 48 | $cSF = new DeleteBatchForm( $par ); |
49 | 49 | |
50 | 50 | $action = $wgRequest->getVal( 'action' ); |
51 | | - if( 'success' == $action ) { |
| 51 | + if ( 'success' == $action ) { |
52 | 52 | /* do something */ |
53 | | - } else if( $wgRequest->wasPosted() && 'submit' == $action && |
| 53 | + } else if ( $wgRequest->wasPosted() && 'submit' == $action && |
54 | 54 | $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
55 | 55 | $cSF->doSubmit(); |
56 | 56 | } else { |
57 | | - $cSF->showForm(''); |
| 57 | + $cSF->showForm( '' ); |
58 | 58 | } |
59 | 59 | } |
60 | 60 | } |
— | — | @@ -102,37 +102,37 @@ |
103 | 103 | $scFile = ''; |
104 | 104 | } |
105 | 105 | |
106 | | - $wgOut->addHTML(" |
| 106 | + $wgOut->addHTML( " |
107 | 107 | <form name=\"deletebatch\" enctype=\"multipart/form-data\" method=\"post\" action=\"{$action}\"> |
108 | 108 | <table border=\"0\"> |
109 | 109 | <tr> |
110 | | - <td align=\"right\">".wfMsg('deletebatch-as')."</td> |
111 | | - <td align=\"left\">"); |
| 110 | + <td align=\"right\">" . wfMsg( 'deletebatch-as' ) . "</td> |
| 111 | + <td align=\"left\">" ); |
112 | 112 | $this->makeSelect( |
113 | 113 | 'wpMode', |
114 | 114 | array( |
115 | | - wfMsg('deletebatch-select-script') => 'script', |
116 | | - wfMsg('deletebatch-select-yourself') => 'you' |
| 115 | + wfMsg( 'deletebatch-select-script' ) => 'script', |
| 116 | + wfMsg( 'deletebatch-select-yourself' ) => 'you' |
117 | 117 | ), |
118 | 118 | $this->mMode, |
119 | 119 | 1 |
120 | 120 | ); |
121 | | - $wgOut->addHTML("</td> |
| 121 | + $wgOut->addHTML( "</td> |
122 | 122 | </tr> |
123 | 123 | <tr> |
124 | | - <td align=\"right\" style=\"vertical-align:top\">".wfMsg('deletebatch-page')."</td> |
| 124 | + <td align=\"right\" style=\"vertical-align:top\">" . wfMsg( 'deletebatch-page' ) . "</td> |
125 | 125 | <td align=\"left\"> |
126 | 126 | <textarea tabindex=\"3\" name=\"wpPage\" id=\"wpPage\" cols=\"40\" rows=\"10\"></textarea> |
127 | 127 | </td> |
128 | 128 | </tr> |
129 | 129 | <tr> |
130 | | - <td align=\"right\">".wfMsg('deletebatch-or')." </td> |
| 130 | + <td align=\"right\">" . wfMsg( 'deletebatch-or' ) . " </td> |
131 | 131 | <td align=\"left\"> |
132 | 132 |   |
133 | 133 | </td> |
134 | 134 | </tr> |
135 | 135 | <tr> |
136 | | - <td align=\"right\">".wfMsg('deletebatch-caption')."</td> |
| 136 | + <td align=\"right\">" . wfMsg( 'deletebatch-caption' ) . "</td> |
137 | 137 | <td align=\"left\"> |
138 | 138 | <input type=\"file\" tabindex=\"4\" name=\"wpFile\" id=\"wpFile\" value=\"{$scFile}\" /> |
139 | 139 | </td> |
— | — | @@ -140,25 +140,25 @@ |
141 | 141 | <tr> |
142 | 142 | <td align=\"right\"> </td> |
143 | 143 | <td align=\"left\"> |
144 | | - <input tabindex=\"5\" name=\"wpdeletebatchSubmit\" type=\"submit\" value=\"".strtoupper( wfMsg( 'delete' ) )."\" /> |
| 144 | + <input tabindex=\"5\" name=\"wpdeletebatchSubmit\" type=\"submit\" value=\"" . wfMsg( 'delete' ) . "\" /> |
145 | 145 | </td> |
146 | 146 | </tr> |
147 | 147 | </table> |
148 | 148 | <input type='hidden' name='wpEditToken' value=\"{$token}\" /> |
149 | | -</form>"); |
| 149 | +</form>" ); |
150 | 150 | } |
151 | 151 | |
152 | 152 | /* draws select and selects it properly */ |
153 | 153 | function makeSelect( $name, $options_array, $current, $tabindex ) { |
154 | 154 | global $wgOut; |
155 | | - $wgOut->addHTML("<select tabindex=\"$tabindex\" name=\"$name\">"); |
156 | | - foreach( $options_array as $key => $value ) { |
157 | | - if( $value == $current ) |
158 | | - $wgOut->addHTML("<option value=\"$value\" selected=\"selected\">$key</option>"); |
| 155 | + $wgOut->addHTML( "<select tabindex=\"$tabindex\" name=\"$name\">" ); |
| 156 | + foreach ( $options_array as $key => $value ) { |
| 157 | + if ( $value == $current ) |
| 158 | + $wgOut->addHTML( "<option value=\"$value\" selected=\"selected\">$key</option>" ); |
159 | 159 | else |
160 | | - $wgOut->addHTML("<option value=\"$value\">$key</option>"); |
| 160 | + $wgOut->addHTML( "<option value=\"$value\">$key</option>" ); |
161 | 161 | } |
162 | | - $wgOut->addHTML("</select>"); |
| 162 | + $wgOut->addHTML( "</select>" ); |
163 | 163 | } |
164 | 164 | |
165 | 165 | /* wraps up multi deletes */ |
— | — | @@ -166,27 +166,27 @@ |
167 | 167 | global $wgUser, $wgOut; |
168 | 168 | |
169 | 169 | /* first, check the file if given */ |
170 | | - if( $filename ) { |
| 170 | + if ( $filename ) { |
171 | 171 | /* both a file and a given page? not too much? */ |
172 | | - if( '' != $this->mPage ) { |
173 | | - $this->showForm( wfMsg('deletebatch-both-modes') ); |
| 172 | + if ( '' != $this->mPage ) { |
| 173 | + $this->showForm( wfMsg( 'deletebatch-both-modes' ) ); |
174 | 174 | return; |
175 | 175 | } |
176 | | - if( "text/plain" != mime_content_type($filename) ) { |
177 | | - $this->showForm( wfMsg('deletebatch-file-bad-format') ); |
| 176 | + if ( "text/plain" != mime_content_type( $filename ) ) { |
| 177 | + $this->showForm( wfMsg( 'deletebatch-file-bad-format' ) ); |
178 | 178 | return; |
179 | 179 | } |
180 | | - $file = fopen($filename, 'r'); |
| 180 | + $file = fopen( $filename, 'r' ); |
181 | 181 | if ( !$file ) { |
182 | | - $this->showForm( wfMsg('deletebatch-file-missing') ); |
| 182 | + $this->showForm( wfMsg( 'deletebatch-file-missing' ) ); |
183 | 183 | return; |
184 | 184 | } |
185 | 185 | } |
186 | 186 | /* switch user if necessary */ |
187 | 187 | $OldUser = $wgUser; |
188 | | - if( 'script' == $this->mMode ) { |
| 188 | + if ( 'script' == $this->mMode ) { |
189 | 189 | $username = 'Delete page script'; |
190 | | - $wgUser = User::newFromName($username); |
| 190 | + $wgUser = User::newFromName( $username ); |
191 | 191 | /* Create the user if necessary */ |
192 | 192 | if ( !$wgUser->getID() ) { |
193 | 193 | $wgUser->addToDatabase(); |
— | — | @@ -195,7 +195,7 @@ |
196 | 196 | |
197 | 197 | /* todo run tests - run many tests */ |
198 | 198 | $dbw = wfGetDB( DB_MASTER ); |
199 | | - if( $filename ) { /* if from filename, delete from filename */ |
| 199 | + if ( $filename ) { /* if from filename, delete from filename */ |
200 | 200 | for ( $linenum = 1; !feof( $file ); $linenum++ ) { |
201 | 201 | $line = trim( fgets( $file ) ); |
202 | 202 | if ( $line == false ) { |
— | — | @@ -205,30 +205,30 @@ |
206 | 206 | the file should contain only "page title|reason"\n lines |
207 | 207 | the rest is trash |
208 | 208 | */ |
209 | | - $arr = explode("|", $line); |
210 | | - is_null($arr[1]) ? $reason = '' : $reason = $arr[1]; |
211 | | - $this->deletePage($arr[0], $reason, $dbw, true, $linenum); |
| 209 | + $arr = explode( "|", $line ); |
| 210 | + is_null( $arr[1] ) ? $reason = '' : $reason = $arr[1]; |
| 211 | + $this->deletePage( $arr[0], $reason, $dbw, true, $linenum ); |
212 | 212 | } |
213 | 213 | } else { |
214 | 214 | /* run through text and do all like it should be */ |
215 | 215 | $lines = explode( "\n", $line ); |
216 | | - foreach( $lines as $single_page ) { |
| 216 | + foreach ( $lines as $single_page ) { |
217 | 217 | /* explode and give me a reason */ |
218 | 218 | $page_data = explode( "|", trim( $single_page ) ); |
219 | | - if( count($page_data) < 2 ) |
| 219 | + if ( count( $page_data ) < 2 ) |
220 | 220 | $page_data[1] = ''; |
221 | | - $result = $this->deletePage($page_data[0], $page_data[1], $dbw, false, 0, $OldUser); |
| 221 | + $result = $this->deletePage( $page_data[0], $page_data[1], $dbw, false, 0, $OldUser ); |
222 | 222 | } |
223 | 223 | } |
224 | 224 | |
225 | 225 | /* restore user back */ |
226 | | - if( 'script' == $this->mMode ) { |
| 226 | + if ( 'script' == $this->mMode ) { |
227 | 227 | $wgUser = $OldUser; |
228 | 228 | } |
229 | 229 | |
230 | 230 | $sk = $wgUser->getSkin(); |
231 | 231 | $titleObj = SpecialPage::getTitleFor( 'DeleteBatch' ); |
232 | | - $link_back = $sk->makeKnownLinkObj( $titleObj, wfMsg('deletebatch-link-back') ); |
| 232 | + $link_back = $sk->linkKnown( $titleObj, wfMsg( 'deletebatch-link-back' ) ); |
233 | 233 | $wgOut->addHTML( "<br /><b>" . $link_back . "</b>" ); |
234 | 234 | } |
235 | 235 | |
— | — | @@ -240,19 +240,19 @@ |
241 | 241 | function deletePage( $line, $reason = '', &$db, $multi = false, $linenum = 0, $user = null ) { |
242 | 242 | global $wgOut, $wgUser; |
243 | 243 | $page = Title::newFromText( $line ); |
244 | | - if( is_null( $page ) ) { /* invalid title? */ |
| 244 | + if ( is_null( $page ) ) { /* invalid title? */ |
245 | 245 | $wgOut->addWikiMsg( 'deletebatch-omitting-invalid', $line ); |
246 | | - if( !$multi ) { |
247 | | - if( !is_null( $user ) ) { |
| 246 | + if ( !$multi ) { |
| 247 | + if ( !is_null( $user ) ) { |
248 | 248 | $wgUser = $user; |
249 | 249 | } |
250 | 250 | } |
251 | 251 | return false; |
252 | 252 | } |
253 | | - if( !$page->exists() ) { /* no such page? */ |
| 253 | + if ( !$page->exists() ) { /* no such page? */ |
254 | 254 | $wgOut->addWikiMsg( 'deletebatch-omitting-nonexistant', $line ); |
255 | | - if( !$multi ) { |
256 | | - if( !is_null( $user ) ) { |
| 255 | + if ( !$multi ) { |
| 256 | + if ( !is_null( $user ) ) { |
257 | 257 | $wgUser = $user; |
258 | 258 | } |
259 | 259 | } |
— | — | @@ -260,24 +260,24 @@ |
261 | 261 | } |
262 | 262 | |
263 | 263 | $db->begin(); |
264 | | - if( NS_MEDIA == $page->getNamespace() ) { |
265 | | - $page = Title::makeTitle( NS_IMAGE, $page->getDBkey() ); |
| 264 | + if ( NS_MEDIA == $page->getNamespace() ) { |
| 265 | + $page = Title::makeTitle( NS_FILE, $page->getDBkey() ); |
266 | 266 | } |
267 | 267 | |
268 | 268 | /* this stuff goes like articleFromTitle in Wiki.php */ |
269 | | - if( $page->getNamespace() == NS_IMAGE ) { |
270 | | - $art = new ImagePage($page); |
| 269 | + if ( $page->getNamespace() == NS_FILE ) { |
| 270 | + $art = new ImagePage( $page ); |
271 | 271 | /*this is absolutely required - creating a new ImagePage object does not automatically |
272 | 272 | provide it with image */ |
273 | 273 | $art->img = new Image( $art->mTitle ); |
274 | 274 | } else { |
275 | | - $art = new Article($page); |
| 275 | + $art = new Article( $page ); |
276 | 276 | } |
277 | 277 | |
278 | 278 | /* what is the generic reason for page deletion? |
279 | 279 | something about the content, I guess... |
280 | 280 | */ |
281 | | - $art->doDelete($reason); |
| 281 | + $art->doDelete( $reason ); |
282 | 282 | $db->commit(); |
283 | 283 | return true; |
284 | 284 | } |
— | — | @@ -286,14 +286,14 @@ |
287 | 287 | function doSubmit() { |
288 | 288 | global $wgOut, $wgUser, $wgRequest, $wgLanguageCode; |
289 | 289 | $wgOut->setPageTitle( wfMsg( 'deletebatch-title' ) ); |
290 | | - if( !$this->mPage && !$this->mFileTemp ) { |
| 290 | + if ( !$this->mPage && !$this->mFileTemp ) { |
291 | 291 | $this->showForm( wfMsg( 'deletebatch-no-page' ) ); |
292 | 292 | return; |
293 | 293 | } |
294 | | - if( $this->mPage ) { |
295 | | - $wgOut->setSubTitle( wfMsg( 'deletebatch-processing-from-form') ); |
| 294 | + if ( $this->mPage ) { |
| 295 | + $wgOut->setSubTitle( wfMsg( 'deletebatch-processing-from-form' ) ); |
296 | 296 | } else { |
297 | | - $wgOut->setSubTitle( wfMsg( 'deletebatch-processing-from-file') ); |
| 297 | + $wgOut->setSubTitle( wfMsg( 'deletebatch-processing-from-file' ) ); |
298 | 298 | } |
299 | 299 | $this->deleteBatch( $this->mUser, $this->mPage, $this->mFileTemp ); |
300 | 300 | } |
Index: trunk/extensions/DeleteBatch/DeleteBatch.php |
— | — | @@ -9,14 +9,14 @@ |
10 | 10 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
11 | 11 | * @link http://www.mediawiki.org/wiki/Extension:DeleteBatch Documentation |
12 | 12 | */ |
13 | | -if( !defined( 'MEDIAWIKI' ) ) |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) |
14 | 14 | die(); |
15 | 15 | |
16 | 16 | // Extension credits that will show up on Special:version |
17 | 17 | $wgExtensionCredits['specialpage'][] = array( |
18 | 18 | 'path' => __FILE__, |
19 | 19 | 'name' => 'Delete Batch', |
20 | | - 'version' => '1.2', |
| 20 | + 'version' => '1.2.1', |
21 | 21 | 'author' => 'Bartek Łapiński', |
22 | 22 | 'url' => 'http://www.mediawiki.org/wiki/Extension:DeleteBatch', |
23 | 23 | 'description' => 'Deletes a batch of pages', |
— | — | @@ -28,10 +28,10 @@ |
29 | 29 | $wgGroupPermissions['bureaucrat']['deletebatch'] = true; |
30 | 30 | |
31 | 31 | // Set up the new special page |
32 | | -$dir = dirname(__FILE__) . '/'; |
| 32 | +$dir = dirname( __FILE__ ) . '/'; |
33 | 33 | $wgExtensionMessagesFiles['DeleteBatch'] = $dir . 'DeleteBatch.i18n.php'; |
34 | 34 | $wgExtensionAliasesFiles['DeleteBatch'] = $dir . 'DeleteBatch.alias.php'; |
35 | | -$wgAutoloadClasses['DeleteBatch'] = $dir. 'DeleteBatch.body.php'; |
| 35 | +$wgAutoloadClasses['DeleteBatch'] = $dir . 'DeleteBatch.body.php'; |
36 | 36 | $wgSpecialPages['DeleteBatch'] = 'DeleteBatch'; |
37 | 37 | // Special page group for MW 1.13+ |
38 | 38 | $wgSpecialPageGroups['DeleteBatch'] = 'pagetools'; |