r91020 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91019‎ | r91020 | r91021 >
Date:21:43, 28 June 2011
Author:foxtrott
Status:deferred
Tags:
Comment:
bugfix: enable checkboxes
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_AutoEditAjaxHandler.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_AutoEditAjaxHandler.php
@@ -29,17 +29,17 @@
3030 $title = Title::newFromText( 'DummyTitle' );
3131
3232 // 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();
3535
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 );
3838 // } else {
3939 // $wgParser->startExternalParse( $title, ParserOptions::newFromUser( $wgUser ), Parser::OT_HTML, true );
4040 // }
4141
4242 // parse options
43 - $this->parseDataFromQueryString( $this->mOptions, $options, true );
 43+ $this->parseDataFromQueryString( $this->mOptions, $options );
4444 }
4545
4646 /**
@@ -285,7 +285,7 @@
286286 * {{#time:}} parser function.
287287 * @return <type>
288288 */
289 - private function parseDataFromQueryString ( &$data, $queryString, $expand = false ) {
 289+ private function parseDataFromQueryString ( &$data, $queryString ) {
290290 $params = explode( '&', $queryString );
291291
292292 foreach ( $params as $i => $param ) {
@@ -295,11 +295,9 @@
296296 $value = count( $elements ) > 1 ? urldecode( $elements[1] ) : null;
297297
298298 if ( $key == "query string" ) {
299 - $this->parseDataFromQueryString( $data, $value, $expand );
300 - } elseif ( $expand ) {
301 - $this->addToArray( $data, $key, $value );
 299+ $this->parseDataFromQueryString( $data, $value );
302300 } else {
303 - $this->addToArray( $data, $key, $value );
 301+ $this->addToArray( $data, $key, $value, true );
304302 }
305303 }
306304
@@ -311,24 +309,28 @@
312310 // $key identifies path to position in tree.
313311 // Format: 1stLevelName[2ndLevel][3rdLevel][...], i.e. normal array notation
314312 // $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();
317316
318317 if ( preg_match( '/^([^\[\]]*)\[([^\[\]]*)\](.*)/', $key, $matches ) ) {
319318
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+ }
322327
323328 if ( !array_key_exists( $key, $array ) )
324 - $array[$key] = array( );
 329+ $array[$key] = array();
325330
326331 $this->addToArray( $array[$key], $matches[2] . $matches[3], $value );
327332 } else {
328333
329334 if ( $key ) {
330 -// $key = str_replace( ' ', '_', $key );
331 -// $key = str_replace( '.', '_', $key );
332 -// var_dump($key);
333335 $array[$key] = $value;
334336 } else {
335337 array_push( $array, $value );

Follow-up revisions

RevisionCommit summaryAuthorDate
r91485followup r91020: bugfix (#autoedit does not correctly process "query string" ...foxtrott20:27, 5 July 2011