r57876 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57875‎ | r57876 | r57877 >
Date:23:08, 18 October 2009
Author:nad
Status:deferred
Tags:
Comment:
allow any wikitext in forms to expand
Modified paths:
  • /trunk/extensions/RecordAdmin/RecordAdmin.php (modified) (history)
  • /trunk/extensions/RecordAdmin/RecordAdmin_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RecordAdmin/RecordAdmin_body.php
@@ -516,9 +516,6 @@
517517 # If values are wikitext, convert to hash
518518 if ( !is_array( $values ) ) $values = $this->valuesFromText( $values );
519519
520 - # Expand any double-brace expressions in the form content (even in its html)
521 - #$this->form = preg_replace_callback( "|\{\{.+?\}\}|s", array( $this, 'parsePart' ), $this->form );
522 -
523520 # Add the values into the form's HTML depending on their type
524521 foreach( $this->types as $k => $type ) {
525522
@@ -559,6 +556,23 @@
560557 # Replace the element in the form with the modified html
561558 $this->form = substr_replace( $this->form, $html, $pos, $len );
562559 }
 560+
 561+ # Parse any brace structures
 562+ global $wgUser, $wgParser;
 563+ $options = ParserOptions::newFromUser( $wgUser );
 564+ $max = 25;
 565+ do {
 566+ $braces = false;
 567+ foreach ( $this->examineBraces( $this->form ) as $brace ) {
 568+ if ( $brace['DEPTH'] == 2 ) $braces = $brace;
 569+ }
 570+ if ( $braces ) {
 571+ $part = substr( $this->form, $braces['OFFSET'], $braces['LENGTH'] );
 572+ $html = $wgParser->parse( $part, $this->title, $options, true, true )->getText();
 573+ $this->form = substr_replace( $this->form, $html, $braces['OFFSET'], $braces['LENGTH'] );
 574+ }
 575+ } while ( --$max > 0 && $braces );
 576+
563577 }
564578
565579 /**
Index: trunk/extensions/RecordAdmin/RecordAdmin.php
@@ -11,7 +11,7 @@
1212 * @licence GNU General Public Licence 2.0 or later
1313 */
1414
15 -define( 'RECORDADMIN_VERSION', '0.8.9, 2009-10-17' );
 15+define( 'RECORDADMIN_VERSION', '0.8.10, 2009-10-19' );
1616
1717 $wgRecordAdminUseNamespaces = false; # Whether record articles should be in a namespace of the same name as their type
1818 $wgRecordAdminCategory = 'Records'; # Category containing record types

Status & tagging log