Legoktm has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/376067 )

Change subject: Avoid using $wgOut and $wgUser
......................................................................

Avoid using $wgOut and $wgUser

Plus improve some documentation

Change-Id: Ie9e7424d9b4a567ec7b935346e52fd0bc6e01b61
---
M frontend/FlaggedRevsUI.hooks.php
1 file changed, 27 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FlaggedRevs 
refs/changes/67/376067/1

diff --git a/frontend/FlaggedRevsUI.hooks.php b/frontend/FlaggedRevsUI.hooks.php
index 425ca68..936c288 100644
--- a/frontend/FlaggedRevsUI.hooks.php
+++ b/frontend/FlaggedRevsUI.hooks.php
@@ -5,9 +5,11 @@
 class FlaggedRevsUIHooks {
        /**
         * Add FlaggedRevs css/js.
+        *
+        * @param OutputPage $out
+        * @return bool
         */
-       protected static function injectStyleAndJS() {
-               global $wgOut, $wgUser;
+       protected static function injectStyleAndJS( OutputPage $out ) {
                static $loadedModules = false;
                if ( $loadedModules ) {
                        return true; // don't double-load
@@ -19,16 +21,23 @@
                        return true;
                }
                # Add main CSS & JS files
-               $wgOut->addModuleStyles( 'ext.flaggedRevs.basic' );
-               $wgOut->addModules( 'ext.flaggedRevs.advanced' );
+               $out->addModuleStyles( 'ext.flaggedRevs.basic' );
+               $out->addModules( 'ext.flaggedRevs.advanced' );
                # Add review form JS for reviewers
-               if ( $wgUser->isAllowed( 'review' ) ) {
-                       $wgOut->addModules( 'ext.flaggedRevs.review' );
-                       $wgOut->addModuleStyles( 
'ext.flaggedRevs.review.styles' );
+               if ( $out->getUser()->isAllowed( 'review' ) ) {
+                       $out->addModules( 'ext.flaggedRevs.review' );
+                       $out->addModuleStyles( 'ext.flaggedRevs.review.styles' 
);
                }
                return true;
        }
 
+       /**
+        * Hook: MakeGlobalVariablesScript
+        *
+        * @param array $globalVars
+        * @param OutputPage $out
+        * @return bool
+        */
        public static function injectGlobalJSVars( array &$globalVars, 
OutputPage $out ) {
                # Get the review tags on this wiki
                $rTags = FlaggedRevs::getJSTagParams();
@@ -80,7 +89,7 @@
                                }
                        }
                        $view->setRobotPolicy(); // set indexing policy
-                       self::injectStyleAndJS(); // full CSS/JS
+                       self::injectStyleAndJS( $out ); // full CSS/JS
                } else {
                        self::maybeAddBacklogNotice( $out ); // RC/Watchlist 
notice
                        self::injectStyleForSpecial( $out ); // try special 
page CSS
@@ -667,8 +676,16 @@
                return true;
        }
 
-       public static function onDiffViewHeader( $diff, $oldRev, $newRev ) {
-               self::injectStyleAndJS();
+       /**
+        * Hook: DiffViewHeader
+        *
+        * @param DifferenceEngine $diff
+        * @param Revision|null $oldRev
+        * @param Revision $newRev
+        * @return bool
+        */
+       public static function onDiffViewHeader( DifferenceEngine $diff, 
$oldRev, $newRev ) {
+               self::injectStyleAndJS( $diff->getOutput() );
                $view = FlaggablePageView::singleton();
                $view->setViewFlags( $diff, $oldRev, $newRev );
                $view->addToDiffView( $diff, $oldRev, $newRev );

-- 
To view, visit https://gerrit.wikimedia.org/r/376067
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie9e7424d9b4a567ec7b935346e52fd0bc6e01b61
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/FlaggedRevs
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to