Index: trunk/extensions/SemanticForms/includes/SF_Utils.php |
— | — | @@ -511,6 +511,30 @@ |
512 | 512 | } |
513 | 513 | |
514 | 514 | /** |
| 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 | + /** |
515 | 539 | * Parse the form definition and store the resulting HTML in the |
516 | 540 | * page_props table, if caching has been specified in LocalSettings.php |
517 | 541 | */ |