Index: trunk/extensions/SemanticForms/includes/SF_AutoEditAjaxHandler.php |
— | — | @@ -29,17 +29,17 @@ |
30 | 30 | $title = Title::newFromText( 'DummyTitle' ); |
31 | 31 | |
32 | 32 | // if ( version_compare( substr( $wgVersion, 0, 4 ), '1.17', '<' ) ) { |
33 | | - if ( !StubObject::isRealObject( $wgParser ) ) |
34 | | - $wgParser->_unstub(); |
| 33 | + if ( !StubObject::isRealObject( $wgParser ) ) |
| 34 | + $wgParser->_unstub(); |
35 | 35 | |
36 | | - // perform offensive operation |
37 | | - $wgParser->startExternalParse( $title, ParserOptions::newFromUser( $wgUser ), Parser::OT_HTML, true ); |
| 36 | + // perform offensive operation |
| 37 | + $wgParser->startExternalParse( $title, ParserOptions::newFromUser( $wgUser ), Parser::OT_HTML, true ); |
38 | 38 | // } else { |
39 | 39 | // $wgParser->startExternalParse( $title, ParserOptions::newFromUser( $wgUser ), Parser::OT_HTML, true ); |
40 | 40 | // } |
41 | 41 | |
42 | 42 | // parse options |
43 | | - $this->parseDataFromQueryString( $this->mOptions, $options, true ); |
| 43 | + $this->parseDataFromQueryString( $this->mOptions, $options ); |
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
— | — | @@ -285,7 +285,7 @@ |
286 | 286 | * {{#time:}} parser function. |
287 | 287 | * @return <type> |
288 | 288 | */ |
289 | | - private function parseDataFromQueryString ( &$data, $queryString, $expand = false ) { |
| 289 | + private function parseDataFromQueryString ( &$data, $queryString ) { |
290 | 290 | $params = explode( '&', $queryString ); |
291 | 291 | |
292 | 292 | foreach ( $params as $i => $param ) { |
— | — | @@ -295,11 +295,9 @@ |
296 | 296 | $value = count( $elements ) > 1 ? urldecode( $elements[1] ) : null; |
297 | 297 | |
298 | 298 | if ( $key == "query string" ) { |
299 | | - $this->parseDataFromQueryString( $data, $value, $expand ); |
300 | | - } elseif ( $expand ) { |
301 | | - $this->addToArray( $data, $key, $value ); |
| 299 | + $this->parseDataFromQueryString( $data, $value ); |
302 | 300 | } else { |
303 | | - $this->addToArray( $data, $key, $value ); |
| 301 | + $this->addToArray( $data, $key, $value, true ); |
304 | 302 | } |
305 | 303 | } |
306 | 304 | |
— | — | @@ -311,24 +309,28 @@ |
312 | 310 | // $key identifies path to position in tree. |
313 | 311 | // Format: 1stLevelName[2ndLevel][3rdLevel][...], i.e. normal array notation |
314 | 312 | // $value: the value to insert |
315 | | - private function addToArray ( &$array, $key, $value ) { |
316 | | - $matches = array( ); |
| 313 | + // $toplevel: if this is a toplevel value. |
| 314 | + private function addToArray( &$array, $key, $value, $toplevel = false ) { |
| 315 | + $matches = array(); |
317 | 316 | |
318 | 317 | if ( preg_match( '/^([^\[\]]*)\[([^\[\]]*)\](.*)/', $key, $matches ) ) { |
319 | 318 | |
320 | | - $key = str_replace( ' ', '_', $matches[1] ); |
321 | | - $key = str_replace( '.', '_', $key ); |
| 319 | + // for some reason toplevel keys get their spaces encoded by MW. |
| 320 | + // We have to imitate that. |
| 321 | + // FIXME: Are there other cases than spaces? |
| 322 | + if ( $toplevel ) { |
| 323 | + $key = str_replace( ' ', '_', $matches[1] ); |
| 324 | + } else { |
| 325 | + $key = $matches[1]; |
| 326 | + } |
322 | 327 | |
323 | 328 | if ( !array_key_exists( $key, $array ) ) |
324 | | - $array[$key] = array( ); |
| 329 | + $array[$key] = array(); |
325 | 330 | |
326 | 331 | $this->addToArray( $array[$key], $matches[2] . $matches[3], $value ); |
327 | 332 | } else { |
328 | 333 | |
329 | 334 | if ( $key ) { |
330 | | -// $key = str_replace( ' ', '_', $key ); |
331 | | -// $key = str_replace( '.', '_', $key ); |
332 | | -// var_dump($key); |
333 | 335 | $array[$key] = $value; |
334 | 336 | } else { |
335 | 337 | array_push( $array, $value ); |