Index: branches/RL2/extensions/Gadgets/backend/GadgetRepo.php |
— | — | @@ -113,28 +113,28 @@ |
114 | 114 | |
115 | 115 | /** |
116 | 116 | * Helper function for getAllGadgets(), getAllGadgetIDs(), getAllRemoteGadgets() and getAllRemoteGadgetIDs() |
117 | | - * @param $includeLocal boolean Whether gadgets from the local repo should be included |
118 | | - * @param $getObjects boolean Whether Gadget objects should be constructed. If false, IDs (strings) will be returned |
| 117 | + * @param $source String: one of 'local', 'remote', 'all'. |
| 118 | + * @param $retType String: Whether to return an array of IDs ('ids'), or Gadget objects ('objects'). |
119 | 119 | * @return array of Gadget objects or strings |
120 | 120 | */ |
121 | | - private static function getAllGadgets_internal( $includeLocal, $getObjects ) { |
122 | | - $retval = array(); |
| 121 | + private static function getAllGadgets_internal( $source = 'all', $retType = 'ids' ) { |
| 122 | + $retVal = array(); |
123 | 123 | $repos = GadgetRepo::getAllRepos(); |
124 | 124 | foreach ( $repos as $repo ) { |
125 | | - if ( !$includeLocal && $repo->isLocal() ) { |
| 125 | + if ( $source == 'remote' && $repo->isLocal() ) { |
126 | 126 | continue; |
127 | 127 | } |
128 | 128 | |
129 | 129 | $gadgets = $repo->getGadgetIds(); |
130 | | - if ( $getObjects ) { |
| 130 | + if ( $retType = 'objects' ) { |
131 | 131 | foreach ( $gadgets as $id ) { |
132 | | - $retval[] = $repo->getGadget( $id ); |
| 132 | + $retVal[] = $repo->getGadget( $id ); |
133 | 133 | } |
134 | 134 | } else { |
135 | | - $retval = array_merge( $retval, $gadgets ); |
| 135 | + $retVal = array_merge( $retVal, $gadgets ); |
136 | 136 | } |
137 | 137 | } |
138 | | - return $retval; |
| 138 | + return $retVal; |
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
— | — | @@ -142,7 +142,7 @@ |
143 | 143 | * @return array of Gadget objects |
144 | 144 | */ |
145 | 145 | public static function getAllGadgets() { |
146 | | - return self::getAllGadgets_internal( true, true ); |
| 146 | + return self::getAllGadgets_internal( 'all', 'objects' ); |
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
— | — | @@ -150,7 +150,7 @@ |
151 | 151 | * @return array of gadget IDs (strings) |
152 | 152 | */ |
153 | 153 | public static function getAllGadgetIDs() { |
154 | | - return self::getAllGadgets_internal( true, false ); |
| 154 | + return self::getAllGadgets_internal( 'all', 'ids' ); |
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
— | — | @@ -158,7 +158,7 @@ |
159 | 159 | * @return array of Gadget objects |
160 | 160 | */ |
161 | 161 | public static function getAllRemoteGadgets() { |
162 | | - return self::getAllGadgets_internal( false, true ); |
| 162 | + return self::getAllGadgets_internal( 'remote', 'objects' ); |
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
— | — | @@ -166,6 +166,6 @@ |
167 | 167 | * @return array of gadget IDs (strings) |
168 | 168 | */ |
169 | 169 | public static function getAllRemoteGadgetIDs() { |
170 | | - return self::getAllGadgets_internal( false, false ); |
| 170 | + return self::getAllGadgets_internal( 'remote', 'ids' ); |
171 | 171 | } |
172 | 172 | } |