Index: trunk/phase3/includes/Linker.php |
— | — | @@ -1769,6 +1769,50 @@ |
1770 | 1770 | } |
1771 | 1771 | |
1772 | 1772 | /** |
| 1773 | + * Get a revision-deletion link, or disabled link, or nothing, depending |
| 1774 | + * on user permissions & the settings on the revision. |
| 1775 | + * |
| 1776 | + * Will use forward-compatible revision ID in the Special:RevDelete link |
| 1777 | + * if possible, otherwise the timestamp-based ID which may break after |
| 1778 | + * undeletion. |
| 1779 | + * |
| 1780 | + * @param User $user |
| 1781 | + * @param Revision $rev |
| 1782 | + * @param Revision $title |
| 1783 | + * @return string HTML fragment |
| 1784 | + */ |
| 1785 | + public static function getRevDeleteLink( User $user, Revision $rev, Title $title ) { |
| 1786 | + $canHide = $user->isAllowed( 'deleterevision' ); |
| 1787 | + if ( $canHide || ( $rev->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) ) { |
| 1788 | + if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) { |
| 1789 | + $revdlink = Linker::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops |
| 1790 | + } else { |
| 1791 | + if ( $rev->getId() ) { |
| 1792 | + // RevDelete links using revision ID are stable across |
| 1793 | + // page deletion and undeletion; use when possible. |
| 1794 | + $query = array( |
| 1795 | + 'type' => 'revision', |
| 1796 | + 'target' => $title->getPrefixedDBkey(), |
| 1797 | + 'ids' => $rev->getId() |
| 1798 | + ); |
| 1799 | + } else { |
| 1800 | + // Older deleted entries didn't save a revision ID. |
| 1801 | + // We have to refer to these by timestamp, ick! |
| 1802 | + $query = array( |
| 1803 | + 'type' => 'archive', |
| 1804 | + 'target' => $title->getPrefixedDBkey(), |
| 1805 | + 'ids' => $rev->getTimestamp() |
| 1806 | + ); |
| 1807 | + } |
| 1808 | + return Linker::revDeleteLink( $query, |
| 1809 | + $rev->isDeleted( File::DELETED_RESTRICTED ), $canHide ); |
| 1810 | + } |
| 1811 | + } else { |
| 1812 | + return ''; |
| 1813 | + } |
| 1814 | + } |
| 1815 | + |
| 1816 | + /** |
1773 | 1817 | * Creates a (show/hide) link for deleting revisions/log entries |
1774 | 1818 | * |
1775 | 1819 | * @param $query Array: query parameters to be passed to link() |
— | — | @@ -2003,4 +2047,3 @@ |
2004 | 2048 | return call_user_func_array( array( 'Linker', $fname ), $args ); |
2005 | 2049 | } |
2006 | 2050 | } |
2007 | | - |
Index: trunk/phase3/includes/specials/SpecialUndelete.php |
— | — | @@ -844,9 +844,9 @@ |
845 | 845 | |
846 | 846 | // Revision delete links |
847 | 847 | if ( !$this->mDiff ) { |
848 | | - $revdel = $this->revDeleteLink( $rev ); |
| 848 | + $revdel = Linker::getRevDeleteLink( $this->getUser(), $rev, $this->mTargetObj ); |
849 | 849 | if ( $revdel ) { |
850 | | - $out->addHTML( $revdel ); |
| 850 | + $out->addHTML( "$revdel " ); |
851 | 851 | } |
852 | 852 | } |
853 | 853 | |
— | — | @@ -897,48 +897,6 @@ |
898 | 898 | } |
899 | 899 | |
900 | 900 | /** |
901 | | - * Get a revision-deletion link, or disabled link, or nothing, depending |
902 | | - * on user permissions & the settings on the revision. |
903 | | - * |
904 | | - * Will use forward-compatible revision ID in the Special:RevDelete link |
905 | | - * if possible, otherwise the timestamp-based ID which may break after |
906 | | - * undeletion. |
907 | | - * |
908 | | - * @param Revision $rev |
909 | | - * @return string HTML fragment |
910 | | - */ |
911 | | - function revDeleteLink( $rev ) { |
912 | | - $canHide = $this->getUser()->isAllowed( 'deleterevision' ); |
913 | | - if( $canHide || ( $rev->getVisibility() && $this->getUser()->isAllowed( 'deletedhistory' ) ) ) { |
914 | | - if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) { |
915 | | - $revdlink = Linker::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops |
916 | | - } else { |
917 | | - if ( $rev->getId() ) { |
918 | | - // RevDelete links using revision ID are stable across |
919 | | - // page deletion and undeletion; use when possible. |
920 | | - $query = array( |
921 | | - 'type' => 'revision', |
922 | | - 'target' => $this->mTargetObj->getPrefixedDBkey(), |
923 | | - 'ids' => $rev->getId() |
924 | | - ); |
925 | | - } else { |
926 | | - // Older deleted entries didn't save a revision ID. |
927 | | - // We have to refer to these by timestamp, ick! |
928 | | - $query = array( |
929 | | - 'type' => 'archive', |
930 | | - 'target' => $this->mTargetObj->getPrefixedDBkey(), |
931 | | - 'ids' => $rev->getTimestamp() |
932 | | - ); |
933 | | - } |
934 | | - return Linker::revDeleteLink( $query, |
935 | | - $rev->isDeleted( File::DELETED_RESTRICTED ), $canHide ); |
936 | | - } |
937 | | - } else { |
938 | | - return ''; |
939 | | - } |
940 | | - } |
941 | | - |
942 | | - /** |
943 | 901 | * Build a diff display between this and the previous either deleted |
944 | 902 | * or non-deleted edit. |
945 | 903 | * |
— | — | @@ -991,7 +949,8 @@ |
992 | 950 | $targetQuery = array( 'oldid' => $rev->getId() ); |
993 | 951 | } |
994 | 952 | // Add show/hide deletion links if available |
995 | | - $del = $this->revDeleteLink( $rev ); |
| 953 | + $rdel = Linker::getRevDeleteLink( $this->getUser(), $rev, $this->mTargetObj ); |
| 954 | + if ( $rdel ) $rdel = " $rdel"; |
996 | 955 | return |
997 | 956 | '<div id="mw-diff-' . $prefix . 'title1"><strong>' . |
998 | 957 | Linker::link( |
— | — | @@ -1011,7 +970,7 @@ |
1012 | 971 | Linker::revUserTools( $rev ) . '<br />' . |
1013 | 972 | '</div>' . |
1014 | 973 | '<div id="mw-diff-'.$prefix.'title3">' . |
1015 | | - Linker::revComment( $rev ) . $del . '<br />' . |
| 974 | + Linker::revComment( $rev ) . $rdel . '<br />' . |
1016 | 975 | '</div>'; |
1017 | 976 | } |
1018 | 977 | |
— | — | @@ -1274,7 +1233,7 @@ |
1275 | 1234 | // Edit summary |
1276 | 1235 | $comment = Linker::revComment( $rev ); |
1277 | 1236 | // Revision delete links |
1278 | | - $revdlink = $this->revDeleteLink( $rev ); |
| 1237 | + $revdlink = Linker::getRevDeleteLink( $this->getUser(), $rev, $this->mTargetObj ); |
1279 | 1238 | return "<li>$checkBox $revdlink ($last) $pageLink . . $userLink $stxt $comment</li>"; |
1280 | 1239 | } |
1281 | 1240 | |
— | — | @@ -1300,6 +1259,7 @@ |
1301 | 1260 | ')'; |
1302 | 1261 | $data = htmlspecialchars( $data ); |
1303 | 1262 | $comment = $this->getFileComment( $file ); |
| 1263 | + |
1304 | 1264 | // Add show/hide deletion links if available |
1305 | 1265 | $canHide = $this->getUser()->isAllowed( 'deleterevision' ); |
1306 | 1266 | if( $canHide || ( $file->getVisibility() && $this->getUser()->isAllowed( 'deletedhistory' ) ) ) { |
— | — | @@ -1317,6 +1277,7 @@ |
1318 | 1278 | } else { |
1319 | 1279 | $revdlink = ''; |
1320 | 1280 | } |
| 1281 | + |
1321 | 1282 | return "<li>$checkBox $revdlink $pageLink . . $userLink $data $comment</li>\n"; |
1322 | 1283 | } |
1323 | 1284 | |
Index: trunk/phase3/includes/specials/SpecialDeletedContributions.php |
— | — | @@ -213,21 +213,8 @@ |
214 | 214 | } |
215 | 215 | |
216 | 216 | // Revision delete link |
217 | | - $canHide = $wgUser->isAllowed( 'deleterevision' ); |
218 | | - if( $canHide || ($rev->getVisibility() && $wgUser->isAllowed('deletedhistory')) ) { |
219 | | - if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) { |
220 | | - $del = $this->mSkin->revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops |
221 | | - } else { |
222 | | - $query = array( |
223 | | - 'type' => 'archive', |
224 | | - 'target' => $page->getPrefixedDbkey(), |
225 | | - 'ids' => $rev->getTimestamp() ); |
226 | | - $del = $this->mSkin->revDeleteLink( $query, |
227 | | - $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide ) . ' '; |
228 | | - } |
229 | | - } else { |
230 | | - $del = ''; |
231 | | - } |
| 217 | + $del = Linker::getRevDeleteLink( $wgUser, $rev, $page ); |
| 218 | + if ( $del ) $del .= ' '; |
232 | 219 | |
233 | 220 | $tools = Html::rawElement( |
234 | 221 | 'span', |