| Index: branches/RL2/extensions/Gadgets/api/ApiQueryGadgetCategories.php |
| — | — | @@ -42,9 +42,17 @@ |
| 43 | 43 | private function getList() { |
| 44 | 44 | $data = array(); |
| 45 | 45 | $result = $this->getResult(); |
| 46 | | - $gadgets = Gadget::loadStructuredList(); |
| | 46 | + $repo = new LocalGadgetRepo( array() ); |
| | 47 | + $gadgets = $repo->getGadgetNames(); |
| | 48 | + |
| | 49 | + // TODO: Put the grouping in the repo |
| | 50 | + $gadgetsByCategory = array(); |
| | 51 | + foreach ( $gadgets as $name ) { |
| | 52 | + $gadget = $repo->getGadget( $name ); |
| | 53 | + $gadgetsByCategory[$gadget->getCategory()] = $gadget; |
| | 54 | + } |
| 47 | 55 | |
| 48 | | - foreach ( $gadgets as $category => $list ) { |
| | 56 | + foreach ( $gadgetsByCategory as $category => $gadgets ) { |
| 49 | 57 | if ( !$this->neededNames || isset( $this->neededNames[$category] ) ) { |
| 50 | 58 | $row = array(); |
| 51 | 59 | if ( isset( $this->props['name'] ) ) { |
| — | — | @@ -52,6 +60,7 @@ |
| 53 | 61 | } |
| 54 | 62 | if ( $category !== "" ) { |
| 55 | 63 | if ( isset( $this->props['desc'] ) ) { |
| | 64 | + // TODO: Put message into the repo too, with fallback behavior |
| 56 | 65 | $row['desc'] = wfMessage( "gadgetcategory-$category" )->parse(); |
| 57 | 66 | } |
| 58 | 67 | if ( isset( $this->props['desc-raw'] ) ) { |
| — | — | @@ -59,7 +68,7 @@ |
| 60 | 69 | } |
| 61 | 70 | } |
| 62 | 71 | if ( isset( $this->props['members'] ) ) { |
| 63 | | - $row['members'] = count( $list ); |
| | 72 | + $row['members'] = count( $gadgets ); |
| 64 | 73 | } |
| 65 | 74 | $data[] = $row; |
| 66 | 75 | } |