r95948 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95947‎ | r95948 | r95949 >
Date:08:23, 1 September 2011
Author:siebrand
Status:ok
Tags:
Comment:
Update whitespace and braces.
Modified paths:
  • /trunk/extensions/Translate/Groups.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/Groups.php
@@ -30,16 +30,19 @@
3131 * @return string
3232 */
3333 public function getId();
 34+
3435 /**
3536 * Returns the human readable label (as plain text).
3637 * @return string
3738 */
3839 public function getLabel();
 40+
3941 /**
4042 * Returns a longer description about the group. Description can use wiki text.
4143 * @return string
4244 */
4345 public function getDescription();
 46+
4447 /**
4548 * Returns the namespace where messages are placed.
4649 * @return int
@@ -52,6 +55,7 @@
5356 * @return bool
5457 */
5558 public function isMeta();
 59+
5660 /**
5761 * If this function returns false, the message group is ignored and treated
5862 * like it would not be configured at all. Useful for graceful degradation.
@@ -66,12 +70,14 @@
6771 * @return FFS or null
6872 */
6973 public function getFFS();
 74+
7075 /**
7176 * Returns a message checker object or null.
7277 * @todo Make an interface for message checkers.
7378 * @return MessageChecker or null
7479 */
7580 public function getChecker();
 81+
7682 /**
7783 * Return a message mangler or null.
7884 * @todo Make an interface for message manglers
@@ -85,6 +91,7 @@
8692 * @return MessageCollection
8793 */
8894 public function initCollection( $code );
 95+
8996 /**
9097 * Returns a list of messages in a given language code. For some groups
9198 * that list may be identical with the translation in the wiki. For other
@@ -93,12 +100,14 @@
94101 * @return array
95102 */
96103 public function load( $code );
 104+
97105 /**
98106 * Returns message tags. If type is given, only messages keys with that
99107 * tag is returnted. Otherwise an array[tag => keys] is returnted.
100108 * @return array
101109 */
102110 public function getTags( $type = null );
 111+
103112 /**
104113 * Returns the definition or translation for given message key in given
105114 * language code.
@@ -145,6 +154,7 @@
146155
147156 public function getSourceLanguage() {
148157 $conf = $this->getFromConf( 'BASIC', 'sourcelanguage' );
 158+
149159 return $conf !== null ? $conf : 'en';
150160 }
151161
@@ -263,9 +273,11 @@
264274 public function getTags( $type = null ) {
265275 if ( $type === null ) {
266276 $taglist = array();
 277+
267278 foreach ( $this->getRawTags() as $type => $patterns ) {
268279 $taglist[$type] = $this->parseTags( $patterns );
269280 }
 281+
270282 return $taglist;
271283 } else {
272284 return $this->parseTags( $this->getRawTags( $type ) );
@@ -371,7 +383,6 @@
372384 * custom type of message groups.
373385 */
374386 class FileBasedMessageGroup extends MessageGroupBase {
375 -
376387 /**
377388 * Constructs a FileBasedMessageGroup from any normal message group.
378389 * Useful for doing special Gettext exports from any group.
@@ -391,6 +402,7 @@
392403 'targetPattern' => '',
393404 ),
394405 );
 406+
395407 return MessageGroupBase::factory( $conf );
396408 }
397409
@@ -401,18 +413,21 @@
402414 public function load( $code ) {
403415 $ffs = $this->getFFS();
404416 $data = $ffs->read( $code );
 417+
405418 return $data ? $data['MESSAGES'] : array();
406419 }
407420
408421 public function getSourceFilePath( $code ) {
409422 if ( $this->isSourceLanguage( $code ) ) {
410423 $pattern = $this->getFromConf( 'FILES', 'definitionFile' );
 424+
411425 if ( $pattern !== null ) {
412426 return $this->replaceVariables( $pattern, $code );
413427 }
414428 }
415429
416430 $pattern = $this->getFromConf( 'FILES', 'sourcePattern' );
 431+
417432 if ( $pattern === null ) {
418433 throw new MWException( 'No source file pattern defined.' );
419434 }
@@ -470,7 +485,6 @@
471486 public function isValidLanguage( $code ) {
472487 return $this->mapCode( $code ) !== 'x-invalidLanguageCode';
473488 }
474 -
475489 }
476490
477491 /**
@@ -527,7 +541,6 @@
528542 * - Only groups of same type and in the same namespace.
529543 */
530544 class AggregateMessageGroup extends MessageGroupBase {
531 -
532545 public function exists() {
533546 // Group exists if there are any subgroups.
534547 $exists = (bool) $this->conf['GROUPS'];
@@ -553,6 +566,7 @@
554567 if ( !isset( $this->mangler ) ) {
555568 $this->mangler = StringMatcher::emptyMatcher();
556569 }
 570+
557571 return $this->mangler;
558572 }
559573
@@ -582,8 +596,10 @@
583597
584598 $groups[$id] = $group;
585599 }
 600+
586601 $this->groups = $groups;
587602 }
 603+
588604 return $this->groups;
589605 }
590606
@@ -596,6 +612,7 @@
597613 */
598614 protected function expandWildcards( $ids ) {
599615 $hasWild = false;
 616+
600617 foreach ( $ids as $id ) {
601618 if ( strpos( $id, '*' ) !== false ) {
602619 $hasWild = true;
@@ -603,10 +620,13 @@
604621 }
605622 }
606623
607 - if ( !$hasWild ) return $ids;
 624+ if ( !$hasWild ) {
 625+ return $ids;
 626+ }
608627
609628 $matcher = new StringMatcher( '', $ids );
610629 $all = array();
 630+
611631 foreach ( MessageGroups::singleton()->getGroups() as $id => $_ ) {
612632 if ( $matcher->match( $id ) ) {
613633 $all[] = $id;
@@ -617,6 +637,7 @@
618638
619639 public function initCollection( $code ) {
620640 $messages = array();
 641+
621642 foreach ( $this->getGroups() as $group ) {
622643 $cache = new MessageGroupCache( $group );
623644 if ( $cache->exists() ) {
@@ -632,6 +653,7 @@
633654 $namespace = $this->getNamespace();
634655 $definitions = new MessageDefinitions( $namespace, $messages );
635656 $collection = MessageCollection::newFromDefinitions( $definitions, $code );
 657+
636658 $this->setTags( $collection );
637659
638660 return $collection;
@@ -640,6 +662,7 @@
641663 public function getMessage( $key, $code ) {
642664 $id = TranslateUtils::messageKeyToGroup( $this->getNamespace(), $key );
643665 $groups = $this->getGroups();
 666+
644667 if ( isset( $groups[$id] ) ) {
645668 return $groups[$id]->getMessage( $key, $code );
646669 } else {
@@ -649,9 +672,11 @@
650673
651674 public function getTags( $type = null ) {
652675 $tags = array();
 676+
653677 foreach ( $this->getGroups() as $group ) {
654678 $tags = array_merge_recursive( $tags, $group->getTags( $type ) );
655679 }
 680+
656681 return $tags;
657682 }
658683 }

Status & tagging log