Index: trunk/extensions/FlaggedRevs/presentation/FlaggedRevsUI.setup.php |
— | — | @@ -10,17 +10,31 @@ |
11 | 11 | * @param $hooks Array $wgHooks (assoc array of hooks and handlers) |
12 | 12 | * @return void |
13 | 13 | */ |
14 | | - public static function defineHookHandlers( &$hooks ) { |
| 14 | + public static function defineHookHandlers( array &$hooks ) { |
15 | 15 | global $wgFlaggedRevsProtection; |
16 | 16 | |
17 | | - # Override current revision, set cache... |
18 | | - $hooks['ArticleViewHeader'][] = 'FlaggedRevsUIHooks::onArticleViewHeader'; |
19 | | - $hooks['ImagePageFindFile'][] = 'FlaggedRevsUIHooks::onImagePageFindFile'; |
20 | | - # Override redirect behavior... |
21 | | - $hooks['InitializeArticleMaybeRedirect'][] = 'FlaggedRevsUIHooks::overrideRedirect'; |
22 | | - # Set page view tabs |
23 | | - $hooks['SkinTemplateTabs'][] = 'FlaggedRevsUIHooks::onSkinTemplateTabs'; // All skins |
24 | | - $hooks['SkinTemplateNavigation'][] = 'FlaggedRevsUIHooks::onSkinTemplateNavigation'; // Vector |
| 17 | + # XXX: Don't mess with dumpHTML article view output... |
| 18 | + if ( !defined( 'MW_HTML_FOR_DUMP' ) ) { |
| 19 | + # Override current revision, set cache... |
| 20 | + $hooks['ArticleViewHeader'][] = 'FlaggedRevsUIHooks::onArticleViewHeader'; |
| 21 | + $hooks['ImagePageFindFile'][] = 'FlaggedRevsUIHooks::onImagePageFindFile'; |
| 22 | + # Override redirect behavior... |
| 23 | + $hooks['InitializeArticleMaybeRedirect'][] = 'FlaggedRevsUIHooks::overrideRedirect'; |
| 24 | + # Set page view tabs (non-Vector) |
| 25 | + $hooks['SkinTemplateTabs'][] = 'FlaggedRevsUIHooks::onSkinTemplateTabs'; |
| 26 | + # Set page view tabs (Vector) |
| 27 | + $hooks['SkinTemplateNavigation'][] = 'FlaggedRevsUIHooks::onSkinTemplateNavigation'; |
| 28 | + # Add review form |
| 29 | + $hooks['SkinAfterContent'][] = 'FlaggedRevsUIHooks::onSkinAfterContent'; |
| 30 | + # Show unreviewed pages links |
| 31 | + $hooks['CategoryPageView'][] = 'FlaggedRevsUIHooks::onCategoryPageView'; |
| 32 | + # Mark items in file history (shown on page view) |
| 33 | + $hooks['LocalFile::getHistory'][] = 'FlaggedRevsUIHooks::addToFileHistQuery'; |
| 34 | + $hooks['ImagePageFileHistoryLine'][] = 'FlaggedRevsUIHooks::addToFileHistLine'; |
| 35 | + # Add review notice, backlog notices, protect form link, and CSS/JS and set robots |
| 36 | + $hooks['BeforePageDisplay'][] = 'FlaggedRevsUIHooks::onBeforePageDisplay'; |
| 37 | + } |
| 38 | + |
25 | 39 | # Add notice tags to edit view |
26 | 40 | $hooks['EditPage::showEditForm:initial'][] = 'FlaggedRevsUIHooks::addToEditView'; |
27 | 41 | # Tweak submit button name/title |
— | — | @@ -30,57 +44,47 @@ |
31 | 45 | $hooks['EditPage::showEditForm:fields'][] = 'FlaggedRevsUIHooks::addRevisionIDField'; |
32 | 46 | # Add draft link to section edit error |
33 | 47 | $hooks['EditPageNoSuchSection'][] = 'FlaggedRevsUIHooks::onNoSuchSection'; |
34 | | - # Add notice tags to history |
35 | | - $hooks['PageHistoryBeforeList'][] = 'FlaggedRevsUIHooks::addToHistView'; |
36 | | - # Add review form and visiblity settings link |
37 | | - $hooks['SkinAfterContent'][] = 'FlaggedRevsUIHooks::onSkinAfterContent'; |
| 48 | + # Page review on edit |
| 49 | + $hooks['ArticleUpdateBeforeRedirect'][] = 'FlaggedRevsUIHooks::injectPostEditURLParams'; |
| 50 | + |
38 | 51 | # Mark items in page history |
39 | 52 | $hooks['PageHistoryPager::getQueryInfo'][] = 'FlaggedRevsUIHooks::addToHistQuery'; |
40 | 53 | $hooks['PageHistoryLineEnding'][] = 'FlaggedRevsUIHooks::addToHistLine'; |
41 | | - $hooks['LocalFile::getHistory'][] = 'FlaggedRevsUIHooks::addToFileHistQuery'; |
42 | | - $hooks['ImagePageFileHistoryLine'][] = 'FlaggedRevsUIHooks::addToFileHistLine'; |
43 | 54 | # Select extra info & filter items in RC |
44 | 55 | $hooks['SpecialRecentChangesQuery'][] = 'FlaggedRevsUIHooks::modifyRecentChangesQuery'; |
45 | 56 | $hooks['SpecialNewpagesConditions'][] = 'FlaggedRevsUIHooks::modifyNewPagesQuery'; |
46 | 57 | $hooks['SpecialWatchlistQuery'][] = 'FlaggedRevsUIHooks::modifyChangesListQuery'; |
47 | 58 | # Mark items in RC |
48 | 59 | $hooks['ChangesListInsertArticleLink'][] = 'FlaggedRevsUIHooks::addToChangeListLine'; |
| 60 | + if ( !$wgFlaggedRevsProtection ) { |
| 61 | + # Mark items in user contribs |
| 62 | + $hooks['ContribsPager::getQueryInfo'][] = 'FlaggedRevsUIHooks::addToContribsQuery'; |
| 63 | + $hooks['ContributionsLineEnding'][] = 'FlaggedRevsUIHooks::addToContribsLine'; |
| 64 | + } |
| 65 | + |
49 | 66 | # RC filter UIs |
50 | 67 | $hooks['SpecialNewPagesFilters'][] = 'FlaggedRevsUIHooks::addHideReviewedFilter'; |
51 | 68 | $hooks['SpecialRecentChangesFilters'][] = 'FlaggedRevsUIHooks::addHideReviewedFilter'; |
52 | 69 | $hooks['SpecialWatchlistFilters'][] = 'FlaggedRevsUIHooks::addHideReviewedFilter'; |
53 | | - # Page review on edit |
54 | | - $hooks['ArticleUpdateBeforeRedirect'][] = 'FlaggedRevsUIHooks::injectPostEditURLParams'; |
| 70 | + # Add notice tags to history |
| 71 | + $hooks['PageHistoryBeforeList'][] = 'FlaggedRevsUIHooks::addToHistView'; |
55 | 72 | # Diff-to-stable |
56 | 73 | $hooks['DiffViewHeader'][] = 'FlaggedRevsUIHooks::onDiffViewHeader'; |
57 | 74 | # Add diff=review url param alias |
58 | 75 | $hooks['NewDifferenceEngine'][] = 'FlaggedRevsUIHooks::checkDiffUrl'; |
59 | 76 | # Local user account preference |
60 | 77 | $hooks['GetPreferences'][] = 'FlaggedRevsUIHooks::onGetPreferences'; |
61 | | - # Show unreviewed pages links |
62 | | - $hooks['CategoryPageView'][] = 'FlaggedRevsUIHooks::onCategoryPageView'; |
63 | 78 | # Review/stability log links |
64 | 79 | $hooks['LogLine'][] = 'FlaggedRevsUIHooks::logLineLinks'; |
65 | | - # Add review notice, backlog notices and CSS/JS and set robots |
66 | | - $hooks['BeforePageDisplay'][] = 'FlaggedRevsUIHooks::onBeforePageDisplay'; |
67 | 80 | # Add global JS vars |
68 | 81 | $hooks['MakeGlobalVariablesScript'][] = 'FlaggedRevsUIHooks::injectGlobalJSVars'; |
69 | 82 | |
70 | | - if ( !$wgFlaggedRevsProtection ) { |
71 | | - # Mark items in user contribs |
72 | | - $hooks['ContribsPager::getQueryInfo'][] = 'FlaggedRevsUIHooks::addToContribsQuery'; |
73 | | - $hooks['ContributionsLineEnding'][] = 'FlaggedRevsUIHooks::addToContribsLine'; |
74 | | - } else { |
| 83 | + if ( $wgFlaggedRevsProtection ) { |
75 | 84 | # Add protection form field |
76 | 85 | $hooks['ProtectionForm::buildForm'][] = 'FlaggedRevsUIHooks::onProtectionForm'; |
77 | 86 | $hooks['ProtectionForm::showLogExtract'][] = 'FlaggedRevsUIHooks::insertStabilityLog'; |
78 | 87 | # Save stability settings |
79 | 88 | $hooks['ProtectionForm::save'][] = 'FlaggedRevsUIHooks::onProtectionSave'; |
80 | | - # Parser stuff |
81 | | - $hooks['ParserFirstCallInit'][] = 'FlaggedRevsHooks::onParserFirstCallInit'; |
82 | | - $hooks['LanguageGetMagic'][] = 'FlaggedRevsHooks::onLanguageGetMagic'; |
83 | | - $hooks['ParserGetVariableValueSwitch'][] = 'FlaggedRevsHooks::onParserGetVariableValueSwitch'; |
84 | | - $hooks['MagicWordwgVariableIDs'][] = 'FlaggedRevsHooks::onMagicWordwgVariableIDs'; |
85 | 89 | } |
86 | 90 | } |
87 | 91 | |
— | — | @@ -134,7 +138,7 @@ |
135 | 139 | * @param $modules Array $wgResourceModules (list of modules) |
136 | 140 | * @return void |
137 | 141 | */ |
138 | | - public static function defineResourceModules( &$modules ) { |
| 142 | + public static function defineResourceModules( array &$modules ) { |
139 | 143 | $localModulePath = dirname( __FILE__ ) . '/modules/'; |
140 | 144 | $remoteModulePath = 'FlaggedRevs/presentation/modules'; |
141 | 145 | $modules['ext.flaggedRevs.basic'] = array( |
— | — | @@ -178,7 +182,7 @@ |
179 | 183 | * @param $ajaxExportList Array $wgAjaxExportList |
180 | 184 | * @return void |
181 | 185 | */ |
182 | | - public static function defineAjaxFunctions( &$ajaxExportList ) { |
| 186 | + public static function defineAjaxFunctions( array &$ajaxExportList ) { |
183 | 187 | $ajaxExportList[] = 'RevisionReview::AjaxReview'; |
184 | 188 | $ajaxExportList[] = 'FlaggablePageView::AjaxBuildDiffHeaderItems'; |
185 | 189 | } |
— | — | @@ -190,7 +194,9 @@ |
191 | 195 | * @param $filterLogTypes Array $wgFilterLogTypes |
192 | 196 | * @return void |
193 | 197 | */ |
194 | | - public static function defineLogBasicDescription( &$logNames, &$logHeaders, &$filterLogTypes ) { |
| 198 | + public static function defineLogBasicDescription( |
| 199 | + array &$logNames, array &$logHeaders, array &$filterLogTypes |
| 200 | + ) { |
195 | 201 | $logNames['review'] = 'review-logpage'; |
196 | 202 | $logHeaders['review'] = 'review-logpagetext'; |
197 | 203 | |
— | — | @@ -206,7 +212,9 @@ |
207 | 213 | * @param $logActionsHandlers Array $wgLogActionsHandlers (assoc array of log handlers) |
208 | 214 | * @return void |
209 | 215 | */ |
210 | | - public static function defineLogActionHandlers( &$logActions, &$logActionsHandlers ) { |
| 216 | + public static function defineLogActionHandlers( |
| 217 | + array &$logActions, array &$logActionsHandlers |
| 218 | + ) { |
211 | 219 | # Various actions are used for log filtering ... |
212 | 220 | $logActions['review/approve'] = 'review-logentry-app'; // checked (again) |
213 | 221 | $logActions['review/approve2'] = 'review-logentry-app'; // quality (again) |
Index: trunk/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php |
— | — | @@ -63,7 +63,7 @@ |
64 | 64 | } |
65 | 65 | |
66 | 66 | /* |
67 | | - * Add tag notice, CSS/JS, and set robots policy |
| 67 | + * Add tag notice, CSS/JS, protect form link, and set robots policy |
68 | 68 | */ |
69 | 69 | public static function onBeforePageDisplay( &$out, &$skin ) { |
70 | 70 | if ( $out->getTitle()->getNamespace() != NS_SPECIAL ) { |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.setup.php |
— | — | @@ -9,6 +9,8 @@ |
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Signal that LocalSettings.php is loaded. |
| 13 | + |
| 14 | + * @return void |
13 | 15 | */ |
14 | 16 | public static function setReady() { |
15 | 17 | self::$canLoad = true; |
— | — | @@ -16,6 +18,7 @@ |
17 | 19 | |
18 | 20 | /* |
19 | 21 | * The FlaggedRevs class uses this as a sanity check. |
| 22 | + |
20 | 23 | * @return bool |
21 | 24 | */ |
22 | 25 | public static function isReady() { |
— | — | @@ -31,7 +34,9 @@ |
32 | 35 | * @param $aliasesFiles Array $wgExtensionAliasesFiles |
33 | 36 | * @return void |
34 | 37 | */ |
35 | | - public static function defineSourcePaths( &$classes, &$messagesFiles, &$aliasesFiles ) { |
| 38 | + public static function defineSourcePaths( |
| 39 | + array &$classes, array &$messagesFiles, array &$aliasesFiles |
| 40 | + ) { |
36 | 41 | $dir = dirname( __FILE__ ); |
37 | 42 | |
38 | 43 | # Basic directory layout |
— | — | @@ -233,15 +238,23 @@ |
234 | 239 | * @return void |
235 | 240 | */ |
236 | 241 | public static function setConditionalHooks() { |
237 | | - global $wgHooks; |
| 242 | + global $wgHooks, $wgFlaggedRevsProtection; |
238 | 243 | |
| 244 | + # Give bots the 'autoreview' right (here so it triggers after CentralAuth) |
| 245 | + # @TODO: better way to ensure hook order |
| 246 | + $wgHooks['UserGetRights'][] = 'FlaggedRevsHooks::onUserGetRights'; |
| 247 | + |
| 248 | + if ( $wgFlaggedRevsProtection ) { |
| 249 | + # Add pending changes related magic words |
| 250 | + $wgHooks['ParserFirstCallInit'][] = 'FlaggedRevsHooks::onParserFirstCallInit'; |
| 251 | + $wgHooks['LanguageGetMagic'][] = 'FlaggedRevsHooks::onLanguageGetMagic'; |
| 252 | + $wgHooks['ParserGetVariableValueSwitch'][] = 'FlaggedRevsHooks::onParserGetVariableValueSwitch'; |
| 253 | + $wgHooks['MagicWordwgVariableIDs'][] = 'FlaggedRevsHooks::onMagicWordwgVariableIDs'; |
| 254 | + } |
| 255 | + |
239 | 256 | # ######## User interface ######### |
240 | 257 | FlaggedRevsUISetup::defineHookHandlers( $wgHooks ); |
241 | 258 | # ######## |
242 | | - |
243 | | - # Give bots the 'autoreview' right (here so it triggers after CentralAuth) |
244 | | - # @TODO: better way to ensure hook order |
245 | | - $wgHooks['UserGetRights'][] = 'FlaggedRevsHooks::onUserGetRights'; |
246 | 259 | } |
247 | 260 | |
248 | 261 | /** |
— | — | @@ -252,6 +265,7 @@ |
253 | 266 | public static function setAutopromoteConfig() { |
254 | 267 | global $wgFlaggedRevsAutoconfirm, $wgFlaggedRevsAutopromote; |
255 | 268 | global $wgAutopromoteOnce, $wgGroupPermissions; |
| 269 | + |
256 | 270 | # $wgFlaggedRevsAutoconfirm is now a wrapper around $wgAutopromoteOnce |
257 | 271 | $req = $wgFlaggedRevsAutoconfirm; // convenience |
258 | 272 | if ( is_array( $req ) ) { |
— | — | @@ -312,6 +326,7 @@ |
313 | 327 | */ |
314 | 328 | public static function setSpecialPages() { |
315 | 329 | global $wgSpecialPages, $wgSpecialPageGroups, $wgSpecialPageCacheUpdates; |
| 330 | + |
316 | 331 | FlaggedRevsUISetup::defineSpecialPages( |
317 | 332 | $wgSpecialPages, $wgSpecialPageGroups, $wgSpecialPageCacheUpdates ); |
318 | 333 | } |
— | — | @@ -324,6 +339,7 @@ |
325 | 340 | public static function setAPIModules() { |
326 | 341 | global $wgAPIModules, $wgAPIListModules, $wgAPIPropModules; |
327 | 342 | global $wgFlaggedRevsProtection; |
| 343 | + |
328 | 344 | if ( $wgFlaggedRevsProtection ) { |
329 | 345 | $wgAPIModules['stabilize'] = 'ApiStabilizeProtect'; |
330 | 346 | } else { |
— | — | @@ -351,6 +367,7 @@ |
352 | 368 | */ |
353 | 369 | public static function setConditionalRights() { |
354 | 370 | global $wgGroupPermissions, $wgFlaggedRevsProtection; |
| 371 | + |
355 | 372 | if ( $wgFlaggedRevsProtection ) { |
356 | 373 | // XXX: Removes sp:ListGroupRights cruft |
357 | 374 | if ( isset( $wgGroupPermissions['editor'] ) ) { |
— | — | @@ -369,6 +386,7 @@ |
370 | 387 | */ |
371 | 388 | public static function setConditionalPreferences() { |
372 | 389 | global $wgDefaultUserOptions, $wgSimpleFlaggedRevsUI; |
| 390 | + |
373 | 391 | $wgDefaultUserOptions['flaggedrevssimpleui'] = (int)$wgSimpleFlaggedRevsUI; |
374 | 392 | } |
375 | 393 | } |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -40,11 +40,6 @@ |
41 | 41 | # Load default configuration variables |
42 | 42 | require( "FlaggedRevs.config.php" ); |
43 | 43 | |
44 | | -# XXX: Don't mess with dump HTML... |
45 | | -if ( defined( 'MW_HTML_FOR_DUMP' ) ) { |
46 | | - return; // done after default config set to avoid LocalSettings errors |
47 | | -} |
48 | | - |
49 | 44 | # Define were classes and i18n files are located |
50 | 45 | require( "FlaggedRevs.setup.php" ); |
51 | 46 | FlaggedRevsSetup::defineSourcePaths( |
— | — | @@ -96,7 +91,7 @@ |
97 | 92 | # Load the extension after setup is finished |
98 | 93 | $wgExtensionFunctions[] = 'efLoadFlaggedRevs'; |
99 | 94 | |
100 | | -/* |
| 95 | +/** |
101 | 96 | * This function is for setup that has to happen in Setup.php |
102 | 97 | * when the functions in $wgExtensionFunctions get executed. |
103 | 98 | * Note: avoid calls to FlaggedRevs class here for performance. |