Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.php |
— | — | @@ -44,12 +44,10 @@ |
45 | 45 | |
46 | 46 | class SFTextInput extends SFFormInput { |
47 | 47 | static function uploadLinkHTML( $input_id, $delimiter = null, $default_filename = null ) { |
48 | | - global $wgOut, $sfgScriptPath, $sfgFancyBoxInputs; |
| 48 | + global $wgOut, $sfgScriptPath; |
49 | 49 | |
50 | 50 | $upload_window_page = SpecialPage::getPage( 'UploadWindow' ); |
51 | 51 | $query_string = "sfInputID=$input_id"; |
52 | | - $fancybox_id = "fancybox_$input_id"; |
53 | | - $sfgFancyBoxInputs[] = $input_id; |
54 | 52 | if ( $delimiter != null ) |
55 | 53 | $query_string .= "&sfDelimiter=$delimiter"; |
56 | 54 | if ( $default_filename != null ) |
— | — | @@ -62,7 +60,13 @@ |
63 | 61 | else |
64 | 62 | $style = ''; |
65 | 63 | |
66 | | - $text = " <a id=\"$fancybox_id\" href=\"$upload_window_url\" title=\"$upload_label\" rev=\"$style\">$upload_label</a>"; |
| 64 | + $linkAttrs = array( |
| 65 | + 'href' => $upload_window_url, |
| 66 | + 'class' => 'sfFancyBox', |
| 67 | + 'title' => $upload_label, |
| 68 | + 'rev' => $style |
| 69 | + ); |
| 70 | + $text = "\t" . Xml::element( 'a', $linkAttrs, $upload_label ) . "\n"; |
67 | 71 | return $text; |
68 | 72 | } |
69 | 73 | |
— | — | @@ -76,59 +80,52 @@ |
77 | 81 | if ( array_key_exists( 'possible_values', $other_args ) && $other_args['possible_values'] != null ) |
78 | 82 | return SFDropdownInput::getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
79 | 83 | |
80 | | - global $sfgTabIndex, $sfgFieldNum, $sfgJSValidationCalls; |
| 84 | + global $sfgTabIndex, $sfgFieldNum; |
81 | 85 | |
82 | | - $className = ( $is_mandatory ) ? "createboxInput mandatoryField" : "createboxInput"; |
83 | | - if ( array_key_exists( 'class', $other_args ) ) |
| 86 | + $className = "createboxInput"; |
| 87 | + if ( $is_mandatory ) { |
| 88 | + $className .= " mandatoryField"; |
| 89 | + } |
| 90 | + if ( array_key_exists( 'class', $other_args ) ) { |
84 | 91 | $className .= " " . $other_args['class']; |
| 92 | + } |
85 | 93 | $input_id = "input_$sfgFieldNum"; |
86 | | - $info_id = "info_$sfgFieldNum"; |
87 | 94 | // set size based on pre-set size, or field type - if field type is set, |
88 | 95 | // possibly add validation too |
89 | | - if ( array_key_exists( 'size', $other_args ) ) { |
90 | | - $size = $other_args['size']; |
91 | | - } elseif ( array_key_exists( 'field_type', $other_args ) ) { |
92 | | - $validation_type_str = ""; |
93 | | - if ( $other_args['field_type'] == 'integer' ) { |
| 96 | + $size = 35; |
| 97 | + if ( array_key_exists( 'field_type', $other_args ) ) { |
| 98 | + if ( $other_args['field_type'] == 'number' ) { |
94 | 99 | $size = 10; |
95 | | - $validation_type_str = 'integer'; |
96 | | - } elseif ( $other_args['field_type'] == 'number' ) { |
97 | | - $size = 10; |
98 | | - $validation_type_str = 'number'; |
| 100 | + $inputType = 'number'; |
99 | 101 | } elseif ( $other_args['field_type'] == 'URL' ) { |
100 | 102 | $size = 100; |
101 | | - $validation_type_str = 'URL'; |
| 103 | + $inputType = 'URL'; |
102 | 104 | } elseif ( $other_args['field_type'] == 'email' ) { |
103 | 105 | $size = 45; |
104 | | - $validation_type_str = 'email'; |
105 | | - } else { |
106 | | - $size = 35; |
| 106 | + $inputType = 'email'; |
107 | 107 | } |
108 | | - if ( $validation_type_str != '' ) { |
109 | | - if ( array_key_exists( 'part_of_multiple', $other_args ) ) { |
110 | | - $sfgJSValidationCalls[] = "validate_type_of_multiple_fields($sfgFieldNum, '$validation_type_str')"; |
111 | | - } else { |
112 | | - $sfgJSValidationCalls[] = "validate_field_type('$input_id', '$validation_type_str', '$info_id')"; |
113 | | - } |
114 | | - } |
115 | | - } else { |
116 | | - $size = 35; |
117 | 108 | } |
118 | | - if ( ! is_null( $cur_value ) && ! is_array( $cur_value ) ) |
119 | | - $cur_value = htmlspecialchars( $cur_value ); |
| 109 | + if ( array_key_exists( 'size', $other_args ) ) { |
| 110 | + $size = $other_args['size']; |
| 111 | + } |
120 | 112 | |
121 | | - $text = <<<END |
122 | | - <input id="$input_id" tabindex="$sfgTabIndex" class="$className" name="$input_name" type="text" value="$cur_value" size="$size" |
123 | | -END; |
124 | | - if ( $is_disabled ) |
125 | | - $text .= " disabled"; |
126 | | - if ( array_key_exists( 'maxlength', $other_args ) ) |
127 | | - $text .= ' maxlength="' . $other_args['maxlength'] . '"'; |
128 | | - $text .= <<<END |
129 | | -/> |
130 | | - <span id="$info_id" class="errorMessage"></span> |
| 113 | + $inputAttrs = array( |
| 114 | + 'type' => 'text', |
| 115 | + 'id' => $input_id, |
| 116 | + 'tabindex' => $sfgTabIndex, |
| 117 | + 'class' => $className, |
| 118 | + 'name' => $input_name, |
| 119 | + 'value' => $cur_value, |
| 120 | + 'size' => $size |
| 121 | + ); |
| 122 | + if ( $is_disabled ) { |
| 123 | + $inputAttrs['disabled'] = 'disabled'; |
| 124 | + } |
| 125 | + if ( array_key_exists( 'maxlength', $other_args ) ) { |
| 126 | + $inputAttrs['maxlength'] = $other_args['maxlength']; |
| 127 | + } |
| 128 | + $text = Xml::element( 'input', $inputAttrs ); |
131 | 129 | |
132 | | -END; |
133 | 130 | if ( array_key_exists( 'is_uploadable', $other_args ) && $other_args['is_uploadable'] == true ) { |
134 | 131 | if ( array_key_exists( 'is_list', $other_args ) && $other_args['is_list'] == true ) { |
135 | 132 | if ( array_key_exists( 'delimiter', $other_args ) ) { |
— | — | @@ -146,7 +143,11 @@ |
147 | 144 | } |
148 | 145 | $text .= self::uploadLinkHTML( $input_id, $delimiter, $default_filename ); |
149 | 146 | } |
150 | | - return array( $text, null ); |
| 147 | + $spanClass = "inputSpan"; |
| 148 | + $spanClass .= " {$inputType}Input"; |
| 149 | + if ( $is_mandatory ) { $spanClass .= " mandatoryFieldSpan"; } |
| 150 | + $text = Xml::tags( 'span', array( 'class' => $spanClass ), $text ); |
| 151 | + return $text; |
151 | 152 | } |
152 | 153 | |
153 | 154 | public static function getParameters() { |
— | — | @@ -161,69 +162,67 @@ |
162 | 163 | |
163 | 164 | class SFDropdownInput extends SFEnumInput { |
164 | 165 | static function getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
165 | | - global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelectCalls; |
| 166 | + global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect; |
166 | 167 | |
167 | 168 | $className = ( $is_mandatory ) ? "mandatoryField" : "createboxInput"; |
168 | 169 | if ( array_key_exists( 'class', $other_args ) ) |
169 | 170 | $className .= " " . $other_args['class']; |
170 | 171 | $input_id = "input_$sfgFieldNum"; |
171 | | - $info_id = "info_$sfgFieldNum"; |
172 | | - $disabled_text = ( $is_disabled ) ? "disabled" : ""; |
173 | 172 | if ( array_key_exists( 'show on select', $other_args ) ) { |
| 173 | + $className .= " sfShowIfSelected"; |
174 | 174 | foreach ( $other_args['show on select'] as $div_id => $options ) { |
175 | | - $options_str = implode( "', '", $options ); |
176 | | - $js_text = "showIfSelected('$input_id', ['$options_str'], '$div_id'); "; |
177 | | - $sfgShowOnSelectCalls[] = "jQuery('#$input_id').change( function() { $js_text } );"; |
178 | | - $sfgShowOnSelectCalls[] = $js_text; |
| 175 | + if ( array_key_exists( $input_id, $sfgShowOnSelect ) ) { |
| 176 | + $sfgShowOnSelect[$input_id][] = array( $options, $div_id ); |
| 177 | + } else { |
| 178 | + $sfgShowOnSelect[$input_id] = array( array( $options, $div_id ) ); |
| 179 | + } |
179 | 180 | } |
180 | 181 | } |
181 | | - $text = <<<END |
182 | | - <select id="$input_id" tabindex="$sfgTabIndex" name="$input_name" class="$className" $disabled_text> |
183 | | - |
184 | | -END; |
| 182 | + $innerDropdown = ""; |
185 | 183 | // add a blank value at the beginning, unless this is a mandatory field |
186 | 184 | // and there's a current value in place (either through a default value |
187 | 185 | // or because we're editing an existing page) |
188 | 186 | if ( ! $is_mandatory || $cur_value == '' ) { |
189 | | - $text .= " <option value=\"\"></option>\n"; |
| 187 | + $innerDropdown .= " <option value=\"\"></option>\n"; |
190 | 188 | } |
191 | 189 | if ( ( $possible_values = $other_args['possible_values'] ) == null ) |
192 | 190 | $possible_values = array(); |
193 | 191 | foreach ( $possible_values as $possible_value ) { |
194 | | - $text .= " <option value=\"$possible_value\""; |
195 | | - if ( $possible_value == $cur_value ) { $text .= " selected=\"selected\""; } |
196 | | - $text .= ">"; |
| 192 | + $optionAttrs = array( 'value' => $possible_value ); |
| 193 | + if ( $possible_value == $cur_value ) { |
| 194 | + $optionAttrs['selected'] = "selected"; |
| 195 | + } |
197 | 196 | if ( array_key_exists( 'value_labels', $other_args ) && is_array( $other_args['value_labels'] ) && array_key_exists( $possible_value, $other_args['value_labels'] ) ) |
198 | | - $text .= htmlspecialchars( $other_args['value_labels'][$possible_value] ); |
| 197 | + $label = $other_args['value_labels'][$possible_value]; |
199 | 198 | else |
200 | | - $text .= $possible_value; |
201 | | - $text .= "</option>\n"; |
| 199 | + $label = $possible_value; |
| 200 | + $innerDropdown .= Xml::element( 'option', $optionAttrs, $label ); |
202 | 201 | } |
203 | | - $text .= <<<END |
204 | | - </select> |
205 | | - <span id="$info_id" class="errorMessage"></span> |
206 | | - |
207 | | -END; |
208 | | - return array( $text, null ); |
| 202 | + $selectAttrs = array( |
| 203 | + 'id' => $input_id, |
| 204 | + 'tabindex' => $sfgTabIndex, |
| 205 | + 'name' => $input_name, |
| 206 | + 'class' => $className |
| 207 | + ); |
| 208 | + if ( $is_disabled ) { |
| 209 | + $selectAttrs['disabled'] = 'disabled'; |
| 210 | + } |
| 211 | + $text = Xml::tags( 'select', $selectAttrs, $innerDropdown ); |
| 212 | + $spanClass = "inputSpan"; |
| 213 | + if ( $is_mandatory ) { $spanClass .= " mandatoryFieldSpan"; } |
| 214 | + $text = Xml::tags( 'span', array( 'class' => $spanClass ), $text ); |
| 215 | + return $text; |
209 | 216 | } |
210 | 217 | } |
211 | 218 | |
212 | 219 | class SFListBoxInput extends SFMultiEnumInput { |
213 | 220 | static function getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
214 | | - global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelectCalls; |
| 221 | + global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect; |
215 | 222 | |
216 | 223 | $className = ( $is_mandatory ) ? "mandatoryField" : "createboxInput"; |
217 | 224 | if ( array_key_exists( 'class', $other_args ) ) |
218 | 225 | $className .= " " . $other_args['class']; |
219 | 226 | $input_id = "input_$sfgFieldNum"; |
220 | | - $info_id = "info_$sfgFieldNum"; |
221 | | - $hidden_input_name = $input_name . "[is_list]"; |
222 | | - $input_name .= "[]"; // needed so that this input will send an array |
223 | | - if ( array_key_exists( 'size', $other_args ) ) |
224 | | - $size_text = "size=" . $other_args['size']; |
225 | | - else |
226 | | - $size_text = ""; |
227 | | - $disabled_text = ( $is_disabled ) ? "disabled" : ""; |
228 | 227 | // get list delimiter - default is comma |
229 | 228 | if ( array_key_exists( 'delimiter', $other_args ) ) { |
230 | 229 | $delimiter = $other_args['delimiter']; |
— | — | @@ -231,68 +230,67 @@ |
232 | 231 | $delimiter = ","; |
233 | 232 | } |
234 | 233 | $cur_values = SFUtils::getValuesArray( $cur_value, $delimiter ); |
| 234 | + $className .= " sfShowIfSelected"; |
235 | 235 | |
236 | | - $text = <<<END |
237 | | - <select id="$input_id" tabindex="$sfgTabIndex" name="$input_name" class="$className" multiple $size_text $disabled_text> |
238 | | - |
239 | | -END; |
240 | 236 | if ( ( $possible_values = $other_args['possible_values'] ) == null ) |
241 | 237 | $possible_values = array(); |
242 | | - $enum_input_ids = array(); |
| 238 | + $optionsText = ""; |
243 | 239 | foreach ( $possible_values as $possible_value ) { |
244 | | - // create array $enum_input_ids to associate values with their input IDs, |
245 | | - // for use in creating the 'show on select' Javascript later |
246 | | - $enum_input_ids[$possible_value] = $input_id; |
247 | | - $text .= " <option value=\"$possible_value\""; |
248 | | - if ( in_array( $possible_value, $cur_values ) ) { $text .= " selected"; } |
249 | | - $text .= ">"; |
250 | 240 | if ( array_key_exists( 'value_labels', $other_args ) && is_array( $other_args['value_labels'] ) && array_key_exists( $possible_value, $other_args['value_labels'] ) ) |
251 | | - $text .= htmlspecialchars( $other_args['value_labels'][$possible_value] ); |
| 241 | + $optionLabel = $other_args['value_labels'][$possible_value]; |
252 | 242 | else |
253 | | - $text .= $possible_value; |
254 | | - $text .= "</option>\n"; |
| 243 | + $optionLabel = $possible_value; |
| 244 | + $optionAttrs = array( 'value' => $possible_value ); |
| 245 | + if ( in_array( $possible_value, $cur_values ) ) { |
| 246 | + $optionAttrs['selected'] = 'selected'; |
| 247 | + } |
| 248 | + $optionsText .= Xml::element( 'option', $optionAttrs, $optionLabel ); |
255 | 249 | } |
256 | | - $text .= <<<END |
257 | | - </select> |
258 | | - <span id="$info_id" class="errorMessage"></span> |
259 | | - <input type="hidden" name="$hidden_input_name" value="1" /> |
| 250 | + $selectAttrs = array( |
| 251 | + 'id' => $input_id, |
| 252 | + 'tabindex' => $sfgTabIndex, |
| 253 | + 'name' => $input_name . '[]', |
| 254 | + 'class' => $className, |
| 255 | + 'multiple' => 'multiple' |
| 256 | + ); |
| 257 | + if ( array_key_exists( 'size', $other_args ) ) { |
| 258 | + $selectAttrs['size'] = $other_args['size']; |
| 259 | + } |
| 260 | + if ( $is_disabled ) { |
| 261 | + $selectAttrs['disabled'] = 'disabled'; |
| 262 | + } |
| 263 | + $text = Xml::tags( 'select', $selectAttrs, $optionsText ); |
| 264 | + $hiddenInputAttrs = array( |
| 265 | + 'value' => 1, |
| 266 | + ); |
| 267 | + $text .= "\t" . Xml::hidden( $input_name . '[is_list]', $hiddenInputAttrs ) . "\n"; |
| 268 | + if ( $is_mandatory ) { |
| 269 | + $text = Xml::tags( 'span', array( 'class' => 'inputSpan mandatoryFieldSpan' ), $text ); |
| 270 | + } |
260 | 271 | |
261 | | -END; |
262 | | - |
263 | 272 | if ( array_key_exists( 'show on select', $other_args ) ) { |
264 | 273 | foreach ( $other_args['show on select'] as $div_id => $options ) { |
265 | | - $cur_input_ids = array(); |
266 | | - foreach ( $options as $option ) { |
267 | | - if ( array_key_exists( $option, $enum_input_ids ) ) { |
268 | | - $cur_input_ids[] = $enum_input_ids[$option]; |
269 | | - } |
| 274 | + if ( array_key_exists( $input_id, $sfgShowOnSelect ) ) { |
| 275 | + $sfgShowOnSelect[$input_id][] = array( $options, $div_id ); |
| 276 | + } else { |
| 277 | + $sfgShowOnSelect[$input_id] = array( array( $options, $div_id ) ); |
270 | 278 | } |
271 | | - $options_str = "['" . implode( "', '", $options ) . "']"; |
272 | | - $js_text = "showIfSelectedInListBox('$input_id', $options_str, '$div_id'); "; |
273 | | - $sfgShowOnSelectCalls[] = $js_text; |
274 | | - foreach ( $possible_values as $key => $possible_value ) { |
275 | | - $cur_input_id = $enum_input_ids[$possible_value]; |
276 | | - if ( in_array( $possible_value, $options ) ) { |
277 | | - $sfgShowOnSelectCalls[] = "jQuery('#$cur_input_id').click( function() { $js_text } );"; |
278 | | - } |
279 | | - } |
280 | 279 | } |
281 | 280 | } |
282 | 281 | |
283 | | - return array( $text, null ); |
| 282 | + return $text; |
284 | 283 | } |
285 | 284 | } |
286 | 285 | |
287 | 286 | class SFCheckboxesInput extends SFMultiEnumInput { |
288 | 287 | static function getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
289 | | - global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelectCalls; |
| 288 | + global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect; |
290 | 289 | |
291 | 290 | $checkbox_class = ( $is_mandatory ) ? "mandatoryField" : "createboxInput"; |
292 | 291 | $span_class = "checkboxSpan"; |
293 | 292 | if ( array_key_exists( 'class', $other_args ) ) |
294 | 293 | $span_class .= " " . $other_args['class']; |
295 | 294 | $input_id = "input_$sfgFieldNum"; |
296 | | - $hidden_input_name = $input_name . "[is_list]"; |
297 | 295 | // get list delimiter - default is comma |
298 | 296 | if ( array_key_exists( 'delimiter', $other_args ) ) { |
299 | 297 | $delimiter = $other_args['delimiter']; |
— | — | @@ -304,15 +302,11 @@ |
305 | 303 | if ( ( $possible_values = $other_args['possible_values'] ) == null ) |
306 | 304 | $possible_values = array(); |
307 | 305 | $text = ""; |
308 | | - $enum_input_ids = array(); |
309 | 306 | foreach ( $possible_values as $key => $possible_value ) { |
310 | | - // create array $enum_input_ids to associate values with their input IDs, |
311 | | - // for use in creating the 'show on select' Javascript later |
312 | | - $enum_input_ids[$possible_value] = $input_id; |
313 | 307 | $cur_input_name = $input_name . "[" . $key . "]"; |
314 | 308 | |
315 | 309 | if ( array_key_exists( 'value_labels', $other_args ) && is_array( $other_args['value_labels'] ) && array_key_exists( $possible_value, $other_args['value_labels'] ) ) |
316 | | - $label = htmlspecialchars( $other_args['value_labels'][$possible_value] ); |
| 310 | + $label = $other_args['value_labels'][$possible_value]; |
317 | 311 | else |
318 | 312 | $label = $possible_value; |
319 | 313 | |
— | — | @@ -331,51 +325,38 @@ |
332 | 326 | $checkbox_attrs['disabled'] = 'disabled'; |
333 | 327 | } |
334 | 328 | $checkbox_input = Xml::element( 'input', $checkbox_attrs ); |
| 329 | + |
| 330 | + // Make a span around each checkbox, for CSS purposes. |
335 | 331 | $text .= ' ' . Xml::tags( 'span', |
336 | 332 | array( 'class' => $span_class ), |
337 | 333 | $checkbox_input . ' ' . $label |
338 | 334 | ) . "\n"; |
339 | 335 | $sfgTabIndex++; |
340 | 336 | $sfgFieldNum++; |
341 | | - $input_id = "input_$sfgFieldNum"; |
342 | 337 | } |
343 | | - // if it's mandatory, add a span around all the checkboxes, since |
344 | | - // some browsers don't support formatting of checkboxes |
| 338 | + |
| 339 | + $outerSpanID = "span_$sfgFieldNum"; |
| 340 | + $outerSpanClass = "checkboxesSpan"; |
345 | 341 | if ( $is_mandatory ) { |
346 | | - $text = ' ' . Xml::tags( 'span', |
347 | | - array( |
348 | | - 'id' => $input_id, |
349 | | - 'class' => 'mandatoryFieldsSpan', |
350 | | - ), $text ) . "\n"; |
| 342 | + $outerSpanClass .= " mandatoryFieldSpan"; |
351 | 343 | } |
352 | | - $info_id = "info_$sfgFieldNum"; |
353 | | - $text .= <<<END |
354 | | - <span id="$info_id" class="errorMessage"></span> |
355 | | - <input type="hidden" name="$hidden_input_name" value="1" /> |
356 | 344 | |
357 | | -END; |
358 | | - |
359 | 345 | if ( array_key_exists( 'show on select', $other_args ) ) { |
| 346 | + $outerSpanClass .= " sfShowIfChecked"; |
360 | 347 | foreach ( $other_args['show on select'] as $div_id => $options ) { |
361 | | - $cur_input_ids = array(); |
362 | | - foreach ( $options as $option ) { |
363 | | - if ( array_key_exists( $option, $enum_input_ids ) ) { |
364 | | - $cur_input_ids[] = $enum_input_ids[$option]; |
365 | | - } |
| 348 | + if ( array_key_exists( $outerSpanID, $sfgShowOnSelect ) ) { |
| 349 | + $sfgShowOnSelect[$outerSpanID][] = array( $options, $div_id ); |
| 350 | + } else { |
| 351 | + $sfgShowOnSelect[$outerSpanID] = array( array( $options, $div_id ) ); |
366 | 352 | } |
367 | | - $options_str = "['" . implode( "', '", $cur_input_ids ) . "']"; |
368 | | - $js_text = "showIfChecked($options_str, '$div_id'); "; |
369 | | - $sfgShowOnSelectCalls[] = $js_text; |
370 | | - foreach ( $possible_values as $key => $possible_value ) { |
371 | | - $cur_input_id = $enum_input_ids[$possible_value]; |
372 | | - if ( in_array( $possible_value, $options ) ) { |
373 | | - $sfgShowOnSelectCalls[] = "jQuery('#$cur_input_id').click( function() { $js_text } );"; |
374 | | - } |
375 | | - } |
376 | 353 | } |
377 | 354 | } |
378 | 355 | |
379 | | - return array( $text, null ); |
| 356 | + $text .= "\t" . Xml::hidden( $input_name . '[is_list]', array( 'value' => 1 ) ) . "\n"; |
| 357 | + $outerSpanAttrs = array( 'id' => $outerSpanID, 'class' => $outerSpanClass ); |
| 358 | + $text = "\t" . Xml::tags( 'span', $outerSpanAttrs, $text ) . "\n"; |
| 359 | + |
| 360 | + return $text; |
380 | 361 | } |
381 | 362 | } |
382 | 363 | |
— | — | @@ -392,14 +373,18 @@ |
393 | 374 | |
394 | 375 | global $sfgTabIndex, $sfgFieldNum, $wgOut, $sfgScriptPath, $wgJsMimeType; |
395 | 376 | global $smwgScriptPath, $smwgJqUIAutoIncluded; |
396 | | - global $sfgAutocompleteMappings, $sfgComboBoxInputs, $sfgAutogrowInputs; |
| 377 | + global $sfgAutocompleteMappings; |
397 | 378 | |
398 | 379 | $autocomplete_field_type = ""; |
399 | 380 | $autocompletion_source = ""; |
400 | 381 | |
401 | | - $className = ( $is_mandatory ) ? "autocompleteInput mandatoryField" : "autocompleteInput createboxInput"; |
402 | | - if ( array_key_exists( 'class', $other_args ) ) |
| 382 | + $className = "sfComboBox"; |
| 383 | + if ( $is_mandatory ) { |
| 384 | + $className .= " mandatoryField"; |
| 385 | + } |
| 386 | + if ( array_key_exists( 'class', $other_args ) ) { |
403 | 387 | $className .= " " . $other_args['class']; |
| 388 | + } |
404 | 389 | $disabled_text = ( $is_disabled ) ? "disabled" : ""; |
405 | 390 | if ( array_key_exists( 'autocomplete field type', $other_args ) ) { |
406 | 391 | $autocomplete_field_type = $other_args['autocomplete field type']; |
— | — | @@ -415,9 +400,7 @@ |
416 | 401 | $size = "35"; |
417 | 402 | |
418 | 403 | $input_id = "input_" . $sfgFieldNum; |
419 | | - $info_id = "info_" . $sfgFieldNum; |
420 | | - $div_name = "div_" . $sfgFieldNum; |
421 | | - |
| 404 | + |
422 | 405 | $options_str_key = str_replace( "'", "\'", $autocompletion_source ); |
423 | 406 | $sfgAutocompleteMappings[$sfgFieldNum] = $options_str_key; |
424 | 407 | |
— | — | @@ -425,9 +408,11 @@ |
426 | 409 | |
427 | 410 | /*adding code for displaying dropdown of autocomplete values*/ |
428 | 411 | |
| 412 | + $divClass = "ui-widget"; |
| 413 | + if ($is_mandatory) { $divClass .= " mandatory"; } |
429 | 414 | $text =<<<END |
430 | | -<div class="ui-widget"> |
431 | | - <select id="input_$sfgFieldNum" name="$input_name" tabindex="$sfgTabIndex"> |
| 415 | +<div class="$divClass"> |
| 416 | + <select id="input_$sfgFieldNum" name="$input_name" class="$className" tabindex="$sfgTabIndex"> |
432 | 417 | <option value="$cur_value"></option> |
433 | 418 | |
434 | 419 | END; |
— | — | @@ -436,10 +421,8 @@ |
437 | 422 | } |
438 | 423 | $text .= <<<END |
439 | 424 | </select> |
440 | | - <span id="$info_id" class="errorMessage"></span> |
441 | 425 | </div> |
442 | 426 | END; |
443 | | - $sfgComboBoxInputs[] = $sfgFieldNum; |
444 | 427 | // there's no direct correspondence between the 'size=' attribute for |
445 | 428 | // text inputs and the number of pixels, but multiplying by 6 seems to |
446 | 429 | // be about right for the major browsers |
— | — | @@ -450,7 +433,7 @@ |
451 | 434 | </style> |
452 | 435 | END; |
453 | 436 | $wgOut->addScript($combobox_css); |
454 | | - return array( $text, null ); |
| 437 | + return $text; |
455 | 438 | } |
456 | 439 | } |
457 | 440 | |
— | — | @@ -467,7 +450,7 @@ |
468 | 451 | return SFDropdownInput::getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
469 | 452 | |
470 | 453 | global $sfgTabIndex, $sfgFieldNum, $sfgScriptPath, $wgJsMimeType, $smwgScriptPath, $smwgJqUIAutoIncluded; |
471 | | - global $sfgAutogrowInputs, $sfgAutocompleteMappings, $sfgAutocompleteDataTypes, $sfgAutocompleteValues; |
| 454 | + global $sfgAutocompleteMappings, $sfgAutocompleteDataTypes, $sfgAutocompleteValues; |
472 | 455 | |
473 | 456 | $className = ( $is_mandatory ) ? "autocompleteInput mandatoryField" : "autocompleteInput createboxInput"; |
474 | 457 | if ( array_key_exists( 'class', $other_args ) ) |
— | — | @@ -481,15 +464,12 @@ |
482 | 465 | } |
483 | 466 | } |
484 | 467 | $input_id = "input_" . $sfgFieldNum; |
485 | | - $info_id = "info_" . $sfgFieldNum; |
486 | | - $div_name = "div_" . $sfgFieldNum; |
487 | 468 | if ( array_key_exists( 'input_type', $other_args ) && $other_args['input_type'] == "textarea" ) { |
488 | 469 | |
489 | 470 | $rows = $other_args['rows']; |
490 | 471 | $cols = $other_args['cols']; |
491 | 472 | $text = ""; |
492 | 473 | if ( array_key_exists( 'autogrow', $other_args ) ) { |
493 | | - $sfgAutogrowInputs[] = $input_id; |
494 | 474 | $className .= ' autoGrow'; |
495 | 475 | if ( ! method_exists( 'OutputPage', 'addModules' ) ) { |
496 | 476 | global $wgOut; |
— | — | @@ -528,15 +508,22 @@ |
529 | 509 | else |
530 | 510 | $size = "35"; |
531 | 511 | |
532 | | - $text = <<<END |
533 | | - <input tabindex="$sfgTabIndex" id="$input_id" name="$input_name" type="text" value="" size="$size" class="$className" |
534 | | - |
535 | | -END; |
536 | | - if ( $is_disabled ) |
537 | | - $text .= " disabled"; |
538 | | - if ( array_key_exists( 'maxlength', $other_args ) ) |
539 | | - $text .= ' maxlength="' . $other_args['maxlength'] . '"'; |
540 | | - $text .= "/>\n"; |
| 512 | + $inputAttrs = array( |
| 513 | + 'type' => 'text', |
| 514 | + 'id' => $input_id, |
| 515 | + 'name' => $input_name, |
| 516 | + 'value' => $cur_value, |
| 517 | + 'size' => $size, |
| 518 | + 'class' => $className, |
| 519 | + 'tabindex' => $sfgTabIndex, |
| 520 | + ); |
| 521 | + if ( $is_disabled ) { |
| 522 | + $inputAttrs['disabled'] = 'disabled'; |
| 523 | + } |
| 524 | + if ( array_key_exists( 'maxlength', $other_args ) ) { |
| 525 | + $text .= ' maxlength="' . $other_args['maxlength'] . '"'; |
| 526 | + } |
| 527 | + $text = "\t" . Xml::element( 'input', $inputAttrs ) . "\n"; |
541 | 528 | } |
542 | 529 | // is_list and delimiter variables - needed later |
543 | 530 | $is_list = ( array_key_exists( 'is_list', $other_args ) && $other_args['is_list'] == true ); |
— | — | @@ -557,11 +544,10 @@ |
558 | 545 | } |
559 | 546 | $text .= self::uploadLinkHTML( $input_id, $delimiter, $default_filename ); |
560 | 547 | } |
561 | | - $text .= <<<END |
562 | | - <span id="$info_id" class="errorMessage"></span> |
563 | | - <div class="page_name_auto_complete" id="$div_name"></div> |
564 | 548 | |
565 | | -END; |
| 549 | + $spanClass = "inputSpan"; |
| 550 | + if ( $is_mandatory ) { $spanClass .= " mandatoryFieldSpan"; } |
| 551 | + $text = Xml::tags( 'span', array( 'class' => $spanClass ), $text ); |
566 | 552 | |
567 | 553 | $options_str_key = $autocompletion_source; |
568 | 554 | if ( $is_list ) { |
— | — | @@ -578,19 +564,7 @@ |
579 | 565 | $autocomplete_values = SFUtils::getAutocompleteValues( $autocompletion_source, $autocomplete_field_type ); |
580 | 566 | $sfgAutocompleteValues[$options_str_key] = $autocomplete_values; |
581 | 567 | } |
582 | | - if ( $cur_value ) { |
583 | | - // replace various values to not break the Javascript |
584 | | - $cur_value = str_replace( '"', '\"', $cur_value ); |
585 | | - $cur_value = str_replace( "\n", '\n', $cur_value ); |
586 | | - $cur_value = str_replace( "\r", '\r', $cur_value ); |
587 | | - $text .= <<<END |
588 | | - <script type="text/javascript">/* <![CDATA[ */ |
589 | | - document.getElementById('$input_id').value = "$cur_value" |
590 | | - /* ]]> */</script> |
591 | | - |
592 | | -END; |
593 | | - } |
594 | | - return array( $text, null ); |
| 568 | + return $text; |
595 | 569 | } |
596 | 570 | |
597 | 571 | public static function getParameters() { |
— | — | @@ -617,21 +591,18 @@ |
618 | 592 | return SFTextWithAutocompleteInput::getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); |
619 | 593 | } |
620 | 594 | |
621 | | - global $sfgTabIndex, $sfgFieldNum, $smwgScriptPath, $sfgScriptPath, $sfgAutogrowInputs; |
| 595 | + global $sfgTabIndex, $sfgFieldNum, $smwgScriptPath, $sfgScriptPath; |
622 | 596 | |
623 | 597 | $className = ( $is_mandatory ) ? "mandatoryField" : "createboxInput"; |
624 | 598 | if ( array_key_exists( 'class', $other_args ) ) |
625 | 599 | $className .= " " . $other_args['class']; |
626 | | - $info_id = "info_$sfgFieldNum"; |
627 | 600 | // use a special ID for the free text field, for FCK's needs |
628 | 601 | $input_id = $input_name == "free_text" ? "free_text" : "input_$sfgFieldNum"; |
629 | 602 | |
630 | 603 | $rows = $other_args['rows']; |
631 | 604 | $cols = $other_args['cols']; |
632 | 605 | |
633 | | - $text = ""; |
634 | 606 | if ( array_key_exists( 'autogrow', $other_args ) ) { |
635 | | - $sfgAutogrowInputs[] = $input_id; |
636 | 607 | $className .= ' autoGrow'; |
637 | 608 | if ( ! method_exists( 'OutputPage', 'addModules' ) ) { |
638 | 609 | global $wgOut; |
— | — | @@ -662,13 +633,11 @@ |
663 | 634 | $textarea_attrs['onKeyDown'] = $maxLengthJSCheck; |
664 | 635 | $textarea_attrs['onKeyUp'] = $maxLengthJSCheck; |
665 | 636 | } |
666 | | - $textarea_input = Xml::element( 'textarea', $textarea_attrs, $cur_value, false ); |
667 | | - $text .= <<<END |
668 | | - $textarea_input |
669 | | - <span id="$info_id" class="errorMessage"></span> |
670 | | - |
671 | | -END; |
672 | | - return array( $text, null ); |
| 637 | + $text = Xml::element( 'textarea', $textarea_attrs, $cur_value, false ); |
| 638 | + $spanClass = "inputSpan"; |
| 639 | + if ( $is_mandatory ) { $spanClass .= " mandatoryFieldSpan"; } |
| 640 | + $text = Xml::tags( 'span', array( 'class' => $spanClass ), $text ); |
| 641 | + return $text; |
673 | 642 | } |
674 | 643 | |
675 | 644 | public static function getParameters() { |
— | — | @@ -682,33 +651,35 @@ |
683 | 652 | |
684 | 653 | class SFDateInput extends SFFormInput { |
685 | 654 | static function monthDropdownHTML( $cur_month, $input_name, $is_disabled ) { |
686 | | - global $sfgTabIndex, $sfgFieldNum, $wgAmericanDates; |
| 655 | + global $sfgTabIndex, $wgAmericanDates; |
687 | 656 | |
688 | | - $disabled_text = ( $is_disabled ) ? "disabled" : ""; |
689 | | - $text = ' <select tabindex="' . $sfgTabIndex . '" id="input_' . $sfgFieldNum . '_month" name="' . $input_name . "[month]\" $disabled_text>\n"; |
| 657 | + $optionsText = ""; |
690 | 658 | $month_names = SFFormUtils::getMonthNames(); |
691 | 659 | foreach ( $month_names as $i => $name ) { |
692 | 660 | // pad out month to always be two digits |
693 | 661 | $month_value = ( $wgAmericanDates == true ) ? $name : str_pad( $i + 1, 2, "0", STR_PAD_LEFT ); |
694 | | - $text .= " <option value=\"$month_value\""; |
695 | | - if ( $name == $cur_month || ( $i + 1 ) == $cur_month ) { $text .= " selected=\"selected\""; } |
696 | | - $text .= ">$name</option>\n"; |
| 662 | + $optionAttrs = array ( 'value' => $month_value ); |
| 663 | + if ( $name == $cur_month || ( $i + 1 ) == $cur_month ) { |
| 664 | + $optionAttrs['selected'] = 'selected'; |
| 665 | + } |
| 666 | + $optionsText .= Xml::element( 'option', $optionAttrs, $name ); |
697 | 667 | } |
698 | | - $text .= " </select>\n"; |
| 668 | + $selectAttrs = array( |
| 669 | + 'class' => 'monthInput', |
| 670 | + 'name' => $input_name . '[month]', |
| 671 | + 'tabindex' => $sfgTabIndex |
| 672 | + ); |
| 673 | + if ( $is_disabled ) { |
| 674 | + $selectAttrs['disabled'] = 'disabled'; |
| 675 | + } |
| 676 | + $text = Xml::tags( 'select', $selectAttrs, $optionsText ); |
699 | 677 | return $text; |
700 | 678 | } |
701 | 679 | |
702 | | - static function getText( $date, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
703 | | - global $sfgTabIndex, $sfgFieldNum, $sfgJSValidationCalls, $wgAmericanDates; |
| 680 | + static function getMainHTML( $date, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 681 | + global $sfgTabIndex, $sfgFieldNum, $wgAmericanDates; |
704 | 682 | |
705 | 683 | $input_id = "input_$sfgFieldNum"; |
706 | | - $info_id = "info_$sfgFieldNum"; |
707 | | - // add to validation calls |
708 | | - if ( array_key_exists( 'part_of_multiple', $other_args ) ) { |
709 | | - $sfgJSValidationCalls[] = "validate_type_of_multiple_fields($sfgFieldNum, 'date')"; |
710 | | - } else { |
711 | | - $sfgJSValidationCalls[] = "validate_field_type('$input_id', 'date', '$info_id')"; |
712 | | - } |
713 | 684 | |
714 | 685 | if ( $date ) { |
715 | 686 | // can show up here either as an array or a string, depending on |
— | — | @@ -737,17 +708,24 @@ |
738 | 709 | } |
739 | 710 | $text = ""; |
740 | 711 | $disabled_text = ( $is_disabled ) ? "disabled" : ""; |
| 712 | + $monthInput = self::monthDropdownHTML( $month, $input_name, $is_disabled ); |
| 713 | + $dayInput = ' <input tabindex="' . $sfgTabIndex . '" class="dayInput" name="' . $input_name . '[day]" type="text" value="' . $day . '" size="2" ' . $disabled_text . '/>'; |
741 | 714 | if ( $wgAmericanDates ) { |
742 | | - $text .= self::monthDropdownHTML( $month, $input_name, $is_disabled ); |
743 | | - $text .= ' <input tabindex="' . $sfgTabIndex . '" id="' . $input_id . '_day" name="' . $input_name . '[day]" type="text" value="' . $day . '" size="2" ' . $disabled_text . '/>' . "\n"; |
| 715 | + $text .= "$monthInput\n$dayInput\n"; |
744 | 716 | } else { |
745 | | - $text .= ' <input tabindex="' . $sfgTabIndex . '" id="' . $input_id . '_day" name="' . $input_name . '[day]" type="text" value="' . $day . '" size="2" ' . $disabled_text . '/>' . "\n"; |
746 | | - $text .= self::monthDropdownHTML( $month, $input_name, $is_disabled ); |
| 717 | + $text .= "$dayInput\n$monthInput\n"; |
747 | 718 | } |
748 | | - $text .= ' <input tabindex="' . $sfgTabIndex . '" id="' . $input_id . '_year" name="' . $input_name . '[year]" type="text" value="' . $year . '" size="4" ' . $disabled_text . '/>' . "\n"; |
749 | | - $text .= " <span id=\"$info_id\" class=\"errorMessage\"></span>"; |
750 | | - return array( $text, null ); |
| 719 | + $text .= ' <input tabindex="' . $sfgTabIndex . '" class="yearInput" name="' . $input_name . '[year]" type="text" value="' . $year . '" size="4" ' . $disabled_text . '/>' . "\n"; |
| 720 | + return $text; |
751 | 721 | } |
| 722 | + |
| 723 | + static function getText( $date, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 724 | + $text = self::getMainHTML( $date, $input_name, $is_mandatory, $is_disabled, $other_args ); |
| 725 | + $spanClass = "dateInput"; |
| 726 | + if ( $is_mandatory ) { $spanClass .= " mandatoryFieldSpan"; } |
| 727 | + $text = Xml::tags( 'span', array( 'class' => $spanClass ), $text ); |
| 728 | + return $text; |
| 729 | + } |
752 | 730 | } |
753 | 731 | |
754 | 732 | class SFDateTimeInput extends SFDateInput { |
— | — | @@ -792,7 +770,7 @@ |
793 | 771 | $timezone = ""; |
794 | 772 | } |
795 | 773 | |
796 | | - list( $text, $javascript_text ) = parent::getText( $datetime, $input_name, $is_mandatory, $is_disabled, $other_args ); |
| 774 | + $text = parent::getMainHTML( $datetime, $input_name, $is_mandatory, $is_disabled, $other_args ); |
797 | 775 | $disabled_text = ( $is_disabled ) ? "disabled" : ""; |
798 | 776 | $text .= '  <input tabindex="' . $sfgTabIndex . '" name="' . $input_name . '[hour]" type="text" value="' . $hour . '" size="2"/ ' . $disabled_text . '>'; |
799 | 777 | $sfgTabIndex++; |
— | — | @@ -817,38 +795,22 @@ |
818 | 796 | $text .= ' <input tabindex="' . $sfgTabIndex . '" name="' . $input_name . '[timezone]" type="text" value="' . $timezone . '" size="2"/ ' . $disabled_text . '>' . "\n"; |
819 | 797 | } |
820 | 798 | |
821 | | - return array( $text, null ); |
| 799 | + return $text; |
822 | 800 | } |
823 | 801 | } |
824 | 802 | |
825 | 803 | class SFRadioButtonInput extends SFEnumInput { |
826 | 804 | static function getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
827 | | - global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelectCalls; |
| 805 | + global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect; |
828 | 806 | |
829 | | - $span_class = "checkboxSpan"; |
830 | | - if ( array_key_exists( 'class', $other_args ) ) |
831 | | - $span_class .= " " . $other_args['class']; |
832 | | - |
833 | | - $check_set = false; |
834 | | - $text = ""; |
835 | | - // if it's mandatory, add a span around all the radiobuttons, since |
836 | | - // some browsers don't support formatting of radiobuttons |
837 | | - if ( $is_mandatory ) |
838 | | - $text .= ' <span class="mandatoryFieldsSpan">' . "\n"; |
839 | | - |
840 | 807 | if ( ( $possible_values = $other_args['possible_values'] ) == null ) |
841 | 808 | $possible_values = array(); |
842 | 809 | |
843 | | - // Add a "None" value, unless this is a mandatory field and there's a |
844 | | - // current value in place (either through a default value or because |
845 | | - // we're editing an existing page). |
846 | | - // We place it at the end of the array, instead of the beginning (even |
847 | | - // though it gets displayed at the beginning) so that the "None" value's |
848 | | - // ID will match that of the "error message" span, which is created at |
849 | | - // the end of the process - the validation Javascript requires that the |
850 | | - // two be matching |
| 810 | + // Add a "None" value at the beginning, unless this is a mandatory |
| 811 | + // field and there's a current value in place (either through a |
| 812 | + // default value or because we're editing an existing page). |
851 | 813 | if ( ! $is_mandatory || $cur_value == '' ) { |
852 | | - $possible_values[] = ''; |
| 814 | + array_unshift( $possible_values, '' ); |
853 | 815 | } |
854 | 816 | |
855 | 817 | // Set $cur_value to be one of the allowed options, if it isn't already - |
— | — | @@ -861,18 +823,12 @@ |
862 | 824 | $cur_value = $possible_values[0]; |
863 | 825 | } |
864 | 826 | |
865 | | - $enum_input_ids = array(); |
866 | | - $radiobuttons_text = ''; |
867 | | - $none_radiobutton_text = ''; |
| 827 | + $text = ''; |
868 | 828 | foreach ( $possible_values as $i => $possible_value ) { |
869 | 829 | $sfgTabIndex++; |
870 | 830 | $sfgFieldNum++; |
871 | 831 | $input_id = "input_$sfgFieldNum"; |
872 | 832 | |
873 | | - // create array $enum_input_ids to associate values with their input IDs, |
874 | | - // for use in creating the 'show on select' Javascript later |
875 | | - $enum_input_ids[$possible_value] = $input_id; |
876 | | - |
877 | 833 | $radiobutton_attrs = array( |
878 | 834 | 'type' => 'radio', |
879 | 835 | 'id' => $input_id, |
— | — | @@ -893,77 +849,53 @@ |
894 | 850 | else |
895 | 851 | $label = $possible_value; |
896 | 852 | |
897 | | - $radiobutton_text = ' ' . |
898 | | - Xml::element ( 'input', $radiobutton_attrs ) . " $label\n"; |
| 853 | + $text .= "\t" . Xml::element ( 'input', $radiobutton_attrs ) . " $label\n"; |
| 854 | + } |
899 | 855 | |
900 | | - // There's special handling for the "None" radiobutton, if it exists, |
901 | | - // because it's created last but displayed first - see above. |
902 | | - if ( $possible_value == '' ) { |
903 | | - $none_radiobutton_text = $radiobutton_text; |
904 | | - } else { |
905 | | - $radiobuttons_text .= $radiobutton_text; |
906 | | - } |
| 856 | + $spanClass = "radioButtonSpan"; |
| 857 | + if ( array_key_exists( 'class', $other_args ) ) { |
| 858 | + $spanClass .= " " . $other_args['class']; |
907 | 859 | } |
908 | | - $text = $none_radiobutton_text . $radiobuttons_text; |
| 860 | + if ( $is_mandatory ) { |
| 861 | + $spanClass .= " mandatoryFieldSpan"; |
| 862 | + } |
909 | 863 | |
910 | | - // close span |
911 | | - if ( $is_mandatory ) |
912 | | - $text .= " </span>"; |
913 | | - $info_id = "info_$sfgFieldNum"; |
914 | | - $text .= <<<END |
915 | | - <span id="$info_id" class="errorMessage"></span> |
| 864 | + $spanID = "span_$sfgFieldNum"; |
916 | 865 | |
917 | | -END; |
918 | | - |
919 | | - // Finally, we do the 'show on select' handling. |
| 866 | + // Do the 'show on select' handling. |
920 | 867 | if ( array_key_exists( 'show on select', $other_args ) ) { |
| 868 | + $spanClass .= " sfShowIfChecked"; |
921 | 869 | foreach ( $other_args['show on select'] as $div_id => $options ) { |
922 | | - $cur_input_ids = array(); |
923 | | - foreach ( $options as $option ) { |
924 | | - if ( array_key_exists( $option, $enum_input_ids ) ) { |
925 | | - $cur_input_ids[] = $enum_input_ids[$option]; |
926 | | - } |
| 870 | + if ( array_key_exists( $spanID, $sfgShowOnSelect ) ) { |
| 871 | + $sfgShowOnSelect[$spanID][] = array( $options, $div_id ); |
| 872 | + } else { |
| 873 | + $sfgShowOnSelect[$spanID] = array( array( $options, $div_id ) ); |
927 | 874 | } |
928 | | - // If there were no matches to existing radiobutton options, escape |
929 | | - if ( count( $cur_input_ids ) == 0 ) { |
930 | | - continue; |
931 | | - } |
932 | | - $options_str = "['" . implode( "', '", $cur_input_ids ) . "']"; |
933 | | - $js_text = "showIfChecked($options_str, '$div_id');"; |
934 | | - $sfgShowOnSelectCalls[] = $js_text; |
935 | | - foreach ( $possible_values as $key => $possible_value ) { |
936 | | - // We need to add each click handler to each radiobutton, |
937 | | - // because there doesn't seem to be any way for a radiobutton |
938 | | - // to know that it was unchecked - rather, the newly-checked |
939 | | - // radiobutton has to handle the change. |
940 | | - foreach ( $enum_input_ids as $cur_input_id ) { |
941 | | - if ( in_array( $possible_value, $options ) ) { |
942 | | - $sfgShowOnSelectCalls[] = "jQuery('#$cur_input_id').click( function() { $js_text } );"; |
943 | | - } |
944 | | - } |
945 | | - } |
946 | 875 | } |
947 | 876 | } |
| 877 | + $spanAttrs = array( |
| 878 | + 'id' => $spanID, |
| 879 | + 'class' => $spanClass |
| 880 | + ); |
| 881 | + $text = Xml::tags( 'span', $spanAttrs, $text ); |
948 | 882 | |
949 | | - return array( $text, null ); |
| 883 | + return $text; |
950 | 884 | } |
951 | 885 | } |
952 | 886 | |
953 | 887 | class SFCheckboxInput extends SFFormInput { |
954 | 888 | static function getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
955 | | - global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelectCalls; |
| 889 | + global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect; |
956 | 890 | |
957 | 891 | $className = ( $is_mandatory ) ? "mandatoryField" : "createboxInput"; |
958 | 892 | if ( array_key_exists( 'class', $other_args ) ) |
959 | 893 | $className .= " " . $other_args['class']; |
960 | | - $info_id = "info_$sfgFieldNum"; |
961 | 894 | $input_id = "input_$sfgFieldNum"; |
962 | 895 | $disabled_text = ( $is_disabled ) ? "disabled" : ""; |
963 | 896 | if ( array_key_exists( 'show on select', $other_args ) ) { |
| 897 | + $className .= " sfShowIfCheckedCheckbox"; |
964 | 898 | $div_id = key( $other_args['show on select'] ); |
965 | | - $js_text = "showIfChecked(['$input_id'], '$div_id');"; |
966 | | - $sfgShowOnSelectCalls[] = $js_text; |
967 | | - $sfgShowOnSelectCalls[] = "jQuery('#$input_id').click( function() { $js_text } );"; |
| 899 | + $sfgShowOnSelect[$input_id] = $div_id; |
968 | 900 | } |
969 | 901 | |
970 | 902 | // can show up here either as an array or a string, depending on |
— | — | @@ -984,10 +916,9 @@ |
985 | 917 | $text = <<<END |
986 | 918 | <input name="{$input_name}[is_checkbox]" type="hidden" value="true" /> |
987 | 919 | <input id="$input_id" name="{$input_name}[value]" type="checkbox" class="$className" tabindex="$sfgTabIndex" $checked_str $disabled_text/> |
988 | | - <span id="$info_id" class="errorMessage"></span> |
989 | 920 | |
990 | 921 | END; |
991 | | - return array( $text, null ); |
| 922 | + return $text; |
992 | 923 | } |
993 | 924 | } |
994 | 925 | |
— | — | @@ -995,7 +926,7 @@ |
996 | 927 | static function getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
997 | 928 | // escape if CategoryTree extension isn't included |
998 | 929 | if ( ! function_exists( 'efCategoryTreeParserHook' ) ) |
999 | | - return array( null, null ); |
| 930 | + return null; |
1000 | 931 | |
1001 | 932 | global $sfgTabIndex, $sfgFieldNum; |
1002 | 933 | |
— | — | @@ -1006,7 +937,7 @@ |
1007 | 938 | $top_category = $other_args['top category']; |
1008 | 939 | } else { |
1009 | 940 | // escape - we can't do anything |
1010 | | - return array( null, null ); |
| 941 | + return null; |
1011 | 942 | } |
1012 | 943 | if ( array_key_exists( 'height', $other_args ) ) { |
1013 | 944 | $height = $other_args['height']; |
— | — | @@ -1018,8 +949,6 @@ |
1019 | 950 | } else { |
1020 | 951 | $width = "500"; |
1021 | 952 | } |
1022 | | - $input_id = "input_$sfgFieldNum"; |
1023 | | - $info_id = "info_$sfgFieldNum"; |
1024 | 953 | |
1025 | 954 | $text = '<div style="overflow: auto; padding: 5px; border: 1px #aaaaaa solid; max-height: ' . $height . 'px; width: ' . $width . 'px;">'; |
1026 | 955 | |
— | — | @@ -1027,9 +956,7 @@ |
1028 | 957 | // and there's a current value in place (either through a default value |
1029 | 958 | // or because we're editing an existing page) |
1030 | 959 | if ( ! $is_mandatory || $cur_value == '' ) { |
1031 | | - $input_id = "input_$sfgFieldNum"; |
1032 | | - $info_id = "info_$sfgFieldNum"; |
1033 | | - $text .= ' <input type="radio" id="' . $input_id . '" tabindex="' . $sfgTabIndex . '" name="' . $input_name . '" value=""'; |
| 960 | + $text .= ' <input type="radio" tabindex="' . $sfgTabIndex . '" name="' . $input_name . '" value=""'; |
1034 | 961 | if ( ! $cur_value ) { |
1035 | 962 | $text .= ' checked="checked"'; |
1036 | 963 | } |
— | — | @@ -1048,7 +975,7 @@ |
1049 | 976 | $cur_value = $wgContLang->ucfirst( $cur_value ); |
1050 | 977 | } |
1051 | 978 | |
1052 | | - $tree = preg_replace( '/(<a class="CategoryTreeLabel.*>)(.*)(<\/a>)/', '<input id="' . $input_id . '" tabindex="' . $sfgTabIndex . '" name="' . $input_name . '" value="$2" type="radio"> $1$2$3', $tree ); |
| 979 | + $tree = preg_replace( '/(<a class="CategoryTreeLabel.*>)(.*)(<\/a>)/', '<input tabindex="' . $sfgTabIndex . '" name="' . $input_name . '" value="$2" type="radio"> $1$2$3', $tree ); |
1053 | 980 | $tree = str_replace( "value=\"$cur_value\"", "value=\"$cur_value\" checked=\"checked\"", $tree ); |
1054 | 981 | // if it's disabled, set all to disabled |
1055 | 982 | if ( $is_disabled ) { |
— | — | @@ -1056,12 +983,11 @@ |
1057 | 984 | } |
1058 | 985 | $text .= $tree . '</div>'; |
1059 | 986 | |
1060 | | - $text .= <<<END |
1061 | | - <span id="$info_id" class="errorMessage"></span> |
| 987 | + $spanClass = "radioButtonSpan"; |
| 988 | + if ( $is_mandatory) { $spanClass .= " mandatoryFieldSpan"; } |
| 989 | + $text = Xml::tags( 'span', array( 'class' => $spanClass ), $text ); |
1062 | 990 | |
1063 | | -END; |
1064 | | - |
1065 | | - return array( $text, null ); |
| 991 | + return $text; |
1066 | 992 | } |
1067 | 993 | } |
1068 | 994 | |
— | — | @@ -1069,7 +995,7 @@ |
1070 | 996 | static function getText( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
1071 | 997 | // escape if CategoryTree extension isn't included |
1072 | 998 | if ( ! function_exists( 'efCategoryTreeParserHook' ) ) |
1073 | | - return array( null, null ); |
| 999 | + return null; |
1074 | 1000 | |
1075 | 1001 | global $sfgTabIndex, $sfgFieldNum, $wgCapitalLinks; |
1076 | 1002 | |
— | — | @@ -1078,7 +1004,6 @@ |
1079 | 1005 | $className .= " " . $other_args['class']; |
1080 | 1006 | $input_id = "input_$sfgFieldNum"; |
1081 | 1007 | $info_id = "info_$sfgFieldNum"; |
1082 | | - $hidden_input_name = $input_name . "[is_list]"; |
1083 | 1008 | // get list delimiter - default is comma |
1084 | 1009 | if ( array_key_exists( 'delimiter', $other_args ) ) { |
1085 | 1010 | $delimiter = $other_args['delimiter']; |
— | — | @@ -1090,7 +1015,7 @@ |
1091 | 1016 | $top_category = $other_args['top category']; |
1092 | 1017 | } else { |
1093 | 1018 | // escape - we can't do anything |
1094 | | - return array( null, null ); |
| 1019 | + return null; |
1095 | 1020 | } |
1096 | 1021 | if ( array_key_exists( 'height', $other_args ) ) { |
1097 | 1022 | $height = $other_args['height']; |
— | — | @@ -1132,11 +1057,11 @@ |
1133 | 1058 | } |
1134 | 1059 | $text = '<div style="overflow: auto; padding: 5px; border: 1px #aaaaaa solid; max-height: ' . $height . 'px; width: ' . $width . 'px;">' . $tree . '</div>'; |
1135 | 1060 | |
1136 | | - $text .= <<<END |
1137 | | - <input type="hidden" name="$hidden_input_name" value="1" /> |
| 1061 | + $text .= "\t" . Xml::hidden( $input_name . '[is_list]', array( 'value' => 1 ) ) . "\n"; |
| 1062 | + $spanClass = "checkboxesSpan"; |
| 1063 | + if ( $is_mandatory) { $spanClass .= " mandatoryFieldSpan"; } |
| 1064 | + $text = "\t" . Xml::tags( 'span', array( 'class' => $spanClass ), $text ) . "\n"; |
1138 | 1065 | |
1139 | | -END; |
1140 | | - |
1141 | | - return array( $text, null ); |
| 1066 | + return $text; |
1142 | 1067 | } |
1143 | 1068 | } |