* Send new password e-mail in users preference language
* LanguageConverter now support nested using of manual convert syntax like "-{-{}-}-"
* (bug 16281) Show copyright system message on special pages
+* Upload license preview now uses the API instead of action=ajax
=== Bug fixes in 1.16 ===
* to ensure that client-side caches do not keep obsolete copies of global
* styles.
*/
-$wgStyleVersion = '261';
+$wgStyleVersion = '262';
# Server-side caching:
$wgAjaxUploadDestCheck = true;
/**
- * Enable previewing licences via AJAX
+ * Enable previewing licences via AJAX. Also requires $wgEnableAPI to be true.
*/
$wgAjaxLicensePreview = true;
if ( $wgAjaxWatch ) $wgAjaxExportList[] = 'wfAjaxWatch';
if ( $wgAjaxUploadDestCheck ) $wgAjaxExportList[] = 'SpecialUpload::ajaxGetExistsWarning';
-if( $wgAjaxLicensePreview )
- $wgAjaxExportList[] = 'SpecialUpload::ajaxGetLicensePreview';
# Placeholders in case of DB error
$wgTitle = null;
return $s;
}
- /**
- * Render a preview of a given license for the AJAX preview on upload
- *
- * @param string $license
- * @return string
- */
- public static function ajaxGetLicensePreview( $license ) {
- global $wgParser, $wgUser;
- $text = '{{' . $license . '}}';
- $title = Title::makeTitle( NS_FILE, 'Sample.jpg' );
- $options = ParserOptions::newFromUser( $wgUser );
-
- // Expand subst: first, then live templates...
- $text = $wgParser->preSaveTransform( $text, $title, $wgUser, $options );
- $output = $wgParser->parse( $text, $title, $options );
-
- return $output->getText();
- }
-
/**
* Construct a warning and a gallery from an array of duplicate files.
*/
* filename text box
*/
protected function addUploadJS( ) {
- global $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview;
+ global $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview, $wgEnableAPI;
global $wgOut;
$useAjaxDestCheck = $wgUseAjax && $wgAjaxUploadDestCheck;
- $useAjaxLicensePreview = $wgUseAjax && $wgAjaxLicensePreview;
+ $useAjaxLicensePreview = $wgUseAjax && $wgAjaxLicensePreview && $wgEnableAPI;
$scriptVars = array(
- 'wgAjaxUploadDestCheck' => $wgUseAjax && $wgAjaxUploadDestCheck,
- 'wgAjaxLicensePreview' => $wgUseAjax && $wgAjaxLicensePreview,
+ 'wgAjaxUploadDestCheck' => $useAjaxDestCheck,
+ 'wgAjaxLicensePreview' => $useAjaxLicensePreview,
'wgUploadAutoFill' => !$this->mForReUpload,
'wgUploadSourceIds' => $this->mSourceIds,
);
'responseCache' : { '' : '' },
'fetchPreview': function( license ) {
- if( !wgAjaxLicensePreview || !sajax_init_object() ) return;
+ if( !wgAjaxLicensePreview ) return;
for (cached in this.responseCache) {
if (cached == license) {
this.showPreview( this.responseCache[license] );
}
}
injectSpinner( document.getElementById( 'wpLicense' ), 'license' );
- sajax_do_call( 'SpecialUpload::ajaxGetLicensePreview', [license],
- function( result ) {
- wgUploadLicenseObj.processResult( result, license );
- }
- );
+
+ var title = document.getElementById('wpDestFile').value;
+ if ( !title ) title = 'File:Sample.jpg';
+
+ var url = wgScriptPath + '/api' + wgScriptExtension
+ + '?action=parse&text={{' + encodeURIComponent( license ) + '}}'
+ + '&title=' + encodeURIComponent( title )
+ + '&prop=text&pst&format=json';
+
+ var req = sajax_init_object();
+ req.onreadystatechange = function() {
+ if ( req.readyState == 4 && req.status == 200 )
+ wgUploadLicenseObj.processResult( eval( '(' + req.responseText + ')' ), license );
+ };
+ req.open( 'GET', url, true );
+ req.send( '' );
},
'processResult' : function( result, license ) {
removeSpinner( 'license' );
- this.showPreview( result.responseText );
- this.responseCache[license] = result.responseText;
+ this.responseCache[license] = result['parse']['text']['*'];
+ this.showPreview( this.responseCache[license] );
+
},
'showPreview' : function( preview ) {