jenkins-bot has submitted this change and it was merged.

Change subject: Remove default gadgets from Special:GadgetUsage
......................................................................


Remove default gadgets from Special:GadgetUsage

The numbers for default gadgets are inconsistent and can be misleading.

Change-Id: Ib46084d617a536e4e25da80424ad70cec2a09f5a
---
M SpecialGadgetUsage.php
1 file changed, 25 insertions(+), 4 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/SpecialGadgetUsage.php b/SpecialGadgetUsage.php
index 8356d7e..88205d2 100644
--- a/SpecialGadgetUsage.php
+++ b/SpecialGadgetUsage.php
@@ -96,6 +96,23 @@
        }
 
        /**
+        * Get a list of default gadgets
+        * @return list
+       */
+       protected function getDefaultGadgets() {
+               $gadgetRepo = GadgetRepo::singleton();
+               $gadgetIds = $gadgetRepo->getGadgetIds();
+               $gadgetsList = array();
+               foreach ( $gadgetIds as $g ) {
+                       $gadget = $gadgetRepo->getGadget( $g );
+                       if ( $gadget->isOnByDefault() ) {
+                               $gadgetsList[] = $gadget->getName();
+                       }
+               }
+               return $gadgetsList;
+       }
+
+       /**
         * Format and output report results using the given information plus
         * OutputPage
         *
@@ -107,13 +124,17 @@
         * @param int $offset Paging offset
         */
        protected function outputResults( $out, $skin, $dbr, $res, $num, 
$offset ) {
+               $defaultGadgets = $this->getDefaultGadgets();
                if ( $num > 0 ) {
                        $this->outputTableStart();
-
                        foreach ( $res as $row ) {
-                               $line = $this->formatResult( $skin, $row );
-                               if ( $line ) {
-                                       $out->addHTML( $line );
+                               // Remove the 'gadget-' part of the result 
string and compare if it's present
+                               // in $defaultGadgets, if not we format it and 
add it to the output
+                               if ( !in_array( substr( $row->title, 7 ), 
$defaultGadgets ) ) {
+                                       $line = $this->formatResult( $skin, 
$row );
+                                       if ( $line ) {
+                                               $out->addHTML( $line );
+                                       }
                                }
                        }
                        // Close table element

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib46084d617a536e4e25da80424ad70cec2a09f5a
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Gadgets
Gerrit-Branch: master
Gerrit-Owner: Niharika29 <[email protected]>
Gerrit-Reviewer: Glaisher <[email protected]>
Gerrit-Reviewer: Kaldari <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to