Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.inc |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | * Create a comma-delimited string of values that match the specified |
16 | 16 | * source name and type, for use by Javascript autocompletion. |
17 | 17 | */ |
18 | | - static function createAutocompleteValuesArray($source_name, $source_type) { |
| 18 | + static function createAutocompleteValuesString($source_name, $source_type) { |
19 | 19 | $names_array = array(); |
20 | 20 | // the query depends on whether this is a property, category, concept |
21 | 21 | // or namespace |
— | — | @@ -31,7 +31,12 @@ |
32 | 32 | $names_array = SFUtils::getAllPagesForNamespace($source_name); |
33 | 33 | } |
34 | 34 | // 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; |
36 | 41 | } |
37 | 42 | |
38 | 43 | static function uploadLinkHTML($input_id, $delimiter = null, $default_filename = null) { |
— | — | @@ -381,11 +386,7 @@ |
382 | 387 | $other_args['remote autocompletion'] == true) { |
383 | 388 | $javascript_text .= "autocompletedatatypes['$options_str_key'] = '$autocomplete_field_type';\n"; |
384 | 389 | } 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); |
390 | 391 | $javascript_text .= "autocompletestrings['$options_str_key'] = $autocomplete_string;\n"; |
391 | 392 | } |
392 | 393 | if ($cur_value) { |