Index: trunk/extensions/StrategyWiki/ActiveStrategy/ActiveStrategy_body.php |
— | — | @@ -1,9 +1,15 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class ActiveStrategy { |
5 | | - static function getTaskForces() { |
| 5 | + static function getTaskForces( $limit ) { |
6 | 6 | $dbr = wfGetDB( DB_SLAVE ); |
7 | 7 | |
| 8 | + $options = array(); |
| 9 | + |
| 10 | + if ($limit) { |
| 11 | + $options['LIMIT'] = $limit; |
| 12 | + } |
| 13 | + |
8 | 14 | $res = $dbr->select( |
9 | 15 | array( "page", 'categorylinks', |
10 | 16 | 'categorylinks as finishedcategory' ), |
— | — | @@ -20,7 +26,7 @@ |
21 | 27 | 'finishedcategory.cl_from IS NULL', |
22 | 28 | ), |
23 | 29 | __METHOD__, |
24 | | - array(), |
| 30 | + $options, |
25 | 31 | array( |
26 | 32 | 'categorylinks' => array( 'RIGHT JOIN', |
27 | 33 | array( |
— | — | @@ -177,9 +183,10 @@ |
178 | 184 | $html = ''; |
179 | 185 | $db = wfGetDB( DB_MASTER ); |
180 | 186 | $sk = $wgUser->getSkin(); |
| 187 | + $limit = null; |
181 | 188 | |
182 | 189 | if ( empty( $args['type'] ) ) { |
183 | | - $args['type'] = 'taskforces'; |
| 190 | + $args['type'] = 'taskforce'; |
184 | 191 | } |
185 | 192 | |
186 | 193 | $sortField = 'members'; |
— | — | @@ -188,15 +195,12 @@ |
189 | 196 | $sortField = $args['sort']; |
190 | 197 | } |
191 | 198 | |
192 | | - if ( $args['type'] == 'taskforces' ) { |
193 | | - $masterPages = self::getTaskForces(); |
194 | | - } elseif ( $args['type'] == 'proposal' ) { |
195 | | -// $masterPages = self::getProposals(); |
| 199 | + if ( isset( $args['max'] ) ) { |
| 200 | + $limit = intval($args['max']); |
196 | 201 | } |
197 | 202 | |
198 | | - // Sorting by number of members doesn't require any |
199 | | - if ($sortField == 'members' ) { |
200 | | - return self::handleSortByMembers( $masterPages ); |
| 203 | + if ( $args['type'] == 'taskforce' ) { |
| 204 | + $masterPages = self::getTaskForces( $limit ); |
201 | 205 | } |
202 | 206 | |
203 | 207 | $tables = array( ); |
— | — | @@ -206,7 +210,11 @@ |
207 | 211 | $options = array( 'GROUP BY' => 'keyfield', 'ORDER BY' => 'value DESC' ); |
208 | 212 | $lookup = NULL; |
209 | 213 | |
210 | | - if ( $args['type'] == 'taskforces' ) { |
| 214 | + if ( $limit ) { |
| 215 | + $options['LIMIT'] = intval($limit); |
| 216 | + } |
| 217 | + |
| 218 | + if ( $args['type'] == 'taskforce' ) { |
211 | 219 | self::getTaskForcePageConditions( $masterPages, $tables, $fields, |
212 | 220 | $conds, $joinConds, $lookup ); |
213 | 221 | } elseif( $args['type'] == 'proposal' ) { |
— | — | @@ -244,10 +252,13 @@ |
245 | 253 | $joinConds['pagelinks'] = array( 'left join', |
246 | 254 | array( 'pl_namespace=page_namespace', 'pl_title=page_title' ) ); |
247 | 255 | $fields[] = 'count(distinct pl_from) as value'; |
| 256 | + } elseif ( $sortField == 'members' ) { |
| 257 | + $tables[] = 'pagelinks'; |
| 258 | + $joinConds['pagelinks'] = array( 'left join', |
| 259 | + array( 'pl_from=page_id', 'pl_namespace' => NS_USER ) ); |
| 260 | + $fields[] = 'count(distinct pl_title) AS value'; |
248 | 261 | } |
249 | 262 | |
250 | | -// die( $db->selectSQLText( $tables, $fields, $conds, __METHOD__, $options, $joinConds ) ); |
251 | | - |
252 | 263 | $result = $db->select( $tables, $fields, $conds, |
253 | 264 | __METHOD__, $options, $joinConds ); |
254 | 265 | |