r80487 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80486‎ | r80487 | r80488 >
Date:03:51, 18 January 2011
Author:yaron
Status:deferred
Tags:
Comment:
Bug fix so that only the first pipe in each template call is skipped
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php
@@ -438,13 +438,17 @@
439439 if ( array_key_exists( 0, $matches ) && array_key_exists( 1, $matches[0] ) ) {
440440 $start_char = $matches[0][1];
441441 $fields_start_char = $start_char + 2 + strlen( $search_template_str );
442 - // skip ahead to the first real character
443 - while ( in_array( $existing_page_content[$fields_start_char], array( ' ', '\n', '|' ) ) ) {
 442+ // Skip ahead to the first real character.
 443+ while ( in_array( $existing_page_content[$fields_start_char], array( ' ', '\n' ) ) ) {
444444 $fields_start_char++;
445445 }
 446+ // If the next character is a pipe, skip that too.
 447+ if( $existing_page_content[$fields_start_char] == '|' ) {
 448+ $fields_start_char++;
 449+ }
446450 $template_contents = array( '0' => '' );
447 - // cycle through template call, splitting it up by pipes ('|'),
448 - // except when that pipe is part of a piped link
 451+ // Cycle through template call, splitting it up by pipes ('|'),
 452+ // except when that pipe is part of a piped link.
449453 $field = "";
450454 $uncompleted_square_brackets = 0;
451455 $uncompleted_curly_brackets = 2;
@@ -526,6 +530,7 @@
527531 if ( $all_values_for_template ) {
528532 $cur_key = key( $all_values_for_template );
529533 // skip the input coming in from the "starter" div
 534+ // TODO: this code is probably no longer necessary
530535 if ( $cur_key == 'num' ) {
531536 unset( $all_values_for_template[$cur_key] );
532537 $cur_key = key( $all_values_for_template );