Index: trunk/extensions/GNSM/SpecialGNSM_body.php |
— | — | @@ -123,6 +123,7 @@ |
124 | 124 | |
125 | 125 | // FIXME: figure out how to fail with no results gracefully |
126 | 126 | if ( $dbr->numRows( $res ) == 0 ){ |
| 127 | + $feed->outFooter(); |
127 | 128 | if ( false == $this->params['suppressErrors'] ) |
128 | 129 | return htmlspecialchars( wfMsg( 'gnsm_noresults' ) ); |
129 | 130 | else |
— | — | @@ -492,10 +493,32 @@ |
493 | 494 | function getKeywords ( $title ){ |
494 | 495 | $cats = $title->getParentCategories(); |
495 | 496 | $str = ''; |
| 497 | + #the following code is based (stolen) from r56954 of flagged revs. |
| 498 | + $catMap = Array(); |
| 499 | + $catMask = Array(); |
| 500 | + $msg = wfMsg( 'gnsm_categorymap' ); |
| 501 | + if ( !wfEmptyMsg( 'gnsm_categorymap', $msg ) ) { |
| 502 | + $list = explode( "\n*", "\n$msg"); |
| 503 | + foreach($list as $item) { |
| 504 | + $mapping = explode('|', $item, 2); |
| 505 | + if ( trim( $mapping[1] ) == '__MASK__') { |
| 506 | + $catMask[trim($mapping[0])] = true; |
| 507 | + } else { |
| 508 | + $catMap[trim($mapping[0])] = trim($mapping[1]); |
| 509 | + } |
| 510 | + } |
| 511 | + } |
496 | 512 | foreach ( $cats as $key => $val ){ |
497 | | - $str .= ', ' . str_replace( '_', ' ', trim( substr( $key, strpos( $key, ':' ) + 1 ) ) ); |
| 513 | + $cat = str_replace( '_', ' ', trim( substr( $key, strpos( $key, ':' ) + 1 ) ) ); |
| 514 | + if (!$catMask[$cat]) { |
| 515 | + if (isset($catMap[$cat])) { |
| 516 | + $str .= ', ' . str_replace( '_', ' ', trim ( $catMap[$cat] ) ); |
| 517 | + } else { |
| 518 | + $str .= ', ' . $cat; |
| 519 | + } |
| 520 | + } |
498 | 521 | } |
499 | | - $str = substr( $str, 2 ); |
| 522 | + $str = substr( $str, 2 ); #to remove leading ', ' |
500 | 523 | return $str; |
501 | 524 | } |
502 | 525 | |
— | — | @@ -634,4 +657,4 @@ |
635 | 658 | echo '</urlset>'; |
636 | 659 | } |
637 | 660 | |
638 | | -} |
\ No newline at end of file |
| 661 | +} |
Index: trunk/extensions/GNSM/SpecialGNSM.i18n.php |
— | — | @@ -15,6 +15,7 @@ |
16 | 16 | $messages['en'] = array( |
17 | 17 | 'gnsm' => 'Google News SiteMap', |
18 | 18 | 'gnsm-desc' => 'Outputs an Atom/RSS feed as a Google News Sitemap.', |
| 19 | + 'gnsm_categorymap' => '', #default empty. list of categories to map to keywords. do not translate. |
19 | 20 | 'gnsm_toomanycats' => 'Error: Too many categories!', |
20 | 21 | 'gnsm_toofewcats' => 'Error: Too few categories!', |
21 | 22 | 'gnsm_noresults' => 'Error: No results!', |
— | — | @@ -31,5 +32,5 @@ |
32 | 33 | 'gnsm_toomanycats' => 'Erreur: Trop de nombreuses catégories!', |
33 | 34 | 'gnsm_toofewcats' => 'Erreur: Trop peu de catégories!', |
34 | 35 | 'gnsm_noresults' => 'Erreur: Pas de résultats!', |
35 | | - 'gnsm_noincludecats' => 'Erreur: Vous devez inclure au moins une catégorie, ou spécifier un nom d''espace !' |
36 | | -); |
\ No newline at end of file |
| 36 | + 'gnsm_noincludecats' => 'Erreur: Vous devez inclure au moins une catégorie, ou spécifier un nom d\'espace !' |
| 37 | +); |