http://www.mediawiki.org/wiki/Special:Code/MediaWiki/95981

Revision: 95981
Author:   catrope
Date:     2011-09-01 13:31:21 +0000 (Thu, 01 Sep 2011)
Log Message:
-----------
RL2: Make list=gadgetcategories work again

Modified Paths:
--------------
    branches/RL2/extensions/Gadgets/api/ApiQueryGadgetCategories.php

Modified: branches/RL2/extensions/Gadgets/api/ApiQueryGadgetCategories.php
===================================================================
--- branches/RL2/extensions/Gadgets/api/ApiQueryGadgetCategories.php    
2011-09-01 13:20:08 UTC (rev 95980)
+++ branches/RL2/extensions/Gadgets/api/ApiQueryGadgetCategories.php    
2011-09-01 13:31:21 UTC (rev 95981)
@@ -42,9 +42,17 @@
        private function getList() {
                $data = array();
                $result = $this->getResult();
-               $gadgets = Gadget::loadStructuredList();
+               $repo = new LocalGadgetRepo( array() );
+               $gadgets = $repo->getGadgetNames();
+               
+               // TODO: Put the grouping in the repo
+               $gadgetsByCategory = array();
+               foreach ( $gadgets as $name ) {
+                       $gadget = $repo->getGadget( $name );
+                       $gadgetsByCategory[$gadget->getCategory()] = $gadget;
+               }
 
-               foreach ( $gadgets as $category => $list ) {
+               foreach ( $gadgetsByCategory as $category => $gadgets ) {
                        if ( !$this->neededNames || isset( 
$this->neededNames[$category] ) ) {
                                $row = array();
                                if ( isset( $this->props['name'] ) ) {
@@ -52,6 +60,7 @@
                                }
                                if ( $category !== "" ) {
                                        if ( isset( $this->props['desc'] ) ) {
+                                               // TODO: Put message into the 
repo too, with fallback behavior
                                                $row['desc'] = wfMessage( 
"gadgetcategory-$category" )->parse();
                                        }
                                        if ( isset( $this->props['desc-raw'] ) 
) {
@@ -59,7 +68,7 @@
                                        }
                                }
                                if ( isset( $this->props['members'] ) ) {
-                                       $row['members'] = count( $list );
+                                       $row['members'] = count( $gadgets );
                                }
                                $data[] = $row;
                        }


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

Reply via email to