Index: trunk/phase3/skins/common/upload.js |
— | — | @@ -1,17 +1,16 @@ |
2 | 2 | function licenseSelectorCheck() { |
3 | 3 | var selector = document.getElementById( "wpLicense" ); |
| 4 | + var selection = selector.options[selector.selectedIndex].value; |
4 | 5 | if( selector.selectedIndex > 0 ) { |
5 | | - var selection = selector.options[selector.selectedIndex].value; |
6 | 6 | if( selection == "" ) { |
7 | 7 | // Option disabled, but browser is broken and doesn't respect this |
8 | 8 | selector.selectedIndex = 0; |
9 | | - } else { |
10 | | - // We might show a preview |
11 | | - if( wgAjaxLicencePreview ) { |
12 | | - wgUploadLicenceObj.fetchPreview( selection ); |
13 | | - } |
14 | 9 | } |
15 | 10 | } |
| 11 | + // We might show a preview |
| 12 | + if( wgAjaxLicensePreview ) { |
| 13 | + wgUploadLicenseObj.fetchPreview( selection ); |
| 14 | + } |
16 | 15 | } |
17 | 16 | |
18 | 17 | function licenseSelectorFixup() { |
— | — | @@ -138,31 +137,33 @@ |
139 | 138 | } |
140 | 139 | } |
141 | 140 | |
142 | | -var wgUploadLicenceObj = { |
| 141 | +var wgUploadLicenseObj = { |
143 | 142 | |
144 | 143 | 'responseCache' : { '' : '' }, |
145 | 144 | |
146 | | - 'fetchPreview': function( licence ) { |
147 | | - if( licence in this.responseCache ) { |
148 | | - this.showPreview( this.responseCache[licence] ); |
| 145 | + 'fetchPreview': function( license ) { |
| 146 | + if( license == "" ) { |
| 147 | + this.showPreview( "" ); |
| 148 | + } else if( license in this.responseCache ) { |
| 149 | + this.showPreview( this.responseCache[license] ); |
149 | 150 | } else { |
150 | | - injectSpinner( document.getElementById( 'wpLicense' ), 'licence' ); |
151 | | - sajax_do_call( 'UploadForm::ajaxGetLicencePreview', [licence], |
| 151 | + injectSpinner( document.getElementById( 'wpLicense' ), 'license' ); |
| 152 | + sajax_do_call( 'UploadForm::ajaxGetLicensePreview', [license], |
152 | 153 | function( result ) { |
153 | | - wgUploadLicenceObj.processResult( result, licence ); |
| 154 | + wgUploadLicenseObj.processResult( result, license ); |
154 | 155 | } |
155 | 156 | ); |
156 | 157 | } |
157 | 158 | }, |
158 | 159 | |
159 | | - 'processResult' : function( result, licence ) { |
160 | | - removeSpinner( 'licence' ); |
| 160 | + 'processResult' : function( result, license ) { |
| 161 | + removeSpinner( 'license' ); |
161 | 162 | this.showPreview( result.responseText ); |
162 | | - this.responseCache[licence] = result.responseText; |
| 163 | + this.responseCache[license] = result.responseText; |
163 | 164 | }, |
164 | 165 | |
165 | 166 | 'showPreview' : function( preview ) { |
166 | | - var previewPanel = document.getElementById( 'mw-licence-preview' ); |
| 167 | + var previewPanel = document.getElementById( 'mw-license-preview' ); |
167 | 168 | if( previewPanel.innerHTML != preview ) |
168 | 169 | previewPanel.innerHTML = preview; |
169 | 170 | } |
Index: trunk/phase3/includes/Setup.php |
— | — | @@ -258,8 +258,8 @@ |
259 | 259 | if ( $wgAjaxSearch ) $wgAjaxExportList[] = 'wfSajaxSearch'; |
260 | 260 | if ( $wgAjaxWatch ) $wgAjaxExportList[] = 'wfAjaxWatch'; |
261 | 261 | if ( $wgAjaxUploadDestCheck ) $wgAjaxExportList[] = 'UploadForm::ajaxGetExistsWarning'; |
262 | | -if( $wgAjaxLicencePreview ) |
263 | | - $wgAjaxExportList[] = 'UploadForm::ajaxGetLicencePreview'; |
| 262 | +if( $wgAjaxLicensePreview ) |
| 263 | + $wgAjaxExportList[] = 'UploadForm::ajaxGetLicensePreview'; |
264 | 264 | |
265 | 265 | wfSeedRandom(); |
266 | 266 | |
Index: trunk/phase3/includes/SpecialUpload.php |
— | — | @@ -559,43 +559,25 @@ |
560 | 560 | } |
561 | 561 | |
562 | 562 | /** |
563 | | - * Render a preview of a given licence for the AJAX preview on upload |
| 563 | + * Render a preview of a given license for the AJAX preview on upload |
564 | 564 | * |
565 | | - * @param string $licence |
| 565 | + * @param string $license |
566 | 566 | * @return string |
567 | 567 | */ |
568 | | - public static function ajaxGetLicencePreview( $licence ) { |
569 | | - global $wgParser; |
570 | | - $licence = self::getLicenceTitle( $licence ); |
571 | | - if( $licence instanceof Title && $licence->exists() ) { |
572 | | - $title = SpecialPage::getTitleFor( 'Upload' ); |
573 | | - $revision = Revision::newFromTitle( $licence ); |
574 | | - $output = $wgParser->parse( $revision->getText(), $title, new ParserOptions() ); |
575 | | - return $output->getText(); |
576 | | - } |
577 | | - return wfMsgHtml( 'license-nopreview' ); |
| 568 | + public static function ajaxGetLicensePreview( $license ) { |
| 569 | + global $wgParser, $wgUser; |
| 570 | + $text = '{{' . $license . '}}'; |
| 571 | + $title = Title::makeTitle( NS_IMAGE, 'Sample.jpg' ); |
| 572 | + $options = ParserOptions::newFromUser( $wgUser ); |
| 573 | + |
| 574 | + // Expand subst: first, then live templates... |
| 575 | + $text = $wgParser->preSaveTransform( $text, $title, $wgUser, $options ); |
| 576 | + $output = $wgParser->parse( $text, $title, $options ); |
| 577 | + |
| 578 | + return $output->getText(); |
578 | 579 | } |
579 | 580 | |
580 | 581 | /** |
581 | | - * Get the title of the page associated with a given licence |
582 | | - * string, i.e. do a quick resolution of {{$license}} without |
583 | | - * invoking the full parser |
584 | | - * |
585 | | - * @param string $licence |
586 | | - * @return Title |
587 | | - */ |
588 | | - private static function getLicenceTitle( $licence ) { |
589 | | - $template = substr( $licence, 0, 1 ) != ':'; |
590 | | - $title = Title::newFromText( ltrim( $licence, ':' ) ); |
591 | | - if( $title instanceof Title && $title->getNamespace() == NS_MAIN ) { |
592 | | - return $template |
593 | | - ? Title::makeTitle( NS_TEMPLATE, $title->getText() ) |
594 | | - : $title; |
595 | | - } |
596 | | - return $title; |
597 | | - } |
598 | | - |
599 | | - /** |
600 | 582 | * Stash a file in a temporary directory for later processing |
601 | 583 | * after the user has confirmed it. |
602 | 584 | * |
— | — | @@ -750,19 +732,19 @@ |
751 | 733 | */ |
752 | 734 | function mainUploadForm( $msg='' ) { |
753 | 735 | global $wgOut, $wgUser; |
754 | | - global $wgUseCopyrightUpload, $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicencePreview; |
| 736 | + global $wgUseCopyrightUpload, $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview; |
755 | 737 | global $wgRequest, $wgAllowCopyUploads, $wgEnableAPI; |
756 | 738 | global $wgStylePath, $wgStyleVersion; |
757 | 739 | |
758 | 740 | $useAjaxDestCheck = $wgUseAjax && $wgAjaxUploadDestCheck; |
759 | | - $useAjaxLicencePreview = $wgUseAjax && $wgAjaxLicencePreview; |
| 741 | + $useAjaxLicensePreview = $wgUseAjax && $wgAjaxLicensePreview; |
760 | 742 | |
761 | 743 | $adc = wfBoolToStr( $useAjaxDestCheck ); |
762 | | - $alp = wfBoolToStr( $useAjaxLicencePreview ); |
| 744 | + $alp = wfBoolToStr( $useAjaxLicensePreview ); |
763 | 745 | |
764 | 746 | $wgOut->addScript( "<script type=\"text/javascript\"> |
765 | 747 | wgAjaxUploadDestCheck = {$adc}; |
766 | | -wgAjaxLicencePreview = {$alp}; |
| 748 | +wgAjaxLicensePreview = {$alp}; |
767 | 749 | </script> |
768 | 750 | <script type=\"text/javascript\" src=\"{$wgStylePath}/common/upload.js?{$wgStyleVersion}\"></script> |
769 | 751 | " ); |
— | — | @@ -889,10 +871,10 @@ |
890 | 872 | </td> |
891 | 873 | </tr> |
892 | 874 | <tr>" ); |
893 | | - if( $useAjaxLicencePreview ) { |
| 875 | + if( $useAjaxLicensePreview ) { |
894 | 876 | $wgOut->addHtml( " |
895 | 877 | <td></td> |
896 | | - <td id=\"mw-licence-preview\"></td> |
| 878 | + <td id=\"mw-license-preview\"></td> |
897 | 879 | </tr> |
898 | 880 | <tr>" ); |
899 | 881 | } |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -1201,7 +1201,7 @@ |
1202 | 1202 | * to ensure that client-side caches don't keep obsolete copies of global |
1203 | 1203 | * styles. |
1204 | 1204 | */ |
1205 | | -$wgStyleVersion = '85'; |
| 1205 | +$wgStyleVersion = '86'; |
1206 | 1206 | |
1207 | 1207 | |
1208 | 1208 | # Server-side caching: |
— | — | @@ -2563,7 +2563,7 @@ |
2564 | 2564 | /** |
2565 | 2565 | * Enable previewing licences via AJAX |
2566 | 2566 | */ |
2567 | | -$wgAjaxLicencePreview = true; |
| 2567 | +$wgAjaxLicensePreview = true; |
2568 | 2568 | |
2569 | 2569 | /** |
2570 | 2570 | * Allow DISPLAYTITLE to change title display |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -137,7 +137,7 @@ |
138 | 138 | * (bug 10530) Introduce optional "sp-contributions-explain" message for |
139 | 139 | additional explanation in Special:Contributions |
140 | 140 | * (bug 10520) Preview licences during upload via AJAX (toggle with |
141 | | - $wgAjaxLicencePreview) |
| 141 | + $wgAjaxLicensePreview) |
142 | 142 | * New Parser::setTransparentTagHook for parser extension and template |
143 | 143 | compatibility |
144 | 144 | * Introduced 'ContributionsToolLinks' hook; see docs/hooks.txt for more |