Index: trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php |
— | — | @@ -501,9 +501,9 @@ |
502 | 502 | * @param Title $title |
503 | 503 | * @return Array of String: list of keywords |
504 | 504 | */ |
505 | | - public function getKeywords( $title ) { |
| 505 | + public function getKeywords( Title $title ) { |
506 | 506 | wfProfileIn( __METHOD__ ); |
507 | | - $cats = $title->getParentCategories(); |
| 507 | + $cats = $this->getVisibleCategories( $title ); |
508 | 508 | $res = array(); |
509 | 509 | |
510 | 510 | # the following code is based (stolen) from r56954 of flagged revs. |
— | — | @@ -520,7 +520,7 @@ |
521 | 521 | if ( !$targetTitle ) { |
522 | 522 | continue; |
523 | 523 | } |
524 | | - $target = $targetTitle->getPrefixedDBkey(); |
| 524 | + $target = $targetTitle->getDBkey(); |
525 | 525 | $mapTo = trim( $mapping[1] ); |
526 | 526 | |
527 | 527 | if ( $mapTo === '__MASK__' ) { |
— | — | @@ -531,7 +531,7 @@ |
532 | 532 | } |
533 | 533 | } |
534 | 534 | } |
535 | | - foreach ( $cats as $cat => $val ) { |
| 535 | + foreach ( $cats as $cat ) { |
536 | 536 | if ( !isset( $catMask[$cat] ) ) { |
537 | 537 | if ( isset( $catMap[$cat] ) ) { |
538 | 538 | // Its mapped. |
— | — | @@ -546,4 +546,48 @@ |
547 | 547 | wfProfileOut( __METHOD__ ); |
548 | 548 | return $res; |
549 | 549 | } |
| 550 | + |
| 551 | + /** |
| 552 | + * Get all non-hidden categories for a title. |
| 553 | + * |
| 554 | + * Kind of similar to title::getParentCategories. |
| 555 | + * |
| 556 | + * @param Title $title Which title to get the categories for. |
| 557 | + * @return Array of String's that are the (non-prefixed) db-keys of the cats. |
| 558 | + */ |
| 559 | + private function getVisibleCategories ( Title $title ) { |
| 560 | + $dbr = wfGetDB( DB_SLAVE ); |
| 561 | + |
| 562 | + $where = array( |
| 563 | + 'cl_from' => $title->getArticleID(), |
| 564 | + 'pp_propname' => null |
| 565 | + ); |
| 566 | + |
| 567 | + $joins = array( |
| 568 | + 'page' => array( |
| 569 | + 'LEFT OUTER JOIN', |
| 570 | + array( 'page_namespace' => NS_CATEGORY, 'page_title=cl_to' ) |
| 571 | + ), |
| 572 | + 'page_props' => array( |
| 573 | + 'LEFT OUTER JOIN', |
| 574 | + array( 'pp_page=page_id', 'pp_propname' => 'hiddencat' ) |
| 575 | + ) |
| 576 | + ); |
| 577 | + |
| 578 | + $res = $dbr->select( |
| 579 | + array( 'categorylinks', 'page', 'page_props' ), |
| 580 | + 'cl_to', |
| 581 | + $where, |
| 582 | + __METHOD__, |
| 583 | + array(), /* options */ |
| 584 | + $joins |
| 585 | + ); |
| 586 | + $finalResult = array(); |
| 587 | + if ( $res !== false ) { |
| 588 | + foreach( $res as $row ) { |
| 589 | + $finalResult[] = $row->cl_to; |
| 590 | + } |
| 591 | + } |
| 592 | + return $finalResult; |
| 593 | + } |
550 | 594 | } |