Index: trunk/extensions/Translate/SpecialTranslationStats.php |
— | — | @@ -44,7 +44,6 @@ |
45 | 45 | if ( $t === 'group' ) { |
46 | 46 | $values = preg_replace( '~^page_~', 'page|', $values ); |
47 | 47 | } |
48 | | - //var_dump( implode( ',', $values ) ); |
49 | 48 | $opts[$t] = implode( ',', $values ); |
50 | 49 | } |
51 | 50 | |
— | — | @@ -301,11 +300,13 @@ |
302 | 301 | foreach ( $res as $row ) { |
303 | 302 | $date = $wgLang->sprintfDate( $dateFormat, $row->rc_timestamp ); |
304 | 303 | |
305 | | - $index = $so->indexOf( $row ); |
306 | | - if ( $index < 0 ) continue; |
| 304 | + $indexes = $so->indexOf( $row ); |
| 305 | + if ( $indexes === -1 ) continue; |
307 | 306 | |
308 | | - if ( !isset( $data[$date][$index] ) ) $data[$date][$index] = 0; |
309 | | - $data[$date][$index]++; |
| 307 | + foreach ( (array) $indexes as $index ) { |
| 308 | + if ( !isset( $data[$date][$index] ) ) $data[$date][$index] = 0; |
| 309 | + $data[$date][$index]++; |
| 310 | + } |
310 | 311 | } |
311 | 312 | |
312 | 313 | $labels = null; |
— | — | @@ -389,13 +390,18 @@ |
390 | 391 | public function preQuery( &$tables, &$fields, &$conds, &$type, &$options ) { |
391 | 392 | $db = wfGetDB( DB_SLAVE ); |
392 | 393 | |
393 | | - $groups = explode( ',', $this->opts['group'] ); |
394 | | - $codes = explode( ',', $this->opts['language'] ); |
| 394 | + $groups = array_map( 'trim', explode( ',', $this->opts['group'] ) ); |
| 395 | + $codes = array_map( 'trim', explode( ',', $this->opts['language'] ) ); |
395 | 396 | |
396 | 397 | $filters['language'] = trim( $this->opts['language'] ) !== ''; |
397 | 398 | $filters['group'] = trim( $this->opts['group'] ) !== ''; |
398 | 399 | |
| 400 | + $namespaces = array(); |
| 401 | + |
399 | 402 | foreach ( $groups as $group ) { |
| 403 | + if ( $group === '' ) continue; |
| 404 | + $ns = MessageGroups::getGroup( $group )->getNamespace(); |
| 405 | + $namespaces[$ns] = true; |
400 | 406 | |
401 | 407 | foreach ( $codes as $code ) { |
402 | 408 | if ( $code !== '' ) $key = "$group ($code)"; |
— | — | @@ -404,9 +410,14 @@ |
405 | 411 | } |
406 | 412 | } |
407 | 413 | |
| 414 | + if ( count( $namespaces ) ) { |
| 415 | + $conds['rc_namespace'] = array_keys( $namespaces ); |
| 416 | + } |
| 417 | + |
408 | 418 | if ( $filters['language'] ) { |
409 | 419 | $myconds = array(); |
410 | 420 | foreach ( $codes as $code ) { |
| 421 | + if ( $code === '' ) continue; |
411 | 422 | $myconds[] = 'rc_title like \'%%/' . $db->escapeLike( $code ) . "'"; |
412 | 423 | } |
413 | 424 | |
— | — | @@ -444,26 +455,35 @@ |
445 | 456 | } |
446 | 457 | |
447 | 458 | if ( !max( $this->filters ) ) return 0; |
448 | | - if ( strpos( $row->rc_title, '/' ) === false ) return - 1; |
| 459 | + if ( strpos( $row->rc_title, '/' ) === false ) return -1; |
| 460 | + if ( !count( $this->cache ) ) return 0; |
449 | 461 | |
450 | 462 | list( $key, $code ) = TranslateUtils::figureMessage( $row->rc_title ); |
451 | | - $indexKey = ''; |
| 463 | + $indexKeys = array(); |
452 | 464 | |
453 | 465 | if ( $this->filters['group'] ) { |
454 | | - $group = TranslateUtils::messageKeyToGroup( $row->rc_namespace, $key ); |
455 | | - if ( $group === null ) return - 1; |
456 | | - $indexKey .= $group; |
| 466 | + $groups = TranslateUtils::messageKeyToGroups( $row->rc_namespace, $key ); |
| 467 | + if ( !count( $groups ) ) { |
| 468 | + return -1; |
| 469 | + } |
| 470 | + foreach ( $groups as $group ) $indexKeys[] = $group; |
457 | 471 | } |
458 | 472 | |
459 | 473 | if ( $this->filters['language'] ) { |
460 | | - $indexKey .= " ($code)"; |
| 474 | + foreach ( $indexKeys as &$value ) { |
| 475 | + $value .= " ($code)"; |
| 476 | + } |
461 | 477 | } |
462 | 478 | |
463 | | - if ( count( $this->cache ) ) { |
464 | | - return isset( $this->cache[$indexKey] ) ? $this->cache[$indexKey] : - 1; |
465 | | - } else { |
466 | | - return 0; |
| 479 | + $indexes = array(); |
| 480 | + |
| 481 | + foreach ( $indexKeys as $value ) { |
| 482 | + if ( isset( $this->cache[$value] ) ) { |
| 483 | + $indexes[] = $this->cache[$value]; |
| 484 | + } |
467 | 485 | } |
| 486 | + |
| 487 | + return $indexes; |
468 | 488 | } |
469 | 489 | |
470 | 490 | public function labels( &$labels ) { |