Index: trunk/extensions/Translate/api/ApiAggregateGroups.php |
— | — | @@ -38,6 +38,7 @@ |
39 | 39 | $aggregateGroups = array_unique( $aggregateGroups ); |
40 | 40 | $newSubGroups = implode( ',', $aggregateGroups ); |
41 | 41 | TranslateMetadata::set( $aggregateGroup, 'subgroups' , $newSubGroups ) ; |
| 42 | + MessageGroups::clearCache(); |
42 | 43 | } |
43 | 44 | if ( $requestParams['do'] === 'dissociate' ) { |
44 | 45 | $group = $requestParams['group']; |
— | — | @@ -48,11 +49,13 @@ |
49 | 50 | } |
50 | 51 | $aggregateGroups = array_flip( $aggregateGroups ); |
51 | 52 | TranslateMetadata::set( $aggregateGroup, 'subgroups' , implode( ',', $aggregateGroups ) ) ; |
| 53 | + MessageGroups::clearCache(); |
52 | 54 | } |
53 | 55 | if ( $requestParams['do'] === 'remove' ) { |
54 | 56 | TranslateMetadata::set( $aggregateGroup, 'subgroups', false ) ; |
55 | 57 | TranslateMetadata::set( $aggregateGroup, 'name', false ) ; |
56 | 58 | TranslateMetadata::set( $aggregateGroup, 'description', false ) ; |
| 59 | + MessageGroups::clearCache(); |
57 | 60 | } |
58 | 61 | if ( $requestParams['do'] === 'add' ) { |
59 | 62 | TranslateMetadata::set( $aggregateGroup, 'subgroups' , '' ) ; |
— | — | @@ -62,6 +65,7 @@ |
63 | 66 | if ( trim( $requestParams['groupdescription'] ) ) { |
64 | 67 | TranslateMetadata::set( $aggregateGroup, 'description' , trim( $requestParams['groupdescription'] ) ) ; |
65 | 68 | } |
| 69 | + MessageGroups::clearCache(); |
66 | 70 | } |
67 | 71 | $output = array( 'result' => 'ok' ); |
68 | 72 | $this->getResult()->addValue( null, $this->getModuleName(), $output ); |
— | — | @@ -79,7 +83,6 @@ |
80 | 84 | } |
81 | 85 | |
82 | 86 | public function getAllowedParams() { |
83 | | - global $wgTranslateWorkflowStates; |
84 | 87 | return array( |
85 | 88 | 'do' => array( |
86 | 89 | ApiBase::PARAM_TYPE => array( 'associate', 'dissociate', 'remove' , 'add' ), |
— | — | @@ -116,32 +119,6 @@ |
117 | 120 | ); |
118 | 121 | } |
119 | 122 | |
120 | | - public static function getAggregateGroups() { |
121 | | - $dbr = wfGetDB( DB_MASTER ); |
122 | | - $tables = array( 'translate_metadata' ); |
123 | | - $vars = array( 'tmd_group', 'tmd_value' ); |
124 | | - $conds = array( |
125 | | - 'tmd_key' => 'subgroups', |
126 | | - ); |
127 | | - $options = array( |
128 | | - 'ORDER BY' => 'tmd_group', |
129 | | - ); |
130 | | - $res = $dbr->select( $tables, $vars, $conds, __METHOD__, $options ); |
131 | | - $aggregateGroups = array(); |
132 | | - foreach ( $res as $r ) { |
133 | | - $aggregateGroups[$r->tmd_group] = array(); |
134 | | - $aggregateGroups[$r->tmd_group]['id'] = $r->tmd_group; |
135 | | - $aggregateGroups[$r->tmd_group]['name'] = TranslateMetadata::get( $r->tmd_group, 'name' ); |
136 | | - $aggregateGroups[$r->tmd_group]['description'] = TranslateMetadata::get( $r->tmd_group, 'description' ); |
137 | | - $subGroupsArray = explode( ',', $r->tmd_value ) ; |
138 | | - $subGroups = array(); |
139 | | - foreach ( $subGroupsArray as $subGroup ) { |
140 | | - $subGroups[$subGroup] = MessageGroups::getGroup( trim( $subGroup ) ); |
141 | | - } |
142 | | - $aggregateGroups[$r->tmd_group]['subgroups'] = $subGroups ; |
143 | | - } |
144 | | - return $aggregateGroups; |
145 | | - } |
146 | 123 | |
147 | 124 | public function getDescription() { |
148 | 125 | return 'Manage aggregate groups'; |
Index: trunk/extensions/Translate/specials/SpecialAggregateGroups.php |
— | — | @@ -81,7 +81,7 @@ |
82 | 82 | global $wgOut; |
83 | 83 | $wgOut->addModules( 'ext.translate.special.aggregategroups' ); |
84 | 84 | |
85 | | - $aggregategroups = ApiAggregateGroups::getAggregateGroups( ); |
| 85 | + $aggregategroups = MessageGroups::getAggregateGroups( ); |
86 | 86 | $res = $this->loadPagesFromDB(); |
87 | 87 | $pages = $this->buildPageArray( $res ); |
88 | 88 | foreach ( $aggregategroups as $id => $group ) { |
Index: trunk/extensions/Translate/MessageGroups.php |
— | — | @@ -1167,6 +1167,21 @@ |
1168 | 1168 | } |
1169 | 1169 | } |
1170 | 1170 | |
| 1171 | + $aggregategroups = self::getAggregateGroups( ); |
| 1172 | + foreach ( $aggregategroups as $id => $group ) { |
| 1173 | + $conf = array(); |
| 1174 | + $conf['BASIC'] = array(); |
| 1175 | + $conf['BASIC']['id'] = $id; |
| 1176 | + $conf['BASIC']['label'] = $group['name']; |
| 1177 | + $conf['BASIC']['meta'] = 1; |
| 1178 | + $conf['BASIC']['class'] = 'AggregateMessageGroup'; |
| 1179 | + $conf['BASIC']['description'] = $group['description']; |
| 1180 | + $conf['BASIC']['namespace'] = 'NS_TRANSLATIONS'; |
| 1181 | + $subgroups = explode( ',', TranslateMetadata::get( $id, 'subgroups' ) ) ; |
| 1182 | + $conf['GROUPS'] = $subgroups; |
| 1183 | + $group = MessageGroupBase::factory( $conf ); |
| 1184 | + $wgTranslateCC[$id] = $group; |
| 1185 | + } |
1171 | 1186 | $key = wfMemckey( 'translate-groups' ); |
1172 | 1187 | $value = array( |
1173 | 1188 | 'ac' => $wgTranslateAC, |
— | — | @@ -1497,6 +1512,37 @@ |
1498 | 1513 | array_unshift( $tree, $parent ); |
1499 | 1514 | return $tree; |
1500 | 1515 | } |
| 1516 | + |
| 1517 | + /* |
| 1518 | + * Get all the aggregate groups defined in translate_metadata table, along with |
| 1519 | + * subgroups as MessageGroup objects. |
| 1520 | + */ |
| 1521 | + public static function getAggregateGroups() { |
| 1522 | + $dbr = wfGetDB( DB_MASTER ); |
| 1523 | + $tables = array( 'translate_metadata' ); |
| 1524 | + $vars = array( 'tmd_group', 'tmd_value' ); |
| 1525 | + $conds = array( |
| 1526 | + 'tmd_key' => 'subgroups', |
| 1527 | + ); |
| 1528 | + $options = array( |
| 1529 | + 'ORDER BY' => 'tmd_group', |
| 1530 | + ); |
| 1531 | + $res = $dbr->select( $tables, $vars, $conds, __METHOD__, $options ); |
| 1532 | + $aggregateGroups = array(); |
| 1533 | + foreach ( $res as $r ) { |
| 1534 | + $aggregateGroups[$r->tmd_group] = array(); |
| 1535 | + $aggregateGroups[$r->tmd_group]['id'] = $r->tmd_group; |
| 1536 | + $aggregateGroups[$r->tmd_group]['name'] = TranslateMetadata::get( $r->tmd_group, 'name' ); |
| 1537 | + $aggregateGroups[$r->tmd_group]['description'] = TranslateMetadata::get( $r->tmd_group, 'description' ); |
| 1538 | + $subGroupsArray = explode( ',', $r->tmd_value ) ; |
| 1539 | + $subGroups = array(); |
| 1540 | + foreach ( $subGroupsArray as $subGroup ) { |
| 1541 | + $subGroups[$subGroup] = MessageGroups::getGroup( trim( $subGroup ) ); |
| 1542 | + } |
| 1543 | + $aggregateGroups[$r->tmd_group]['subgroups'] = $subGroups ; |
| 1544 | + } |
| 1545 | + return $aggregateGroups; |
| 1546 | + } |
1501 | 1547 | |
1502 | 1548 | } |
1503 | 1549 | |