Index: trunk/extensions/SemanticFormsInputs/SemanticFormsInputs.php |
— | — | @@ -4,9 +4,8 @@ |
5 | 5 | * |
6 | 6 | * @author Stephan Gambke |
7 | 7 | * @author Sanyam Goyal |
8 | | - * @version 0.2 |
9 | | - * @date 16-Aug-2010 |
10 | | - */ |
| 8 | + * @version 0.3.1 |
| 9 | + */ |
11 | 10 | |
12 | 11 | if ( !defined( 'MEDIAWIKI' ) ) { |
13 | 12 | die( 'This file is a MediaWiki extension, it is not a valid entry point.' ); |
Index: trunk/extensions/SemanticFormsInputs/SFI_Settings.php |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | * Settings for the Semantic Forms Inputs extension. |
5 | 5 | * |
6 | 6 | * @author Stephan Gambke |
7 | | - * @version 0.2 |
| 7 | + * @version 0.3 |
8 | 8 | * @date 06-Nov-2009 |
9 | 9 | * |
10 | 10 | * To change the default settings you can uncomment (or copy) the |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | */ |
14 | 14 | |
15 | 15 | ### |
16 | | -# This is the path to your installation of Semantic Forms as |
| 16 | +# This is the path to your installation of Semantic Forms Inputs as |
17 | 17 | # seen from the web. No final slash. |
18 | 18 | ## |
19 | 19 | $sfigSettings->scriptPath = $wgScriptPath . '/extensions/SemanticFormsInputs'; |
— | — | @@ -160,4 +160,4 @@ |
161 | 161 | # characters of the wiki short names and 1char are the initials of the |
162 | 162 | # wiki short names. |
163 | 163 | ## |
164 | | -$sfigSettings->datePickerMonthNames = "short"; |
| 164 | +$sfigSettings->datePickerDayNames = "short"; |
Index: trunk/extensions/SemanticFormsInputs/SFI_Inputs.php |
— | — | @@ -5,6 +5,7 @@ |
6 | 6 | * @author Stephan Gambke |
7 | 7 | * @author Sanyam Goyal |
8 | 8 | * @author Yaron Koren |
| 9 | + * @version 0.3.1 |
9 | 10 | * |
10 | 11 | */ |
11 | 12 | |
— | — | @@ -17,7 +18,7 @@ |
18 | 19 | * Setup for input type regexp. |
19 | 20 | * Adds the Javascript code used by all regexp filters. |
20 | 21 | */ |
21 | | -function regexpSetup() { |
| 22 | +static function regexpSetup() { |
22 | 23 | |
23 | 24 | global $wgOut; |
24 | 25 | |
— | — | @@ -29,8 +30,11 @@ |
30 | 31 | wfLoadExtensionMessages( 'SemanticFormsInputs' ); |
31 | 32 | |
32 | 33 | $jstext = <<<JAVASCRIPT |
33 | | - function validate_input_with_regexp(input_number, re, inverse, message, multiple){ |
| 34 | + function validate_input_with_regexp(input_number, retext, inverse, message, multiple){ |
34 | 35 | |
| 36 | + var decoded = jQuery("<div/>").html(retext).text(); |
| 37 | + var re = new RegExp(decoded); |
| 38 | + |
35 | 39 | if (multiple) { |
36 | 40 | res = true; |
37 | 41 | for (i = 1; i <= num_elements; i++) { |
— | — | @@ -69,7 +73,7 @@ |
70 | 74 | /* |
71 | 75 | * Definition of input type "regexp" |
72 | 76 | */ |
73 | | -function regexpHTML ( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 77 | +static function regexpHTML ( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
74 | 78 | |
75 | 79 | global $wgRequest, $wgUser, $wgParser; |
76 | 80 | global $sfgTabIndex; // used to represent the current tab index in the form |
— | — | @@ -112,21 +116,28 @@ |
113 | 117 | |
114 | 118 | // set regexp string |
115 | 119 | if ( array_key_exists( 'regexp', $other_args ) ) { |
| 120 | + |
116 | 121 | $regexp = str_replace( $orChar, '|', trim( $other_args['regexp'] ) ); |
117 | 122 | unset( $other_args['regexp'] ); |
| 123 | + |
| 124 | + // check for leading/trailing delimiter and remove it (else dump regexp) |
| 125 | + if ( preg_match ( "/^\/.*\/\$/", $regexp ) ) { |
| 126 | + |
| 127 | + $regexp = substr( $regexp, 1, strlen( $regexp ) - 2 ); |
| 128 | + |
| 129 | + } |
| 130 | + else $regexp = '.*'; |
| 131 | + |
118 | 132 | } |
119 | | - else $regexp = '/.*/'; |
| 133 | + else $regexp = '.*'; |
120 | 134 | |
121 | | - // set regexp string |
| 135 | + // set failure message string |
122 | 136 | if ( array_key_exists( 'message', $other_args ) ) { |
123 | 137 | $message = trim( $other_args['message'] ); |
124 | 138 | unset( $other_args['message'] ); |
125 | 139 | } |
126 | 140 | else $message = wfMsg( 'semanticformsinputs-wrongformat' ); |
127 | 141 | |
128 | | - $message = str_replace( '\\', '\\\\', $message ); |
129 | | - $message = str_replace( '\'', '\\\'', $message ); |
130 | | - |
131 | 142 | $new_other_args = array(); |
132 | 143 | |
133 | 144 | foreach ( $other_args as $key => $value ) |
— | — | @@ -144,10 +155,15 @@ |
145 | 156 | |
146 | 157 | $hook_values = $sfgFormPrinter->mInputTypeHooks[$baseType]; |
147 | 158 | |
| 159 | + // sanitize error message and regexp for JS |
| 160 | + $message = Xml::encodeJsVar( $message ); |
| 161 | + $regexp = Xml::encodeJsVar( $regexp ); |
| 162 | + |
| 163 | + // $sfgJSValidationCalls are sanitized for HTML by SF before output, no htmlspecialchars() here |
148 | 164 | if ( array_key_exists( 'part_of_multiple', $other_args ) && $other_args['part_of_multiple'] == 1 ) { |
149 | | - $sfgJSValidationCalls[] = "validate_input_with_regexp($sfgFieldNum, {$regexp}, {$inverseString}, '$message', true)"; |
| 165 | + $sfgJSValidationCalls[] = "validate_input_with_regexp($sfgFieldNum, {$regexp}, {$inverseString}, {$message}, true)"; |
150 | 166 | } else { |
151 | | - $sfgJSValidationCalls[] = "validate_input_with_regexp($sfgFieldNum, {$regexp}, {$inverseString}, '$message', false)"; |
| 167 | + $sfgJSValidationCalls[] = "validate_input_with_regexp($sfgFieldNum, {$regexp}, {$inverseString}, {$message}, false)"; |
152 | 168 | } |
153 | 169 | |
154 | 170 | list( $htmltext, $jstext ) = call_user_func_array( $hook_values[0], $funcArgs ); |
— | — | @@ -160,7 +176,7 @@ |
161 | 177 | * Setup for input type datepicker. |
162 | 178 | * Adds the Javascript code used by all date pickers. |
163 | 179 | */ |
164 | | -function datePickerSetup () { |
| 180 | +static function datePickerSetup () { |
165 | 181 | global $wgOut; |
166 | 182 | global $sfigSettings; |
167 | 183 | |
— | — | @@ -320,6 +336,7 @@ |
321 | 337 | if (sfiElements[id]) sfiElements[id].clear(); |
322 | 338 | document.getElementById(id).value=""; |
323 | 339 | } |
| 340 | + |
324 | 341 | JAVASCRIPT; |
325 | 342 | |
326 | 343 | $jstext .= $locString; |
— | — | @@ -331,9 +348,10 @@ |
332 | 349 | /* |
333 | 350 | * Definition of input type "simpledatepicker". |
334 | 351 | */ |
335 | | -function jqDatePickerHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 352 | +static function jqDatePickerHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
336 | 353 | |
337 | | - global $wgRequest, $wgUser, $wgParser, $wgOut, $wgScriptPath, $wgLanguageCode, $sfgFieldNum, $sfgScriptPath; |
| 354 | + global $wgRequest, $wgUser, $wgParser, $wgOut, $wgScriptPath, $wgLanguageCode; |
| 355 | + global $sfgFieldNum, $sfgScriptPath, $sfigSettings; |
338 | 356 | |
339 | 357 | static $hasRun = false; |
340 | 358 | |
— | — | @@ -341,30 +359,38 @@ |
342 | 360 | $hasRun = true; |
343 | 361 | |
344 | 362 | $wgOut->addScript( '<script type="text/javascript" src="' . $sfgScriptPath . '/libs/jquery-ui/jquery.ui.datepicker.min.js"></script> ' ); |
| 363 | + |
345 | 364 | if ( strcmp( $wgLanguageCode, "en" ) != 0 ) { |
346 | 365 | $wgOut->addScript( '<script type="text/javascript" src="' . $sfgScriptPath . '/libs/jquery-ui/jquery-ui-i18n.js"></script> ' ); |
347 | 366 | } |
348 | 367 | |
349 | | - $jstext = "<script> jQuery.noConflict(); jQuery(function(){"; |
350 | | - $image_path = $wgScriptPath . '/extensions/SemanticFormsInputs/calendar.gif'; |
351 | | - if ( strcmp( $wgLanguageCode, "en" ) != 0 ) { |
352 | | - $jstext .= "jQuery(\"#input_" . $sfgFieldNum . "\").datepicker({showOn: 'both', buttonImage: '$image_path', buttonImageOnly: true , dateFormat: 'yy-mm-dd' }, jQuery.datepicker.regional['$wgLanguageCode']); } ); </script> "; |
353 | | - } else { |
354 | | - $jstext .= "jQuery(\"#input_" . $sfgFieldNum . "\").datepicker({showOn: 'both', buttonImage: '$image_path', buttonImageOnly: true , dateFormat: 'yy-mm-dd' }); } ); </script> "; |
355 | | - } |
| 368 | + } |
356 | 369 | |
357 | | - $wgOut->addScript( $jstext ); |
| 370 | + if ( strcmp( $wgLanguageCode, "en" ) != 0 ) { |
| 371 | + $langCodeString = ", jQuery.datepicker.regional['$wgLanguageCode']"; |
| 372 | + } else { |
| 373 | + $langCodeString = ""; |
| 374 | + } |
358 | 375 | |
| 376 | + $jstext = <<<JAVASCRIPT |
| 377 | +jQuery ( |
| 378 | + function() { |
| 379 | + jQuery("#input_$sfgFieldNum").datepicker({showOn: 'both', buttonImage: '$sfigSettings->scriptPath/DatePickerButton.gif', buttonImageOnly: false , dateFormat: 'yy-mm-dd' }$langCodeString); |
359 | 380 | } |
360 | | - $html = '<p><input type="text" id="input_' . $sfgFieldNum . '" name="' . $input_name . '" value ="' . $cur_value . '" size="30"/></p>'; |
| 381 | +); |
361 | 382 | |
362 | | - return array( $html, "" ); |
| 383 | +JAVASCRIPT; |
| 384 | + |
| 385 | + $html = '<input type="text" id="input_' . $sfgFieldNum . '" name="' . htmlspecialchars( $input_name ) . '" value ="' . htmlspecialchars( $cur_value ) . '" size="30"/>' . |
| 386 | + '<span id="info_' . $sfgFieldNum . '" class="errorMessage"></span>'; |
| 387 | + |
| 388 | + return array( $html, $jstext ); |
363 | 389 | } |
364 | 390 | |
365 | 391 | /* |
366 | 392 | * Definition of input type "datepicker". |
367 | 393 | */ |
368 | | -function datePickerHTML ( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
| 394 | +static function datePickerHTML ( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
369 | 395 | |
370 | 396 | global $wgRequest, $wgUser, $wgParser, $wgOut, $wgScriptPath; |
371 | 397 | |
— | — | @@ -377,11 +403,11 @@ |
378 | 404 | if ( !( array_key_exists( 'hidden', $other_args ) || $is_disabled ) ) self::datePickerSetup(); |
379 | 405 | |
380 | 406 | // set size string |
381 | | - if ( array_key_exists( 'size', $other_args ) ) $sizeString = 'size="' . $other_args['size'] . '" '; |
| 407 | + if ( array_key_exists( 'size', $other_args ) ) $sizeString = 'size="' . htmlspecialchars( $other_args['size'] ) . '" '; |
382 | 408 | else $sizeString = ''; |
383 | 409 | |
384 | 410 | // set maxlength string |
385 | | - if ( array_key_exists( 'maxlength', $other_args ) ) $maxlengthString = 'maxlength="' . $other_args['maxlength'] . '" '; |
| 411 | + if ( array_key_exists( 'maxlength', $other_args ) ) $maxlengthString = 'maxlength="' . htmlspecialchars( $other_args['maxlength'] ) . '" '; |
386 | 412 | else $maxlengthString = ''; |
387 | 413 | |
388 | 414 | // set mandatory string |
— | — | @@ -482,19 +508,19 @@ |
483 | 509 | foreach ( explode( ',', $disabledDates ) as $range ) { |
484 | 510 | if ( strpos( $range, '-' ) === false ) { |
485 | 511 | $dateArray = explode( '/', $range ); |
486 | | - $disabledDatesString .= '"' . |
487 | | - $dateArray[1] . '/' . |
| 512 | + $disabledDatesString .= |
| 513 | + Xml::encodeJsVar( $dateArray[1] . '/' . |
488 | 514 | $dateArray[0] . '/' . |
489 | | - $dateArray[2] . '", '; |
| 515 | + $dateArray[2] ) . ', '; |
490 | 516 | } else { |
491 | 517 | $dateArray = explode( '/', str_replace( '-', '/', $range ) ); |
492 | | - $disabledDatesString .= '"' . |
493 | | - $dateArray[1] . '/' . |
| 518 | + $disabledDatesString .= |
| 519 | + Xml::encodeJsVar( $dateArray[1] . '/' . |
494 | 520 | $dateArray[0] . '/' . |
495 | 521 | $dateArray[2] . '-' . |
496 | 522 | $dateArray[4] . '/' . |
497 | 523 | $dateArray[3] . '/' . |
498 | | - $dateArray[5] . '", '; |
| 524 | + $dateArray[5] ) . ', '; |
499 | 525 | } |
500 | 526 | } |
501 | 527 | |
— | — | @@ -502,7 +528,7 @@ |
503 | 529 | |
504 | 530 | if ( array_key_exists( 'possible_values', $other_args ) && $other_args['possible_values'] ) { |
505 | 531 | |
506 | | - $enabledDates = array(); |
| 532 | + $enabledDates = array(); // stores enabled date ranges, i.e. arrays containing first and last enabled day |
507 | 533 | |
508 | 534 | foreach ( $other_args['possible_values'] as $range ) { |
509 | 535 | |
— | — | @@ -525,6 +551,7 @@ |
526 | 552 | |
527 | 553 | $prevStartOfDisabled = $firstDate; |
528 | 554 | |
| 555 | + // from the list of enabled dates create a list of disabled dates |
529 | 556 | while ( list( $currKey, $currRange ) = each( $enabledDates ) ) { |
530 | 557 | |
531 | 558 | $currEndOfDisabled = clone $enabledDates[$currKey][0]; |
— | — | @@ -565,13 +592,19 @@ |
566 | 593 | |
567 | 594 | // set first date string and last date string |
568 | 595 | if ( $firstDate ) { |
569 | | - $firstDateString = '"' . $firstDate->format( 'n' ) . '/' . $firstDate->format( 'j' ) . '/' . $firstDate->format( 'Y' ) . '"'; |
| 596 | + $firstDateString = |
| 597 | + $firstDate->format( 'n' ) . '/' . |
| 598 | + $firstDate->format( 'j' ) . '/' . |
| 599 | + $firstDate->format( 'Y' ); |
570 | 600 | } else { |
571 | 601 | $firstDateString = 'null'; |
572 | 602 | } |
573 | 603 | |
574 | 604 | if ( $lastDate ) { |
575 | | - $lastDateString = '"' . $lastDate->format( 'n' ) . '/' . $lastDate->format( 'j' ) . '/' . $lastDate->format( 'Y' ) . '"'; |
| 605 | + $lastDateString = |
| 606 | + $lastDate->format( 'n' ) . '/' . |
| 607 | + $lastDate->format( 'j' ) . '/' . |
| 608 | + $lastDate->format( 'Y' ); |
576 | 609 | } else { |
577 | 610 | $lastDateString = 'null'; |
578 | 611 | } |
— | — | @@ -590,19 +623,19 @@ |
591 | 624 | foreach ( explode( ',', $highlightedDates ) as $range ) { |
592 | 625 | if ( strpos( $range, '-' ) === false ) { |
593 | 626 | $dateArray = explode( '/', $range ); |
594 | | - $highlightedDatesString .= '"' . |
595 | | - $dateArray[1] . '/' . |
| 627 | + $highlightedDatesString .= |
| 628 | + Xml::encodeJsVar( $dateArray[1] . '/' . |
596 | 629 | $dateArray[0] . '/' . |
597 | | - $dateArray[2] . '", '; |
| 630 | + $dateArray[2] ) . ', '; |
598 | 631 | } else { |
599 | 632 | $dateArray = explode( '/', str_replace( '-', '/', $range ) ); |
600 | | - $highlightedDatesString .= '"' . |
601 | | - $dateArray[1] . '/' . |
| 633 | + $highlightedDatesString .= |
| 634 | + Xml::encodeJsVar( $dateArray[1] . '/' . |
602 | 635 | $dateArray[0] . '/' . |
603 | 636 | $dateArray[2] . '-' . |
604 | 637 | $dateArray[4] . '/' . |
605 | 638 | $dateArray[3] . '/' . |
606 | | - $dateArray[5] . '", '; |
| 639 | + $dateArray[5] ) . ', '; |
607 | 640 | } |
608 | 641 | } |
609 | 642 | |
— | — | @@ -618,25 +651,7 @@ |
619 | 652 | |
620 | 653 | // set default date string |
621 | 654 | $defaultDateString = 'null'; |
622 | | - $setDefaultDateString = ''; |
623 | 655 | |
624 | | - if ( $cur_value ) { |
625 | | - $parts = explode( '/', $cur_value ); |
626 | | - if ( count( $parts ) == 3 ) { |
627 | | - $defaultDateString = '"' . $parts[1] . '/' . $parts[0] . '/' . $parts[2] . '"'; |
628 | | - |
629 | | - $setDefaultDateString = <<<JAVASCRIPT |
630 | | - document.getElementById("input_{$sfgFieldNum}").value= |
631 | | - YAHOO.util.Date.format( |
632 | | - new Date(Date.parse($defaultDateString)), |
633 | | - {format:"$dateFormatString"}, |
634 | | - 'wiki' |
635 | | - ); |
636 | | -JAVASCRIPT; |
637 | | - |
638 | | - } |
639 | | - } |
640 | | - |
641 | 656 | // set month strings |
642 | 657 | if ( array_key_exists( 'month names', $other_args ) ) { |
643 | 658 | $monthNames = $other_args['month names']; |
— | — | @@ -646,7 +661,7 @@ |
647 | 662 | |
648 | 663 | // set day strings |
649 | 664 | if ( array_key_exists( 'day names', $other_args ) ) { |
650 | | - $dayNames = $other_args['day names']; |
| 665 | + $dayNames = Xml::encodeJsVar( $other_args['day names'] ); |
651 | 666 | } else { |
652 | 667 | $dayNames = $sfigSettings->datePickerDayNames; |
653 | 668 | } |
— | — | @@ -660,6 +675,14 @@ |
661 | 676 | $showResetButton = $sfigSettings->datePickerShowResetButton; |
662 | 677 | } |
663 | 678 | |
| 679 | + $classString = htmlspecialchars( $classString ); |
| 680 | + $cur_value = htmlspecialchars( $cur_value ); |
| 681 | + // $mandatoryString: contains a fixed string ("mandatory ", "") |
| 682 | + $input_name = htmlspecialchars( $input_name ); |
| 683 | + // $sizeString: already sanitized |
| 684 | + // $maxlengthString: already sanitized |
| 685 | + // $disableInputString: contains a fixed string ("readonly ", "") |
| 686 | + |
664 | 687 | if ( $showResetButton && $is_disabled ) { |
665 | 688 | |
666 | 689 | $resetButtonString = |
— | — | @@ -679,42 +702,77 @@ |
680 | 703 | |
681 | 704 | // compose html text |
682 | 705 | if ( array_key_exists( 'hidden', $other_args ) ) { |
683 | | - $htmltext = '<input type="hidden" id="input_' . $sfgFieldNum . '" value="' . $cur_value . |
684 | | - '" class="createboxInput ' . $mandatoryString . $classString . '" name="' . $input_name . '" /><span id="info_' . $sfgFieldNum . '" class="errorMessage"></span>'; |
| 706 | + |
| 707 | + $htmltext = '<input type="hidden" id="input_' . $sfgFieldNum |
| 708 | + . '" value="' . $cur_value |
| 709 | + . '" class="createboxInput ' . $mandatoryString . $classString |
| 710 | + . '" name="' . $input_name . '" /><span id="info_' . $sfgFieldNum |
| 711 | + . '" class="errorMessage"></span>'; |
| 712 | + |
685 | 713 | } elseif ( $is_disabled ) { |
686 | 714 | $htmltext = |
687 | | - '<span class="yui-skin-sam">' . |
688 | | - '<input type="text" ' . $sizeString . $maxlengthString . ' id="input_' . $sfgFieldNum . '" ' . |
689 | | - 'value="' . $cur_value . '" class="createboxInput ' . $mandatoryString . $classString . '" ' . |
690 | | - 'style="vertical-align:middle;" name="' . $input_name . '" readonly />' . |
691 | | - '<button tabindex="-1" type=button id="input_' . $sfgFieldNum . '_button" class="' . $classString . '" onclick="return false;" ' . |
692 | | - 'style="height:1.5em;width:1.5em;vertical-align:middle;background-image: url(' . $sfigSettings->scriptPath . '/DatePickerButtonDisabled.gif);' . |
693 | | - 'background-position: center center; background-repeat: no-repeat;" disabled ></button>' . |
694 | | - $resetButtonString . "\n" . |
695 | | - '<span id="info_' . $sfgFieldNum . '" class="errorMessage"></span>' . |
696 | | - '</span>'; |
| 715 | + '<span class="yui-skin-sam">' |
| 716 | + . '<input type="text" ' . $sizeString . $maxlengthString |
| 717 | + . ' id="input_' . $sfgFieldNum . '" ' . 'value="' . $cur_value |
| 718 | + . '" class="createboxInput ' . $mandatoryString . $classString . '" ' |
| 719 | + . 'style="vertical-align:middle;" name="' . $input_name . '" readonly />' |
| 720 | + . '<button tabindex="-1" type=button id="input_' . $sfgFieldNum |
| 721 | + . '_button" class="' . $classString . '" onclick="return false;" ' |
| 722 | + . 'style="height:1.5em;width:1.5em;vertical-align:middle;background-image: url(' |
| 723 | + . $sfigSettings->scriptPath . '/DatePickerButtonDisabled.gif);' |
| 724 | + . 'background-position: center center; background-repeat: no-repeat;" disabled ></button>' . |
| 725 | + $resetButtonString . "\n" |
| 726 | + . '<span id="info_' . $sfgFieldNum . '" class="errorMessage"></span>' |
| 727 | + . '</span>'; |
697 | 728 | |
698 | | - } else { |
| 729 | + } else { // not hidden, not disabled |
699 | 730 | $htmltext = |
700 | | - '<span class="yui-skin-sam">' . |
701 | | - '<span id="input_' . $sfgFieldNum . '_container" style="position:absolute;display:inline;margin-top:2em;"><span id="input_' . $sfgFieldNum . '_calendar"></span></span>' . |
702 | | - '<input type="text" ' . $sizeString . $maxlengthString . $disableInputString . ' id="input_' . $sfgFieldNum . '" ' . |
703 | | - 'value="' . $cur_value . '" class="createboxInput ' . $mandatoryString . $classString . '" ' . |
704 | | - 'style="vertical-align:middle;" name="' . $input_name . '" />' . |
705 | | - '<button tabindex="-1" type=button id="input_' . $sfgFieldNum . '_button" class="' . $classString . '" onclick="toggle_datepicker(this);" ' . |
706 | | - 'style="height: 1.5em; width: 1.5em;vertical-align:middle;background-image: url(' . $sfigSettings->scriptPath . '/DatePickerButton.gif);' . |
707 | | - 'background-position: center center; background-repeat: no-repeat;" ></button>' . |
708 | | - $resetButtonString . "\n" . |
709 | | - '<span id="info_' . $sfgFieldNum . '" class="errorMessage"></span>' . |
710 | | - '</span>'; |
| 731 | + '<span class="yui-skin-sam">' |
| 732 | + . '<span id="input_' . $sfgFieldNum |
| 733 | + . '_container" style="position:absolute;display:inline;margin-top:2em;">' |
| 734 | + . '<span id="input_' . $sfgFieldNum . '_calendar"></span></span>' |
| 735 | + . '<input type="text" ' . $sizeString . $maxlengthString . $disableInputString |
| 736 | + . ' id="input_' . $sfgFieldNum . '" ' . 'value="' . $cur_value |
| 737 | + . '" class="createboxInput ' . $mandatoryString . $classString . '" ' |
| 738 | + . 'style="vertical-align:middle;" name="' . $input_name . '" />' |
| 739 | + . '<button tabindex="-1" type=button id="input_' . $sfgFieldNum |
| 740 | + . '_button" class="' . $classString . '" onclick="toggle_datepicker(this);" ' |
| 741 | + . 'style="height: 1.5em; width: 1.5em;vertical-align:middle;background-image: url(' |
| 742 | + . $sfigSettings->scriptPath . '/DatePickerButton.gif);' |
| 743 | + . 'background-position: center center; background-repeat: no-repeat;" ></button>' |
| 744 | + . $resetButtonString . "\n" |
| 745 | + . '<span id="info_' . $sfgFieldNum . '" class="errorMessage"></span>' |
| 746 | + . '</span>'; |
711 | 747 | } |
712 | 748 | |
713 | 749 | // compose Javascript |
714 | | - if ( array_key_exists( 'hidden', $other_args ) ) { |
| 750 | + if ( array_key_exists( 'hidden', $other_args ) || $is_disabled ) { |
715 | 751 | $jstext = ''; |
716 | | - } elseif ( $is_disabled ) { |
717 | | - $jstext = ''; |
718 | 752 | } else { |
| 753 | + |
| 754 | + $weekStartString = htmlspecialchars( Xml::encodeJsVar( $weekStartString ), ENT_NOQUOTES ); |
| 755 | + // $weekNumberString: contains a fixed string ("true", "false") |
| 756 | + // $disabledDaysOfWeek: input filtered, only numbers and commas allowed |
| 757 | + // $highlightedDaysOfWeek: input filtered, only numbers and commas allowed |
| 758 | + $disabledDatesString = htmlspecialchars( $disabledDatesString, ENT_NOQUOTES ); // Js sanitized on input |
| 759 | + $highlightedDatesString = htmlspecialchars( $highlightedDatesString, ENT_NOQUOTES ); // Js sanitized on input |
| 760 | + |
| 761 | + if ( strcmp( $firstDateString, "null" ) ) { |
| 762 | + $firstDateString = htmlspecialchars( Xml::encodeJsVar( $firstDateString ), ENT_NOQUOTES ); |
| 763 | + } |
| 764 | + |
| 765 | + if ( strcmp( $lastDateString, "null" ) ) { |
| 766 | + $lastDateString = htmlspecialchars( Xml::encodeJsVar( $lastDateString ), ENT_NOQUOTES ); |
| 767 | + } |
| 768 | + |
| 769 | + if ( strcmp( $defaultDateString, "null" ) ) { |
| 770 | + $defaultDateString = htmlspecialchars( Xml::encodeJsVar( $defaultDateString ), ENT_NOQUOTES ); |
| 771 | + } |
| 772 | + |
| 773 | + $monthNames = htmlspecialchars( Xml::encodeJsVar( $monthNames ), ENT_NOQUOTES ); |
| 774 | + $dayNames = htmlspecialchars( Xml::encodeJsVar( $dayNames ), ENT_NOQUOTES ); |
| 775 | + $dateFormatString = htmlspecialchars( Xml::encodeJsVar( $dateFormatString ), ENT_NOQUOTES ); |
| 776 | + |
719 | 777 | $jstext = <<<JAVASCRIPT |
720 | 778 | function setup_input_{$sfgFieldNum}() { |
721 | 779 | |
— | — | @@ -728,17 +786,17 @@ |
729 | 787 | sfiElements['settings_$sfgFieldNum'].first_day = $firstDateString; |
730 | 788 | sfiElements['settings_$sfgFieldNum'].last_day = $lastDateString; |
731 | 789 | sfiElements['settings_$sfgFieldNum'].default_day = $defaultDateString; |
732 | | - sfiElements['settings_$sfgFieldNum'].locale_months = "$monthNames"; |
733 | | - sfiElements['settings_$sfgFieldNum'].locale_weekdays = "$dayNames"; |
734 | | - sfiElements['settings_$sfgFieldNum'].date_format = "$dateFormatString"; |
| 790 | + sfiElements['settings_$sfgFieldNum'].locale_months = $monthNames; |
| 791 | + sfiElements['settings_$sfgFieldNum'].locale_weekdays = $dayNames; |
| 792 | + sfiElements['settings_$sfgFieldNum'].date_format = $dateFormatString; |
735 | 793 | |
736 | | - $setDefaultDateString; |
737 | 794 | } |
738 | 795 | |
739 | 796 | addOnloadHook(setup_input_{$sfgFieldNum}); |
| 797 | + |
740 | 798 | JAVASCRIPT; |
741 | 799 | } |
742 | 800 | |
743 | 801 | return array( $htmltext, $jstext ); |
744 | | - } |
745 | 802 | } |
| 803 | +} |