r101040 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101039‎ | r101040 | r101041 >
Date:20:30, 27 October 2011
Author:yaron
Status:deferred (Comments)
Tags:
Comment:
Added display of warning if there are unclosed curly or square brackets within the page
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php
@@ -514,7 +514,7 @@
515515 // Also replace periods with underlines, since that's what
516516 // POST does to strings anyway.
517517 $query_template_name = str_replace( '.', '_', $query_template_name );
518 - // ...and escape apostrophes.
 518+ // ...and escape apostrophes.
519519 $query_template_name = str_replace( "'", "\'", $query_template_name );
520520 // Cycle through the other components.
521521 for ( $i = 2; $i < count( $tag_components ); $i++ ) {
@@ -653,6 +653,14 @@
654654 $field .= $c;
655655 }
656656 }
 657+ // If there are uncompleted opening brackets, the whole form will get messed up -
 658+ // display a warning.
 659+ // (If there are too many *closing* brackets, some template stuff will end up in
 660+ // the "free text" field - which is bad, but it's harder for the code to detect
 661+ // the problem - though hopefully, easier for users.)
 662+ if ( $uncompleted_curly_brackets > 0 || $uncompleted_square_brackets > 0 ) {
 663+ $form_text .= "\t" . '<div class="warningbox">' . wfMsg( 'sf_formedit_mismatchedbrackets', $this->mPageTitle->getFullURL( array( 'action' => 'edit' ) ) ) . "</div>\n<br clear=\"both\" />\n";
 664+ }
657665 $existing_template_text = substr( $existing_page_content, $start_char, $i - $start_char );
658666 // now remove this template from the text being edited
659667 // if this is a partial form, establish a new insertion point
@@ -1436,7 +1444,7 @@
14371445 unset ( $template_label );
14381446 }
14391447 $form_text = preg_replace( '/' . self::makePlaceholderInFormHTML( $curPlaceholder ) . '/',
1440 - $multipleTemplateString, $form_text );
 1448+ $multipleTemplateString, $form_text );
14411449 }
14421450 if ( ! $all_instances_printed ) {
14431451 // This will cause the section to be

Comments

#Comment by Nikerabbit (talk | contribs)   06:50, 28 October 2011

Why are you adding the used messages in a different commit?