r61887 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61886‎ | r61887 | r61888 >
Date:21:56, 2 February 2010
Author:yaron
Status:deferred
Tags:
Comment:
Changed createAutocompleteValuesArray() to createAutocompleteValuesString()
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormInputs.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.inc
@@ -14,7 +14,7 @@
1515 * Create a comma-delimited string of values that match the specified
1616 * source name and type, for use by Javascript autocompletion.
1717 */
18 - static function createAutocompleteValuesArray($source_name, $source_type) {
 18+ static function createAutocompleteValuesString($source_name, $source_type) {
1919 $names_array = array();
2020 // the query depends on whether this is a property, category, concept
2121 // or namespace
@@ -31,7 +31,12 @@
3232 $names_array = SFUtils::getAllPagesForNamespace($source_name);
3333 }
3434 // escape quotes, to avoid Javascript errors
35 - return array_map('addslashes', $names_array);
 35+ $names_array = array_map('addslashes', $names_array);
 36+ $autocomplete_string = "[['" . implode("'], ['", $names_array) . "']]";
 37+ // replace any newlines in the string, just to avoid breaking the Javascript
 38+ $autocomplete_string = str_replace("\n", ' ', $autocomplete_string);
 39+ $autocomplete_string = str_replace("\r", ' ', $autocomplete_string);
 40+ return $autocomplete_string;
3641 }
3742
3843 static function uploadLinkHTML($input_id, $delimiter = null, $default_filename = null) {
@@ -381,11 +386,7 @@
382387 $other_args['remote autocompletion'] == true) {
383388 $javascript_text .= "autocompletedatatypes['$options_str_key'] = '$autocomplete_field_type';\n";
384389 } elseif ($autocompletion_source != '') {
385 - $autocomplete_values = self::createAutocompleteValuesArray($autocompletion_source, $autocomplete_field_type);
386 - $autocomplete_string = "[['" . implode("'], ['", $autocomplete_values) . "']]";
387 - // replace any newlines in the string, just to avoid breaking the Javascript
388 - $autocomplete_string = str_replace("\n", ' ', $autocomplete_string);
389 - $autocomplete_string = str_replace("\r", ' ', $autocomplete_string);
 390+ $autocomplete_string = self::createAutocompleteValuesString($autocompletion_source, $autocomplete_field_type);
390391 $javascript_text .= "autocompletestrings['$options_str_key'] = $autocomplete_string;\n";
391392 }
392393 if ($cur_value) {

Status & tagging log