Index: trunk/extensions/MassEditRegex/MassEditRegex.i18n.php |
— | — | @@ -12,6 +12,7 @@ |
13 | 13 | * @author Adam Nielsen |
14 | 14 | */ |
15 | 15 | $messages['en'] = array( |
| 16 | + 'action-masseditregex' => 'perform a bulk edit', |
16 | 17 | 'masseditregex' => 'Mass edit using regular expressions', |
17 | 18 | 'masseditregex-desc' => 'Use regular expressions to [[Special:MassEditRegex|edit many pages in one operation]]', |
18 | 19 | 'masseditregextext' => 'Enter one or more regular expressions (one per line) for matching, and one or more expressions to replace each match with. |
Index: trunk/extensions/MassEditRegex/MassEditRegex.class.php |
— | — | @@ -121,7 +121,7 @@ |
122 | 122 | Xml::openElement('form', array( |
123 | 123 | 'id' => 'masseditregex', |
124 | 124 | 'method' => 'post', |
125 | | - 'action' => $titleObj->escapeLocalURL('action=submit') |
| 125 | + 'action' => $titleObj->getLocalURL('action=submit') |
126 | 126 | )) . |
127 | 127 | Xml::element('p', |
128 | 128 | null, wfMsg( 'masseditregex-pagelisttxt' ) |
— | — | @@ -389,7 +389,7 @@ |
390 | 390 | } |
391 | 391 | |
392 | 392 | function perform( $bPerformEdits = true ) { |
393 | | - global $wgOut, $wgUser, $wgTitle, $wgLang; |
| 393 | + global $wgRequest, $wgOut, $wgUser, $wgTitle, $wgLang; |
394 | 394 | |
395 | 395 | $iMaxPerCriterion = $bPerformEdits ? MER_MAX_EXECUTE_PAGES : MER_MAX_PREVIEW_DIFFS; |
396 | 396 | $aErrors = array(); |
— | — | @@ -405,28 +405,20 @@ |
406 | 406 | $diff = new DifferenceEngine(); |
407 | 407 | $diff->showDiffStyle(); // send CSS link to the browser for diff colours |
408 | 408 | |
409 | | - // Save the state until the MW Edit API does it for us |
410 | | - if ( $bPerformEdits ) { |
411 | | - $o_wgOut = clone $wgOut; // need to do a deep copy here |
412 | | - $wgOut->disable(); // not strictly necessary, but might speed things up |
413 | | - $o_wgTitle = $wgTitle; |
414 | | - } else { |
415 | | - // No difference here, but having the same variable name simplifies code |
416 | | - $o_wgOut = $wgOut; |
417 | | - } |
| 409 | + $wgOut->addHTML( '<ul>' ); |
418 | 410 | |
419 | | - $o_wgOut->addHTML( '<ul>' ); |
420 | | - |
421 | 411 | if (count($aErrors)) |
422 | | - $o_wgOut->addHTML( '<li>' . join( '</li><li> ', $aErrors) . '</li>' ); |
| 412 | + $wgOut->addHTML( '<li>' . join( '</li><li> ', $aErrors) . '</li>' ); |
423 | 413 | |
424 | 414 | $htmlDiff = ''; |
425 | 415 | |
| 416 | + $editToken = $wgUser->editToken(); |
| 417 | + |
426 | 418 | $iArticleCount = 0; |
427 | 419 | foreach ( $aPages as $p ) { |
428 | 420 | $iArticleCount++; |
429 | 421 | if ( !isset( $p['revisions'] ) ) { |
430 | | - $o_wgOut->addHTML( '<li>' |
| 422 | + $wgOut->addHTML( '<li>' |
431 | 423 | . wfMsg( 'masseditregex-page-not-exists', $p['title'] ) |
432 | 424 | . '</li>' ); |
433 | 425 | continue; // empty page |
— | — | @@ -442,32 +434,33 @@ |
443 | 435 | else { |
444 | 436 | $strErrorMsg = '<li>' . wfMsg( 'masseditregex-badregex' ) . ' <b>' |
445 | 437 | . htmlspecialchars($strMatch) . '</b></li>'; |
446 | | - $o_wgOut->addHTML( $strErrorMsg ); |
| 438 | + $wgOut->addHTML( $strErrorMsg ); |
447 | 439 | unset($this->aMatch[$i]); |
448 | 440 | } |
449 | 441 | } |
450 | 442 | |
451 | 443 | if ( $bPerformEdits ) { |
452 | 444 | // Not in preview mode, make the edits |
453 | | - // print_r( $p ); |
454 | | - $o_wgOut->addHTML( '<li>' . wfMsg( 'masseditregex-num-changes', |
| 445 | + $wgOut->addHTML( '<li>' . wfMsg( 'masseditregex-num-changes', |
455 | 446 | $p['title'], $iCount ) . '</li>' ); |
456 | 447 | |
457 | | - $req = new FauxRequest( array( |
| 448 | + $req = new DerivativeRequest( $wgRequest, array( |
458 | 449 | 'action' => 'edit', |
459 | 450 | 'bot' => true, |
460 | | - 'token' => $p['edittoken'], |
461 | 451 | 'title' => $p['title'], |
462 | 452 | 'summary' => $this->strSummary, |
463 | 453 | 'text' => $newContent, |
464 | | - 'basetimestamp' => $p['starttimestamp'] |
| 454 | + 'basetimestamp' => $p['starttimestamp'], |
| 455 | + 'watchlist' => 'nochange', |
| 456 | + 'nocreate' => 1, |
| 457 | + 'token' => $editToken, |
465 | 458 | ), true ); |
466 | 459 | $processor = new ApiMain( $req, true ); |
467 | 460 | try { |
468 | 461 | $processor->execute(); |
469 | 462 | } catch ( UsageException $e ) { |
470 | | - $o_wgOut->addHTML('<li><ul><li>' . wfMsg( 'masseditregex-editfailed') |
471 | | - . $e . '</li></ul></li>' |
| 463 | + $wgOut->addHTML('<li><ul><li>' . wfMsg( 'masseditregex-editfailed') |
| 464 | + . ' ' . $e . '</li></ul></li>' |
472 | 465 | ); |
473 | 466 | } |
474 | 467 | } else { |
— | — | @@ -489,13 +482,9 @@ |
490 | 483 | |
491 | 484 | } |
492 | 485 | |
493 | | - $o_wgOut->addHTML( '</ul>' ); |
| 486 | + $wgOut->addHTML( '</ul>' ); |
494 | 487 | |
495 | 488 | if ( $bPerformEdits ) { |
496 | | - // Restore the state after the Edit API has messed with it |
497 | | - $wgTitle = $o_wgTitle; |
498 | | - $wgOut = $o_wgOut; |
499 | | - |
500 | 489 | $wgOut->addWikiMsg( 'masseditregex-num-articles-changed', $iArticleCount ); |
501 | 490 | $wgOut->addHTML( |
502 | 491 | $this->sk->makeKnownLinkObj( |