Index: trunk/extensions/Translate/api/ApiAggregateGroups.php |
— | — | @@ -66,7 +66,10 @@ |
67 | 67 | TranslateMetadata::set( $aggregateGroup, 'name', false ) ; |
68 | 68 | TranslateMetadata::set( $aggregateGroup, 'description', false ) ; |
69 | 69 | } elseif ( $action === 'add' ) { |
70 | | - // @FIXME: check that the group id unused and valid (like, no commas) |
| 70 | + if ( TranslateMetadata::get( $aggregateGroup, 'subgroups') ) { |
| 71 | + $this->dieUsage( 'Aggregate Group aleady exists', 'duplicateaggregategroup' ); |
| 72 | + } |
| 73 | + // @FIXME: check that the group id is valid (like, no commas) |
71 | 74 | TranslateMetadata::set( $aggregateGroup, 'subgroups', '' ) ; |
72 | 75 | $name = trim( $params['groupname'] ); |
73 | 76 | $desc = trim( $params['groupdescription'] ); |
Index: trunk/extensions/Translate/resources/ext.translate.special.aggregategroups.js |
— | — | @@ -91,6 +91,15 @@ |
92 | 92 | var params = $.extend( getApiParams( $target ), {'do' : 'remove' } ); |
93 | 93 | $.post( mw.util.wikiScript( 'api' ), params, successFunction ); |
94 | 94 | } |
| 95 | + |
| 96 | + /* |
| 97 | + * Replace some special characters like space, comma, brackets etc to _ in a string. Also convert it to lowercase. |
| 98 | + */ |
| 99 | + function createId( s ){ |
| 100 | + if ( s !== undefined ) { |
| 101 | + return s.toLowerCase().replace( /[\x00-\x1f\x23\x2c\x3c\x3e\x5b\x5d\x7b\x7c\x7d\x7f\s]+/g, '_' ); |
| 102 | + } |
| 103 | + } |
95 | 104 | |
96 | 105 | $( '.tp-aggregate-add-button' ).click( associate ); |
97 | 106 | $( '.tp-aggregate-remove-button' ).click( dissociate ); |
— | — | @@ -101,7 +110,7 @@ |
102 | 111 | } ); |
103 | 112 | |
104 | 113 | $( '#tpt-aggregategroups-save' ). on ( "click", function( event ){ |
105 | | - var aggregateGroup = $( 'input.tp-aggregategroup-add-name' ).val().toLowerCase().replace( ' ', '_'); |
| 114 | + var aggregateGroup = createId( $( 'input.tp-aggregategroup-add-name' ).val() ); |
106 | 115 | var aggregateGroupName = $( 'input.tp-aggregategroup-add-name' ).val(); |
107 | 116 | var aggregateGroupDesc = $( 'input.tp-aggregategroup-add-description' ).val(); |
108 | 117 | var $select = $( 'select.tp-aggregate-group-chooser' ); |