Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.inc |
— | — | @@ -14,12 +14,11 @@ |
15 | 15 | // the query depends on whether this field is a relation (property of type |
16 | 16 | // Page), attribute (property of any other type), category or namespace |
17 | 17 | if ($autocomplete_field_type == 'relation' || $autocomplete_field_type == 'attribute' || $autocomplete_field_type == 'property') { |
18 | | - $smw_version = SMW_VERSION; |
19 | | - if ($smw_version{0} == '0') { |
| 18 | + if (version_compare(SMW_VERSION, '1.2', '>=' )) { |
| 19 | + $names_array = sffGetAllPagesForProperty_1_2($field_name); |
| 20 | + } else { |
20 | 21 | $is_relation = ($autocomplete_field_type == 'relation'); |
21 | 22 | $names_array = sffGetAllPagesForProperty_0_7($is_relation, $field_name); |
22 | | - } else { |
23 | | - $names_array = sffGetAllPagesForProperty_1_0($field_name); |
24 | 23 | } |
25 | 24 | } elseif ($autocomplete_field_type == 'category') { |
26 | 25 | $names_array = sffGetAllPagesForCategory($field_name, 10); |
— | — | @@ -29,19 +28,32 @@ |
30 | 29 | return $names_array; |
31 | 30 | } |
32 | 31 | |
| 32 | + function uploadLinkHTML($input_id, $delimiter = null) { |
| 33 | + $upload_window_page = SpecialPage::getPage('UploadWindow'); |
| 34 | + $query_string = "sfInputID=$input_id"; |
| 35 | + if ($delimiter != null) |
| 36 | + $query_string .= "&sfDelimiter=$delimiter"; |
| 37 | + $upload_window_url = $upload_window_page->getTitle()->getFullURL($query_string); |
| 38 | + $upload_label = wfMsg('upload'); |
| 39 | + $text = " <a href=\"$upload_window_url\" title=\"$upload_label\" rel=\"iframe\" rev=\"width:550 height:380\">$upload_label</a>"; |
| 40 | + return $text; |
| 41 | + } |
| 42 | + |
33 | 43 | function textEntryHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) { |
34 | 44 | // if it's an autocomplete, call the with-autocomplete function instead |
35 | 45 | // we test to make sure that autocompletion hasn't been disabled, and |
36 | 46 | // that either the property is a relation (i.e. it's of type Page) or |
37 | | - // autocompletion has been specifified in the form |
38 | | - $autocompletion_disabled = array_key_exists('autocomplete on', $other_args) && $other_args['autocomplete on'] == ""; |
| 47 | + // autocompletion has been specified in the form |
| 48 | + $autocompletion_disabled = (array_key_exists('autocomplete on', $other_args) && $other_args['autocomplete on'] == "") || |
| 49 | + (array_key_exists('no autocomplete', $other_args) && $other_args['no autocomplete'] == true); |
39 | 50 | if (! $autocompletion_disabled) { |
40 | 51 | if ((array_key_exists('is_relation', $other_args) && $other_args['is_relation'] == true) || |
41 | 52 | array_key_exists('autocomplete', $other_args) || |
42 | 53 | array_key_exists('autocomplete on property', $other_args) || |
43 | 54 | array_key_exists('autocomplete on category', $other_args) || |
44 | 55 | array_key_exists('autocomplete on', $other_args) || |
45 | | - array_key_exists('autocomplete on namespace', $other_args)) { |
| 56 | + array_key_exists('autocomplete on namespace', $other_args) || |
| 57 | + array_key_exists('remote autocompletion', $other_args)) { |
46 | 58 | return SFFormInputs::textInputWithAutocompleteHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args); |
47 | 59 | } |
48 | 60 | } |
— | — | @@ -103,10 +115,16 @@ |
104 | 116 | |
105 | 117 | END; |
106 | 118 | if (array_key_exists('is_uploadable', $other_args) && $other_args['is_uploadable'] == true) { |
107 | | - $upload_window_page = SpecialPage::getPage('UploadWindow'); |
108 | | - $upload_window_url = $upload_window_page->getTitle()->getFullURL("wpInputID=$input_id"); |
109 | | - $upload_label = wfMsg('upload'); |
110 | | - $text .= " <a href=\"$upload_window_url\" title=\"$upload_label\" rel=\"iframe\" rev=\"width:550 height:380\">$upload_label</a>"; |
| 119 | + if (array_key_exists('is_list', $other_args) && $other_args['is_list'] == true) { |
| 120 | + if (array_key_exists('delimiter', $other_args)) { |
| 121 | + $delimiter = $other_args['delimiter']; |
| 122 | + } else { |
| 123 | + $delimiter = ","; |
| 124 | + } |
| 125 | + } else { |
| 126 | + $delimiter = null; |
| 127 | + } |
| 128 | + $text .= SFFormInputs::uploadLinkHTML($input_id, $delimiter); |
111 | 129 | } |
112 | 130 | return array($text, null); |
113 | 131 | } |
— | — | @@ -304,11 +322,19 @@ |
305 | 323 | $text .= ' maxlength="' . $other_args['maxlength'] . '"'; |
306 | 324 | $text .= "/>\n"; |
307 | 325 | } |
| 326 | + // is_list and delimiter variables - needed later |
| 327 | + $is_list = (array_key_exists('is_list', $other_args) && $other_args['is_list'] == true); |
| 328 | + if ($is_list) { |
| 329 | + if (array_key_exists('delimiter', $other_args)) { |
| 330 | + $delimiter = $other_args['delimiter']; |
| 331 | + } else { |
| 332 | + $delimiter = ","; |
| 333 | + } |
| 334 | + } else { |
| 335 | + $delimiter = null; |
| 336 | + } |
308 | 337 | if (array_key_exists('is_uploadable', $other_args) && $other_args['is_uploadable'] == true) { |
309 | | - $upload_window_page = SpecialPage::getPage('UploadWindow'); |
310 | | - $upload_window_url = $upload_window_page->getTitle()->getFullURL("wpInputID=$input_id"); |
311 | | - $upload_label = wfMsg('upload'); |
312 | | - $text .= " <a href=\"$upload_window_url\" title=\"$upload_label\" rel=\"iframe\" rev=\"width:550 height:380\">$upload_label</a>"; |
| 338 | + $text .= SFFormInputs::uploadLinkHTML($input_id, $delimiter); |
313 | 339 | } |
314 | 340 | $text .=<<<END |
315 | 341 | <span id="$info_id" class="errorMessage"></span> |
— | — | @@ -317,10 +343,10 @@ |
318 | 344 | |
319 | 345 | END; |
320 | 346 | $options_str_key = str_replace("'", "\'", $semantic_field_name); |
321 | | - if (array_key_exists('is_list', $other_args) && $other_args['is_list'] == true) { |
| 347 | + if ($is_list) { |
322 | 348 | $options_str_key .= ",list"; |
323 | | - if (array_key_exists('delimiter', $other_args) && $other_args['delimiter'] != ",") { |
324 | | - $options_str_key .= "," . $other_args['delimiter']; |
| 349 | + if ($delimiter != ",") { |
| 350 | + $options_str_key .= "," . $delimiter; |
325 | 351 | } |
326 | 352 | } |
327 | 353 | $javascript_text = "autocompletemappings[$sfgFieldNum] = '$options_str_key';\n"; |
— | — | @@ -352,7 +378,8 @@ |
353 | 379 | if ((array_key_exists('is_relation', $other_args) && $other_args['is_relation'] == true) || |
354 | 380 | array_key_exists('autocomplete', $other_args) || |
355 | 381 | array_key_exists('autocomplete on', $other_args) || |
356 | | - array_key_exists('autocomplete on namespace', $other_args)) { |
| 382 | + array_key_exists('autocomplete on namespace', $other_args) || |
| 383 | + array_key_exists('remote autocompletion', $other_args)) { |
357 | 384 | $other_args['input_type'] = "textarea"; |
358 | 385 | return SFFormInputs::textInputWithAutocompleteHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args); |
359 | 386 | } |