r48142 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48141‎ | r48142 | r48143 >
Date:21:07, 7 March 2009
Author:nad
Status:deferred
Tags:
Comment:
fix problem with select lists using wikitext to generate their options
Modified paths:
  • /trunk/extensions/RecordAdmin/RecordAdmin_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RecordAdmin/RecordAdmin_body.php
@@ -29,7 +29,7 @@
3030 $newtype = $wgRequest->getText( 'wpNewType' );
3131 $record = $wgRequest->getText( 'wpRecord' );
3232 $invert = $wgRequest->getText( 'wpInvert' );
33 - $title = Title::makeTitle( NS_SPECIAL, 'RecordAdmin' );
 33+ $title = $this->title = Title::makeTitle( NS_SPECIAL, 'RecordAdmin' );
3434 $wpTitle = trim( $wgRequest->getText( 'wpTitle' ) );
3535
3636 if ( $type && $wgRecordAdminUseNamespaces ) {
@@ -399,6 +399,7 @@
400400 if ( $v ) $html = preg_replace( "|(/?>)$|", " checked $1", $html );
401401 break;
402402 case 'list':
 403+ $html = preg_replace_callback("|\{\{.+\}\}|s", array($this, 'parsePart'), $html); # parse any braces
403404 $html = preg_replace( "|(<option[^<>]*) selected|", "$1", $html );
404405 if ( $v ) $html = preg_replace( "|(<option[^>]*)(?=>$v</option>)|s", "$1 selected", $html );
405406 break;
@@ -413,6 +414,17 @@
414415 }
415416
416417 /**
 418+ * Used to parse any braces in select lists when populating form
 419+ */
 420+ function parsePart($part) {
 421+ global $wgUser, $wgParser;
 422+ $parser = new Parser;
 423+ $options = ParserOptions::newFromUser( $wgUser );
 424+ $html = $parser->parse( $part[0], $this->title, $options, true, true )->getText();
 425+ return '';
 426+ }
 427+
 428+ /**
417429 * Returns an array of types used by the passed HTML text form
418430 * - supported types, text, select, checkbox, textarea
419431 */

Status & tagging log