r113709 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113708‎ | r113709 | r113710 >
Date:06:32, 13 March 2012
Author:santhosh
Status:resolved (Comments)
Tags:i18nreview 
Comment:
create the groupdId by more better.
While adding a new group, check whether it exists or not.
Modified paths:
  • /trunk/extensions/Translate/api/ApiAggregateGroups.php (modified) (history)
  • /trunk/extensions/Translate/resources/ext.translate.special.aggregategroups.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/api/ApiAggregateGroups.php
@@ -66,7 +66,10 @@
6767 TranslateMetadata::set( $aggregateGroup, 'name', false ) ;
6868 TranslateMetadata::set( $aggregateGroup, 'description', false ) ;
6969 } 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)
7174 TranslateMetadata::set( $aggregateGroup, 'subgroups', '' ) ;
7275 $name = trim( $params['groupname'] );
7376 $desc = trim( $params['groupdescription'] );
Index: trunk/extensions/Translate/resources/ext.translate.special.aggregategroups.js
@@ -91,6 +91,15 @@
9292 var params = $.extend( getApiParams( $target ), {'do' : 'remove' } );
9393 $.post( mw.util.wikiScript( 'api' ), params, successFunction );
9494 }
 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+ }
95104
96105 $( '.tp-aggregate-add-button' ).click( associate );
97106 $( '.tp-aggregate-remove-button' ).click( dissociate );
@@ -101,7 +110,7 @@
102111 } );
103112
104113 $( '#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() );
106115 var aggregateGroupName = $( 'input.tp-aggregategroup-add-name' ).val();
107116 var aggregateGroupDesc = $( 'input.tp-aggregategroup-add-description' ).val();
108117 var $select = $( 'select.tp-aggregate-group-chooser' );

Follow-up revisions

RevisionCommit summaryAuthorDate
r113918Fix typonikerabbit14:43, 15 March 2012
r114002Minor white space fix...santhosh07:18, 16 March 2012
r114008More validations , limit the maxlength of aggregate group name....santhosh11:14, 16 March 2012

Comments

#Comment by Nikerabbit (talk | contribs)   14:44, 15 March 2012

The id should not conflict with any existing group. We talked about prefixing these groups at some point but did not implement that?

Status & tagging log