Index: trunk/extensions/Narayam/Narayam.php |
— | — | @@ -129,6 +129,10 @@ |
130 | 130 | return true; |
131 | 131 | } |
132 | 132 | |
| 133 | + function formatSchemes( $str ) { |
| 134 | + return sprintf( 'tr_%s', $str ); |
| 135 | + } |
| 136 | + |
133 | 137 | /** |
134 | 138 | * Generate JavaScript code according to configuration settings |
135 | 139 | * |
— | — | @@ -153,12 +157,12 @@ |
154 | 158 | // $str .= 'Narayam.default_state = ' . Narayam::boolToString($wgNarayamConfig['default_state']) . ";\n"; |
155 | 159 | $str .= "Narayam.schemes = [\n"; |
156 | 160 | $schemeCount = count( $wgNarayamConfig['schemes'] ); |
157 | | - for ( $i = 0; $i < $schemeCount; $i++ ) { |
158 | | - $str .= sprintf( 'tr_%s', $wgNarayamConfig['schemes'][$i] ); |
159 | | - if ( $i < ( $schemeCount - 1 ) ) { |
160 | | - $str .= ', '; |
161 | | - } |
| 161 | + |
| 162 | + if ( $schemeCount > 0 ) { |
| 163 | + $transformed = array_map( array( $this, 'formatSchemes' ) , $wgNarayamConfig['schemes'] ); |
| 164 | + $str .= implode( ',', $transformed ); |
162 | 165 | } |
| 166 | + |
163 | 167 | $str .= "];\n"; |
164 | 168 | $str .= sprintf( "Narayam.default_scheme_index = %d;", $wgNarayamConfig['default_scheme_index'] ); |
165 | 169 | for ( $i = 0; $i < $schemeCount; $i++ ) { |