Index: trunk/extensions/Translate/MessageGroups.php |
— | — | @@ -1110,6 +1110,28 @@ |
1111 | 1111 | return isset( $groups[$id] ) ? $groups[$id] : ''; |
1112 | 1112 | } |
1113 | 1113 | |
| 1114 | + /** |
| 1115 | + * Returns the message groups this message group is part of. |
| 1116 | + * @since 2011-12-15 |
| 1117 | + * @return array |
| 1118 | + */ |
| 1119 | + public static function getParentGroups( MessageGroup $group ) { |
| 1120 | + // Take the first message, get a handle for it and check |
| 1121 | + // if that message belongs to other groups. Those are the |
| 1122 | + // parent aggregate groups. Ideally we loop over all keys, |
| 1123 | + // but this should be enough. |
| 1124 | + $keys = array_keys( $group->getDefinitions() ); |
| 1125 | + $title = Title::makeTitle( $group->getNamespace(), $keys[0] ); |
| 1126 | + $handle = new MessageHandle( $title ); |
| 1127 | + $ids = $handle->getGroupIds(); |
| 1128 | + foreach ( $ids as $index => $id ) { |
| 1129 | + if ( $id === $group->getId() ) { |
| 1130 | + unset( $ids[$index] ); |
| 1131 | + } |
| 1132 | + } |
| 1133 | + return $ids; |
| 1134 | + } |
| 1135 | + |
1114 | 1136 | /// @todo Make protected. |
1115 | 1137 | public $classes; |
1116 | 1138 | private function __construct() { |
Index: trunk/extensions/Translate/tag/SpecialPageTranslation.php |
— | — | @@ -87,6 +87,11 @@ |
88 | 88 | $dbw->replace( $table, array( $index ), $row, __METHOD__ ); |
89 | 89 | } |
90 | 90 | $this->listPages(); |
| 91 | + |
| 92 | + $group = MessageGroups::getGroup( $id ); |
| 93 | + $parents = MessageGroups::getParentGroups( $group ); |
| 94 | + MessageGroupStats::clearGroup( $parents ); |
| 95 | + |
91 | 96 | return; |
92 | 97 | } |
93 | 98 | |
Index: trunk/extensions/Translate/utils/MessageHandle.php |
— | — | @@ -35,15 +35,20 @@ |
36 | 36 | */ |
37 | 37 | public function figureMessage() { |
38 | 38 | if ( $this->key === null ) { |
39 | | - $text = $this->getTitle()->getDBkey(); |
| 39 | + $title = $this->getTitle(); |
| 40 | + // Check if this is a valid message first |
| 41 | + $ns = $title->getNamespace(); |
| 42 | + $text = $title->getDBkey(); |
| 43 | + $known = TranslateUtils::messageKeyToGroups( $ns, $text ); |
| 44 | + |
40 | 45 | $pos = strrpos( $text, '/' ); |
41 | | - |
42 | | - if ( $pos === false ) { |
| 46 | + if ( $known || $pos === false ) { |
43 | 47 | $this->code = ''; |
44 | 48 | $this->key = $text; |
45 | 49 | } else { |
46 | 50 | $this->code = substr( $text, $pos + 1 ); |
47 | 51 | $this->key = substr( $text, 0, $pos ); |
| 52 | + |
48 | 53 | } |
49 | 54 | } |
50 | 55 | return array( $this->key, $this->code ); |