Index: branches/wmf/1.17wmf1/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php |
— | — | @@ -500,9 +500,9 @@ |
501 | 501 | * @param Title $title |
502 | 502 | * @return Array of String: list of keywords |
503 | 503 | */ |
504 | | - public function getKeywords ( $title ) { |
| 504 | + public function getKeywords ( Title $title ) { |
505 | 505 | wfProfileIn( __METHOD__ ); |
506 | | - $cats = $title->getParentCategories(); |
| 506 | + $cats = $this->getVisibleCategories( $title ); |
507 | 507 | $res = array(); |
508 | 508 | |
509 | 509 | # the following code is based (stolen) from r56954 of flagged revs. |
— | — | @@ -519,7 +519,7 @@ |
520 | 520 | if ( !$targetTitle ) { |
521 | 521 | continue; |
522 | 522 | } |
523 | | - $target = $targetTitle->getPrefixedDBkey(); |
| 523 | + $target = $targetTitle->getDBkey(); |
524 | 524 | $mapTo = trim( $mapping[1] ); |
525 | 525 | |
526 | 526 | if ( $mapTo === '__MASK__' ) { |
— | — | @@ -530,7 +530,7 @@ |
531 | 531 | } |
532 | 532 | } |
533 | 533 | } |
534 | | - foreach ( $cats as $cat => $val ) { |
| 534 | + foreach ( $cats as $cat ) { |
535 | 535 | if ( !isset( $catMask[$cat] ) ) { |
536 | 536 | if ( isset( $catMap[$cat] ) ) { |
537 | 537 | // Its mapped. |
— | — | @@ -545,4 +545,48 @@ |
546 | 546 | wfProfileOut( __METHOD__ ); |
547 | 547 | return $res; |
548 | 548 | } |
| 549 | + |
| 550 | + /** |
| 551 | + * Get all non-hidden categories for a title. |
| 552 | + * |
| 553 | + * Kind of similar to title::getParentCategories. |
| 554 | + * |
| 555 | + * @param Title $title Which title to get the categories for. |
| 556 | + * @return Array of String's that are the (non-prefixed) db-keys of the cats. |
| 557 | + */ |
| 558 | + private function getVisibleCategories ( Title $title ) { |
| 559 | + $dbr = wfGetDB( DB_SLAVE ); |
| 560 | + |
| 561 | + $where = array( |
| 562 | + 'cl_from' => $title->getArticleID(), |
| 563 | + 'pp_propname' => null |
| 564 | + ); |
| 565 | + |
| 566 | + $joins = array( |
| 567 | + 'page' => array( |
| 568 | + 'LEFT OUTER JOIN', |
| 569 | + array( 'page_namespace' => NS_CATEGORY, 'page_title=cl_to' ) |
| 570 | + ), |
| 571 | + 'page_props' => array( |
| 572 | + 'LEFT OUTER JOIN', |
| 573 | + array( 'pp_page=page_id', 'pp_propname' => 'hiddencat' ) |
| 574 | + ) |
| 575 | + ); |
| 576 | + |
| 577 | + $res = $dbr->select( |
| 578 | + array( 'categorylinks', 'page', 'page_props' ), |
| 579 | + 'cl_to', |
| 580 | + $where, |
| 581 | + __METHOD__, |
| 582 | + array(), /* options */ |
| 583 | + $joins |
| 584 | + ); |
| 585 | + $finalResult = array(); |
| 586 | + if ( $res !== false ) { |
| 587 | + foreach( $res as $row ) { |
| 588 | + $finalResult[] = $row->cl_to; |
| 589 | + } |
| 590 | + } |
| 591 | + return $finalResult; |
| 592 | + } |
549 | 593 | } |
Property changes on: branches/wmf/1.17wmf1/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php |
___________________________________________________________________ |
Added: svn:mergeinfo |
550 | 594 | Merged /branches/sqlite/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php:r58211-58321 |
551 | 595 | Merged /trunk/phase3/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php:r79828,79830,79848,79853,79950-79951,79954,79989,80006-80007,80013,80016,80080,80083,80124,80128,80238,80406,81833,83212,83590 |
552 | 596 | Merged /branches/new-installer/phase3/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php:r43664-66004 |
553 | 597 | Merged /branches/wmf-deployment/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php:r60970 |
554 | 598 | Merged /branches/REL1_15/phase3/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php:r51646 |
555 | 599 | Merged /branches/wmf/1.16wmf4/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php:r67177,69199,76243,77266 |
556 | 600 | Merged /trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php:r87153,87157,87236,87458,88402,88634 |