r53575 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53574‎ | r53575 | r53576 >
Date:00:15, 21 July 2009
Author:nad
Status:deferred
Tags:
Comment:
multiple selects working
Modified paths:
  • /trunk/extensions/RecordAdmin/RecordAdmin_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RecordAdmin/RecordAdmin_body.php
@@ -47,7 +47,7 @@
4848
4949 # Get posted form values if any
5050 $posted = array();
51 - foreach ( $_REQUEST as $k => $v ) if ( ereg( '^ra_(.+)$', $k, $m ) ) $posted[$m[1]] = $v;
 51+ foreach ( $_REQUEST as $k => $v ) if ( preg_match( '|^ra_(\\w+)|', $k, $m ) ) $posted[$m[1]] = is_array( $v ) ? join( "\n", $v ) : $v;
5252
5353 # Read in and prepare the form for this record type if one has been selected
5454 if ( $type ) $this->preProcessForm( $type );
@@ -450,10 +450,10 @@
451451 if ( !is_array( $values ) ) $values = $this->valuesFromText( $values );
452452
453453 # Add the values into the form's HTML depending on their type
454 - foreach ( $this->types as $k => $type ) {
 454+ foreach( $this->types as $k => $type ) {
455455
456456 # Get this input element's html text and position and length
457 - preg_match( "|<([a-zA-Z]+)[^<]+?name=\"ra_$k\".*?>(.*?</\\1>)?|s", $this->form, $m, PREG_OFFSET_CAPTURE );
 457+ preg_match( "|<([a-zA-Z]+)[^<]+?name=\"ra_$k\\[?\\]?\".*?>(.*?</\\1>)?|s", $this->form, $m, PREG_OFFSET_CAPTURE );
458458 list( $html, $pos ) = $m[0];
459459 $len = strlen( $html );
460460
@@ -471,11 +471,15 @@
472472 break;
473473 case 'list':
474474 $html = preg_replace_callback("|\{\{.+\}\}|s", array($this, 'parsePart'), $html); # parse any braces
475 - if ( empty( $this->record ) ) $html = preg_replace( "|(<option[^<>]*) selected|", "$1", $html ); # remove the currently selected option
 475+ #if ( empty( $this->record ) )
 476+ $html = preg_replace( "|(<option[^<>]*) selected|", "$1", $html ); # remove the currently selected option
476477 if ( $v ) {
477 - $html = preg_match( "|<option[^>]+value\s*=|s", $html )
478 - ? preg_replace( "|(<option)([^>]+value\s*=\s*[\"']{$v}['\"])|s", "$1 selected$2", $html )
479 - : preg_replace( "|(<option[^>]*)(?=>$v</option>)|s", "$1 selected", $html );
 478+ foreach( split( "\n", $v ) as $v ) {
 479+ print $v;
 480+ $html = preg_match( "|<option[^>]+value\s*=|s", $html )
 481+ ? preg_replace( "|(<option)([^>]+value\s*=\s*[\"']{$v}['\"])|s", "$1 selected$2", $html )
 482+ : preg_replace( "|(<option[^>]*)(?=>$v</option>)|s", "$1 selected", $html );
 483+ }
480484 }
481485 break;
482486 case 'blob':
@@ -504,7 +508,7 @@
505509 */
506510 function examineForm() {
507511 $this->types = array();
508 - preg_match_all( "|<([a-zA-Z]+)[^<]+?name=\"ra_(.+?)\".*?>|", $this->form, $m );
 512+ preg_match_all( "|<([a-zA-Z]+)[^<]+?name=\"ra_(.+?)\\[?\\]?\".*?>|", $this->form, $m );
509513 foreach ( $m[2] as $i => $k ) {
510514 $tag = $m[1][$i];
511515 $type = preg_match( "|type\s*=\s*\"(.+?)\"|", $m[0][$i], $n ) ? $n[1] : '';

Status & tagging log