Index: trunk/phase3/includes/Article.php |
— | — | @@ -1229,6 +1229,13 @@ |
1230 | 1230 | } |
1231 | 1231 | |
1232 | 1232 | /** |
| 1233 | + * User interface for rollback operations |
| 1234 | + */ |
| 1235 | + public function rollback() { |
| 1236 | + Action::factory( 'rollback', $this )->show(); |
| 1237 | + } |
| 1238 | + |
| 1239 | + /** |
1233 | 1240 | * Output a redirect back to the article. |
1234 | 1241 | * This is typically used after an edit. |
1235 | 1242 | * |
— | — | @@ -1616,92 +1623,6 @@ |
1617 | 1624 | } |
1618 | 1625 | |
1619 | 1626 | /** |
1620 | | - * User interface for rollback operations |
1621 | | - */ |
1622 | | - public function rollback() { |
1623 | | - global $wgUser, $wgOut, $wgRequest; |
1624 | | - |
1625 | | - $details = null; |
1626 | | - |
1627 | | - $result = $this->mPage->doRollback( |
1628 | | - $wgRequest->getVal( 'from' ), |
1629 | | - $wgRequest->getText( 'summary' ), |
1630 | | - $wgRequest->getVal( 'token' ), |
1631 | | - $wgRequest->getBool( 'bot' ), |
1632 | | - $details |
1633 | | - ); |
1634 | | - |
1635 | | - if ( in_array( array( 'actionthrottledtext' ), $result ) ) { |
1636 | | - $wgOut->rateLimited(); |
1637 | | - return; |
1638 | | - } |
1639 | | - |
1640 | | - if ( isset( $result[0][0] ) && ( $result[0][0] == 'alreadyrolled' || $result[0][0] == 'cantrollback' ) ) { |
1641 | | - $wgOut->setPageTitle( wfMsg( 'rollbackfailed' ) ); |
1642 | | - $errArray = $result[0]; |
1643 | | - $errMsg = array_shift( $errArray ); |
1644 | | - $wgOut->addWikiMsgArray( $errMsg, $errArray ); |
1645 | | - |
1646 | | - if ( isset( $details['current'] ) ) { |
1647 | | - $current = $details['current']; |
1648 | | - |
1649 | | - if ( $current->getComment() != '' ) { |
1650 | | - $wgOut->addWikiMsgArray( 'editcomment', array( |
1651 | | - Linker::formatComment( $current->getComment() ) ), array( 'replaceafter' ) ); |
1652 | | - } |
1653 | | - } |
1654 | | - |
1655 | | - return; |
1656 | | - } |
1657 | | - |
1658 | | - # Display permissions errors before read-only message -- there's no |
1659 | | - # point in misleading the user into thinking the inability to rollback |
1660 | | - # is only temporary. |
1661 | | - if ( !empty( $result ) && $result !== array( array( 'readonlytext' ) ) ) { |
1662 | | - # array_diff is completely broken for arrays of arrays, sigh. |
1663 | | - # Remove any 'readonlytext' error manually. |
1664 | | - $out = array(); |
1665 | | - foreach ( $result as $error ) { |
1666 | | - if ( $error != array( 'readonlytext' ) ) { |
1667 | | - $out [] = $error; |
1668 | | - } |
1669 | | - } |
1670 | | - $wgOut->showPermissionsErrorPage( $out ); |
1671 | | - |
1672 | | - return; |
1673 | | - } |
1674 | | - |
1675 | | - if ( $result == array( array( 'readonlytext' ) ) ) { |
1676 | | - $wgOut->readOnlyPage(); |
1677 | | - |
1678 | | - return; |
1679 | | - } |
1680 | | - |
1681 | | - $current = $details['current']; |
1682 | | - $target = $details['target']; |
1683 | | - $newId = $details['newid']; |
1684 | | - $wgOut->setPageTitle( wfMsg( 'actioncomplete' ) ); |
1685 | | - $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
1686 | | - |
1687 | | - if ( $current->getUserText() === '' ) { |
1688 | | - $old = wfMsg( 'rev-deleted-user' ); |
1689 | | - } else { |
1690 | | - $old = Linker::userLink( $current->getUser(), $current->getUserText() ) |
1691 | | - . Linker::userToolLinks( $current->getUser(), $current->getUserText() ); |
1692 | | - } |
1693 | | - |
1694 | | - $new = Linker::userLink( $target->getUser(), $target->getUserText() ) |
1695 | | - . Linker::userToolLinks( $target->getUser(), $target->getUserText() ); |
1696 | | - $wgOut->addHTML( wfMsgExt( 'rollback-success', array( 'parse', 'replaceafter' ), $old, $new ) ); |
1697 | | - $wgOut->returnToMain( false, $this->getTitle() ); |
1698 | | - |
1699 | | - if ( !$wgRequest->getBool( 'hidediff', false ) && !$wgUser->getBoolOption( 'norollbackdiff', false ) ) { |
1700 | | - $de = new DifferenceEngine( $this->getTitle(), $current->getId(), $newId, false, true ); |
1701 | | - $de->showDiff( '', '' ); |
1702 | | - } |
1703 | | - } |
1704 | | - |
1705 | | - /** |
1706 | 1627 | * Generate the navigation links when browsing through an article revisions |
1707 | 1628 | * It shows the information as: |
1708 | 1629 | * Revision as of \<date\>; view current revision |
Index: trunk/phase3/includes/actions/RollbackAction.php |
— | — | @@ -0,0 +1,122 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Edit rollback user interface |
| 5 | + * |
| 6 | + * This program is free software; you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU General Public License as published by |
| 8 | + * the Free Software Foundation; either version 2 of the License, or |
| 9 | + * (at your option) any later version. |
| 10 | + * |
| 11 | + * This program is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | + * GNU General Public License for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU General Public License |
| 17 | + * along with this program; if not, write to the Free Software |
| 18 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
| 19 | + * |
| 20 | + * @file |
| 21 | + * @ingroup Action |
| 22 | + */ |
| 23 | + |
| 24 | +/** |
| 25 | + * User interface for the rollback action |
| 26 | + * |
| 27 | + * @ingroup Action |
| 28 | + */ |
| 29 | +class RollbackAction extends FormlessAction { |
| 30 | + |
| 31 | + public function getName() { |
| 32 | + return 'rollback'; |
| 33 | + } |
| 34 | + |
| 35 | + public function getRestriction() { |
| 36 | + return 'rollback'; |
| 37 | + } |
| 38 | + |
| 39 | + public function onView() { |
| 40 | + $details = null; |
| 41 | + |
| 42 | + $request = $this->getRequest(); |
| 43 | + |
| 44 | + $result = $this->page->doRollback( |
| 45 | + $request->getVal( 'from' ), |
| 46 | + $request->getText( 'summary' ), |
| 47 | + $request->getVal( 'token' ), |
| 48 | + $request->getBool( 'bot' ), |
| 49 | + $details, |
| 50 | + $this->getUser() |
| 51 | + ); |
| 52 | + |
| 53 | + if ( in_array( array( 'actionthrottledtext' ), $result ) ) { |
| 54 | + throw new ThrottledError; |
| 55 | + } |
| 56 | + |
| 57 | + if ( isset( $result[0][0] ) && ( $result[0][0] == 'alreadyrolled' || $result[0][0] == 'cantrollback' ) ) { |
| 58 | + $this->getOutput()->setPageTitle( wfMsg( 'rollbackfailed' ) ); |
| 59 | + $errArray = $result[0]; |
| 60 | + $errMsg = array_shift( $errArray ); |
| 61 | + $this->getOutput()->addWikiMsgArray( $errMsg, $errArray ); |
| 62 | + |
| 63 | + if ( isset( $details['current'] ) ) { |
| 64 | + $current = $details['current']; |
| 65 | + |
| 66 | + if ( $current->getComment() != '' ) { |
| 67 | + $this->getOutput()->addWikiMsgArray( 'editcomment', array( |
| 68 | + Linker::formatComment( $current->getComment() ) ), array( 'replaceafter' ) ); |
| 69 | + } |
| 70 | + } |
| 71 | + |
| 72 | + return; |
| 73 | + } |
| 74 | + |
| 75 | + # Display permissions errors before read-only message -- there's no |
| 76 | + # point in misleading the user into thinking the inability to rollback |
| 77 | + # is only temporary. |
| 78 | + if ( !empty( $result ) && $result !== array( array( 'readonlytext' ) ) ) { |
| 79 | + # array_diff is completely broken for arrays of arrays, sigh. |
| 80 | + # Remove any 'readonlytext' error manually. |
| 81 | + $out = array(); |
| 82 | + foreach ( $result as $error ) { |
| 83 | + if ( $error != array( 'readonlytext' ) ) { |
| 84 | + $out [] = $error; |
| 85 | + } |
| 86 | + } |
| 87 | + $this->getOutput()->showPermissionsErrorPage( $out ); |
| 88 | + |
| 89 | + return; |
| 90 | + } |
| 91 | + |
| 92 | + if ( $result == array( array( 'readonlytext' ) ) ) { |
| 93 | + throw new ReadOnlyError; |
| 94 | + } |
| 95 | + |
| 96 | + $current = $details['current']; |
| 97 | + $target = $details['target']; |
| 98 | + $newId = $details['newid']; |
| 99 | + $this->getOutput()->setPageTitle( wfMsg( 'actioncomplete' ) ); |
| 100 | + $this->getOutput()->setRobotPolicy( 'noindex,nofollow' ); |
| 101 | + |
| 102 | + if ( $current->getUserText() === '' ) { |
| 103 | + $old = wfMsg( 'rev-deleted-user' ); |
| 104 | + } else { |
| 105 | + $old = Linker::userLink( $current->getUser(), $current->getUserText() ) |
| 106 | + . Linker::userToolLinks( $current->getUser(), $current->getUserText() ); |
| 107 | + } |
| 108 | + |
| 109 | + $new = Linker::userLink( $target->getUser(), $target->getUserText() ) |
| 110 | + . Linker::userToolLinks( $target->getUser(), $target->getUserText() ); |
| 111 | + $this->getOutput()->addHTML( wfMsgExt( 'rollback-success', array( 'parse', 'replaceafter' ), $old, $new ) ); |
| 112 | + $this->getOutput()->returnToMain( false, $this->getTitle() ); |
| 113 | + |
| 114 | + if ( !$request->getBool( 'hidediff', false ) && !$this->getUser()->getBoolOption( 'norollbackdiff', false ) ) { |
| 115 | + $de = new DifferenceEngine( $this->getTitle(), $current->getId(), $newId, false, true ); |
| 116 | + $de->showDiff( '', '' ); |
| 117 | + } |
| 118 | + } |
| 119 | + |
| 120 | + protected function getDescription() { |
| 121 | + return ''; |
| 122 | + } |
| 123 | +} |
Property changes on: trunk/phase3/includes/actions/RollbackAction.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 124 | + native |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -264,6 +264,7 @@ |
265 | 265 | 'RevertAction' => 'includes/actions/RevertAction.php', |
266 | 266 | 'RevertFileAction' => 'includes/actions/RevertAction.php', |
267 | 267 | 'RevisiondeleteAction' => 'includes/actions/RevisiondeleteAction.php', |
| 268 | + 'RollbackAction' => 'includes/actions/RollbackAction.php', |
268 | 269 | 'UnwatchAction' => 'includes/actions/WatchAction.php', |
269 | 270 | 'WatchAction' => 'includes/actions/WatchAction.php', |
270 | 271 | |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -464,7 +464,6 @@ |
465 | 465 | wfProfileOut( __METHOD__ . '-raw' ); |
466 | 466 | break; |
467 | 467 | case 'delete': |
468 | | - case 'rollback': |
469 | 468 | case 'protect': |
470 | 469 | case 'unprotect': |
471 | 470 | case 'render': |
Index: trunk/phase3/includes/WikiPage.php |
— | — | @@ -1719,7 +1719,7 @@ |
1720 | 1720 | return $errors; |
1721 | 1721 | } |
1722 | 1722 | |
1723 | | - return $this->commitRollback( $user, $fromP, $summary, $bot, $resultDetails ); |
| 1723 | + return $this->commitRollback( $fromP, $summary, $bot, $resultDetails, $user ); |
1724 | 1724 | } |
1725 | 1725 | |
1726 | 1726 | /** |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -5063,6 +5063,7 @@ |
5064 | 5064 | 'purge' => true, |
5065 | 5065 | 'revert' => true, |
5066 | 5066 | 'revisiondelete' => true, |
| 5067 | + 'rollback' => true, |
5067 | 5068 | 'unwatch' => true, |
5068 | 5069 | 'watch' => true, |
5069 | 5070 | ); |