r83974 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83973‎ | r83974 | r83975 >
Date:22:58, 14 March 2011
Author:dale
Status:ok
Tags:
Comment:
* bug 28046 moved all configuration into UploadWizard.config.php, export it to javascript and page render time and added notes about how to set any given configuration value
* method namespaced mw.log calls so its more obvious what log msg is coming from what file and what method
* upload wizard should not have its own local copy of globals such as wgUserLanguage, should instead grab them from global config.
* renamed $dir to $wgUpwizDir so there is no conflicts and other functions can access the uploadWizard php directory
Modified paths:
  • /trunk/extensions/UploadWizard/SpecialUploadWizard.php (modified) (history)
  • /trunk/extensions/UploadWizard/UploadWizard.config.php (added) (history)
  • /trunk/extensions/UploadWizard/UploadWizard.php (modified) (history)
  • /trunk/extensions/UploadWizard/UploadWizardPage.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.Api.edit.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.Api.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.ApiUploadHandler.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.DestinationChecker.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.IframeTransport.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadApiProcessor.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizard.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizardDeed.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UtilitiesTime.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/UploadWizard.config.php
@@ -0,0 +1,102 @@
 2+<?php
 3+/**
 4+ * Upload Wizard Configuration
 5+ * Do not modify this file, instead use localsettings.php and set:
 6+ * $wgUploadWizardConfig[ 'name'] = 'value';
 7+ */
 8+global $wgFileExtensions, $wgServer, $wgScriptPath;
 9+return array(
 10+ // Upload wizard has an internal debug flag
 11+ 'debug' => false,
 12+
 13+ // If the uploaded file should be auto categorized
 14+ 'autoCategory' => true,
 15+
 16+ // File extensions acceptable in this wiki
 17+ 'fileExtensions' => $wgFileExtensions,
 18+
 19+ // The default api url is for the current wiki ( can override at run time )
 20+ 'apiUrl' => $wgServer . $wgScriptPath . '/api.php',
 21+
 22+ // Default thumbnail width
 23+ 'thumbnailWidth' => 120,
 24+
 25+ // Max thumbnail height:
 26+ 'thumbnailMaxHeight' => 200,
 27+
 28+ // Min thumbnail width
 29+ 'smallThumbnailWidth' => 60,
 30+
 31+ // Small thumbnail max height
 32+ 'smallThumbnailMaxHeight' => 100,
 33+
 34+ // Icon thumbnail width:
 35+ 'iconThumbnailWidth' => 32,
 36+
 37+ // Icon thumbnail height:
 38+ 'iconThumbnailMaxHeight' => 32,
 39+
 40+ // Max author string length
 41+ 'maxAuthorLength' => 50,
 42+
 43+ // Min author string length
 44+ 'minAuthorLength' => 2,
 45+
 46+ // Max source string length
 47+ 'maxSourceLength' => 200,
 48+
 49+ // Min source string length
 50+ 'minSourceLength' => 5,
 51+
 52+ // Max file title string length
 53+ 'maxTitleLength' => 200,
 54+
 55+ // Min file title string length
 56+ 'minTitleLength' => 5,
 57+
 58+ // Max file description length
 59+ 'maxDescriptionLength' => 4096,
 60+
 61+ // Min file description length
 62+ 'minDescriptionLength' => 5,
 63+
 64+ // Max length for other file information:
 65+ 'maxOtherInformationLength' => 4096,
 66+
 67+ // Max number of simultaneous upload requests
 68+ 'maxSimultaneousConnections' => 1,
 69+
 70+ // Max number of uploads for a given form
 71+ 'maxUploads' => 10,
 72+
 73+ // not for use with all wikis.
 74+ // The ISO 639 code for the language tagalog is "tl".
 75+ // Normally we name templates for languages by the ISO 639 code.
 76+ // Commons already had a template called 'tl: though.
 77+ // so, this workaround will cause tagalog descriptions to be saved with this template instead.
 78+ 'languageTemplateFixups' => array( 'tl' => 'tgl' ),
 79+
 80+ // names of all license templates, in order. Case sensitive!
 81+ // n.b. in the future, the licenses for a wiki will probably be defined in PHP or even LocalSettings.
 82+ 'licenses' => array(
 83+ array( 'template' => 'Cc-by-sa-3.0','messageKey' => 'mwe-upwiz-license-cc-by-sa-3.0', 'default' => true ),
 84+ array( 'template' => 'Cc-by-3.0', 'messageKey' => 'mwe-upwiz-license-cc-by-3.0', 'default' => false ),
 85+ array( 'template' => 'Cc-zero', 'messageKey' => 'mwe-upwiz-license-cc-zero', 'default' => false ),
 86+ // n.b. the PD-US is only for testing purposes, obviously we need some geographical discrimination here...
 87+ array( 'template' => 'PD-US', 'messageKey' => 'mwe-upwiz-license-pd-us', 'default' => false ),
 88+ array( 'template' => 'GFDL', 'messageKey' => 'mwe-upwiz-license-gfdl', 'default' => false )
 89+ )
 90+
 91+ // XXX this is horribly confusing -- some file restrictions are client side, others are server side
 92+ // the filename prefix blacklist is at least server side -- all this should be replaced with PHP regex config
 93+ // or actually, in an ideal world, we'd have some way to reliably detect gibberish, rather than trying to
 94+ // figure out what is bad via individual regexes, we'd detect badness. Might not be too hard.
 95+ //
 96+ // we can export these to JS if we so want.
 97+ // filenamePrefixBlacklist: wgFilenamePrefixBlacklist,
 98+ //
 99+ // filenameRegexBlacklist: [
 100+ // /^(test|image|img|bild|example?[\s_-]*)$/, // test stuff
 101+ // /^(\d{10}[\s_-][0-9a-f]{10}[\s_-][a-z])$/ // flickr
 102+ // ]
 103+);
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardDeed.js
@@ -88,7 +88,7 @@
8989 // XXX do we need to escape authorInput, or is wikitext a feature here?
9090 // what about scripts?
9191 getAuthorWikiText: function() {
92 - return "[[User:" + mw.UploadWizard.config[ 'userName' ] + '|' + $j( _this.authorInput ).val() + ']]';
 92+ return "[[User:" + mw.config.get( 'wgUserName' ) + '|' + $j( _this.authorInput ).val() + ']]';
9393 },
9494
9595
@@ -155,7 +155,7 @@
156156 $formFields.find( '.mwe-upwiz-sign' )
157157 .attr( {
158158 title: gM( 'mwe-upwiz-tooltip-sign' ),
159 - value: mw.UploadWizard.config[ 'userName' ]
 159+ value: mw.config.get( 'wgUserName' )
160160 } )
161161 .keyup( function() {
162162 var thisInput = this;
Index: trunk/extensions/UploadWizard/resources/mw.DestinationChecker.js
@@ -138,7 +138,7 @@
139139
140140 if ( !data || !data.query || !data.query.pages ) {
141141 // Ignore a null result
142 - mw.log(" No data in checkUnique result");
 142+ mw.log("mw.DestinationChecker::checkUnique> No data in checkUnique result");
143143 return;
144144 }
145145
@@ -146,7 +146,7 @@
147147
148148 if ( data.query.pages[-1] ) {
149149 // No conflict found; this file name is unique
150 - mw.log(" No pages in checkUnique result");
 150+ mw.log("mw.DestinationChecker::checkUnique> No pages in checkUnique result");
151151 result = { isUnique: true };
152152
153153 } else {
@@ -157,7 +157,7 @@
158158 }
159159
160160 // Conflict found, this filename is NOT unique
161 - mw.log( " conflict! " );
 161+ mw.log( "mw.DestinationChecker::checkUnique> conflict! " );
162162
163163 var ntitle;
164164 if ( data.query.normalized ) {
Index: trunk/extensions/UploadWizard/resources/mw.Api.js
@@ -48,7 +48,7 @@
4949 // caller can supply handlers for http transport error or api errors
5050 err: function( code, result ) {
5151 var errorMsg = "mw.Api error: " + code;
52 - mw.log( errorMsg );
 52+ mw.log( _method + errorMsg );
5353 },
5454
5555 timeout: 30000, /* 30 seconds */
Index: trunk/extensions/UploadWizard/resources/mw.UtilitiesTime.js
@@ -15,7 +15,7 @@
1616 */
1717 mw.seconds2npt = function( sec, show_ms ) {
1818 if ( isNaN( sec ) ) {
19 - mw.log("Warning: trying to get npt time on NaN:" + sec);
 19+ mw.log("mw.seconds2npt> Warning: trying to get npt time on NaN:" + sec);
2020 return '0:00:00';
2121 }
2222
Index: trunk/extensions/UploadWizard/resources/mw.Api.edit.js
@@ -19,35 +19,36 @@
2020 */
2121 postWithEditToken: function( params, ok, err ) {
2222 var api = this;
 23+ var _method = 'mw.api.edit::postWithEditToken> ';
2324 mw.log( 'post with edit token' );
2425 if ( cachedToken === null ) {
25 - mw.log( 'no cached token' );
 26+ mw.log( _method + 'no cached token' );
2627 // We don't have a valid cached token, so get a fresh one and try posting.
2728 // We do not trap any 'badtoken' or 'notoken' errors, because we don't want
2829 // an infinite loop. If this fresh token is bad, something else is very wrong.
2930 var useTokenToPost = function( token ) {
30 - mw.log( 'posting with token = ' + token );
 31+ mw.log( _method + 'posting with token = ' + token );
3132 params.token = token;
3233 this.post( params, ok, err );
3334 };
34 - mw.log( 'getting edit token' );
 35+ mw.log( _method + 'getting edit token' );
3536 api.getEditToken( useTokenToPost, err );
3637 } else {
3738 // We do have a token, but it might be expired. So if it is 'bad' then
3839 // start over with a new token.
3940 params.token = cachedToken;
40 - mw.log( 'we do have a token = ' + params.token );
 41+ mw.log( _method + 'we do have a token = ' + params.token );
4142 var getTokenIfBad = function( code, result ) {
42 - mw.log( "error with posting with token!" );
 43+ mw.log( _method + "error with posting with token!" );
4344 if ( code === 'badtoken' ) {
44 - mw.log( "bad token; try again" );
 45+ mw.log( _method + "bad token; try again" );
4546 cachedToken = null; // force a new token
4647 api.postWidthEditToken( params, ok, err );
4748 } else {
4849 err( code, result );
4950 }
5051 };
51 - mw.log ( "posting with the token that was cached " );
 52+ mw.log ( _method + "posting with the token that was cached " );
5253 api.post( params, ok, getTokenIfBad );
5354 }
5455 },
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js
@@ -227,7 +227,7 @@
228228
229229 this.api.get( params, function( data ) {
230230 if ( !data || !data.query || !data.query.stashimageinfo ) {
231 - mw.log(" No data? ");
 231+ mw.log("mw.UploadWizardUpload::getThumbnail> No data? ");
232232 // XXX do something about the thumbnail spinner, maybe call the callback with a broken image.
233233 return;
234234 }
@@ -235,7 +235,7 @@
236236 for ( var i = 0; i < thumbnails.length; i++ ) {
237237 var thumb = thumbnails[i];
238238 if ( ! ( thumb.thumburl && thumb.thumbwidth && thumb.thumbheight ) ) {
239 - mw.log( "thumbnail missing information" );
 239+ mw.log( "mw.UploadWizardUpload::getThumbnail> thumbnail missing information" );
240240 // XXX error
241241 }
242242 var image = document.createElement( 'img' );
@@ -927,7 +927,7 @@
928928
929929 mw.UploadWizardUtil.makeToggler( moreDetailsCtrlDiv, moreDetailsDiv );
930930
931 - _this.addDescription( true, mw.UploadWizard.config[ 'userLanguage' ] );
 931+ _this.addDescription( true, mw.config.get( 'wgUserLanguage' ) );
932932 $j( containerDiv ).append( _this.div );
933933
934934 // make this a category picker
@@ -1189,7 +1189,7 @@
11901190 */
11911191 populate: function() {
11921192 var _this = this;
1193 - mw.log( "populating details from upload" );
 1193+ mw.log( "mw.UploadWizardUpload::populate> populating details from upload" );
11941194 _this.upload.setThumbnail( _this.thumbnailDiv, mw.UploadWizard.config['thumbnailWidth'], mw.UploadWizard.config['thumbnailMaxHeight'] );
11951195 _this.prefillDate();
11961196 _this.prefillSource();
@@ -1439,7 +1439,7 @@
14401440
14411441 // XXX check state of details for okayness ( license selected, at least one desc, sane filename )
14421442 var wikiText = _this.getWikiText();
1443 - mw.log( wikiText );
 1443+ mw.log( "mw.UploadWizardUpload::submit> submiting wikiText:\n" + wikiText );
14441444
14451445 var params = {
14461446 action: 'upload',
@@ -1454,11 +1454,10 @@
14551455 _this.completeDetailsSubmission();
14561456 };
14571457
1458 - mw.log( "uploading!" );
1459 - mw.log( params );
 1458+ mw.log( "mw.UploadWizardUpload::submit> uploading: \n" + params );
14601459 var callback = function( result ) {
1461 - mw.log( result );
1462 - mw.log( "successful upload" );
 1460+ mw.log( "mw.UploadWizardUpload::submit> result:\n" + result );
 1461+ mw.log( "mw.UploadWizardUpload::submit> successful upload" );
14631462 finalCallback( result );
14641463 };
14651464
@@ -1815,13 +1814,13 @@
18161815 $j( upload.ui.div ).bind( 'filenameAccepted', function(e) { _this.updateFileCounts(); e.stopPropagation(); } );
18171816 $j( upload.ui.div ).bind( 'removeUploadEvent', function(e) { _this.removeUpload( upload ); e.stopPropagation(); } );
18181817 $j( upload.ui.div ).bind( 'filled', function(e) {
1819 - mw.log( "filled! received!" );
 1818+ mw.log( "mw.UploadWizardUpload::newUpload> filled! received!" );
18201819 _this.newUpload();
1821 - mw.log( "filled! new upload!" );
 1820+ mw.log( "mw.UploadWizardUpload::newUpload> filled! new upload!" );
18221821 _this.setUploadFilled(upload);
1823 - mw.log( "filled! set upload filled!" );
 1822+ mw.log( "mw.UploadWizardUpload::newUpload> filled! set upload filled!" );
18241823 e.stopPropagation();
1825 - mw.log( "filled! stop propagation!" );
 1824+ mw.log( "mw.UploadWizardUpload::newUpload> filled! stop propagation!" );
18261825 } );
18271826 // XXX bind to some error state
18281827
@@ -2019,7 +2018,7 @@
20202019 function( upload ) {
20212020 upload.start();
20222021 },
2023 - function() {
 2022+ function() {
20242023 allowCloseWindow();
20252024 $j().notify( gM( 'mwe-upwiz-files-complete' ) );
20262025 _this.showFileNext();
@@ -2053,7 +2052,7 @@
20542053 } else if ( upload.state === 'stashed' ) {
20552054 stashedCount++;
20562055 } else {
2057 - mw.log( "upload " + i + " not in appropriate state for filenext: " + upload.state );
 2056+ mw.log( "mw.UploadWizardUpload::showFileNext> upload " + i + " not in appropriate state for filenext: " + upload.state );
20582057 }
20592058 } );
20602059 var selector = null;
Index: trunk/extensions/UploadWizard/resources/mw.ApiUploadHandler.js
@@ -39,7 +39,7 @@
4040 */
4141 configureForm: function() {
4242 var _this = this;
43 - mw.log( "configuring form for Upload API" );
 43+ mw.log( "mw.ApiUploadHandler::configureForm> configuring form for Upload API" );
4444
4545 _this.addFormInputIfMissing( 'action', 'upload' );
4646
@@ -93,7 +93,7 @@
9494 start: function() {
9595 var _this = this;
9696 var ok = function() {
97 - mw.log( "api: upload start!" );
 97+ mw.log( "mw.ApiUploadHandler::start> upload start!" );
9898 _this.beginTime = ( new Date() ).getTime();
9999 _this.upload.ui.setStatus( 'mwe-upwiz-transport-started' );
100100 _this.upload.ui.showTransportProgress();
Index: trunk/extensions/UploadWizard/resources/mw.UploadApiProcessor.js
@@ -73,13 +73,13 @@
7474 */
7575 processResult: function( result ) {
7676 var _this = this;
77 - mw.log( 'processResult::' );
 77+ mw.log( 'mw.UploadApiProcessor::processResult> ' );
7878
7979
8080 var parsedResult = _this.parseResult(result);
8181
8282 if ( _this.doneCb && typeof _this.doneCb == 'function' ) {
83 - mw.log( "call doneCb" );
 83+ mw.log( "mw.UploadApiProcessor::processResult> call doneCb" );
8484 _this.doneCb( parsedResult );
8585
8686 }
@@ -130,7 +130,7 @@
131131
132132 if ( !error_code || error_code == 'unknown-error' ) {
133133 if ( typeof JSON != 'undefined' ) {
134 - mw.log( 'Error: result: ' + JSON.stringify( result ) );
 134+ mw.log( 'mw.UploadApiProcessor::parseResult> Error: result: ' + JSON.stringify( result ) );
135135 }
136136 if ( result.upload.error == 'internal-error' ) {
137137 // Do a remote message load
@@ -172,14 +172,14 @@
173173 return false;
174174 }
175175
176 - mw.log( 'get key: ' + _this.error_msg_key[ error_code ] );
 176+ mw.log( 'mw.UploadApiProcessor::parseResult> get key: ' + _this.error_msg_key[ error_code ] );
177177 mw.getRemoteMsg( _this.error_msg_key[ error_code ], function() {
178178 _this.ui.setPrompt(
179179 gM( 'mwe-uploaderror' ),
180180 gM( _this.error_msg_key[ error_code ], errorReplaceArg ),
181181 buttons );
182182 });
183 - mw.log( "api.error" );
 183+ mw.log( "mw.UploadApiProcessor::parseResult> api.error" );
184184 return false;
185185 }
186186
Index: trunk/extensions/UploadWizard/resources/mw.IframeTransport.js
@@ -42,21 +42,21 @@
4343 * Ensure callback on completion of upload
4444 */
4545 configureForm: function() {
46 - mw.log( "configuring form for iframe transport" );
 46+ mw.log( "mw.IframeTransport::configureForm> configuring form for iframe transport" );
4747 // Set the form target to the iframe
4848 this.$form.attr( 'target', this.iframeId );
4949
5050 // attach an additional handler to the form, so, when submitted, it starts showing the progress
5151 // XXX this is lame .. there should be a generic way to indicate busy status...
5252 this.$form.submit( function() {
53 - mw.log( "submitting to iframe..." );
 53+ mw.log( "mw.IframeTransport::configureForm> submitting to iframe..." );
5454 return true;
5555 } );
5656
5757 // Set up the completion callback
5858 var _this = this;
5959 $j( '#' + this.iframeId ).load( function() {
60 - mw.log( "received result in iframe" );
 60+ mw.log( "mw.IframeTransport::configureForm> received result in iframe" );
6161 _this.progressCb( 1.0 );
6262 _this.processIframeResult( $j( this ).get( 0 ) );
6363 } );
@@ -73,13 +73,13 @@
7474 var doc = iframe.contentDocument ? iframe.contentDocument : frames[iframe.id].document;
7575 // Fix for Opera 9.26
7676 if ( doc.readyState && doc.readyState != 'complete' ) {
77 - mw.log( "not complete" );
 77+ mw.log( "mw.IframeTransport::processIframeResult> not complete" );
7878 return;
7979 }
8080
8181 // Fix for Opera 9.64
8282 if ( doc.body && doc.body.innerHTML == "false" ) {
83 - mw.log( "no innerhtml" );
 83+ mw.log( "mw.IframeTransport::processIframeResult> innerhtml" );
8484 return;
8585 }
8686 var response;
@@ -92,7 +92,7 @@
9393 // according to mdale we need to do this
9494 // because IE does not load JSON properly in an iframe
9595 json = $j( doc.body ).find( 'pre' ).text();
96 - mw.log( 'iframe:json::' + json );
 96+ mw.log( "mw.IframeTransport::processIframeResult> iframe:json::" + json );
9797 // check that the JSON is not an XML error message
9898 // (this happens when user aborts upload, we get the API docs in XML wrapped in HTML)
9999 if ( json && json.substring(0, 5) !== '<?xml' ) {
Index: trunk/extensions/UploadWizard/UploadWizard.php
@@ -30,18 +30,18 @@
3131
3232
3333
34 -$dir = dirname( __FILE__ );
 34+$wgUpwizDir = dirname( __FILE__ );
3535
36 -$wgExtensionMessagesFiles['UploadWizard'] = $dir . '/UploadWizard.i18n.php';
37 -$wgExtensionAliasesFiles['UploadWizard'] = $dir . '/UploadWizard.alias.php';
 36+$wgExtensionMessagesFiles['UploadWizard'] = $wgUpwizDir . '/UploadWizard.i18n.php';
 37+$wgExtensionAliasesFiles['UploadWizard'] = $wgUpwizDir . '/UploadWizard.alias.php';
3838
39 -# Require modules, includeing the special page
 39+# Require modules, including the special page
4040 foreach ( array( 'SpecialUploadWizard',
4141 'UploadWizardMessages',
4242 'UploadWizardHooks',
4343 'UploadWizardTutorial',
4444 'UploadWizardDependencyLoader' ) as $module ) {
45 - $wgAutoloadLocalClasses[$module] = $dir . "/" . $module . ".php";
 45+ $wgAutoloadLocalClasses[$module] = $wgUpwizDir . "/" . $module . ".php";
4646 }
4747
4848
@@ -60,3 +60,8 @@
6161 // for ResourceLoader
6262 $wgHooks['ResourceLoaderRegisterModules'][] = 'UploadWizardHooks::resourceLoaderRegisterModules';
6363 $wgHooks['CanonicalNamespaces'][] = 'UploadWizardHooks::canonicalNamespaces';
 64+
 65+// Init the upload wizard config array
 66+// UploadWizard.config.php includes default configuration
 67+// any value can be modified in localSettings.php by setting $wgUploadWizardConfig['name'] = 'value;
 68+$wgUploadWizardConfig = array();
Index: trunk/extensions/UploadWizard/SpecialUploadWizard.php
@@ -38,7 +38,7 @@
3939 */
4040 public function execute( $subPage ) {
4141 global $wgLang, $wgUser, $wgOut, $wgExtensionAssetsPath,
42 - $wgUploadWizardDebug, $wgUploadWizardDisableResourceLoader;
 42+ $wgUploadWizardDisableResourceLoader;
4343
4444 // side effects: if we can't upload, will print error page to wgOut
4545 // and return false
@@ -65,7 +65,7 @@
6666 } else {
6767 $basepath = "$wgExtensionAssetsPath/UploadWizard";
6868 $dependencyLoader = new UploadWizardDependencyLoader( $wgLang->getCode() );
69 - if ( $wgUploadWizardDebug ) {
 69+ if ( $wgUploadWizardConfig['debug'] ) {
7070 // each file as an individual script or style
7171 $dependencyLoader->outputHtmlDebug( $wgOut, $basepath );
7272 } else {
@@ -82,35 +82,34 @@
8383
8484 /**
8585 * Adds some global variables for our use, as well as initializes the UploadWizard
 86+ *
 87+ * TODO once bug https://bugzilla.wikimedia.org/show_bug.cgi?id=26901
 88+ * is fixed we should package configuration with the upload wizard instead of
 89+ * in uploadWizard output page.
 90+ *
8691 * @param subpage, e.g. the "foo" in Special:UploadWizard/foo
8792 */
8893 public function addJsVars( $subPage ) {
89 - global $wgUser, $wgOut, $wgUseAjax, $wgAjaxLicensePreview, $wgEnableAPI,
90 - $wgEnableFirefogg, $wgFileExtensions,$wgUploadWizardDebug, $wgSitename,
91 - $wgUploadWizardAutoCategory;
 94+ global $wgOut, $wgUpwizDir, $wgUploadWizardConfig, $wgSitename;
9295
93 - $wgOut->addScript( Skin::makeVariablesScript( array(
94 - 'wgUploadWizardDebug' => (bool)$wgUploadWizardDebug,
95 -
96 - 'wgUploadWizardAutoCategory' => $wgUploadWizardAutoCategory,
 96+ // Merge the default configuration with the local settings $wgUploadWizardConfig configuration
 97+ $configPath = $wgUpwizDir . '/UploadWizard.config.php';
 98+ if( is_file( $configPath ) ){
 99+ $wgUploadWizardConfig = array_merge( include( $configPath ), $wgUploadWizardConfig );
 100+ }
 101+
 102+ $wgOut->addScript(
 103+ Skin::makeVariablesScript(
 104+ array(
 105+ 'UploadWizardConfig' => $wgUploadWizardConfig
 106+ ) +
 107+ // Site name is a true global not specific to Upload Wizard
 108+ array(
 109+ 'wgSiteName' => $wgSitename
 110+ )
 111+ )
 112+ );
97113
98 - // uncertain if this is relevant. Can we do license preview with API?
99 - 'wgAjaxLicensePreview' => $wgUseAjax && $wgAjaxLicensePreview,
100 -
101 - 'wgEnableFirefogg' => (bool)$wgEnableFirefogg,
102 -
103 - // what is acceptable in this wiki
104 - 'wgFileExtensions' => $wgFileExtensions,
105 -
106 - 'wgSubPage' => $subPage,
107 -
108 - // XXX need to have a better function for testing viability of a filename
109 - // 'wgFilenamePrefixBlacklist' => UploadBase::getFilenamePrefixBlacklist()
110 -
111 - 'wgSitename' => $wgSitename
112 -
113 - ) ) );
114 -
115114 }
116115
117116 /**
Index: trunk/extensions/UploadWizard/UploadWizardPage.js
@@ -9,72 +9,10 @@
1010 // create UploadWizard
1111 mw.UploadWizardPage = function() {
1212
13 - var apiUrl = false;
14 - if ( typeof wgServer != 'undefined' && typeof wgScriptPath != 'undefined' ) {
15 - apiUrl = wgServer + wgScriptPath + '/api.php';
16 - }
17 -
18 - var config = {
19 - debug: wgUploadWizardDebug,
20 - autoCategory: wgUploadWizardAutoCategory,
21 - userName: wgUserName,
22 - userLanguage: wgUserLanguage,
23 - fileExtensions: wgFileExtensions,
24 - apiUrl: apiUrl,
25 -
26 - thumbnailWidth: 120,
27 - thumbnailMaxHeight: 200,
28 - smallThumbnailWidth: 60,
29 - smallThumbnailMaxHeight: 100,
30 - iconThumbnailWidth: 32,
31 - iconThumbnailMaxHeight: 32,
32 - maxAuthorLength: 50,
33 - minAuthorLength: 2,
34 - maxSourceLength: 200,
35 - minSourceLength: 5,
36 - maxTitleLength: 200,
37 - minTitleLength: 5,
38 - maxDescriptionLength: 4096,
39 - minDescriptionLength: 5,
40 - maxOtherInformationLength: 4096,
41 - maxSimultaneousConnections: 1,
42 - maxUploads: 10,
43 -
44 - // not for use with all wikis.
45 - // The ISO 639 code for the language tagalog is "tl".
46 - // Normally we name templates for languages by the ISO 639 code.
47 - // Commons already had a template called 'tl: though.
48 - // so, this workaround will cause tagalog descriptions to be saved with this template instead.
49 - languageTemplateFixups: { tl: 'tgl' },
50 -
51 - // names of all license templates, in order. Case sensitive!
52 - // n.b. in the future, the licenses for a wiki will probably be defined in PHP or even LocalSettings.
53 - licenses: [
54 - { template: 'Cc-by-sa-3.0', messageKey: 'mwe-upwiz-license-cc-by-sa-3.0', 'default': true },
55 - { template: 'Cc-by-3.0', messageKey: 'mwe-upwiz-license-cc-by-3.0', 'default': false },
56 - { template: 'Cc-zero', messageKey: 'mwe-upwiz-license-cc-zero', 'default': false },
57 - // n.b. the PD-US is only for testing purposes, obviously we need some geographical discrimination here...
58 - { template: 'PD-US', messageKey: 'mwe-upwiz-license-pd-us', 'default': false },
59 - { template: 'GFDL', messageKey: 'mwe-upwiz-license-gfdl', 'default': false }
60 - ]
61 -
62 - // XXX this is horribly confusing -- some file restrictions are client side, others are server side
63 - // the filename prefix blacklist is at least server side -- all this should be replaced with PHP regex config
64 - // or actually, in an ideal world, we'd have some way to reliably detect gibberish, rather than trying to
65 - // figure out what is bad via individual regexes, we'd detect badness. Might not be too hard.
66 - //
67 - // we can export these to JS if we so want.
68 - // filenamePrefixBlacklist: wgFilenamePrefixBlacklist,
69 - //
70 - // filenameRegexBlacklist: [
71 - // /^(test|image|img|bild|example?[\s_-]*)$/, // test stuff
72 - // /^(\d{10}[\s_-][0-9a-f]{10}[\s_-][a-z])$/ // flickr
73 - // ]
74 - };
75 -
 13+ var config = mw.config.get( 'UploadWizardConfig' );
7614 if ( !config.debug ) {
7715 mw.log.level = mw.log.NONE;
78 - }
 16+ }
7917
8018 var uploadWizard = new mw.UploadWizard( config );
8119 uploadWizard.createInterface( '#upload-wizard' );
@@ -84,7 +22,11 @@
8523 jQuery( document ).ready( function() {
8624 // add "magic" to Language template parser for keywords
8725
88 - var options = { magic: { 'SITENAME' : wgSitename } };
 26+ var options = {
 27+ magic: {
 28+ 'SITENAME' : mw.config.get('wgSitename')
 29+ }
 30+ };
8931
9032 window.gM = mediaWiki.language.getMessageFunction( options );
9133 $j.fn.msg = mediaWiki.language.getJqueryMessagePlugin( options );

Status & tagging log