r79159 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79158‎ | r79159 | r79160 >
Date:03:46, 29 December 2010
Author:yaron
Status:deferred
Tags:
Comment:
Added getFormTagComponents() (and a related helper function, convertBackToPipes()), to finally allow for correct parsing of form-tag params that contain parser functions
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_Utils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_Utils.php
@@ -511,6 +511,30 @@
512512 }
513513
514514 /**
 515+ * A helper function, used by getFormTagComponents().
 516+ */
 517+ static function convertBackToPipes( $s ) {
 518+ return str_replace( "\1", '|', $s );
 519+ }
 520+
 521+ /**
 522+ * This function is basically equivalent to calling
 523+ * explode( '|', $str ), except that it doesn't split on pipes
 524+ * that are within parser function calls - i.e., pipes within
 525+ * double curly brackets.
 526+ */
 527+ static function getFormTagComponents( $str ) {
 528+ // Turn each pipe within double curly brackets into another,
 529+ // unused character (here, "\1"), then do the explode, then
 530+ // convert them back.
 531+ $pattern = '/({{.*)\|(.*}})/';
 532+ while ( preg_match($pattern, $str, $matches) ) {
 533+ $str = preg_replace($pattern, "$1" . "\1" . "$2", $str);
 534+ }
 535+ return array_map( array(self, 'convertBackToPipes'), explode('|', $str) );
 536+ }
 537+
 538+ /**
515539 * Parse the form definition and store the resulting HTML in the
516540 * page_props table, if caching has been specified in LocalSettings.php
517541 */

Follow-up revisions

RevisionCommit summaryAuthorDate
r79223Fix bug in r79159: Static callback functions need class name instead of an ob...foxtrott01:33, 30 December 2010

Status & tagging log