r99339 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99338‎ | r99339 | r99340 >
Date:06:31, 9 October 2011
Author:aaron
Status:ok
Tags:
Comment:
Moved UI-related hooks to FlaggedRevsUISetup::defineHookHandlers()
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/presentation/FlaggedRevsUI.setup.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -195,63 +195,9 @@
196196 # JS/CSS modules and message bundles used by JS scripts
197197 FlaggedRevsUISetup::defineResourceModules( $wgResourceModules );
198198
199 -# ####### EVENT-HANDLER FUNCTIONS #########
 199+# ####### EVENT-HANDLER FUNCTIONS #########
200200
201 -# ######## User interface #########
202 -# Override current revision, add patrol links, set cache...
203 -$wgHooks['ArticleViewHeader'][] = 'FlaggedRevsUIHooks::onArticleViewHeader';
204 -$wgHooks['ImagePageFindFile'][] = 'FlaggedRevsUIHooks::onImagePageFindFile';
205 -# Override redirect behavior...
206 -$wgHooks['InitializeArticleMaybeRedirect'][] = 'FlaggedRevsUIHooks::overrideRedirect';
207 -# Set page view tabs
208 -$wgHooks['SkinTemplateTabs'][] = 'FlaggedRevsUIHooks::onSkinTemplateTabs'; // All skins
209 -$wgHooks['SkinTemplateNavigation'][] = 'FlaggedRevsUIHooks::onSkinTemplateNavigation'; // Vector
210 -# Add notice tags to edit view
211 -$wgHooks['EditPage::showEditForm:initial'][] = 'FlaggedRevsUIHooks::addToEditView';
212 -# Tweak submit button name/title
213 -$wgHooks['EditPageBeforeEditButtons'][] = 'FlaggedRevsUIHooks::onBeforeEditButtons';
214 -# Autoreview information from form
215 -$wgHooks['EditPageBeforeEditChecks'][] = 'FlaggedRevsUIHooks::addReviewCheck';
216 -$wgHooks['EditPage::showEditForm:fields'][] = 'FlaggedRevsUIHooks::addRevisionIDField';
217 -# Add draft link to section edit error
218 -$wgHooks['EditPageNoSuchSection'][] = 'FlaggedRevsUIHooks::onNoSuchSection';
219 -# Add notice tags to history
220 -$wgHooks['PageHistoryBeforeList'][] = 'FlaggedRevsUIHooks::addToHistView';
221 -# Add review form and visiblity settings link
222 -$wgHooks['SkinAfterContent'][] = 'FlaggedRevsUIHooks::onSkinAfterContent';
223 -# Mark items in page history
224 -$wgHooks['PageHistoryPager::getQueryInfo'][] = 'FlaggedRevsUIHooks::addToHistQuery';
225 -$wgHooks['PageHistoryLineEnding'][] = 'FlaggedRevsUIHooks::addToHistLine';
226 -$wgHooks['LocalFile::getHistory'][] = 'FlaggedRevsUIHooks::addToFileHistQuery';
227 -$wgHooks['ImagePageFileHistoryLine'][] = 'FlaggedRevsUIHooks::addToFileHistLine';
228 -# Select extra info & filter items in RC
229 -$wgHooks['SpecialRecentChangesQuery'][] = 'FlaggedRevsUIHooks::modifyRecentChangesQuery';
230 -$wgHooks['SpecialNewpagesConditions'][] = 'FlaggedRevsUIHooks::modifyNewPagesQuery';
231 -$wgHooks['SpecialWatchlistQuery'][] = 'FlaggedRevsUIHooks::modifyChangesListQuery';
232 -# Mark items in RC
233 -$wgHooks['ChangesListInsertArticleLink'][] = 'FlaggedRevsUIHooks::addToChangeListLine';
234 -# RC filter UIs
235 -$wgHooks['SpecialNewPagesFilters'][] = 'FlaggedRevsUIHooks::addHideReviewedFilter';
236 -$wgHooks['SpecialRecentChangesFilters'][] = 'FlaggedRevsUIHooks::addHideReviewedFilter';
237 -$wgHooks['SpecialWatchlistFilters'][] = 'FlaggedRevsUIHooks::addHideReviewedFilter';
238 -# Page review on edit
239 -$wgHooks['ArticleUpdateBeforeRedirect'][] = 'FlaggedRevsUIHooks::injectPostEditURLParams';
240 -# Diff-to-stable
241 -$wgHooks['DiffViewHeader'][] = 'FlaggedRevsUIHooks::onDiffViewHeader';
242 -# Add diff=review url param alias
243 -$wgHooks['NewDifferenceEngine'][] = 'FlaggedRevsUIHooks::checkDiffUrl';
244 -# Local user account preference
245 -$wgHooks['GetPreferences'][] = 'FlaggedRevsUIHooks::onGetPreferences';
246 -# Show unreviewed pages links
247 -$wgHooks['CategoryPageView'][] = 'FlaggedRevsUIHooks::onCategoryPageView';
248 -# Review/stability log links
249 -$wgHooks['LogLine'][] = 'FlaggedRevsUIHooks::logLineLinks';
250 -
251 -# Add review notice, backlog notices and CSS/JS and set robots
252 -$wgHooks['BeforePageDisplay'][] = 'FlaggedRevsUIHooks::onBeforePageDisplay';
253 -# Add global JS vars
254 -$wgHooks['MakeGlobalVariablesScript'][] = 'FlaggedRevsUIHooks::injectGlobalJSVars';
255 -
 201+# ######## API ########
256202 # Add flagging data to ApiQueryRevisions
257203 $wgHooks['APIGetAllowedParams'][] = 'FlaggedRevsApiHooks::addApiRevisionParams';
258204 $wgHooks['APIQueryAfterExecute'][] = 'FlaggedRevsApiHooks::addApiRevisionData';
@@ -316,29 +262,18 @@
317263 # ########
318264
319265 function efSetFlaggedRevsConditionalHooks() {
320 - global $wgHooks, $wgFlaggedRevsProtection;
321 - # Mark items in user contribs
322 - if ( !$wgFlaggedRevsProtection ) {
323 - $wgHooks['ContribsPager::getQueryInfo'][] = 'FlaggedRevsUIHooks::addToContribsQuery';
324 - $wgHooks['ContributionsLineEnding'][] = 'FlaggedRevsUIHooks::addToContribsLine';
325 - } else {
326 - # Add protection form field
327 - $wgHooks['ProtectionForm::buildForm'][] = 'FlaggedRevsUIHooks::onProtectionForm';
328 - $wgHooks['ProtectionForm::showLogExtract'][] = 'FlaggedRevsUIHooks::insertStabilityLog';
329 - # Save stability settings
330 - $wgHooks['ProtectionForm::save'][] = 'FlaggedRevsUIHooks::onProtectionSave';
331 - # Parser stuff
332 - $wgHooks['ParserFirstCallInit'][] = 'FlaggedRevsHooks::onParserFirstCallInit';
333 - $wgHooks['LanguageGetMagic'][] = 'FlaggedRevsHooks::onLanguageGetMagic';
334 - $wgHooks['ParserGetVariableValueSwitch'][] = 'FlaggedRevsHooks::onParserGetVariableValueSwitch';
335 - $wgHooks['MagicWordwgVariableIDs'][] = 'FlaggedRevsHooks::onMagicWordwgVariableIDs';
336 - }
 266+ global $wgHooks;
 267+
 268+ # ######## User interface #########
 269+ FlaggedRevsUISetup::defineHookHandlers( $wgHooks );
 270+ # ########
 271+
337272 # Give bots the 'autoreview' right (here so it triggers after CentralAuth)
338273 # @TODO: better way to ensure hook order
339274 $wgHooks['UserGetRights'][] = 'FlaggedRevsHooks::onUserGetRights';
340275 }
341276
342 -# ####### END HOOK TRIGGERED FUNCTIONS #########
 277+# ####### END HOOK TRIGGERED FUNCTIONS #########
343278
344279 // Note: avoid calls to FlaggedRevs class here for performance
345280 function efLoadFlaggedRevs() {
Index: trunk/extensions/FlaggedRevs/presentation/FlaggedRevsUI.setup.php
@@ -3,6 +3,85 @@
44 * Class containing hooked functions for a FlaggedRevs environment
55 */
66 class FlaggedRevsUISetup {
 7+ /**
 8+ * Register FlaggedRevs hooks.
 9+ * @param $hooks Array $wgHooks (assoc array of hooks and handlers)
 10+ * @return void
 11+ */
 12+ public static function defineHookHandlers( &$hooks ) {
 13+ global $wgFlaggedRevsProtection;
 14+
 15+ # Override current revision, add patrol links, set cache...
 16+ $hooks['ArticleViewHeader'][] = 'FlaggedRevsUIHooks::onArticleViewHeader';
 17+ $hooks['ImagePageFindFile'][] = 'FlaggedRevsUIHooks::onImagePageFindFile';
 18+ # Override redirect behavior...
 19+ $hooks['InitializeArticleMaybeRedirect'][] = 'FlaggedRevsUIHooks::overrideRedirect';
 20+ # Set page view tabs
 21+ $hooks['SkinTemplateTabs'][] = 'FlaggedRevsUIHooks::onSkinTemplateTabs'; // All skins
 22+ $hooks['SkinTemplateNavigation'][] = 'FlaggedRevsUIHooks::onSkinTemplateNavigation'; // Vector
 23+ # Add notice tags to edit view
 24+ $hooks['EditPage::showEditForm:initial'][] = 'FlaggedRevsUIHooks::addToEditView';
 25+ # Tweak submit button name/title
 26+ $hooks['EditPageBeforeEditButtons'][] = 'FlaggedRevsUIHooks::onBeforeEditButtons';
 27+ # Autoreview information from form
 28+ $hooks['EditPageBeforeEditChecks'][] = 'FlaggedRevsUIHooks::addReviewCheck';
 29+ $hooks['EditPage::showEditForm:fields'][] = 'FlaggedRevsUIHooks::addRevisionIDField';
 30+ # Add draft link to section edit error
 31+ $hooks['EditPageNoSuchSection'][] = 'FlaggedRevsUIHooks::onNoSuchSection';
 32+ # Add notice tags to history
 33+ $hooks['PageHistoryBeforeList'][] = 'FlaggedRevsUIHooks::addToHistView';
 34+ # Add review form and visiblity settings link
 35+ $hooks['SkinAfterContent'][] = 'FlaggedRevsUIHooks::onSkinAfterContent';
 36+ # Mark items in page history
 37+ $hooks['PageHistoryPager::getQueryInfo'][] = 'FlaggedRevsUIHooks::addToHistQuery';
 38+ $hooks['PageHistoryLineEnding'][] = 'FlaggedRevsUIHooks::addToHistLine';
 39+ $hooks['LocalFile::getHistory'][] = 'FlaggedRevsUIHooks::addToFileHistQuery';
 40+ $hooks['ImagePageFileHistoryLine'][] = 'FlaggedRevsUIHooks::addToFileHistLine';
 41+ # Select extra info & filter items in RC
 42+ $hooks['SpecialRecentChangesQuery'][] = 'FlaggedRevsUIHooks::modifyRecentChangesQuery';
 43+ $hooks['SpecialNewpagesConditions'][] = 'FlaggedRevsUIHooks::modifyNewPagesQuery';
 44+ $hooks['SpecialWatchlistQuery'][] = 'FlaggedRevsUIHooks::modifyChangesListQuery';
 45+ # Mark items in RC
 46+ $hooks['ChangesListInsertArticleLink'][] = 'FlaggedRevsUIHooks::addToChangeListLine';
 47+ # RC filter UIs
 48+ $hooks['SpecialNewPagesFilters'][] = 'FlaggedRevsUIHooks::addHideReviewedFilter';
 49+ $hooks['SpecialRecentChangesFilters'][] = 'FlaggedRevsUIHooks::addHideReviewedFilter';
 50+ $hooks['SpecialWatchlistFilters'][] = 'FlaggedRevsUIHooks::addHideReviewedFilter';
 51+ # Page review on edit
 52+ $hooks['ArticleUpdateBeforeRedirect'][] = 'FlaggedRevsUIHooks::injectPostEditURLParams';
 53+ # Diff-to-stable
 54+ $hooks['DiffViewHeader'][] = 'FlaggedRevsUIHooks::onDiffViewHeader';
 55+ # Add diff=review url param alias
 56+ $hooks['NewDifferenceEngine'][] = 'FlaggedRevsUIHooks::checkDiffUrl';
 57+ # Local user account preference
 58+ $hooks['GetPreferences'][] = 'FlaggedRevsUIHooks::onGetPreferences';
 59+ # Show unreviewed pages links
 60+ $hooks['CategoryPageView'][] = 'FlaggedRevsUIHooks::onCategoryPageView';
 61+ # Review/stability log links
 62+ $hooks['LogLine'][] = 'FlaggedRevsUIHooks::logLineLinks';
 63+ # Add review notice, backlog notices and CSS/JS and set robots
 64+ $hooks['BeforePageDisplay'][] = 'FlaggedRevsUIHooks::onBeforePageDisplay';
 65+ # Add global JS vars
 66+ $hooks['MakeGlobalVariablesScript'][] = 'FlaggedRevsUIHooks::injectGlobalJSVars';
 67+
 68+ if ( !$wgFlaggedRevsProtection ) {
 69+ # Mark items in user contribs
 70+ $hooks['ContribsPager::getQueryInfo'][] = 'FlaggedRevsUIHooks::addToContribsQuery';
 71+ $hooks['ContributionsLineEnding'][] = 'FlaggedRevsUIHooks::addToContribsLine';
 72+ } else {
 73+ # Add protection form field
 74+ $hooks['ProtectionForm::buildForm'][] = 'FlaggedRevsUIHooks::onProtectionForm';
 75+ $hooks['ProtectionForm::showLogExtract'][] = 'FlaggedRevsUIHooks::insertStabilityLog';
 76+ # Save stability settings
 77+ $hooks['ProtectionForm::save'][] = 'FlaggedRevsUIHooks::onProtectionSave';
 78+ # Parser stuff
 79+ $hooks['ParserFirstCallInit'][] = 'FlaggedRevsHooks::onParserFirstCallInit';
 80+ $hooks['LanguageGetMagic'][] = 'FlaggedRevsHooks::onLanguageGetMagic';
 81+ $hooks['ParserGetVariableValueSwitch'][] = 'FlaggedRevsHooks::onParserGetVariableValueSwitch';
 82+ $hooks['MagicWordwgVariableIDs'][] = 'FlaggedRevsHooks::onMagicWordwgVariableIDs';
 83+ }
 84+ }
 85+
786 /*
887 * Register FlaggedRevs special pages as needed.
988 * @param $pages Array $wgSpecialPages (list of special pages)
@@ -93,6 +172,7 @@
94173 * @param $logNames Array $wgLogNames (assoc array of log name message keys)
95174 * @param $logHeaders Array $wgLogHeaders (assoc array of log header message keys)
96175 * @param $filterLogTypes Array $wgFilterLogTypes
 176+ * @return void
97177 */
98178 public static function defineLogBasicDescription( &$logNames, &$logHeaders, &$filterLogTypes ) {
99179 $logNames['review'] = 'review-logpage';

Status & tagging log