r60302 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60301‎ | r60302 | r60303 >
Date:04:00, 23 December 2009
Author:kim
Status:deferred (Comments)
Tags:
Comment:
Gigs applied the last patch and everything seems to be working.
Modified paths:
  • /trunk/extensions/GNSM/SpecialGNSM.i18n.php (modified) (history)
  • /trunk/extensions/GNSM/SpecialGNSM_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GNSM/SpecialGNSM_body.php
@@ -123,6 +123,7 @@
124124
125125 // FIXME: figure out how to fail with no results gracefully
126126 if ( $dbr->numRows( $res ) == 0 ){
 127+ $feed->outFooter();
127128 if ( false == $this->params['suppressErrors'] )
128129 return htmlspecialchars( wfMsg( 'gnsm_noresults' ) );
129130 else
@@ -492,10 +493,32 @@
493494 function getKeywords ( $title ){
494495 $cats = $title->getParentCategories();
495496 $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+ }
496512 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+ }
498521 }
499 - $str = substr( $str, 2 );
 522+ $str = substr( $str, 2 ); #to remove leading ', '
500523 return $str;
501524 }
502525
@@ -634,4 +657,4 @@
635658 echo '</urlset>';
636659 }
637660
638 -}
\ No newline at end of file
 661+}
Index: trunk/extensions/GNSM/SpecialGNSM.i18n.php
@@ -15,6 +15,7 @@
1616 $messages['en'] = array(
1717 'gnsm' => 'Google News SiteMap',
1818 '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.
1920 'gnsm_toomanycats' => 'Error: Too many categories!',
2021 'gnsm_toofewcats' => 'Error: Too few categories!',
2122 'gnsm_noresults' => 'Error: No results!',
@@ -31,5 +32,5 @@
3233 'gnsm_toomanycats' => 'Erreur: Trop de nombreuses catégories!',
3334 'gnsm_toofewcats' => 'Erreur: Trop peu de catégories!',
3435 '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+);

Comments

#Comment by MarkAHershberger (talk | contribs)   21:20, 23 November 2010

+    'gnsm_categorymap'      => , #default empty. list of categories to map to keywords. do not translate.

Notes about translation like this one should really go into QQQ:

    $messages['qqq'] = array(
          'gnsm_categorymap'      => 'default empty. list of categories to map to keywords. do not translate.'
    );

Status & tagging log