Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -122,8 +122,8 @@ |
123 | 123 | $text = ''; |
124 | 124 | // For message page not locally set, use the i18n message. |
125 | 125 | // For other non-existent articles, use preload text if any. |
126 | | - if( !$this->mTitle->exists() ) { |
127 | | - if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
| 126 | + if ( !$this->mTitle->exists() ) { |
| 127 | + if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
128 | 128 | $wgMessageCache->loadAllMessages(); |
129 | 129 | # If this is a system message, get the default text. |
130 | 130 | $text = wfMsgWeirdKey( $this->mTitle->getText() ) ; |
— | — | @@ -134,14 +134,14 @@ |
135 | 135 | // For existing pages, get text based on "undo" or section parameters. |
136 | 136 | } else { |
137 | 137 | $text = $this->mArticle->getContent(); |
138 | | - if( $undo > 0 && $undoafter > 0 && $undo < $undoafter ) { |
| 138 | + if ( $undo > 0 && $undoafter > 0 && $undo < $undoafter ) { |
139 | 139 | # If they got undoafter and undo round the wrong way, switch them |
140 | 140 | list( $undo, $undoafter ) = array( $undoafter, $undo ); |
141 | 141 | } |
142 | | - if( $undo > 0 && $undo > $undoafter ) { |
| 142 | + if ( $undo > 0 && $undo > $undoafter ) { |
143 | 143 | # Undoing a specific edit overrides section editing; section-editing |
144 | 144 | # doesn't work with undoing. |
145 | | - if( $undoafter ) { |
| 145 | + if ( $undoafter ) { |
146 | 146 | $undorev = Revision::newFromId($undo); |
147 | 147 | $oldrev = Revision::newFromId($undoafter); |
148 | 148 | } else { |
— | — | @@ -152,7 +152,7 @@ |
153 | 153 | # Sanity check, make sure it's the right page, |
154 | 154 | # the revisions exist and they were not deleted. |
155 | 155 | # Otherwise, $text will be left as-is. |
156 | | - if( !is_null( $undorev ) && !is_null( $oldrev ) && |
| 156 | + if ( !is_null( $undorev ) && !is_null( $oldrev ) && |
157 | 157 | $undorev->getPage() == $oldrev->getPage() && |
158 | 158 | $undorev->getPage() == $this->mArticle->getID() && |
159 | 159 | !$undorev->isDeleted( Revision::DELETED_TEXT ) && |
— | — | @@ -161,19 +161,19 @@ |
162 | 162 | $oldrev_text = $oldrev->getText(); |
163 | 163 | $currev_text = $text; |
164 | 164 | |
165 | | - if( $currev_text != $undorev_text ) { |
| 165 | + if ( $currev_text != $undorev_text ) { |
166 | 166 | $result = wfMerge( $undorev_text, $oldrev_text, $currev_text, $text ); |
167 | 167 | } else { |
168 | 168 | # No use doing a merge if it's just a straight revert. |
169 | 169 | $text = $oldrev_text; |
170 | 170 | $result = true; |
171 | 171 | } |
172 | | - if( $result ) { |
| 172 | + if ( $result ) { |
173 | 173 | # Inform the user of our success and set an automatic edit summary |
174 | 174 | $this->editFormPageTop .= $wgOut->parse( wfMsgNoTrans( 'undo-success' ) ); |
175 | 175 | $firstrev = $oldrev->getNext(); |
176 | 176 | # If we just undid one rev, use an autosummary |
177 | | - if( $firstrev->mId == $undo ) { |
| 177 | + if ( $firstrev->mId == $undo ) { |
178 | 178 | $this->summary = wfMsgForContent('undo-summary', $undo, $undorev->getUserText()); |
179 | 179 | } |
180 | 180 | $this->formtype = 'diff'; |
— | — | @@ -187,8 +187,8 @@ |
188 | 188 | // was created, or we may simply have got bogus input. |
189 | 189 | $this->editFormPageTop .= $wgOut->parse( wfMsgNoTrans( 'undo-norev' ) ); |
190 | 190 | } |
191 | | - } else if( $section != '' ) { |
192 | | - if( $section == 'new' ) { |
| 191 | + } else if ( $section != '' ) { |
| 192 | + if ( $section == 'new' ) { |
193 | 193 | $text = $this->getPreloadedText( $preload ); |
194 | 194 | } else { |
195 | 195 | $text = $wgParser->getSection( $text, $section, $def_text ); |
— | — | @@ -207,13 +207,13 @@ |
208 | 208 | * @return string The contents of the page. |
209 | 209 | */ |
210 | 210 | protected function getPreloadedText( $preload ) { |
211 | | - if( $preload === '' ) { |
| 211 | + if ( $preload === '' ) { |
212 | 212 | return ''; |
213 | 213 | } else { |
214 | 214 | $preloadTitle = Title::newFromText( $preload ); |
215 | | - if( isset( $preloadTitle ) && $preloadTitle->userCanRead() ) { |
| 215 | + if ( isset( $preloadTitle ) && $preloadTitle->userCanRead() ) { |
216 | 216 | $rev = Revision::newFromTitle($preloadTitle); |
217 | | - if( is_object( $rev ) ) { |
| 217 | + if ( is_object( $rev ) ) { |
218 | 218 | $text = $rev->getText(); |
219 | 219 | // TODO FIXME: AAAAAAAAAAA, this shouldn't be implementing |
220 | 220 | // its own mini-parser! -ævar |
— | — | @@ -233,8 +233,8 @@ |
234 | 234 | function extractMetaDataFromArticle () { |
235 | 235 | global $wgUseMetadataEdit , $wgMetadataWhitelist , $wgLang ; |
236 | 236 | $this->mMetaData = '' ; |
237 | | - if( !$wgUseMetadataEdit ) return ; |
238 | | - if( $wgMetadataWhitelist == '' ) return ; |
| 237 | + if ( !$wgUseMetadataEdit ) return ; |
| 238 | + if ( $wgMetadataWhitelist == '' ) return ; |
239 | 239 | $s = '' ; |
240 | 240 | $t = $this->getContent(); |
241 | 241 | |
— | — | @@ -254,10 +254,10 @@ |
255 | 255 | $first = explode ( ':' , $first ) ; |
256 | 256 | $ns = array_shift ( $first ) ; |
257 | 257 | $ns = trim ( str_replace ( '[' , '' , $ns ) ) ; |
258 | | - if( strlen ( $ns ) == 2 OR strtolower ( $ns ) == $catlow ) |
| 258 | + if ( strlen ( $ns ) == 2 OR strtolower ( $ns ) == $catlow ) |
259 | 259 | { |
260 | 260 | $add = '[[' . $ns . ':' . implode ( ':' , $first ) . ']]' ; |
261 | | - if( strtolower ( $ns ) == $catlow ) $cat[] = $add ; |
| 261 | + if ( strtolower ( $ns ) == $catlow ) $cat[] = $add ; |
262 | 262 | else $ll[] = $add ; |
263 | 263 | $x = implode ( ']]' , $y ) ; |
264 | 264 | $t[$key] = $x ; |
— | — | @@ -265,8 +265,8 @@ |
266 | 266 | } |
267 | 267 | } |
268 | 268 | } |
269 | | - if( count ( $cat ) ) $s .= implode ( ' ' , $cat ) . "\n" ; |
270 | | - if( count ( $ll ) ) $s .= implode ( ' ' , $ll ) . "\n" ; |
| 269 | + if ( count ( $cat ) ) $s .= implode ( ' ' , $cat ) . "\n" ; |
| 270 | + if ( count ( $ll ) ) $s .= implode ( ' ' , $ll ) . "\n" ; |
271 | 271 | $t = implode ( "\n" , $t ) ; |
272 | 272 | |
273 | 273 | # Load whitelist |
— | — | @@ -283,7 +283,7 @@ |
284 | 284 | $isentry = true ; |
285 | 285 | $x = trim ( substr ( $x , 1 ) ) ; |
286 | 286 | } |
287 | | - if( $isentry ) |
| 287 | + if ( $isentry ) |
288 | 288 | { |
289 | 289 | $sat[] = strtolower ( $x ) ; |
290 | 290 | } |
— | — | @@ -296,12 +296,12 @@ |
297 | 297 | foreach ( $t AS $key => $x ) |
298 | 298 | { |
299 | 299 | $y = explode ( '}}' , $x , 2 ) ; |
300 | | - if( count ( $y ) == 2 ) |
| 300 | + if ( count ( $y ) == 2 ) |
301 | 301 | { |
302 | 302 | $z = $y[0] ; |
303 | 303 | $z = explode ( '|' , $z ) ; |
304 | 304 | $tn = array_shift ( $z ) ; |
305 | | - if( in_array ( strtolower ( $tn ) , $sat ) ) |
| 305 | + if ( in_array ( strtolower ( $tn ) , $sat ) ) |
306 | 306 | { |
307 | 307 | $tl[] = '{{' . $y[0] . '}}' ; |
308 | 308 | $t[$key] = $y[1] ; |
— | — | @@ -309,10 +309,10 @@ |
310 | 310 | } |
311 | 311 | else $t[$key] = '{{' . $x ; |
312 | 312 | } |
313 | | - else if( $key != 0 ) $t[$key] = '{{' . $x ; |
| 313 | + else if ( $key != 0 ) $t[$key] = '{{' . $x ; |
314 | 314 | else $t[$key] = $x ; |
315 | 315 | } |
316 | | - if( count ( $tl ) ) $s .= implode ( ' ' , $tl ) ; |
| 316 | + if ( count ( $tl ) ) $s .= implode ( ' ' , $tl ) ; |
317 | 317 | $t = implode ( '' , $t ) ; |
318 | 318 | |
319 | 319 | $t = str_replace ( "\n\n\n" , "\n" , $t ) ; |
— | — | @@ -327,13 +327,13 @@ |
328 | 328 | * deletes. |
329 | 329 | */ |
330 | 330 | protected function wasDeletedSinceLastEdit() { |
331 | | - if( $this->deletedSinceEdit ) |
| 331 | + if ( $this->deletedSinceEdit ) |
332 | 332 | return true; |
333 | | - if( $this->mTitle->isDeleted() ) { |
| 333 | + if ( $this->mTitle->isDeleted() ) { |
334 | 334 | $this->lastDelete = $this->getLastDelete(); |
335 | | - if( !is_null($this->lastDelete) ) { |
| 335 | + if ( $this->lastDelete ) { |
336 | 336 | $deletetime = $this->lastDelete->log_timestamp; |
337 | | - if( ($deletetime - $this->starttime) > 0 ) { |
| 337 | + if ( ($deletetime - $this->starttime) > 0 ) { |
338 | 338 | $this->deletedSinceEdit = true; |
339 | 339 | } |
340 | 340 | } |
— | — | @@ -359,7 +359,7 @@ |
360 | 360 | function edit() { |
361 | 361 | global $wgOut, $wgUser, $wgRequest; |
362 | 362 | // Allow extensions to modify/prevent this form or submission |
363 | | - if( !wfRunHooks( 'AlternateEdit', array( &$this ) ) ) { |
| 363 | + if ( !wfRunHooks( 'AlternateEdit', array( &$this ) ) ) { |
364 | 364 | return; |
365 | 365 | } |
366 | 366 | |
— | — | @@ -372,18 +372,18 @@ |
373 | 373 | $this->importFormData( $wgRequest ); |
374 | 374 | $this->firsttime = false; |
375 | 375 | |
376 | | - if( $this->live ) { |
| 376 | + if ( $this->live ) { |
377 | 377 | $this->livePreview(); |
378 | 378 | wfProfileOut( __METHOD__ ); |
379 | 379 | return; |
380 | 380 | } |
381 | 381 | |
382 | | - if( wfReadOnly() ) { |
383 | | - if( $this->save ){ |
| 382 | + if ( wfReadOnly() ) { |
| 383 | + if ( $this->save ){ |
384 | 384 | // Force preview |
385 | 385 | $this->save = false; |
386 | 386 | $this->preview = true; |
387 | | - } elseif( $this->preview || $this->diff ) { |
| 387 | + } elseif ( $this->preview || $this->diff ) { |
388 | 388 | // A warning will be displayed instead |
389 | 389 | } else { |
390 | 390 | $this->readOnlyPage( $this->getContent() ); |
— | — | @@ -393,22 +393,22 @@ |
394 | 394 | } |
395 | 395 | |
396 | 396 | $wgOut->addScriptFile( 'edit.js' ); |
397 | | - |
398 | | - if( $permErrors = $this->getEditPermissionErrors() ) { |
| 397 | + $permErrors = $this->getEditPermissionErrors(); |
| 398 | + if ( $permErrors ) { |
399 | 399 | wfDebug( __METHOD__.": User can't edit\n" ); |
400 | 400 | $this->readOnlyPage( $this->getContent(), true, $permErrors, 'edit' ); |
401 | 401 | wfProfileOut( __METHOD__ ); |
402 | 402 | return; |
403 | 403 | } else { |
404 | | - if( $this->save ) { |
| 404 | + if ( $this->save ) { |
405 | 405 | $this->formtype = 'save'; |
406 | | - } else if( $this->preview ) { |
| 406 | + } else if ( $this->preview ) { |
407 | 407 | $this->formtype = 'preview'; |
408 | | - } else if( $this->diff ) { |
| 408 | + } else if ( $this->diff ) { |
409 | 409 | $this->formtype = 'diff'; |
410 | 410 | } else { # First time through |
411 | 411 | $this->firsttime = true; |
412 | | - if( $this->previewOnOpen() ) { |
| 412 | + if ( $this->previewOnOpen() ) { |
413 | 413 | $this->formtype = 'preview'; |
414 | 414 | } else { |
415 | 415 | $this->extractMetaDataFromArticle () ; |
— | — | @@ -425,29 +425,29 @@ |
426 | 426 | $this->isValidCssJsSubpage = $this->mTitle->isValidCssJsSubpage(); |
427 | 427 | |
428 | 428 | # Show applicable editing introductions |
429 | | - if( $this->formtype == 'initial' || $this->firsttime ) |
| 429 | + if ( $this->formtype == 'initial' || $this->firsttime ) |
430 | 430 | $this->showIntro(); |
431 | 431 | |
432 | | - if( $this->mTitle->isTalkPage() ) { |
| 432 | + if ( $this->mTitle->isTalkPage() ) { |
433 | 433 | $wgOut->addWikiMsg( 'talkpagetext' ); |
434 | 434 | } |
435 | 435 | |
436 | 436 | # Optional notices on a per-namespace and per-page basis |
437 | 437 | $editnotice_ns = 'editnotice-'.$this->mTitle->getNamespace(); |
438 | 438 | $editnotice_page = $editnotice_ns.'-'.$this->mTitle->getDBkey(); |
439 | | - if( !wfEmptyMsg( $editnotice_ns, wfMsgForContent( $editnotice_ns ) ) ) { |
| 439 | + if ( !wfEmptyMsg( $editnotice_ns, wfMsgForContent( $editnotice_ns ) ) ) { |
440 | 440 | $wgOut->addWikiText( wfMsgForContent( $editnotice_ns ) ); |
441 | 441 | } |
442 | | - if( MWNamespace::hasSubpages( $this->mTitle->getNamespace() ) ) { |
| 442 | + if ( MWNamespace::hasSubpages( $this->mTitle->getNamespace() ) ) { |
443 | 443 | $parts = explode( '/', $this->mTitle->getDBkey() ); |
444 | 444 | $editnotice_base = $editnotice_ns; |
445 | 445 | while ( count( $parts ) > 0 ) { |
446 | 446 | $editnotice_base .= '-'.array_shift( $parts ); |
447 | | - if( !wfEmptyMsg( $editnotice_base, wfMsgForContent( $editnotice_base ) ) ) { |
| 447 | + if ( !wfEmptyMsg( $editnotice_base, wfMsgForContent( $editnotice_base ) ) ) { |
448 | 448 | $wgOut->addWikiText( wfMsgForContent( $editnotice_base ) ); |
449 | 449 | } |
450 | 450 | } |
451 | | - } else if( !wfEmptyMsg( $editnotice_page, wfMsgForContent( $editnotice_page ) ) ) { |
| 451 | + } else if ( !wfEmptyMsg( $editnotice_page, wfMsgForContent( $editnotice_page ) ) ) { |
452 | 452 | $wgOut->addWikiText( wfMsgForContent( $editnotice_page ) ); |
453 | 453 | } |
454 | 454 | |
— | — | @@ -456,8 +456,8 @@ |
457 | 457 | # that edit() already checked just in case someone tries to sneak |
458 | 458 | # in the back door with a hand-edited submission URL. |
459 | 459 | |
460 | | - if( 'save' == $this->formtype ) { |
461 | | - if( !$this->attemptSave() ) { |
| 460 | + if ( 'save' == $this->formtype ) { |
| 461 | + if ( !$this->attemptSave() ) { |
462 | 462 | wfProfileOut( __METHOD__."-business-end" ); |
463 | 463 | wfProfileOut( __METHOD__ ); |
464 | 464 | return; |
— | — | @@ -466,14 +466,14 @@ |
467 | 467 | |
468 | 468 | # First time through: get contents, set time for conflict |
469 | 469 | # checking, etc. |
470 | | - if( 'initial' == $this->formtype || $this->firsttime ) { |
471 | | - if( $this->initialiseForm() === false) { |
| 470 | + if ( 'initial' == $this->formtype || $this->firsttime ) { |
| 471 | + if ( $this->initialiseForm() === false) { |
472 | 472 | $this->noSuchSectionPage(); |
473 | 473 | wfProfileOut( __METHOD__."-business-end" ); |
474 | 474 | wfProfileOut( __METHOD__ ); |
475 | 475 | return; |
476 | 476 | } |
477 | | - if( !$this->mTitle->getArticleId() ) |
| 477 | + if ( !$this->mTitle->getArticleId() ) |
478 | 478 | wfRunHooks( 'EditFormPreloadText', array( &$this->textbox1, &$this->mTitle ) ); |
479 | 479 | } |
480 | 480 | |
— | — | @@ -486,14 +486,14 @@ |
487 | 487 | global $wgUser; |
488 | 488 | $permErrors = $this->mTitle->getUserPermissionsErrors( 'edit', $wgUser ); |
489 | 489 | # Can this title be created? |
490 | | - if( !$this->mTitle->exists() ) { |
| 490 | + if ( !$this->mTitle->exists() ) { |
491 | 491 | $permErrors = array_merge( $permErrors, |
492 | 492 | wfArrayDiff2( $this->mTitle->getUserPermissionsErrors( 'create', $wgUser ), $permErrors ) ); |
493 | 493 | } |
494 | 494 | # Ignore some permissions errors when a user is just previewing/viewing diffs |
495 | 495 | $remove = array(); |
496 | 496 | foreach( $permErrors as $error ) { |
497 | | - if( ($this->preview || $this->diff) && |
| 497 | + if ( ($this->preview || $this->diff) && |
498 | 498 | ($error[0] == 'blockedtext' || $error[0] == 'autoblockedtext') ) |
499 | 499 | { |
500 | 500 | $remove[] = $error; |
— | — | @@ -510,7 +510,7 @@ |
511 | 511 | */ |
512 | 512 | function readOnlyPage( $source = null, $protected = false, $reasons = array(), $action = null ) { |
513 | 513 | global $wgRequest, $wgOut; |
514 | | - if( $wgRequest->getBool( 'redlink' ) ) { |
| 514 | + if ( $wgRequest->getBool( 'redlink' ) ) { |
515 | 515 | // The edit page was reached via a red link. |
516 | 516 | // Redirect to the article page and let them click the edit tab if |
517 | 517 | // they really want a permission error. |
— | — | @@ -527,19 +527,19 @@ |
528 | 528 | */ |
529 | 529 | protected function previewOnOpen() { |
530 | 530 | global $wgRequest, $wgUser; |
531 | | - if( $wgRequest->getVal( 'preview' ) == 'yes' ) { |
| 531 | + if ( $wgRequest->getVal( 'preview' ) == 'yes' ) { |
532 | 532 | // Explicit override from request |
533 | 533 | return true; |
534 | | - } elseif( $wgRequest->getVal( 'preview' ) == 'no' ) { |
| 534 | + } elseif ( $wgRequest->getVal( 'preview' ) == 'no' ) { |
535 | 535 | // Explicit override from request |
536 | 536 | return false; |
537 | | - } elseif( $this->section == 'new' ) { |
| 537 | + } elseif ( $this->section == 'new' ) { |
538 | 538 | // Nothing *to* preview for new sections |
539 | 539 | return false; |
540 | | - } elseif( ( $wgRequest->getVal( 'preload' ) !== '' || $this->mTitle->exists() ) && $wgUser->getOption( 'previewonfirst' ) ) { |
| 540 | + } elseif ( ( $wgRequest->getVal( 'preload' ) !== '' || $this->mTitle->exists() ) && $wgUser->getOption( 'previewonfirst' ) ) { |
541 | 541 | // Standard preference behaviour |
542 | 542 | return true; |
543 | | - } elseif( !$this->mTitle->exists() && $this->mTitle->getNamespace() == NS_CATEGORY ) { |
| 543 | + } elseif ( !$this->mTitle->exists() && $this->mTitle->getNamespace() == NS_CATEGORY ) { |
544 | 544 | // Categories are special |
545 | 545 | return true; |
546 | 546 | } else { |
— | — | @@ -559,7 +559,7 @@ |
560 | 560 | # Section edit can come from either the form or a link |
561 | 561 | $this->section = $request->getVal( 'wpSection', $request->getVal( 'section' ) ); |
562 | 562 | |
563 | | - if( $request->wasPosted() ) { |
| 563 | + if ( $request->wasPosted() ) { |
564 | 564 | # These fields need to be checked for encoding. |
565 | 565 | # Also remove trailing whitespace, but don't remove _initial_ |
566 | 566 | # whitespace from the text boxes. This may be significant formatting. |
— | — | @@ -577,7 +577,7 @@ |
578 | 578 | |
579 | 579 | $this->scrolltop = $request->getIntOrNull( 'wpScrolltop' ); |
580 | 580 | |
581 | | - if( is_null( $this->edittime ) ) { |
| 581 | + if ( is_null( $this->edittime ) ) { |
582 | 582 | # If the form is incomplete, force to preview. |
583 | 583 | wfDebug( "$fname: Form data appears to be incomplete\n" ); |
584 | 584 | wfDebug( "POST DATA: " . var_export( $_POST, true ) . "\n" ); |
— | — | @@ -591,13 +591,13 @@ |
592 | 592 | // if we forced preview due to session failure. |
593 | 593 | $this->mTriedSave = !$this->preview; |
594 | 594 | |
595 | | - if( $this->tokenOk( $request ) ) { |
| 595 | + if ( $this->tokenOk( $request ) ) { |
596 | 596 | # Some browsers will not report any submit button |
597 | 597 | # if the user hits enter in the comment box. |
598 | 598 | # The unmarked state will be assumed to be a save, |
599 | 599 | # if the form seems otherwise complete. |
600 | 600 | wfDebug( "$fname: Passed token check.\n" ); |
601 | | - } else if( $this->diff ) { |
| 601 | + } else if ( $this->diff ) { |
602 | 602 | # Failed token check, but only requested "Show Changes". |
603 | 603 | wfDebug( "$fname: Failed token check; Show Changes requested.\n" ); |
604 | 604 | } else { |
— | — | @@ -608,11 +608,11 @@ |
609 | 609 | } |
610 | 610 | } |
611 | 611 | $this->save = !$this->preview && !$this->diff; |
612 | | - if( !preg_match( '/^\d{14}$/', $this->edittime )) { |
| 612 | + if ( !preg_match( '/^\d{14}$/', $this->edittime )) { |
613 | 613 | $this->edittime = null; |
614 | 614 | } |
615 | 615 | |
616 | | - if( !preg_match( '/^\d{14}$/', $this->starttime )) { |
| 616 | + if ( !preg_match( '/^\d{14}$/', $this->starttime )) { |
617 | 617 | $this->starttime = null; |
618 | 618 | } |
619 | 619 | |
— | — | @@ -622,7 +622,7 @@ |
623 | 623 | $this->watchthis = $request->getCheck( 'wpWatchthis' ); |
624 | 624 | |
625 | 625 | # Don't force edit summaries when a user is editing their own user or talk page |
626 | | - if( ( $this->mTitle->mNamespace == NS_USER || $this->mTitle->mNamespace == NS_USER_TALK ) && $this->mTitle->getText() == $wgUser->getName() ) { |
| 626 | + if ( ( $this->mTitle->mNamespace == NS_USER || $this->mTitle->mNamespace == NS_USER_TALK ) && $this->mTitle->getText() == $wgUser->getName() ) { |
627 | 627 | $this->allowBlankSummary = true; |
628 | 628 | } else { |
629 | 629 | $this->allowBlankSummary = $request->getBool( 'wpIgnoreBlankSummary' ); |
— | — | @@ -646,7 +646,7 @@ |
647 | 647 | $this->watchthis = false; |
648 | 648 | $this->recreate = false; |
649 | 649 | |
650 | | - if( $this->section == 'new' && $request->getVal( 'preloadtitle' ) ) { |
| 650 | + if ( $this->section == 'new' && $request->getVal( 'preloadtitle' ) ) { |
651 | 651 | $this->summary = $request->getVal( 'preloadtitle' ); |
652 | 652 | } |
653 | 653 | } |
— | — | @@ -679,30 +679,32 @@ |
680 | 680 | */ |
681 | 681 | protected function showIntro() { |
682 | 682 | global $wgOut, $wgUser; |
683 | | - if( $this->suppressIntro ) { |
| 683 | + if ( $this->suppressIntro ) { |
684 | 684 | return; |
685 | 685 | } |
686 | 686 | # Show a warning message when someone creates/edits a user (talk) page but the user does not exists |
687 | | - if( $this->mTitle->getNamespace() == NS_USER || $this->mTitle->getNamespace() == NS_USER_TALK ) { |
| 687 | + if ( $this->mTitle->getNamespace() == NS_USER || $this->mTitle->getNamespace() == NS_USER_TALK ) { |
688 | 688 | $parts = explode( '/', $this->mTitle->getText(), 2 ); |
689 | 689 | $username = $parts[0]; |
690 | 690 | $id = User::idFromName( $username ); |
691 | 691 | $ip = User::isIP( $username ); |
692 | | - if( $id == 0 && !$ip ) { |
| 692 | + if ( $id == 0 && !$ip ) { |
693 | 693 | $wgOut->wrapWikiMsg( '<div class="mw-userpage-userdoesnotexist error">$1</div>', |
694 | 694 | array( 'userpage-userdoesnotexist', $username ) ); |
695 | 695 | } |
696 | 696 | } |
697 | 697 | # Try to add a custom edit intro, or use the standard one if this is not possible. |
698 | | - if( !$this->showCustomIntro() && !$this->mTitle->exists() ) { |
699 | | - if( $wgUser->isLoggedIn() ) { |
| 698 | + if ( !$this->showCustomIntro() && !$this->mTitle->exists() ) { |
| 699 | + if ( $wgUser->isLoggedIn() ) { |
700 | 700 | $wgOut->wrapWikiMsg( '<div class="mw-newarticletext">$1</div>', 'newarticletext' ); |
701 | 701 | } else { |
702 | 702 | $wgOut->wrapWikiMsg( '<div class="mw-newarticletextanon">$1</div>', 'newarticletextanon' ); |
703 | 703 | } |
704 | 704 | } |
705 | 705 | # Give a notice if the user is editing a deleted page... |
706 | | - $this->showDeletionLog( $wgOut ); |
| 706 | + if ( $this->mTitle->exists() ) { |
| 707 | + $this->showDeletionLog( $wgOut ); |
| 708 | + } |
707 | 709 | } |
708 | 710 | |
709 | 711 | /** |
— | — | @@ -711,9 +713,9 @@ |
712 | 714 | * @return bool |
713 | 715 | */ |
714 | 716 | protected function showCustomIntro() { |
715 | | - if( $this->editintro ) { |
| 717 | + if ( $this->editintro ) { |
716 | 718 | $title = Title::newFromText( $this->editintro ); |
717 | | - if( $title instanceof Title && $title->exists() && $title->userCanRead() ) { |
| 719 | + if ( $title instanceof Title && $title->exists() && $title->userCanRead() ) { |
718 | 720 | global $wgOut; |
719 | 721 | $revision = Revision::newFromTitle( $title ); |
720 | 722 | $wgOut->addWikiTextTitleTidy( $revision->getText(), $this->mTitle ); |
— | — | @@ -738,17 +740,17 @@ |
739 | 741 | wfProfileIn( $fname ); |
740 | 742 | wfProfileIn( "$fname-checks" ); |
741 | 743 | |
742 | | - if( !wfRunHooks( 'EditPage::attemptSave', array( &$this ) ) ) |
| 744 | + if ( !wfRunHooks( 'EditPage::attemptSave', array( &$this ) ) ) |
743 | 745 | { |
744 | 746 | wfDebug( "Hook 'EditPage::attemptSave' aborted article saving" ); |
745 | 747 | return self::AS_HOOK_ERROR; |
746 | 748 | } |
747 | 749 | |
748 | 750 | # Check image redirect |
749 | | - if( $this->mTitle->getNamespace() == NS_IMAGE && |
| 751 | + if ( $this->mTitle->getNamespace() == NS_IMAGE && |
750 | 752 | Title::newFromRedirect( $this->textbox1 ) instanceof Title && |
751 | 753 | !$wgUser->isAllowed( 'upload' ) ) { |
752 | | - if( $wgUser->isAnon() ) { |
| 754 | + if ( $wgUser->isAnon() ) { |
753 | 755 | return self::AS_IMAGE_REDIRECT_ANON; |
754 | 756 | } else { |
755 | 757 | return self::AS_IMAGE_REDIRECT_LOGGED; |
— | — | @@ -756,15 +758,15 @@ |
757 | 759 | } |
758 | 760 | |
759 | 761 | # Reintegrate metadata |
760 | | - if( $this->mMetaData != '' ) $this->textbox1 .= "\n" . $this->mMetaData ; |
| 762 | + if ( $this->mMetaData != '' ) $this->textbox1 .= "\n" . $this->mMetaData ; |
761 | 763 | $this->mMetaData = '' ; |
762 | 764 | |
763 | 765 | # Check for spam |
764 | 766 | $match = self::matchSpamRegex( $this->summary ); |
765 | | - if( $match === false ) { |
| 767 | + if ( $match === false ) { |
766 | 768 | $match = self::matchSpamRegex( $this->textbox1 ); |
767 | 769 | } |
768 | | - if( $match !== false ) { |
| 770 | + if ( $match !== false ) { |
769 | 771 | $result['spam'] = $match; |
770 | 772 | $ip = wfGetIP(); |
771 | 773 | $pdbk = $this->mTitle->getPrefixedDBkey(); |
— | — | @@ -774,31 +776,31 @@ |
775 | 777 | wfProfileOut( $fname ); |
776 | 778 | return self::AS_SPAM_ERROR; |
777 | 779 | } |
778 | | - if( $wgFilterCallback && $wgFilterCallback( $this->mTitle, $this->textbox1, $this->section, $this->hookError, $this->summary ) ) { |
| 780 | + if ( $wgFilterCallback && $wgFilterCallback( $this->mTitle, $this->textbox1, $this->section, $this->hookError, $this->summary ) ) { |
779 | 781 | # Error messages or other handling should be performed by the filter function |
780 | 782 | wfProfileOut( "$fname-checks" ); |
781 | 783 | wfProfileOut( $fname ); |
782 | 784 | return self::AS_FILTERING; |
783 | 785 | } |
784 | | - if( !wfRunHooks( 'EditFilter', array( $this, $this->textbox1, $this->section, &$this->hookError, $this->summary ) ) ) { |
| 786 | + if ( !wfRunHooks( 'EditFilter', array( $this, $this->textbox1, $this->section, &$this->hookError, $this->summary ) ) ) { |
785 | 787 | # Error messages etc. could be handled within the hook... |
786 | 788 | wfProfileOut( "$fname-checks" ); |
787 | 789 | wfProfileOut( $fname ); |
788 | 790 | return self::AS_HOOK_ERROR; |
789 | | - } elseif( $this->hookError != '' ) { |
| 791 | + } elseif ( $this->hookError != '' ) { |
790 | 792 | # ...or the hook could be expecting us to produce an error |
791 | 793 | wfProfileOut( "$fname-checks" ); |
792 | 794 | wfProfileOut( $fname ); |
793 | 795 | return self::AS_HOOK_ERROR_EXPECTED; |
794 | 796 | } |
795 | | - if( $wgUser->isBlockedFrom( $this->mTitle, false ) ) { |
| 797 | + if ( $wgUser->isBlockedFrom( $this->mTitle, false ) ) { |
796 | 798 | # Check block state against master, thus 'false'. |
797 | 799 | wfProfileOut( "$fname-checks" ); |
798 | 800 | wfProfileOut( $fname ); |
799 | 801 | return self::AS_BLOCKED_PAGE_FOR_USER; |
800 | 802 | } |
801 | 803 | $this->kblength = (int)(strlen( $this->textbox1 ) / 1024); |
802 | | - if( $this->kblength > $wgMaxArticleSize ) { |
| 804 | + if ( $this->kblength > $wgMaxArticleSize ) { |
803 | 805 | // Error will be displayed by showEditForm() |
804 | 806 | $this->tooBig = true; |
805 | 807 | wfProfileOut( "$fname-checks" ); |
— | — | @@ -806,8 +808,8 @@ |
807 | 809 | return self::AS_CONTENT_TOO_BIG; |
808 | 810 | } |
809 | 811 | |
810 | | - if( !$wgUser->isAllowed('edit') ) { |
811 | | - if( $wgUser->isAnon() ) { |
| 812 | + if ( !$wgUser->isAllowed('edit') ) { |
| 813 | + if ( $wgUser->isAnon() ) { |
812 | 814 | wfProfileOut( "$fname-checks" ); |
813 | 815 | wfProfileOut( $fname ); |
814 | 816 | return self::AS_READ_ONLY_PAGE_ANON; |
— | — | @@ -819,12 +821,12 @@ |
820 | 822 | } |
821 | 823 | } |
822 | 824 | |
823 | | - if( wfReadOnly() ) { |
| 825 | + if ( wfReadOnly() ) { |
824 | 826 | wfProfileOut( "$fname-checks" ); |
825 | 827 | wfProfileOut( $fname ); |
826 | 828 | return self::AS_READ_ONLY_PAGE; |
827 | 829 | } |
828 | | - if( $wgUser->pingLimiter() ) { |
| 830 | + if ( $wgUser->pingLimiter() ) { |
829 | 831 | wfProfileOut( "$fname-checks" ); |
830 | 832 | wfProfileOut( $fname ); |
831 | 833 | return self::AS_RATE_LIMITED; |
— | — | @@ -832,7 +834,7 @@ |
833 | 835 | |
834 | 836 | # If the article has been deleted while editing, don't save it without |
835 | 837 | # confirmation |
836 | | - if( $this->wasDeletedSinceLastEdit() && !$this->recreate ) { |
| 838 | + if ( $this->wasDeletedSinceLastEdit() && !$this->recreate ) { |
837 | 839 | wfProfileOut( "$fname-checks" ); |
838 | 840 | wfProfileOut( $fname ); |
839 | 841 | return self::AS_ARTICLE_WAS_DELETED; |
— | — | @@ -842,23 +844,23 @@ |
843 | 845 | |
844 | 846 | # If article is new, insert it. |
845 | 847 | $aid = $this->mTitle->getArticleID( GAID_FOR_UPDATE ); |
846 | | - if( 0 == $aid ) { |
| 848 | + if ( 0 == $aid ) { |
847 | 849 | |
848 | 850 | // Late check for create permission, just in case *PARANOIA* |
849 | | - if( !$this->mTitle->userCan( 'create' ) ) { |
| 851 | + if ( !$this->mTitle->userCan( 'create' ) ) { |
850 | 852 | wfDebug( "$fname: no create permission\n" ); |
851 | 853 | wfProfileOut( $fname ); |
852 | 854 | return self::AS_NO_CREATE_PERMISSION; |
853 | 855 | } |
854 | 856 | |
855 | 857 | # Don't save a new article if it's blank. |
856 | | - if( '' == $this->textbox1 ) { |
| 858 | + if ( '' == $this->textbox1 ) { |
857 | 859 | wfProfileOut( $fname ); |
858 | 860 | return self::AS_BLANK_ARTICLE; |
859 | 861 | } |
860 | 862 | |
861 | 863 | // Run post-section-merge edit filter |
862 | | - if( !wfRunHooks( 'EditFilterMerged', array( $this, $this->textbox1, &$this->hookError, $this->summary ) ) ) { |
| 864 | + if ( !wfRunHooks( 'EditFilterMerged', array( $this, $this->textbox1, &$this->hookError, $this->summary ) ) ) { |
863 | 865 | # Error messages etc. could be handled within the hook... |
864 | 866 | wfProfileOut( $fname ); |
865 | 867 | return self::AS_HOOK_ERROR; |
— | — | @@ -880,10 +882,10 @@ |
881 | 883 | |
882 | 884 | wfDebug("timestamp: {$this->mArticle->getTimestamp()}, edittime: {$this->edittime}\n"); |
883 | 885 | |
884 | | - if( $this->mArticle->getTimestamp() != $this->edittime ) { |
| 886 | + if ( $this->mArticle->getTimestamp() != $this->edittime ) { |
885 | 887 | $this->isConflict = true; |
886 | | - if( $this->section == 'new' ) { |
887 | | - if( $this->mArticle->getUserText() == $wgUser->getName() && |
| 888 | + if ( $this->section == 'new' ) { |
| 889 | + if ( $this->mArticle->getUserText() == $wgUser->getName() && |
888 | 890 | $this->mArticle->getComment() == $this->summary ) { |
889 | 891 | // Probably a duplicate submission of a new comment. |
890 | 892 | // This can happen when squid resends a request after |
— | — | @@ -898,7 +900,7 @@ |
899 | 901 | } |
900 | 902 | $userid = $wgUser->getId(); |
901 | 903 | |
902 | | - if( $this->isConflict ) { |
| 904 | + if ( $this->isConflict ) { |
903 | 905 | wfDebug( "EditPage::editForm conflict! getting section '$this->section' for time '$this->edittime' (article time '" . |
904 | 906 | $this->mArticle->getTimestamp() . "')\n" ); |
905 | 907 | $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary, $this->edittime); |
— | — | @@ -907,21 +909,21 @@ |
908 | 910 | wfDebug( "EditPage::editForm getting section '$this->section'\n" ); |
909 | 911 | $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary); |
910 | 912 | } |
911 | | - if( is_null( $text ) ) { |
| 913 | + if ( is_null( $text ) ) { |
912 | 914 | wfDebug( "EditPage::editForm activating conflict; section replace failed.\n" ); |
913 | 915 | $this->isConflict = true; |
914 | 916 | $text = $this->textbox1; |
915 | 917 | } |
916 | 918 | |
917 | 919 | # Suppress edit conflict with self, except for section edits where merging is required. |
918 | | - if( ( $this->section == '' ) && ( 0 != $userid ) && ( $this->mArticle->getUser() == $userid ) ) { |
| 920 | + if ( ( $this->section == '' ) && ( 0 != $userid ) && ( $this->mArticle->getUser() == $userid ) ) { |
919 | 921 | wfDebug( "EditPage::editForm Suppressing edit conflict, same user.\n" ); |
920 | 922 | $this->isConflict = false; |
921 | 923 | } else { |
922 | 924 | # switch from section editing to normal editing in edit conflict |
923 | | - if( $this->isConflict ) { |
| 925 | + if ( $this->isConflict ) { |
924 | 926 | # Attempt merge |
925 | | - if( $this->mergeChangesInto( $text ) ) { |
| 927 | + if ( $this->mergeChangesInto( $text ) ) { |
926 | 928 | // Successful merge! Maybe we should tell the user the good news? |
927 | 929 | $this->isConflict = false; |
928 | 930 | wfDebug( "EditPage::editForm Suppressing edit conflict, successful merge.\n" ); |
— | — | @@ -933,7 +935,7 @@ |
934 | 936 | } |
935 | 937 | } |
936 | 938 | |
937 | | - if( $this->isConflict ) { |
| 939 | + if ( $this->isConflict ) { |
938 | 940 | wfProfileOut( $fname ); |
939 | 941 | return self::AS_CONFLICT_DETECTED; |
940 | 942 | } |
— | — | @@ -941,19 +943,19 @@ |
942 | 944 | $oldtext = $this->mArticle->getContent(); |
943 | 945 | |
944 | 946 | // Run post-section-merge edit filter |
945 | | - if( !wfRunHooks( 'EditFilterMerged', array( $this, $text, &$this->hookError, $this->summary ) ) ) { |
| 947 | + if ( !wfRunHooks( 'EditFilterMerged', array( $this, $text, &$this->hookError, $this->summary ) ) ) { |
946 | 948 | # Error messages etc. could be handled within the hook... |
947 | 949 | wfProfileOut( $fname ); |
948 | 950 | return self::AS_HOOK_ERROR; |
949 | 951 | } |
950 | 952 | |
951 | 953 | # Handle the user preference to force summaries here, but not for null edits |
952 | | - if( $this->section != 'new' && !$this->allowBlankSummary && $wgUser->getOption( 'forceeditsummary') && |
| 954 | + if ( $this->section != 'new' && !$this->allowBlankSummary && $wgUser->getOption( 'forceeditsummary') && |
953 | 955 | 0 != strcmp($oldtext, $text) && |
954 | 956 | !is_object( Title::newFromRedirect( $text ) ) # check if it's not a redirect |
955 | 957 | ) { |
956 | 958 | |
957 | | - if( md5( $this->summary ) == $this->autoSumm ) { |
| 959 | + if ( md5( $this->summary ) == $this->autoSumm ) { |
958 | 960 | $this->missingSummary = true; |
959 | 961 | wfProfileOut( $fname ); |
960 | 962 | return self::AS_SUMMARY_NEEDED; |
— | — | @@ -961,8 +963,8 @@ |
962 | 964 | } |
963 | 965 | |
964 | 966 | # And a similar thing for new sections |
965 | | - if( $this->section == 'new' && !$this->allowBlankSummary && $wgUser->getOption( 'forceeditsummary' ) ) { |
966 | | - if(trim($this->summary) == '') { |
| 967 | + if ( $this->section == 'new' && !$this->allowBlankSummary && $wgUser->getOption( 'forceeditsummary' ) ) { |
| 968 | + if (trim($this->summary) == '') { |
967 | 969 | $this->missingSummary = true; |
968 | 970 | wfProfileOut( $fname ); |
969 | 971 | return self::AS_SUMMARY_NEEDED; |
— | — | @@ -972,26 +974,26 @@ |
973 | 975 | # All's well |
974 | 976 | wfProfileIn( "$fname-sectionanchor" ); |
975 | 977 | $sectionanchor = ''; |
976 | | - if( $this->section == 'new' ) { |
977 | | - if( $this->textbox1 == '' ) { |
| 978 | + if ( $this->section == 'new' ) { |
| 979 | + if ( $this->textbox1 == '' ) { |
978 | 980 | $this->missingComment = true; |
979 | 981 | return self::AS_TEXTBOX_EMPTY; |
980 | 982 | } |
981 | | - if( $this->summary != '' ) { |
| 983 | + if ( $this->summary != '' ) { |
982 | 984 | $sectionanchor = $wgParser->guessSectionNameFromWikiText( $this->summary ); |
983 | 985 | # This is a new section, so create a link to the new section |
984 | 986 | # in the revision summary. |
985 | 987 | $cleanSummary = $wgParser->stripSectionName( $this->summary ); |
986 | 988 | $this->summary = wfMsgForContent( 'newsectionsummary', $cleanSummary ); |
987 | 989 | } |
988 | | - } elseif( $this->section != '' ) { |
| 990 | + } elseif ( $this->section != '' ) { |
989 | 991 | # Try to get a section anchor from the section source, redirect to edited section if header found |
990 | 992 | # XXX: might be better to integrate this into Article::replaceSection |
991 | 993 | # for duplicate heading checking and maybe parsing |
992 | 994 | $hasmatch = preg_match( "/^ *([=]{1,6})(.*?)(\\1) *\\n/i", $this->textbox1, $matches ); |
993 | 995 | # we can't deal with anchors, includes, html etc in the header for now, |
994 | 996 | # headline would need to be parsed to improve this |
995 | | - if( $hasmatch and strlen($matches[2]) > 0 ) { |
| 997 | + if ( $hasmatch and strlen($matches[2]) > 0 ) { |
996 | 998 | $sectionanchor = $wgParser->guessSectionNameFromWikiText( $matches[2] ); |
997 | 999 | } |
998 | 1000 | } |
— | — | @@ -1006,14 +1008,14 @@ |
1007 | 1009 | |
1008 | 1010 | // Check for length errors again now that the section is merged in |
1009 | 1011 | $this->kblength = (int)(strlen( $text ) / 1024); |
1010 | | - if( $this->kblength > $wgMaxArticleSize ) { |
| 1012 | + if ( $this->kblength > $wgMaxArticleSize ) { |
1011 | 1013 | $this->tooBig = true; |
1012 | 1014 | wfProfileOut( $fname ); |
1013 | 1015 | return self::AS_MAX_ARTICLE_SIZE_EXCEEDED; |
1014 | 1016 | } |
1015 | 1017 | |
1016 | 1018 | # update the article here |
1017 | | - if( $this->mArticle->updateArticle( $text, $this->summary, $this->minoredit, |
| 1019 | + if ( $this->mArticle->updateArticle( $text, $this->summary, $this->minoredit, |
1018 | 1020 | $this->watchthis, $bot, $sectionanchor ) ) { |
1019 | 1021 | wfProfileOut( $fname ); |
1020 | 1022 | return self::AS_SUCCESS_UPDATE; |
— | — | @@ -1030,12 +1032,12 @@ |
1031 | 1033 | */ |
1032 | 1034 | public static function matchSpamRegex( $text ) { |
1033 | 1035 | global $wgSpamRegex; |
1034 | | - if( $wgSpamRegex ) { |
| 1036 | + if ( $wgSpamRegex ) { |
1035 | 1037 | // For back compatibility, $wgSpamRegex may be a single string or an array of regexes. |
1036 | 1038 | $regexes = (array)$wgSpamRegex; |
1037 | 1039 | foreach( $regexes as $regex ) { |
1038 | 1040 | $matches = array(); |
1039 | | - if( preg_match( $regex, $text, $matches ) ) { |
| 1041 | + if ( preg_match( $regex, $text, $matches ) ) { |
1040 | 1042 | return $matches[0]; |
1041 | 1043 | } |
1042 | 1044 | } |
— | — | @@ -1050,9 +1052,9 @@ |
1051 | 1053 | function initialiseForm() { |
1052 | 1054 | $this->edittime = $this->mArticle->getTimestamp(); |
1053 | 1055 | $this->textbox1 = $this->getContent(false); |
1054 | | - if( $this->textbox1 === false) return false; |
| 1056 | + if ( $this->textbox1 === false) return false; |
1055 | 1057 | |
1056 | | - if( !$this->mArticle->exists() && $this->mTitle->getNamespace() == NS_MEDIAWIKI ) |
| 1058 | + if ( !$this->mArticle->exists() && $this->mTitle->getNamespace() == NS_MEDIAWIKI ) |
1057 | 1059 | $this->textbox1 = wfMsgWeirdKey( $this->mTitle->getText() ); |
1058 | 1060 | wfProxyCheck(); |
1059 | 1061 | return true; |
— | — | @@ -1061,17 +1063,17 @@ |
1062 | 1064 | function setHeaders() { |
1063 | 1065 | global $wgOut, $wgTitle; |
1064 | 1066 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
1065 | | - if( $this->formtype == 'preview' ) { |
| 1067 | + if ( $this->formtype == 'preview' ) { |
1066 | 1068 | $wgOut->setPageTitleActionText( wfMsg( 'preview' ) ); |
1067 | 1069 | } |
1068 | | - if( $this->isConflict ) { |
| 1070 | + if ( $this->isConflict ) { |
1069 | 1071 | $wgOut->setPageTitle( wfMsg( 'editconflict', $wgTitle->getPrefixedText() ) ); |
1070 | | - } elseif( $this->section != '' ) { |
| 1072 | + } elseif ( $this->section != '' ) { |
1071 | 1073 | $msg = $this->section == 'new' ? 'editingcomment' : 'editingsection'; |
1072 | 1074 | $wgOut->setPageTitle( wfMsg( $msg, $wgTitle->getPrefixedText() ) ); |
1073 | 1075 | } else { |
1074 | 1076 | # Use the title defined by DISPLAYTITLE magic word when present |
1075 | | - if( isset($this->mParserOutput) |
| 1077 | + if ( isset($this->mParserOutput) |
1076 | 1078 | && ( $dt = $this->mParserOutput->getDisplayTitle() ) !== false ) { |
1077 | 1079 | $title = $dt; |
1078 | 1080 | } else { |
— | — | @@ -1094,7 +1096,7 @@ |
1095 | 1097 | # Some hook probably called this function without checking |
1096 | 1098 | # for is_null($wgTitle) first. Bail out right here so we don't |
1097 | 1099 | # do lots of work just to discard it right after. |
1098 | | - if(is_null($wgTitle)) |
| 1100 | + if (is_null($wgTitle)) |
1099 | 1101 | return; |
1100 | 1102 | |
1101 | 1103 | $fname = 'EditPage::showEditForm'; |
— | — | @@ -1109,7 +1111,7 @@ |
1110 | 1112 | #we parse this near the beginning so that setHeaders can do the title |
1111 | 1113 | #setting work instead of leaving it in getPreviewText |
1112 | 1114 | $previewOutput = ''; |
1113 | | - if( $this->formtype == 'preview' ) { |
| 1115 | + if ( $this->formtype == 'preview' ) { |
1114 | 1116 | $previewOutput = $this->getPreviewText(); |
1115 | 1117 | } |
1116 | 1118 | |
— | — | @@ -1118,20 +1120,20 @@ |
1119 | 1121 | # Enabled article-related sidebar, toplinks, etc. |
1120 | 1122 | $wgOut->setArticleRelated( true ); |
1121 | 1123 | |
1122 | | - if( $this->isConflict ) { |
| 1124 | + if ( $this->isConflict ) { |
1123 | 1125 | $wgOut->addWikiMsg( 'explainconflict' ); |
1124 | 1126 | |
1125 | 1127 | $this->textbox2 = $this->textbox1; |
1126 | 1128 | $this->textbox1 = $this->getContent(); |
1127 | 1129 | $this->edittime = $this->mArticle->getTimestamp(); |
1128 | 1130 | } else { |
1129 | | - if( $this->section != '' && $this->section != 'new' ) { |
| 1131 | + if ( $this->section != '' && $this->section != 'new' ) { |
1130 | 1132 | $matches = array(); |
1131 | | - if( !$this->summary && !$this->preview && !$this->diff ) { |
| 1133 | + if ( !$this->summary && !$this->preview && !$this->diff ) { |
1132 | 1134 | preg_match( "/^(=+)(.+)\\1/mi", |
1133 | 1135 | $this->textbox1, |
1134 | 1136 | $matches ); |
1135 | | - if( !empty( $matches[2] ) ) { |
| 1137 | + if ( !empty( $matches[2] ) ) { |
1136 | 1138 | global $wgParser; |
1137 | 1139 | $this->summary = "/* " . |
1138 | 1140 | $wgParser->stripSectionName(trim($matches[2])) . |
— | — | @@ -1140,49 +1142,49 @@ |
1141 | 1143 | } |
1142 | 1144 | } |
1143 | 1145 | |
1144 | | - if( $this->missingComment ) { |
| 1146 | + if ( $this->missingComment ) { |
1145 | 1147 | $wgOut->wrapWikiMsg( '<div id="mw-missingcommenttext">$1</div>', 'missingcommenttext' ); |
1146 | 1148 | } |
1147 | 1149 | |
1148 | | - if( $this->missingSummary && $this->section != 'new' ) { |
| 1150 | + if ( $this->missingSummary && $this->section != 'new' ) { |
1149 | 1151 | $wgOut->wrapWikiMsg( '<div id="mw-missingsummary">$1</div>', 'missingsummary' ); |
1150 | 1152 | } |
1151 | 1153 | |
1152 | | - if( $this->missingSummary && $this->section == 'new' ) { |
| 1154 | + if ( $this->missingSummary && $this->section == 'new' ) { |
1153 | 1155 | $wgOut->wrapWikiMsg( '<div id="mw-missingcommentheader">$1</div>', 'missingcommentheader' ); |
1154 | 1156 | } |
1155 | 1157 | |
1156 | | - if( $this->hookError !== '' ) { |
| 1158 | + if ( $this->hookError !== '' ) { |
1157 | 1159 | $wgOut->addWikiText( $this->hookError ); |
1158 | 1160 | } |
1159 | 1161 | |
1160 | | - if( !$this->checkUnicodeCompliantBrowser() ) { |
| 1162 | + if ( !$this->checkUnicodeCompliantBrowser() ) { |
1161 | 1163 | $wgOut->addWikiMsg( 'nonunicodebrowser' ); |
1162 | 1164 | } |
1163 | | - if( isset( $this->mArticle ) && isset( $this->mArticle->mRevision ) ) { |
| 1165 | + if ( isset( $this->mArticle ) && isset( $this->mArticle->mRevision ) ) { |
1164 | 1166 | // Let sysop know that this will make private content public if saved |
1165 | 1167 | |
1166 | | - if( !$this->mArticle->mRevision->userCan( Revision::DELETED_TEXT ) ) { |
| 1168 | + if ( !$this->mArticle->mRevision->userCan( Revision::DELETED_TEXT ) ) { |
1167 | 1169 | $wgOut->addWikiMsg( 'rev-deleted-text-permission' ); |
1168 | | - } else if( $this->mArticle->mRevision->isDeleted( Revision::DELETED_TEXT ) ) { |
| 1170 | + } else if ( $this->mArticle->mRevision->isDeleted( Revision::DELETED_TEXT ) ) { |
1169 | 1171 | $wgOut->addWikiMsg( 'rev-deleted-text-view' ); |
1170 | 1172 | } |
1171 | 1173 | |
1172 | | - if( !$this->mArticle->mRevision->isCurrent() ) { |
| 1174 | + if ( !$this->mArticle->mRevision->isCurrent() ) { |
1173 | 1175 | $this->mArticle->setOldSubtitle( $this->mArticle->mRevision->getId() ); |
1174 | 1176 | $wgOut->addWikiMsg( 'editingold' ); |
1175 | 1177 | } |
1176 | 1178 | } |
1177 | 1179 | } |
1178 | 1180 | |
1179 | | - if( wfReadOnly() ) { |
| 1181 | + if ( wfReadOnly() ) { |
1180 | 1182 | $wgOut->wrapWikiMsg( "<div id=\"mw-read-only-warning\">\n$1\n</div>", array( 'readonlywarning', wfReadOnlyReason() ) ); |
1181 | | - } elseif( $wgUser->isAnon() && $this->formtype != 'preview' ) { |
| 1183 | + } elseif ( $wgUser->isAnon() && $this->formtype != 'preview' ) { |
1182 | 1184 | $wgOut->wrapWikiMsg( '<div id="mw-anon-edit-warning">$1</div>', 'anoneditwarning' ); |
1183 | 1185 | } else { |
1184 | | - if( $this->isCssJsSubpage && $this->formtype != 'preview' ) { |
| 1186 | + if ( $this->isCssJsSubpage && $this->formtype != 'preview' ) { |
1185 | 1187 | # Check the skin exists |
1186 | | - if( $this->isValidCssJsSubpage ) { |
| 1188 | + if ( $this->isValidCssJsSubpage ) { |
1187 | 1189 | $wgOut->addWikiMsg( 'usercssjsyoucanpreview' ); |
1188 | 1190 | } else { |
1189 | 1191 | $wgOut->addWikiMsg( 'userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage() ); |
— | — | @@ -1191,12 +1193,12 @@ |
1192 | 1194 | } |
1193 | 1195 | |
1194 | 1196 | $classes = array(); // Textarea CSS |
1195 | | - if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
| 1197 | + if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
1196 | 1198 | # Show a warning if editing an interface message |
1197 | 1199 | $wgOut->addWikiMsg( 'editinginterface' ); |
1198 | | - } elseif( $this->mTitle->isProtected( 'edit' ) ) { |
| 1200 | + } elseif ( $this->mTitle->isProtected( 'edit' ) ) { |
1199 | 1201 | # Is the title semi-protected? |
1200 | | - if( $this->mTitle->isSemiProtected() ) { |
| 1202 | + if ( $this->mTitle->isSemiProtected() ) { |
1201 | 1203 | $noticeMsg = 'semiprotectedpagewarning'; |
1202 | 1204 | $classes[] = 'mw-textarea-sprotected'; |
1203 | 1205 | } else { |
— | — | @@ -1209,11 +1211,11 @@ |
1210 | 1212 | LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle->getPrefixedText(), '', 1 ); |
1211 | 1213 | $wgOut->addHTML( "</div>\n" ); |
1212 | 1214 | } |
1213 | | - if( $this->mTitle->isCascadeProtected() ) { |
| 1215 | + if ( $this->mTitle->isCascadeProtected() ) { |
1214 | 1216 | # Is this page under cascading protection from some source pages? |
1215 | 1217 | list($cascadeSources, /* $restrictions */) = $this->mTitle->getCascadeProtectionSources(); |
1216 | 1218 | $notice = "$1\n"; |
1217 | | - if( count($cascadeSources) > 0 ) { |
| 1219 | + if ( count($cascadeSources) > 0 ) { |
1218 | 1220 | # Explain, and list the titles responsible |
1219 | 1221 | foreach( $cascadeSources as $page ) { |
1220 | 1222 | $notice .= '* [[:' . $page->getPrefixedText() . "]]\n"; |
— | — | @@ -1221,25 +1223,25 @@ |
1222 | 1224 | } |
1223 | 1225 | $wgOut->wrapWikiMsg( $notice, array( 'cascadeprotectedwarning', count($cascadeSources) ) ); |
1224 | 1226 | } |
1225 | | - if( !$this->mTitle->exists() && ( $createRestrictions = $this->mTitle->getRestrictions( 'create' ) ) != array() ){ |
1226 | | - $wgOut->addWikiMsgArray( 'titleprotectedwarning', $createRestrictions ); |
| 1227 | + if ( !$this->mTitle->exists() && $this->mTitle->getRestrictions( 'create' ) ) { |
| 1228 | + $wgOut->addWikiMsg( 'titleprotectedwarning' ); |
1227 | 1229 | } |
1228 | 1230 | |
1229 | | - if( $this->kblength === false ) { |
| 1231 | + if ( $this->kblength === false ) { |
1230 | 1232 | $this->kblength = (int)(strlen( $this->textbox1 ) / 1024); |
1231 | 1233 | } |
1232 | | - if( $this->tooBig || $this->kblength > $wgMaxArticleSize ) { |
| 1234 | + if ( $this->tooBig || $this->kblength > $wgMaxArticleSize ) { |
1233 | 1235 | $wgOut->addHTML( "<div id='mw-edit-longpageerror'>\n" ); |
1234 | 1236 | $wgOut->addWikiMsg( 'longpageerror', $wgLang->formatNum( $this->kblength ), $wgLang->formatNum( $wgMaxArticleSize ) ); |
1235 | 1237 | $wgOut->addHTML( "</div>\n" ); |
1236 | | - } elseif( $this->kblength > 29 ) { |
| 1238 | + } elseif ( $this->kblength > 29 ) { |
1237 | 1239 | $wgOut->addHTML( "<div id='mw-edit-longpagewarning'>\n" ); |
1238 | 1240 | $wgOut->addWikiMsg( 'longpagewarning', $wgLang->formatNum( $this->kblength ) ); |
1239 | 1241 | $wgOut->addHTML( "</div>\n" ); |
1240 | 1242 | } |
1241 | 1243 | |
1242 | 1244 | $q = 'action='.$this->action; |
1243 | | - #if( "no" == $redirect ) { $q .= "&redirect=no"; } |
| 1245 | + #if ( "no" == $redirect ) { $q .= "&redirect=no"; } |
1244 | 1246 | $action = $wgTitle->escapeLocalURL( $q ); |
1245 | 1247 | |
1246 | 1248 | $colonSep = wfMsg( 'colon-separator' ); |
— | — | @@ -1254,7 +1256,7 @@ |
1255 | 1257 | htmlspecialchars( wfMsg( 'newwindow' ) ); |
1256 | 1258 | |
1257 | 1259 | global $wgRightsText; |
1258 | | - if( $wgRightsText ) { |
| 1260 | + if ( $wgRightsText ) { |
1259 | 1261 | $copywarnMsg = array( 'copyrightwarning', |
1260 | 1262 | '[[' . wfMsgForContent( 'copyrightpage' ) . ']]', |
1261 | 1263 | $wgRightsText ); |
— | — | @@ -1263,7 +1265,7 @@ |
1264 | 1266 | '[[' . wfMsgForContent( 'copyrightpage' ) . ']]' ); |
1265 | 1267 | } |
1266 | 1268 | |
1267 | | - if( $wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage ) { |
| 1269 | + if ( $wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage ) { |
1268 | 1270 | # prepare toolbar for edit buttons |
1269 | 1271 | $toolbar = EditPage::getEditToolbar(); |
1270 | 1272 | } else { |
— | — | @@ -1271,25 +1273,25 @@ |
1272 | 1274 | } |
1273 | 1275 | |
1274 | 1276 | // activate checkboxes if user wants them to be always active |
1275 | | - if( !$this->preview && !$this->diff ) { |
| 1277 | + if ( !$this->preview && !$this->diff ) { |
1276 | 1278 | # Sort out the "watch" checkbox |
1277 | | - if( $wgUser->getOption( 'watchdefault' ) ) { |
| 1279 | + if ( $wgUser->getOption( 'watchdefault' ) ) { |
1278 | 1280 | # Watch all edits |
1279 | 1281 | $this->watchthis = true; |
1280 | | - } elseif( $wgUser->getOption( 'watchcreations' ) && !$this->mTitle->exists() ) { |
| 1282 | + } elseif ( $wgUser->getOption( 'watchcreations' ) && !$this->mTitle->exists() ) { |
1281 | 1283 | # Watch creations |
1282 | 1284 | $this->watchthis = true; |
1283 | | - } elseif( $this->mTitle->userIsWatching() ) { |
| 1285 | + } elseif ( $this->mTitle->userIsWatching() ) { |
1284 | 1286 | # Already watched |
1285 | 1287 | $this->watchthis = true; |
1286 | 1288 | } |
1287 | 1289 | |
1288 | | - if( $wgUser->getOption( 'minordefault' ) ) $this->minoredit = true; |
| 1290 | + if ( $wgUser->getOption( 'minordefault' ) ) $this->minoredit = true; |
1289 | 1291 | } |
1290 | 1292 | |
1291 | 1293 | $wgOut->addHTML( $this->editFormPageTop ); |
1292 | 1294 | |
1293 | | - if( $wgUser->getOption( 'previewontop' ) ) { |
| 1295 | + if ( $wgUser->getOption( 'previewontop' ) ) { |
1294 | 1296 | $this->displayPreviewArea( $previewOutput, true ); |
1295 | 1297 | } |
1296 | 1298 | |
— | — | @@ -1308,10 +1310,10 @@ |
1309 | 1311 | # For a bit more sophisticated detection of blank summaries, hash the |
1310 | 1312 | # automatic one and pass that in the hidden field wpAutoSummary. |
1311 | 1313 | $summaryhiddens = ''; |
1312 | | - if( $this->missingSummary ) $summaryhiddens .= Xml::hidden( 'wpIgnoreBlankSummary', true ); |
| 1314 | + if ( $this->missingSummary ) $summaryhiddens .= Xml::hidden( 'wpIgnoreBlankSummary', true ); |
1313 | 1315 | $autosumm = $this->autoSumm ? $this->autoSumm : md5( $this->summary ); |
1314 | 1316 | $summaryhiddens .= Xml::hidden( 'wpAutoSummary', $autosumm ); |
1315 | | - if( $this->section == 'new' ) { |
| 1317 | + if ( $this->section == 'new' ) { |
1316 | 1318 | $commentsubject="<span id='wpSummaryLabel'><label for='wpSummary'>{$subject}</label></span>\n<input tabindex='1' type='text' value=\"$summarytext\" name='wpSummary' id='wpSummary' maxlength='200' size='60' />{$summaryhiddens}<br />"; |
1317 | 1319 | $editsummary = "<div class='editOptions'>\n"; |
1318 | 1320 | global $wgParser; |
— | — | @@ -1326,7 +1328,7 @@ |
1327 | 1329 | } |
1328 | 1330 | |
1329 | 1331 | # Set focus to the edit box on load, except on preview or diff, where it would interfere with the display |
1330 | | - if( !$this->preview && !$this->diff ) { |
| 1332 | + if ( !$this->preview && !$this->diff ) { |
1331 | 1333 | $wgOut->setOnloadHandler( 'document.editform.wpTextbox1.focus()' ); |
1332 | 1334 | } |
1333 | 1335 | $templates = $this->getTemplates(); |
— | — | @@ -1336,13 +1338,13 @@ |
1337 | 1339 | $formattedhiddencats = $sk->formatHiddenCategories( $hiddencats ); |
1338 | 1340 | |
1339 | 1341 | global $wgUseMetadataEdit ; |
1340 | | - if( $wgUseMetadataEdit ) { |
| 1342 | + if ( $wgUseMetadataEdit ) { |
1341 | 1343 | $metadata = $this->mMetaData ; |
1342 | 1344 | $metadata = htmlspecialchars( $wgContLang->recodeForEdit( $metadata ) ) ; |
1343 | 1345 | $top = wfMsgWikiHtml( 'metadata_help' ); |
1344 | 1346 | /* ToDo: Replace with clean code */ |
1345 | 1347 | $ew = $wgUser->getOption( 'editwidth' ); |
1346 | | - if( $ew ) $ew = " style=\"width:100%\""; |
| 1348 | + if ( $ew ) $ew = " style=\"width:100%\""; |
1347 | 1349 | else $ew = ''; |
1348 | 1350 | /* /ToDo */ |
1349 | 1351 | $metadata = $top . "<textarea name='metadata' rows='3' cols='{$cols}'{$ew}>{$metadata}</textarea>" ; |
— | — | @@ -1350,8 +1352,8 @@ |
1351 | 1353 | else $metadata = "" ; |
1352 | 1354 | |
1353 | 1355 | $recreate = ''; |
1354 | | - if( $this->wasDeletedSinceLastEdit() ) { |
1355 | | - if( 'save' != $this->formtype ) { |
| 1356 | + if ( $this->wasDeletedSinceLastEdit() ) { |
| 1357 | + if ( 'save' != $this->formtype ) { |
1356 | 1358 | $wgOut->addWikiMsg('deletedwhileediting'); |
1357 | 1359 | } else { |
1358 | 1360 | // Hide the toolbar and edit area, use can click preview to get it back |
— | — | @@ -1383,7 +1385,7 @@ |
1384 | 1386 | END |
1385 | 1387 | ); |
1386 | 1388 | |
1387 | | - if( is_callable( $formCallback ) ) { |
| 1389 | + if ( is_callable( $formCallback ) ) { |
1388 | 1390 | call_user_func_array( $formCallback, array( &$wgOut ) ); |
1389 | 1391 | } |
1390 | 1392 | |
— | — | @@ -1447,7 +1449,7 @@ |
1448 | 1450 | END |
1449 | 1451 | ); |
1450 | 1452 | |
1451 | | - if( $this->isConflict && wfRunHooks( 'EditPageBeforeConflictDiff', array( &$this, &$wgOut ) ) ) { |
| 1453 | + if ( $this->isConflict && wfRunHooks( 'EditPageBeforeConflictDiff', array( &$this, &$wgOut ) ) ) { |
1452 | 1454 | $wgOut->wrapWikiMsg( '==$1==', "yourdiff" ); |
1453 | 1455 | |
1454 | 1456 | $de = new DifferenceEngine( $this->mTitle ); |
— | — | @@ -1459,7 +1461,7 @@ |
1460 | 1462 | } |
1461 | 1463 | $wgOut->addHTML( $this->editFormTextBottom ); |
1462 | 1464 | $wgOut->addHTML( "</form>\n" ); |
1463 | | - if( !$wgUser->getOption( 'previewontop' ) ) { |
| 1465 | + if ( !$wgUser->getOption( 'previewontop' ) ) { |
1464 | 1466 | $this->displayPreviewArea( $previewOutput, false ); |
1465 | 1467 | } |
1466 | 1468 | |
— | — | @@ -1478,9 +1480,9 @@ |
1479 | 1481 | protected function showTextbox1( $classes ) { |
1480 | 1482 | $attribs = array( 'tabindex' => 1 ); |
1481 | 1483 | |
1482 | | - if( $this->wasDeletedSinceLastEdit() ) |
| 1484 | + if ( $this->wasDeletedSinceLastEdit() ) |
1483 | 1485 | $attribs['type'] = 'hidden'; |
1484 | | - if( !empty($classes) ) |
| 1486 | + if ( !empty($classes) ) |
1485 | 1487 | $attribs['class'] = implode(' ',$classes); |
1486 | 1488 | |
1487 | 1489 | $this->showTextbox( $this->textbox1, 'wpTextbox1', $attribs ); |
— | — | @@ -1494,7 +1496,7 @@ |
1495 | 1497 | global $wgOut, $wgUser; |
1496 | 1498 | |
1497 | 1499 | $wikitext = $this->safeUnicodeOutput( $content ); |
1498 | | - if( $wikitext !== '' ) { |
| 1500 | + if ( $wikitext !== '' ) { |
1499 | 1501 | // Ensure there's a newline at the end, otherwise adding lines |
1500 | 1502 | // is awkward. |
1501 | 1503 | // But don't add a newline if the ext is empty, or Firefox in XHTML |
— | — | @@ -1505,7 +1507,7 @@ |
1506 | 1508 | $attribs['accesskey'] = ','; |
1507 | 1509 | $attribs['id'] = $name; |
1508 | 1510 | |
1509 | | - if( $wgUser->getOption( 'editwidth' ) ) |
| 1511 | + if ( $wgUser->getOption( 'editwidth' ) ) |
1510 | 1512 | $attribs['style'] = 'width: 100%'; |
1511 | 1513 | |
1512 | 1514 | $wgOut->addHTML( Xml::textarea( |
— | — | @@ -1518,23 +1520,23 @@ |
1519 | 1521 | protected function displayPreviewArea( $previewOutput, $isOnTop = false ) { |
1520 | 1522 | global $wgOut; |
1521 | 1523 | $classes = array(); |
1522 | | - if( $isOnTop ) |
| 1524 | + if ( $isOnTop ) |
1523 | 1525 | $classes[] = 'ontop'; |
1524 | 1526 | |
1525 | 1527 | $attribs = array( 'id' => 'wikiPreview', 'class' => implode( ' ', $classes ) ); |
1526 | 1528 | |
1527 | | - if( $this->formtype != 'preview' ) |
| 1529 | + if ( $this->formtype != 'preview' ) |
1528 | 1530 | $attribs['style'] = 'display: none;'; |
1529 | 1531 | |
1530 | 1532 | $wgOut->addHTML( Xml::openElement( 'div', $attribs ) ); |
1531 | 1533 | |
1532 | | - if( $this->formtype == 'preview' ) { |
| 1534 | + if ( $this->formtype == 'preview' ) { |
1533 | 1535 | $this->showPreview( $previewOutput ); |
1534 | 1536 | } |
1535 | 1537 | |
1536 | 1538 | $wgOut->addHTML( '</div>' ); |
1537 | 1539 | |
1538 | | - if( $this->formtype == 'diff') { |
| 1540 | + if ( $this->formtype == 'diff') { |
1539 | 1541 | $this->showDiff(); |
1540 | 1542 | } |
1541 | 1543 | } |
— | — | @@ -1547,14 +1549,14 @@ |
1548 | 1550 | */ |
1549 | 1551 | protected function showPreview( $text ) { |
1550 | 1552 | global $wgOut; |
1551 | | - if( $this->mTitle->getNamespace() == NS_CATEGORY) { |
| 1553 | + if ( $this->mTitle->getNamespace() == NS_CATEGORY) { |
1552 | 1554 | $this->mArticle->openShowCategory(); |
1553 | 1555 | } |
1554 | 1556 | # This hook seems slightly odd here, but makes things more |
1555 | 1557 | # consistent for extensions. |
1556 | 1558 | wfRunHooks( 'OutputPageBeforeHTML',array( &$wgOut, &$text ) ); |
1557 | 1559 | $wgOut->addHTML( $text ); |
1558 | | - if( $this->mTitle->getNamespace() == NS_CATEGORY ) { |
| 1560 | + if ( $this->mTitle->getNamespace() == NS_CATEGORY ) { |
1559 | 1561 | $this->mArticle->closeShowCategory(); |
1560 | 1562 | } |
1561 | 1563 | } |
— | — | @@ -1587,8 +1589,7 @@ |
1588 | 1590 | |
1589 | 1591 | function getLastDelete() { |
1590 | 1592 | $dbr = wfGetDB( DB_SLAVE ); |
1591 | | - $fname = 'EditPage::getLastDelete'; |
1592 | | - $res = $dbr->select( |
| 1593 | + $data = $dbr->selectRow( |
1593 | 1594 | array( 'logging', 'user' ), |
1594 | 1595 | array( 'log_type', |
1595 | 1596 | 'log_action', |
— | — | @@ -1604,14 +1605,9 @@ |
1605 | 1606 | 'log_type' => 'delete', |
1606 | 1607 | 'log_action' => 'delete', |
1607 | 1608 | 'user_id=log_user' ), |
1608 | | - $fname, |
| 1609 | + __METHOD__, |
1609 | 1610 | array( 'LIMIT' => 1, 'ORDER BY' => 'log_timestamp DESC' ) ); |
1610 | 1611 | |
1611 | | - if( $dbr->numRows($res) ) { |
1612 | | - $data = $dbr->fetchObject( $res ); |
1613 | | - } else { |
1614 | | - $data = null; |
1615 | | - } |
1616 | 1612 | return $data; |
1617 | 1613 | } |
1618 | 1614 | |
— | — | @@ -1624,8 +1620,8 @@ |
1625 | 1621 | |
1626 | 1622 | wfProfileIn( __METHOD__ ); |
1627 | 1623 | |
1628 | | - if( $this->mTriedSave && !$this->mTokenOk ) { |
1629 | | - if( $this->mTokenOkExceptSuffix ) { |
| 1624 | + if ( $this->mTriedSave && !$this->mTokenOk ) { |
| 1625 | + if ( $this->mTokenOkExceptSuffix ) { |
1630 | 1626 | $note = wfMsg( 'token_suffix_mismatch' ); |
1631 | 1627 | } else { |
1632 | 1628 | $note = wfMsg( 'session_fail_preview' ); |
— | — | @@ -1638,7 +1634,7 @@ |
1639 | 1635 | $parserOptions->setEditSection( false ); |
1640 | 1636 | |
1641 | 1637 | global $wgRawHtml; |
1642 | | - if( $wgRawHtml && !$this->mTokenOk ) { |
| 1638 | + if ( $wgRawHtml && !$this->mTokenOk ) { |
1643 | 1639 | // Could be an offsite preview attempt. This is very unsafe if |
1644 | 1640 | // HTML is enabled, as it could be an attack. |
1645 | 1641 | return $wgOut->parse( "<div class='previewnote'>" . |
— | — | @@ -1648,33 +1644,33 @@ |
1649 | 1645 | # don't parse user css/js, show message about preview |
1650 | 1646 | # XXX: stupid php bug won't let us use $wgTitle->isCssJsSubpage() here |
1651 | 1647 | |
1652 | | - if( $this->isCssJsSubpage ) { |
1653 | | - if(preg_match("/\\.css$/", $this->mTitle->getText() ) ) { |
| 1648 | + if ( $this->isCssJsSubpage ) { |
| 1649 | + if (preg_match("/\\.css$/", $this->mTitle->getText() ) ) { |
1654 | 1650 | $previewtext = wfMsg('usercsspreview'); |
1655 | | - } else if(preg_match("/\\.js$/", $this->mTitle->getText() ) ) { |
| 1651 | + } else if (preg_match("/\\.js$/", $this->mTitle->getText() ) ) { |
1656 | 1652 | $previewtext = wfMsg('userjspreview'); |
1657 | 1653 | } |
1658 | 1654 | $parserOptions->setTidy(true); |
1659 | 1655 | $parserOutput = $wgParser->parse( $previewtext , $this->mTitle, $parserOptions ); |
1660 | 1656 | //$wgOut->addHTML( $parserOutput->mText ); |
1661 | 1657 | $previewHTML = ''; |
1662 | | - } elseif( $rt = Title::newFromRedirect( $this->textbox1 ) ) { |
| 1658 | + } elseif ( $rt = Title::newFromRedirect( $this->textbox1 ) ) { |
1663 | 1659 | $previewHTML = $this->mArticle->viewRedirect( $rt, false ); |
1664 | 1660 | } else { |
1665 | 1661 | $toparse = $this->textbox1; |
1666 | 1662 | |
1667 | 1663 | # If we're adding a comment, we need to show the |
1668 | 1664 | # summary as the headline |
1669 | | - if( $this->section=="new" && $this->summary!="" ) { |
| 1665 | + if ( $this->section=="new" && $this->summary!="" ) { |
1670 | 1666 | $toparse="== {$this->summary} ==\n\n".$toparse; |
1671 | 1667 | } |
1672 | 1668 | |
1673 | | - if( $this->mMetaData != "" ) $toparse .= "\n" . $this->mMetaData; |
| 1669 | + if ( $this->mMetaData != "" ) $toparse .= "\n" . $this->mMetaData; |
1674 | 1670 | |
1675 | 1671 | // Parse mediawiki messages with correct target language |
1676 | | - if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
| 1672 | + if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
1677 | 1673 | $pos = strrpos( $this->mTitle->getText(), '/' ); |
1678 | | - if( $pos !== false ) { |
| 1674 | + if ( $pos !== false ) { |
1679 | 1675 | $code = substr( $this->mTitle->getText(), $pos+1 ); |
1680 | 1676 | switch ($code) { |
1681 | 1677 | case $wgLang->getCode(): |
— | — | @@ -1698,14 +1694,14 @@ |
1699 | 1695 | $this->mParserOutput = $parserOutput; |
1700 | 1696 | $wgOut->addParserOutputNoText( $parserOutput ); |
1701 | 1697 | |
1702 | | - if( count( $parserOutput->getWarnings() ) ) { |
| 1698 | + if ( count( $parserOutput->getWarnings() ) ) { |
1703 | 1699 | $note .= "\n\n" . implode( "\n\n", $parserOutput->getWarnings() ); |
1704 | 1700 | } |
1705 | 1701 | } |
1706 | 1702 | |
1707 | 1703 | $previewhead = '<h2>' . htmlspecialchars( wfMsg( 'preview' ) ) . "</h2>\n" . |
1708 | 1704 | "<div class='previewnote'>" . $wgOut->parse( $note ) . "</div>\n"; |
1709 | | - if( $this->isConflict ) { |
| 1705 | + if ( $this->isConflict ) { |
1710 | 1706 | $previewhead .='<h2>' . htmlspecialchars( wfMsg( 'previewconflict' ) ) . "</h2>\n"; |
1711 | 1707 | } |
1712 | 1708 | |
— | — | @@ -1714,9 +1710,9 @@ |
1715 | 1711 | } |
1716 | 1712 | |
1717 | 1713 | function getTemplates() { |
1718 | | - if( $this->preview || $this->section != '' ) { |
| 1714 | + if ( $this->preview || $this->section != '' ) { |
1719 | 1715 | $templates = array(); |
1720 | | - if( !isset($this->mParserOutput) ) return $templates; |
| 1716 | + if ( !isset($this->mParserOutput) ) return $templates; |
1721 | 1717 | foreach( $this->mParserOutput->getTemplates() as $ns => $template) { |
1722 | 1718 | foreach( array_keys( $template ) as $dbk ) { |
1723 | 1719 | $templates[] = Title::makeTitle($ns, $dbk); |
— | — | @@ -1738,14 +1734,14 @@ |
1739 | 1735 | # If the user made changes, preserve them when showing the markup |
1740 | 1736 | # (This happens when a user is blocked during edit, for instance) |
1741 | 1737 | $first = $this->firsttime || ( !$this->save && $this->textbox1 == '' ); |
1742 | | - if( $first ) { |
| 1738 | + if ( $first ) { |
1743 | 1739 | $source = $this->mTitle->exists() ? $this->getContent() : false; |
1744 | 1740 | } else { |
1745 | 1741 | $source = $this->textbox1; |
1746 | 1742 | } |
1747 | 1743 | |
1748 | 1744 | # Spit out the source or the user's modified version |
1749 | | - if( $source !== false ) { |
| 1745 | + if ( $source !== false ) { |
1750 | 1746 | $rows = $wgUser->getIntOption( 'rows' ); |
1751 | 1747 | $cols = $wgUser->getIntOption( 'cols' ); |
1752 | 1748 | $attribs = array( 'id' => 'wpTextbox1', 'name' => 'wpTextbox1', 'cols' => $cols, 'rows' => $rows, 'readonly' => 'readonly' ); |
— | — | @@ -1804,7 +1800,7 @@ |
1805 | 1801 | |
1806 | 1802 | $wgOut->addHtml( '<div id="spamprotected">' ); |
1807 | 1803 | $wgOut->addWikiMsg( 'spamprotectiontext' ); |
1808 | | - if( $match ) |
| 1804 | + if ( $match ) |
1809 | 1805 | $wgOut->addWikiMsg( 'spamprotectionmatch', wfEscapeWikiText( $match ) ); |
1810 | 1806 | $wgOut->addHtml( '</div>' ); |
1811 | 1807 | |
— | — | @@ -1823,7 +1819,7 @@ |
1824 | 1820 | |
1825 | 1821 | // This is the revision the editor started from |
1826 | 1822 | $baseRevision = $this->getBaseRevision(); |
1827 | | - if( is_null( $baseRevision ) ) { |
| 1823 | + if ( is_null( $baseRevision ) ) { |
1828 | 1824 | wfProfileOut( $fname ); |
1829 | 1825 | return false; |
1830 | 1826 | } |
— | — | @@ -1832,14 +1828,14 @@ |
1833 | 1829 | // The current state, we want to merge updates into it |
1834 | 1830 | $currentRevision = Revision::loadFromTitle( |
1835 | 1831 | $db, $this->mTitle ); |
1836 | | - if( is_null( $currentRevision ) ) { |
| 1832 | + if ( is_null( $currentRevision ) ) { |
1837 | 1833 | wfProfileOut( $fname ); |
1838 | 1834 | return false; |
1839 | 1835 | } |
1840 | 1836 | $currentText = $currentRevision->getText(); |
1841 | 1837 | |
1842 | 1838 | $result = ''; |
1843 | | - if( wfMerge( $baseText, $editText, $currentText, $result ) ) { |
| 1839 | + if ( wfMerge( $baseText, $editText, $currentText, $result ) ) { |
1844 | 1840 | $editText = $result; |
1845 | 1841 | wfProfileOut( $fname ); |
1846 | 1842 | return true; |
— | — | @@ -1858,13 +1854,13 @@ |
1859 | 1855 | */ |
1860 | 1856 | function checkUnicodeCompliantBrowser() { |
1861 | 1857 | global $wgBrowserBlackList; |
1862 | | - if( empty( $_SERVER["HTTP_USER_AGENT"] ) ) { |
| 1858 | + if ( empty( $_SERVER["HTTP_USER_AGENT"] ) ) { |
1863 | 1859 | // No User-Agent header sent? Trust it by default... |
1864 | 1860 | return true; |
1865 | 1861 | } |
1866 | 1862 | $currentbrowser = $_SERVER["HTTP_USER_AGENT"]; |
1867 | 1863 | foreach ( $wgBrowserBlackList as $browser ) { |
1868 | | - if( preg_match($browser, $currentbrowser) ) { |
| 1864 | + if ( preg_match($browser, $currentbrowser) ) { |
1869 | 1865 | return false; |
1870 | 1866 | } |
1871 | 1867 | } |
— | — | @@ -2057,7 +2053,7 @@ |
2058 | 2054 | |
2059 | 2055 | $checkboxes['minor'] = ''; |
2060 | 2056 | $minorLabel = wfMsgExt('minoredit', array('parseinline')); |
2061 | | - if( $wgUser->isAllowed('minoredit') ) { |
| 2057 | + if ( $wgUser->isAllowed('minoredit') ) { |
2062 | 2058 | $attribs = array( |
2063 | 2059 | 'tabindex' => ++$tabindex, |
2064 | 2060 | 'accesskey' => wfMsg( 'accesskey-minoredit' ), |
— | — | @@ -2070,7 +2066,7 @@ |
2071 | 2067 | |
2072 | 2068 | $watchLabel = wfMsgExt('watchthis', array('parseinline')); |
2073 | 2069 | $checkboxes['watch'] = ''; |
2074 | | - if( $wgUser->isLoggedIn() ) { |
| 2070 | + if ( $wgUser->isLoggedIn() ) { |
2075 | 2071 | $attribs = array( |
2076 | 2072 | 'tabindex' => ++$tabindex, |
2077 | 2073 | 'accesskey' => wfMsg( 'accesskey-watch' ), |
— | — | @@ -2108,7 +2104,7 @@ |
2109 | 2105 | $buttons['save'] = Xml::element('input', $temp, ''); |
2110 | 2106 | |
2111 | 2107 | ++$tabindex; // use the same for preview and live preview |
2112 | | - if( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) { |
| 2108 | + if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) { |
2113 | 2109 | $temp = array( |
2114 | 2110 | 'id' => 'wpPreview', |
2115 | 2111 | 'name' => 'wpPreview', |
— | — | @@ -2206,7 +2202,7 @@ |
2207 | 2203 | $newtext = $this->mArticle->preSaveTransform( $newtext ); |
2208 | 2204 | $oldtitle = wfMsgExt( 'currentrev', array('parseinline') ); |
2209 | 2205 | $newtitle = wfMsgExt( 'yourtext', array('parseinline') ); |
2210 | | - if( $oldtext !== false || $newtext != '' ) { |
| 2206 | + if ( $oldtext !== false || $newtext != '' ) { |
2211 | 2207 | $de = new DifferenceEngine( $this->mTitle ); |
2212 | 2208 | $de->setText( $oldtext, $newtext ); |
2213 | 2209 | $difftext = $de->getDiff( $oldtitle, $newtitle ); |
— | — | @@ -2273,20 +2269,20 @@ |
2274 | 2270 | $working = 0; |
2275 | 2271 | for( $i = 0; $i < strlen( $invalue ); $i++ ) { |
2276 | 2272 | $bytevalue = ord( $invalue{$i} ); |
2277 | | - if( $bytevalue <= 0x7F ) { //0xxx xxxx |
| 2273 | + if ( $bytevalue <= 0x7F ) { //0xxx xxxx |
2278 | 2274 | $result .= chr( $bytevalue ); |
2279 | 2275 | $bytesleft = 0; |
2280 | | - } elseif( $bytevalue <= 0xBF ) { //10xx xxxx |
| 2276 | + } elseif ( $bytevalue <= 0xBF ) { //10xx xxxx |
2281 | 2277 | $working = $working << 6; |
2282 | 2278 | $working += ($bytevalue & 0x3F); |
2283 | 2279 | $bytesleft--; |
2284 | | - if( $bytesleft <= 0 ) { |
| 2280 | + if ( $bytesleft <= 0 ) { |
2285 | 2281 | $result .= "&#x" . strtoupper( dechex( $working ) ) . ";"; |
2286 | 2282 | } |
2287 | | - } elseif( $bytevalue <= 0xDF ) { //110x xxxx |
| 2283 | + } elseif ( $bytevalue <= 0xDF ) { //110x xxxx |
2288 | 2284 | $working = $bytevalue & 0x1F; |
2289 | 2285 | $bytesleft = 1; |
2290 | | - } elseif( $bytevalue <= 0xEF ) { //1110 xxxx |
| 2286 | + } elseif ( $bytevalue <= 0xEF ) { //1110 xxxx |
2291 | 2287 | $working = $bytevalue & 0x0F; |
2292 | 2288 | $bytesleft = 2; |
2293 | 2289 | } else { //1111 0xxx |
— | — | @@ -2309,7 +2305,7 @@ |
2310 | 2306 | function unmakesafe( $invalue ) { |
2311 | 2307 | $result = ""; |
2312 | 2308 | for( $i = 0; $i < strlen( $invalue ); $i++ ) { |
2313 | | - if( ( substr( $invalue, $i, 3 ) == "&#x" ) && ( $invalue{$i+3} != '0' ) ) { |
| 2309 | + if ( ( substr( $invalue, $i, 3 ) == "&#x" ) && ( $invalue{$i+3} != '0' ) ) { |
2314 | 2310 | $i += 3; |
2315 | 2311 | $hexstring = ""; |
2316 | 2312 | do { |
— | — | @@ -2320,7 +2316,7 @@ |
2321 | 2317 | // Do some sanity checks. These aren't needed for reversability, |
2322 | 2318 | // but should help keep the breakage down if the editor |
2323 | 2319 | // breaks one of the entities whilst editing. |
2324 | | - if( (substr($invalue,$i,1)==";") and (strlen($hexstring) <= 6) ) { |
| 2320 | + if ( (substr($invalue,$i,1)==";") and (strlen($hexstring) <= 6) ) { |
2325 | 2321 | $codepoint = hexdec($hexstring); |
2326 | 2322 | $result .= codepointToUtf8( $codepoint ); |
2327 | 2323 | } else { |
— | — | @@ -2347,21 +2343,19 @@ |
2348 | 2344 | * @param OutputPage $out |
2349 | 2345 | */ |
2350 | 2346 | protected function showDeletionLog( $out ) { |
2351 | | - if( !$this->mTitle->exists() ) { |
2352 | | - global $wgUser; |
2353 | | - $loglist = new LogEventsList( $wgUser->getSkin(), $out ); |
2354 | | - $pager = new LogPager( $loglist, 'delete', false, $this->mTitle->getPrefixedText() ); |
2355 | | - if( $pager->getNumRows() > 0 ) { |
2356 | | - $out->addHtml( '<div id="mw-recreate-deleted-warn">' ); |
2357 | | - $out->addWikiMsg( 'recreate-deleted-warn' ); |
2358 | | - $out->addHTML( |
2359 | | - $loglist->beginLogEventsList() . |
2360 | | - $pager->getBody() . |
2361 | | - $loglist->endLogEventsList() |
2362 | | - ); |
2363 | | - $out->addHtml( '</div>' ); |
2364 | | - return true; |
2365 | | - } |
| 2347 | + global $wgUser; |
| 2348 | + $loglist = new LogEventsList( $wgUser->getSkin(), $out ); |
| 2349 | + $pager = new LogPager( $loglist, 'delete', false, $this->mTitle->getPrefixedText() ); |
| 2350 | + if ( $pager->getNumRows() > 0 ) { |
| 2351 | + $out->addHtml( '<div id="mw-recreate-deleted-warn">' ); |
| 2352 | + $out->addWikiMsg( 'recreate-deleted-warn' ); |
| 2353 | + $out->addHTML( |
| 2354 | + $loglist->beginLogEventsList() . |
| 2355 | + $pager->getBody() . |
| 2356 | + $loglist->endLogEventsList() |
| 2357 | + ); |
| 2358 | + $out->addHtml( '</div>' ); |
| 2359 | + return true; |
2366 | 2360 | } |
2367 | 2361 | return false; |
2368 | 2362 | } |
— | — | @@ -2376,7 +2370,7 @@ |
2377 | 2371 | $resultDetails = false; |
2378 | 2372 | $value = $this->internalAttemptSave( $resultDetails, $wgUser->isAllowed('bot') && $wgRequest->getBool('bot', true) ); |
2379 | 2373 | |
2380 | | - if( $value == self::AS_SUCCESS_UPDATE || $value == self::AS_SUCCESS_NEW_ARTICLE ) { |
| 2374 | + if ( $value == self::AS_SUCCESS_UPDATE || $value == self::AS_SUCCESS_NEW_ARTICLE ) { |
2381 | 2375 | $this->didSave = true; |
2382 | 2376 | } |
2383 | 2377 | |
— | — | @@ -2437,7 +2431,7 @@ |
2438 | 2432 | } |
2439 | 2433 | |
2440 | 2434 | function getBaseRevision() { |
2441 | | - if( $this->mBaseRevision == false ) { |
| 2435 | + if ( $this->mBaseRevision == false ) { |
2442 | 2436 | $db = wfGetDB( DB_MASTER ); |
2443 | 2437 | $baseRevision = Revision::loadFromTimestamp( |
2444 | 2438 | $db, $this->mTitle, $this->edittime ); |