Index: trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php |
— | — | @@ -83,7 +83,7 @@ |
84 | 84 | echo $cached; |
85 | 85 | echo "<!-- From cache: $cacheKey -->"; |
86 | 86 | } else { |
87 | | - $res = $this->doQuery( $params, $categories, $notCategories ); |
| 87 | + $res = $this->getCategories( $params, $categories, $notCategories ); |
88 | 88 | ob_start(); |
89 | 89 | $this->makeFeed( $feed, $res ); |
90 | 90 | $output = ob_get_contents(); |
— | — | @@ -141,12 +141,12 @@ |
142 | 142 | } |
143 | 143 | return $cached[1]; |
144 | 144 | } |
| 145 | + |
145 | 146 | /** |
146 | 147 | * Actually output a feed. |
147 | 148 | * @param ChannelFeed $feed Feed object. |
148 | 149 | * @param $res Result of sql query |
149 | 150 | */ |
150 | | - |
151 | 151 | private function makeFeed( $feed, $res ) { |
152 | 152 | global $wgGNSMcommentNamespace; |
153 | 153 | $feed->outHeader(); |
— | — | @@ -257,7 +257,7 @@ |
258 | 258 | * @param Array $param All the parameters except cats/notcats |
259 | 259 | * @return Result of query. |
260 | 260 | */ |
261 | | - public function doQuery( $params, $categories, $notCategories ) { |
| 261 | + public function getCategories( $params, $categories, $notCategories ) { |
262 | 262 | |
263 | 263 | $dbr = wfGetDB( DB_SLAVE ); |
264 | 264 | |
— | — | @@ -272,33 +272,8 @@ |
273 | 273 | $conditions['page_namespace'] = $params['namespace']; |
274 | 274 | } |
275 | 275 | |
276 | | - // If flagged revisions is in use, check which options selected. |
277 | | - // FIXME: double check the default options; what should it default to? |
278 | | - if ( function_exists( 'efLoadFlaggedRevs' ) ) { |
279 | | - $filterSet = array( self::OPT_ONLY, self::OPT_EXCLUDE ); |
280 | | - # Either involves the same JOIN here... |
281 | | - if ( in_array( $params['stable'], $filterSet ) || in_array( $params['quality'], $filterSet ) ) { |
282 | | - $joins['flaggedpages'] = array( 'LEFT JOIN', 'page_id = fp_page_id' ); |
283 | | - } |
| 276 | + wfRunHooks('GoogleNewsSitemap::Query', array($params, &$joins, &$conditions)); |
284 | 277 | |
285 | | - switch( $params['stable'] ) { |
286 | | - case self::OPT_ONLY: |
287 | | - $conditions[] = 'fp_stable IS NOT NULL '; |
288 | | - break; |
289 | | - case self::OPT_EXCLUDE: |
290 | | - $conditions['fp_stable'] = null; |
291 | | - break; |
292 | | - } |
293 | | - switch( $params['quality'] ) { |
294 | | - case self::OPT_ONLY: |
295 | | - $conditions[] = 'fp_quality >= 1'; |
296 | | - break; |
297 | | - case self::OPT_EXCLUDE: |
298 | | - $conditions['fp_quality'] = 0; |
299 | | - break; |
300 | | - } |
301 | | - } |
302 | | - |
303 | 278 | switch ( $params['redirects'] ) { |
304 | 279 | case self::OPT_ONLY: |
305 | 280 | $conditions['page_is_redirect'] = 1; |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -500,6 +500,9 @@ |
501 | 501 | # Stable dump hook |
502 | 502 | $wgHooks['WikiExporter::dumpStableQuery'][] = 'FlaggedRevsHooks::stableDumpQuery'; |
503 | 503 | |
| 504 | +# GNSM category hooks |
| 505 | +$wgHooks['GoogleNewsSitemap::Query'][] = 'FlaggedRevsHooks::gnsmQueryModifier'; |
| 506 | + |
504 | 507 | # Duplicate flagged* tables in parserTests.php |
505 | 508 | $wgHooks['ParserTestTables'][] = 'FlaggedRevsTestHooks::onParserTestTables'; |
506 | 509 | # Integration tests |
Index: trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevs.hooks.php |
— | — | @@ -1000,4 +1000,32 @@ |
1001 | 1001 | } |
1002 | 1002 | return false; // final |
1003 | 1003 | } |
| 1004 | + |
| 1005 | + public static function gnsmQueryModifier( array $params, array &$joins, array &$conditions ) { |
| 1006 | + $filterSet = array( GoogleNewsSitemap::OPT_ONLY, GoogleNewsSitemap::OPT_EXCLUDE ); |
| 1007 | + # Either involves the same JOIN here... |
| 1008 | + if ( isset( $filterSet[ $params['stable'] ] ) || isset( $filterSet[ $params['quality'] ] ) ) { |
| 1009 | + $joins['flaggedpages'] = array( 'LEFT JOIN', 'page_id = fp_page_id' ); |
| 1010 | + } |
| 1011 | + |
| 1012 | + switch( $params['stable'] ) { |
| 1013 | + case GoogleNewsSitemap::OPT_ONLY: |
| 1014 | + $conditions[] = 'fp_stable IS NOT NULL '; |
| 1015 | + break; |
| 1016 | + case GoogleNewsSitemap::OPT_EXCLUDE: |
| 1017 | + $conditions['fp_stable'] = null; |
| 1018 | + break; |
| 1019 | + } |
| 1020 | + |
| 1021 | + switch( $params['quality'] ) { |
| 1022 | + case GoogleNewsSitemap::OPT_ONLY: |
| 1023 | + $conditions[] = 'fp_quality >= 1'; |
| 1024 | + break; |
| 1025 | + case GoogleNewsSitemap::OPT_EXCLUDE: |
| 1026 | + $conditions['fp_quality'] = 0; |
| 1027 | + break; |
| 1028 | + } |
| 1029 | + |
| 1030 | + return true; |
| 1031 | + } |
1004 | 1032 | } |