Index: trunk/extensions/Oversight/HideRevision.hooks.php |
— | — | @@ -0,0 +1,95 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class HideRevisionHooks { |
| 5 | + /** |
| 6 | + * Hook for article view, giving us a chance to insert a removal |
| 7 | + * tab on old version views. |
| 8 | + */ |
| 9 | + public static function onArticleViewHeader( $article ) { |
| 10 | + $oldid = intval( $article->mOldId ); |
| 11 | + if( $oldid ) { |
| 12 | + self::installTab( $oldid ); |
| 13 | + } |
| 14 | + return true; |
| 15 | + } |
| 16 | + |
| 17 | + /** |
| 18 | + * Hook for diff view, giving us a chance to insert a removal |
| 19 | + * tab on old version views. |
| 20 | + */ |
| 21 | + public static function onDiffViewHeader( $diff, $oldRev, $newRev ) { |
| 22 | + if( !empty( $newRev ) && $newRev->getId() ) { |
| 23 | + self::installTab( $newRev->getId() ); |
| 24 | + } |
| 25 | + return true; |
| 26 | + } |
| 27 | + |
| 28 | + /** |
| 29 | + * Hook for deletion archive revision view, giving us a chance to |
| 30 | + * insert a removal tab for a deleted revision. |
| 31 | + */ |
| 32 | + public static function onUndeleteShowRevision( $title, $rev ) { |
| 33 | + self::installArchiveTab( $title, $rev->getTimestamp() ); |
| 34 | + return true; |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * |
| 39 | + */ |
| 40 | + public static function onContributionsToolLinks( $id, $nt, &$tools ) { |
| 41 | + global $wgUser; |
| 42 | + if( $wgUser->isAllowed( 'oversight' ) ) { |
| 43 | + wfLoadExtensionMessages( 'HideRevision' ); |
| 44 | + $title = SpecialPage::getTitleFor( 'Oversight' ); |
| 45 | + $tools[] = $wgUser->getSkin()->makeKnownLinkObj( $title, wfMsgHtml( 'hiderevision-link' ), 'author=' . $nt->getPartialUrl() ); |
| 46 | + } |
| 47 | + return true; |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * If the user is allowed, installs a tab hook on the skin |
| 52 | + * which links to a handy permanent removal thingy. |
| 53 | + */ |
| 54 | + private static function installTab( $id ) { |
| 55 | + global $wgUser; |
| 56 | + if( $wgUser->isAllowed( 'hiderevision' ) ) { |
| 57 | + global $wgHooks; |
| 58 | + $tab = new HideRevisionTabInstaller( 'revision[]=' . $id ); |
| 59 | + $wgHooks['SkinTemplateTabs'][] = array( $tab, 'insertTab' ); |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * If the user is allowed, installs a tab hook on the skin |
| 65 | + * which links to a handy permanent removal thingy for |
| 66 | + * archived (deleted) pages. |
| 67 | + */ |
| 68 | + private static function installArchiveTab( $target, $timestamp ) { |
| 69 | + global $wgUser; |
| 70 | + if( $wgUser->isAllowed( 'hiderevision' ) ) { |
| 71 | + global $wgHooks; |
| 72 | + $tab = new HideRevisionTabInstaller( |
| 73 | + 'target=' . $target->getPrefixedUrl() . |
| 74 | + '×tamp[]=' . $timestamp ); |
| 75 | + $wgHooks['SkinTemplateBuildContentActionUrlsAfterSpecialPage'][] = |
| 76 | + array( $tab, 'insertTab' ); |
| 77 | + } |
| 78 | + } |
| 79 | +} |
| 80 | + |
| 81 | +class HideRevisionTabInstaller { |
| 82 | + function __construct( $linkParam ) { |
| 83 | + $this->mLinkParam = $linkParam; |
| 84 | + } |
| 85 | + |
| 86 | + function insertTab( $skin, &$content_actions ) { |
| 87 | + wfLoadExtensionMessages( 'HideRevision' ); |
| 88 | + $special = SpecialPage::getTitleFor( 'HideRevision' ); |
| 89 | + $content_actions['hiderevision'] = array( |
| 90 | + 'class' => false, |
| 91 | + 'text' => wfMsgHTML( 'hiderevision-tab' ), |
| 92 | + 'href' => $special->getLocalUrl( $this->mLinkParam ) ); |
| 93 | + return true; |
| 94 | + } |
| 95 | +} |
| 96 | + |
Property changes on: trunk/extensions/Oversight/HideRevision.hooks.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 97 | + native |
Index: trunk/extensions/Oversight/HideRevision.i18n.php |
— | — | @@ -35,6 +35,8 @@ |
36 | 36 | |
37 | 37 | // Tab displayed to allowed users on old revision display |
38 | 38 | 'hiderevision-tab' => 'Hide revision', |
| 39 | + // Displayed on Users contributions |
| 40 | + 'hiderevision-link' => 'Hidden user contributions', |
39 | 41 | |
40 | 42 | // Status & errors on action |
41 | 43 | 'hiderevision-norevisions' => 'No revisions specified to delete.', |
Index: trunk/extensions/Oversight/HideRevision.php |
— | — | @@ -43,103 +43,27 @@ |
44 | 44 | $wgExtensionCredits['specialpage'][] = array( |
45 | 45 | 'name' => 'Oversight', |
46 | 46 | 'author' => 'Brion Vibber', |
47 | | - 'svn-date' => '$LastChangedDate$', |
48 | | - 'svn-revision' => '$LastChangedRevision$', |
| 47 | + 'svn-date' => '$LastChangedDate$', |
| 48 | + 'svn-revision' => '$LastChangedRevision$', |
49 | 49 | 'url' => 'http://www.mediawiki.org/wiki/Extension:Oversight', |
50 | 50 | 'description' => 'Hide individual revisions from all users for legal reasons, etc.', |
51 | 51 | 'descriptionmsg' => 'hiderevision-desc', |
52 | 52 | ); |
53 | 53 | |
54 | | -$dir = dirname(__FILE__) . '/'; |
| 54 | +$dir = dirname( __FILE__ ) . '/'; |
55 | 55 | $wgExtensionMessagesFiles['HideRevision'] = $dir . 'HideRevision.i18n.php'; |
56 | 56 | $wgExtensionAliasesFiles['HideRevision'] = $dir . 'HideRevision.alias.php'; |
57 | 57 | |
58 | 58 | $wgAutoloadClasses['HideRevisionForm'] = $dir . 'HideRevision_body.php'; |
59 | 59 | $wgAutoloadClasses['SpecialOversight'] = $dir . 'HideRevision_body.php'; |
| 60 | +$wgAutoloadClasses['HideRevisionHooks'] = $dir . 'HideRevision.hooks.php'; |
60 | 61 | |
61 | 62 | $wgSpecialPages['HideRevision'] = 'HideRevisionForm'; |
62 | 63 | $wgSpecialPages['Oversight'] = 'SpecialOversight'; |
63 | 64 | $wgSpecialPageGroups['HideRevision'] = 'pagetools'; |
64 | 65 | $wgSpecialPageGroups['Oversight'] = 'pagetools'; |
65 | 66 | |
66 | | -$wgHooks['ArticleViewHeader'][] = 'hrArticleViewHeaderHook'; |
67 | | -$wgHooks['DiffViewHeader'][] = 'hrDiffViewHeaderHook'; |
68 | | -$wgHooks['UndeleteShowRevision'][] = 'hrUndeleteShowRevisionHook'; |
69 | | - |
70 | | -/** |
71 | | - * Hook for article view, giving us a chance to insert a removal |
72 | | - * tab on old version views. |
73 | | - */ |
74 | | -function hrArticleViewHeaderHook( $article ) { |
75 | | - $oldid = intval( $article->mOldId ); |
76 | | - if( $oldid ) { |
77 | | - hrInstallTab( $oldid ); |
78 | | - } |
79 | | - return true; |
80 | | -} |
81 | | - |
82 | | -/** |
83 | | - * Hook for diff view, giving us a chance to insert a removal |
84 | | - * tab on old version views. |
85 | | - */ |
86 | | -function hrDiffViewHeaderHook( $diff, $oldRev, $newRev ) { |
87 | | - if( !empty( $newRev ) && $newRev->getId() ) { |
88 | | - hrInstallTab( $newRev->getId() ); |
89 | | - } |
90 | | - return true; |
91 | | -} |
92 | | - |
93 | | -/** |
94 | | - * Hook for deletion archive revision view, giving us a chance to |
95 | | - * insert a removal tab for a deleted revision. |
96 | | - */ |
97 | | -function hrUndeleteShowRevisionHook( $title, $rev ) { |
98 | | - hrInstallArchiveTab( $title, $rev->getTimestamp() ); |
99 | | - return true; |
100 | | -} |
101 | | - |
102 | | -class HideRevisionTabInstaller { |
103 | | - function __construct( $linkParam ) { |
104 | | - $this->mLinkParam = $linkParam; |
105 | | - } |
106 | | - |
107 | | - function insertTab( $skin, &$content_actions ) { |
108 | | - wfLoadExtensionMessages ('HideRevision'); |
109 | | - $special = Title::makeTitle( NS_SPECIAL, 'HideRevision' ); |
110 | | - $content_actions['hiderevision'] = array( |
111 | | - 'class' => false, |
112 | | - 'text' => wfMsgHTML( 'hiderevision-tab' ), |
113 | | - 'href' => $special->getLocalUrl( $this->mLinkParam ) ); |
114 | | - return true; |
115 | | - } |
116 | | -} |
117 | | - |
118 | | -/** |
119 | | - * If the user is allowed, installs a tab hook on the skin |
120 | | - * which links to a handy permanent removal thingy. |
121 | | - */ |
122 | | -function hrInstallTab( $id ) { |
123 | | - global $wgUser; |
124 | | - if( $wgUser->isAllowed( 'hiderevision' ) ) { |
125 | | - global $wgHooks; |
126 | | - $tab = new HideRevisionTabInstaller( 'revision[]=' . $id ); |
127 | | - $wgHooks['SkinTemplateTabs'][] = array( $tab, 'insertTab' ); |
128 | | - } |
129 | | -} |
130 | | - |
131 | | -/** |
132 | | - * If the user is allowed, installs a tab hook on the skin |
133 | | - * which links to a handy permanent removal thingy for |
134 | | - * archived (deleted) pages. |
135 | | - */ |
136 | | -function hrInstallArchiveTab( $target, $timestamp ) { |
137 | | - global $wgUser; |
138 | | - if( $wgUser->isAllowed( 'hiderevision' ) ) { |
139 | | - global $wgHooks; |
140 | | - $tab = new HideRevisionTabInstaller( |
141 | | - 'target=' . $target->getPrefixedUrl() . |
142 | | - '×tamp[]=' . $timestamp ); |
143 | | - $wgHooks['SkinTemplateBuildContentActionUrlsAfterSpecialPage'][] = |
144 | | - array( $tab, 'insertTab' ); |
145 | | - } |
146 | | -} |
| 67 | +$wgHooks['ArticleViewHeader'][] = 'HideRevisionHooks::onArticleViewHeader'; |
| 68 | +$wgHooks['DiffViewHeader'][] = 'HideRevisionHooks::onDiffViewHeader'; |
| 69 | +$wgHooks['UndeleteShowRevision'][] = 'HideRevisionHooks::onUndeleteShowRevision'; |
| 70 | +$wgHooks['ContributionsToolLinks'][] = 'HideRevisionHooks::onContributionsToolLinks'; |