r58167 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58166‎ | r58167 | r58168 >
Date:22:36, 26 October 2009
Author:yaron
Status:deferred
Tags:
Comment:
Improved handling for forms with more than one similarly-named multiple-instance templates; removed escaping of non-quote characters from content edited with FCKeditor
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc
@@ -324,10 +324,11 @@
325325 // once in that page, and multiple values are allowed, repeat this
326326 // section
327327 $existing_template_text = null;
328 - // replace underlines with spaces in template name, to allow for
329 - // searching on either
330 - $search_template_str = str_replace('_', ' ', $tif->template_name);
331328 if ($source_is_page || $form_is_partial) {
 329+ // replace underlines with spaces in template name, to allow for
 330+ // searching on either
 331+ $search_template_str = str_replace('_', ' ', $tif->template_name);
 332+ $found_instance = preg_match('/{{' . $search_template_str . '\s*[\|}]/i', str_replace('_', ' ', $existing_page_content));
332333 if ($allow_multiple) {
333334 // find instances of this template in the page -
334335 // if there's at least one, re-parse this section of the
@@ -336,7 +337,7 @@
337338 // there has to be a more efficient way to handle multiple
338339 // instances of templates, one that doesn't involve re-parsing
339340 // the same tags, but I don't know what it is.
340 - if (stripos(str_replace('_', ' ', $existing_page_content), '{{' . $search_template_str) !== false) {
 341+ if ($found_instance) {
341342 $instance_num++;
342343 } else {
343344 $all_instances_printed = true;
@@ -344,7 +345,7 @@
345346 }
346347 // get the first instance of this template on the page being edited,
347348 // even if there are more
348 - if (($start_char = stripos(str_replace('_', ' ', $existing_page_content), '{{' . $search_template_str)) !== false) {
 349+ if ($found_instance && ($start_char = stripos(str_replace('_', ' ', $existing_page_content), '{{' . $search_template_str)) !== false) {
349350 $fields_start_char = $start_char + 2 + strlen($search_template_str);
350351 // skip ahead to the first real character
351352 while (in_array($existing_page_content[$fields_start_char], array(' ', '\n', '|'))) {
@@ -1146,7 +1147,7 @@
11471148 global $wgFCKEditorDir;
11481149 if ($wgFCKEditorDir) {
11491150 $showFCKEditor = SFFormUtils::getShowFCKEditor();
1150 - $free_text = htmlspecialchars( $free_text );
 1151+ $free_text = str_replace( '"', '"', $free_text );
11511152 if(!$form_submitted && ($showFCKEditor & RTE_VISIBLE)) {
11521153 $free_text = SFFormUtils::prepareTextForFCK($free_text);
11531154 }

Status & tagging log