r56912 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56911‎ | r56912 | r56913 >
Date:01:16, 25 September 2009
Author:nad
Status:deferred
Tags:
Comment:
not that simple, put brace expansion back into selects only for now
Modified paths:
  • /trunk/extensions/RecordAdmin/RecordAdmin_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RecordAdmin/RecordAdmin_body.php
@@ -452,6 +452,9 @@
453453 # If values are wikitext, convert to hash
454454 if ( !is_array( $values ) ) $values = $this->valuesFromText( $values );
455455
 456+ # Expand any double-brace expressions in the form content (even in its html)
 457+ #$this->form = preg_replace_callback( "|\{\{.+?\}\}|s", array( $this, 'parsePart' ), $this->form );
 458+
456459 # Add the values into the form's HTML depending on their type
457460 foreach( $this->types as $k => $type ) {
458461
@@ -460,9 +463,6 @@
461464 list( $html, $pos ) = $m[0];
462465 $len = strlen( $html );
463466
464 - # Expand any double-brace expressions in the html form section
465 - $html = preg_replace_callback( "|\{\{.+\}\}|s", array( $this, 'parsePart' ), $html );
466 -
467467 # Modify the element according to its type
468468 # - clears default value, then adds new value
469469 $v = isset( $values[$k] ) ? $values[$k] : '';
@@ -476,6 +476,7 @@
477477 if ( $v ) $html = preg_replace( "|(/?>)$|", " checked $1", $html );
478478 break;
479479 case 'list':
 480+ $html = preg_replace_callback( "|\{\{.+?\}\}|s", array( $this, 'parsePart' ), $html );
480481 $html = preg_replace( "|(<option[^<>]*) selected|i", "$1", $html ); # remove the currently selected option
481482 if ( $v ) {
482483 foreach( split( "\n", $v ) as $v ) {
@@ -499,11 +500,11 @@
500501 /**
501502 * Used to parse any braces in select lists when populating form
502503 */
503 - function parsePart($part) {
 504+ function parsePart( $part ) {
504505 global $wgUser, $wgParser;
505506 $options = ParserOptions::newFromUser( $wgUser );
506 - $html = $wgParser->parse($part[0], $this->title, $options, true, true )->getText();
507 - return preg_match("|(<option.+</option>)|is", $html, $m) ? $m[1] : '';
 507+ $html = $wgParser->parse( $part[0], $this->title, $options, true, true )->getText();
 508+ return preg_match( "|(<option.+</option>)|is", $html, $m ) ? $m[1] : '';
508509 }
509510
510511 /**

Status & tagging log