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 @@ |
89 | 89 | // XXX do we need to escape authorInput, or is wikitext a feature here? |
90 | 90 | // what about scripts? |
91 | 91 | getAuthorWikiText: function() { |
92 | | - return "[[User:" + mw.UploadWizard.config[ 'userName' ] + '|' + $j( _this.authorInput ).val() + ']]'; |
| 92 | + return "[[User:" + mw.config.get( 'wgUserName' ) + '|' + $j( _this.authorInput ).val() + ']]'; |
93 | 93 | }, |
94 | 94 | |
95 | 95 | |
— | — | @@ -155,7 +155,7 @@ |
156 | 156 | $formFields.find( '.mwe-upwiz-sign' ) |
157 | 157 | .attr( { |
158 | 158 | title: gM( 'mwe-upwiz-tooltip-sign' ), |
159 | | - value: mw.UploadWizard.config[ 'userName' ] |
| 159 | + value: mw.config.get( 'wgUserName' ) |
160 | 160 | } ) |
161 | 161 | .keyup( function() { |
162 | 162 | var thisInput = this; |
Index: trunk/extensions/UploadWizard/resources/mw.DestinationChecker.js |
— | — | @@ -138,7 +138,7 @@ |
139 | 139 | |
140 | 140 | if ( !data || !data.query || !data.query.pages ) { |
141 | 141 | // Ignore a null result |
142 | | - mw.log(" No data in checkUnique result"); |
| 142 | + mw.log("mw.DestinationChecker::checkUnique> No data in checkUnique result"); |
143 | 143 | return; |
144 | 144 | } |
145 | 145 | |
— | — | @@ -146,7 +146,7 @@ |
147 | 147 | |
148 | 148 | if ( data.query.pages[-1] ) { |
149 | 149 | // 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"); |
151 | 151 | result = { isUnique: true }; |
152 | 152 | |
153 | 153 | } else { |
— | — | @@ -157,7 +157,7 @@ |
158 | 158 | } |
159 | 159 | |
160 | 160 | // Conflict found, this filename is NOT unique |
161 | | - mw.log( " conflict! " ); |
| 161 | + mw.log( "mw.DestinationChecker::checkUnique> conflict! " ); |
162 | 162 | |
163 | 163 | var ntitle; |
164 | 164 | if ( data.query.normalized ) { |
Index: trunk/extensions/UploadWizard/resources/mw.Api.js |
— | — | @@ -48,7 +48,7 @@ |
49 | 49 | // caller can supply handlers for http transport error or api errors |
50 | 50 | err: function( code, result ) { |
51 | 51 | var errorMsg = "mw.Api error: " + code; |
52 | | - mw.log( errorMsg ); |
| 52 | + mw.log( _method + errorMsg ); |
53 | 53 | }, |
54 | 54 | |
55 | 55 | timeout: 30000, /* 30 seconds */ |
Index: trunk/extensions/UploadWizard/resources/mw.UtilitiesTime.js |
— | — | @@ -15,7 +15,7 @@ |
16 | 16 | */ |
17 | 17 | mw.seconds2npt = function( sec, show_ms ) { |
18 | 18 | 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); |
20 | 20 | return '0:00:00'; |
21 | 21 | } |
22 | 22 | |
Index: trunk/extensions/UploadWizard/resources/mw.Api.edit.js |
— | — | @@ -19,35 +19,36 @@ |
20 | 20 | */ |
21 | 21 | postWithEditToken: function( params, ok, err ) { |
22 | 22 | var api = this; |
| 23 | + var _method = 'mw.api.edit::postWithEditToken> '; |
23 | 24 | mw.log( 'post with edit token' ); |
24 | 25 | if ( cachedToken === null ) { |
25 | | - mw.log( 'no cached token' ); |
| 26 | + mw.log( _method + 'no cached token' ); |
26 | 27 | // We don't have a valid cached token, so get a fresh one and try posting. |
27 | 28 | // We do not trap any 'badtoken' or 'notoken' errors, because we don't want |
28 | 29 | // an infinite loop. If this fresh token is bad, something else is very wrong. |
29 | 30 | var useTokenToPost = function( token ) { |
30 | | - mw.log( 'posting with token = ' + token ); |
| 31 | + mw.log( _method + 'posting with token = ' + token ); |
31 | 32 | params.token = token; |
32 | 33 | this.post( params, ok, err ); |
33 | 34 | }; |
34 | | - mw.log( 'getting edit token' ); |
| 35 | + mw.log( _method + 'getting edit token' ); |
35 | 36 | api.getEditToken( useTokenToPost, err ); |
36 | 37 | } else { |
37 | 38 | // We do have a token, but it might be expired. So if it is 'bad' then |
38 | 39 | // start over with a new token. |
39 | 40 | params.token = cachedToken; |
40 | | - mw.log( 'we do have a token = ' + params.token ); |
| 41 | + mw.log( _method + 'we do have a token = ' + params.token ); |
41 | 42 | var getTokenIfBad = function( code, result ) { |
42 | | - mw.log( "error with posting with token!" ); |
| 43 | + mw.log( _method + "error with posting with token!" ); |
43 | 44 | if ( code === 'badtoken' ) { |
44 | | - mw.log( "bad token; try again" ); |
| 45 | + mw.log( _method + "bad token; try again" ); |
45 | 46 | cachedToken = null; // force a new token |
46 | 47 | api.postWidthEditToken( params, ok, err ); |
47 | 48 | } else { |
48 | 49 | err( code, result ); |
49 | 50 | } |
50 | 51 | }; |
51 | | - mw.log ( "posting with the token that was cached " ); |
| 52 | + mw.log ( _method + "posting with the token that was cached " ); |
52 | 53 | api.post( params, ok, getTokenIfBad ); |
53 | 54 | } |
54 | 55 | }, |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js |
— | — | @@ -227,7 +227,7 @@ |
228 | 228 | |
229 | 229 | this.api.get( params, function( data ) { |
230 | 230 | if ( !data || !data.query || !data.query.stashimageinfo ) { |
231 | | - mw.log(" No data? "); |
| 231 | + mw.log("mw.UploadWizardUpload::getThumbnail> No data? "); |
232 | 232 | // XXX do something about the thumbnail spinner, maybe call the callback with a broken image. |
233 | 233 | return; |
234 | 234 | } |
— | — | @@ -235,7 +235,7 @@ |
236 | 236 | for ( var i = 0; i < thumbnails.length; i++ ) { |
237 | 237 | var thumb = thumbnails[i]; |
238 | 238 | if ( ! ( thumb.thumburl && thumb.thumbwidth && thumb.thumbheight ) ) { |
239 | | - mw.log( "thumbnail missing information" ); |
| 239 | + mw.log( "mw.UploadWizardUpload::getThumbnail> thumbnail missing information" ); |
240 | 240 | // XXX error |
241 | 241 | } |
242 | 242 | var image = document.createElement( 'img' ); |
— | — | @@ -927,7 +927,7 @@ |
928 | 928 | |
929 | 929 | mw.UploadWizardUtil.makeToggler( moreDetailsCtrlDiv, moreDetailsDiv ); |
930 | 930 | |
931 | | - _this.addDescription( true, mw.UploadWizard.config[ 'userLanguage' ] ); |
| 931 | + _this.addDescription( true, mw.config.get( 'wgUserLanguage' ) ); |
932 | 932 | $j( containerDiv ).append( _this.div ); |
933 | 933 | |
934 | 934 | // make this a category picker |
— | — | @@ -1189,7 +1189,7 @@ |
1190 | 1190 | */ |
1191 | 1191 | populate: function() { |
1192 | 1192 | var _this = this; |
1193 | | - mw.log( "populating details from upload" ); |
| 1193 | + mw.log( "mw.UploadWizardUpload::populate> populating details from upload" ); |
1194 | 1194 | _this.upload.setThumbnail( _this.thumbnailDiv, mw.UploadWizard.config['thumbnailWidth'], mw.UploadWizard.config['thumbnailMaxHeight'] ); |
1195 | 1195 | _this.prefillDate(); |
1196 | 1196 | _this.prefillSource(); |
— | — | @@ -1439,7 +1439,7 @@ |
1440 | 1440 | |
1441 | 1441 | // XXX check state of details for okayness ( license selected, at least one desc, sane filename ) |
1442 | 1442 | var wikiText = _this.getWikiText(); |
1443 | | - mw.log( wikiText ); |
| 1443 | + mw.log( "mw.UploadWizardUpload::submit> submiting wikiText:\n" + wikiText ); |
1444 | 1444 | |
1445 | 1445 | var params = { |
1446 | 1446 | action: 'upload', |
— | — | @@ -1454,11 +1454,10 @@ |
1455 | 1455 | _this.completeDetailsSubmission(); |
1456 | 1456 | }; |
1457 | 1457 | |
1458 | | - mw.log( "uploading!" ); |
1459 | | - mw.log( params ); |
| 1458 | + mw.log( "mw.UploadWizardUpload::submit> uploading: \n" + params ); |
1460 | 1459 | 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" ); |
1463 | 1462 | finalCallback( result ); |
1464 | 1463 | }; |
1465 | 1464 | |
— | — | @@ -1815,13 +1814,13 @@ |
1816 | 1815 | $j( upload.ui.div ).bind( 'filenameAccepted', function(e) { _this.updateFileCounts(); e.stopPropagation(); } ); |
1817 | 1816 | $j( upload.ui.div ).bind( 'removeUploadEvent', function(e) { _this.removeUpload( upload ); e.stopPropagation(); } ); |
1818 | 1817 | $j( upload.ui.div ).bind( 'filled', function(e) { |
1819 | | - mw.log( "filled! received!" ); |
| 1818 | + mw.log( "mw.UploadWizardUpload::newUpload> filled! received!" ); |
1820 | 1819 | _this.newUpload(); |
1821 | | - mw.log( "filled! new upload!" ); |
| 1820 | + mw.log( "mw.UploadWizardUpload::newUpload> filled! new upload!" ); |
1822 | 1821 | _this.setUploadFilled(upload); |
1823 | | - mw.log( "filled! set upload filled!" ); |
| 1822 | + mw.log( "mw.UploadWizardUpload::newUpload> filled! set upload filled!" ); |
1824 | 1823 | e.stopPropagation(); |
1825 | | - mw.log( "filled! stop propagation!" ); |
| 1824 | + mw.log( "mw.UploadWizardUpload::newUpload> filled! stop propagation!" ); |
1826 | 1825 | } ); |
1827 | 1826 | // XXX bind to some error state |
1828 | 1827 | |
— | — | @@ -2019,7 +2018,7 @@ |
2020 | 2019 | function( upload ) { |
2021 | 2020 | upload.start(); |
2022 | 2021 | }, |
2023 | | - function() { |
| 2022 | + function() { |
2024 | 2023 | allowCloseWindow(); |
2025 | 2024 | $j().notify( gM( 'mwe-upwiz-files-complete' ) ); |
2026 | 2025 | _this.showFileNext(); |
— | — | @@ -2053,7 +2052,7 @@ |
2054 | 2053 | } else if ( upload.state === 'stashed' ) { |
2055 | 2054 | stashedCount++; |
2056 | 2055 | } 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 ); |
2058 | 2057 | } |
2059 | 2058 | } ); |
2060 | 2059 | var selector = null; |
Index: trunk/extensions/UploadWizard/resources/mw.ApiUploadHandler.js |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | */ |
41 | 41 | configureForm: function() { |
42 | 42 | var _this = this; |
43 | | - mw.log( "configuring form for Upload API" ); |
| 43 | + mw.log( "mw.ApiUploadHandler::configureForm> configuring form for Upload API" ); |
44 | 44 | |
45 | 45 | _this.addFormInputIfMissing( 'action', 'upload' ); |
46 | 46 | |
— | — | @@ -93,7 +93,7 @@ |
94 | 94 | start: function() { |
95 | 95 | var _this = this; |
96 | 96 | var ok = function() { |
97 | | - mw.log( "api: upload start!" ); |
| 97 | + mw.log( "mw.ApiUploadHandler::start> upload start!" ); |
98 | 98 | _this.beginTime = ( new Date() ).getTime(); |
99 | 99 | _this.upload.ui.setStatus( 'mwe-upwiz-transport-started' ); |
100 | 100 | _this.upload.ui.showTransportProgress(); |
Index: trunk/extensions/UploadWizard/resources/mw.UploadApiProcessor.js |
— | — | @@ -73,13 +73,13 @@ |
74 | 74 | */ |
75 | 75 | processResult: function( result ) { |
76 | 76 | var _this = this; |
77 | | - mw.log( 'processResult::' ); |
| 77 | + mw.log( 'mw.UploadApiProcessor::processResult> ' ); |
78 | 78 | |
79 | 79 | |
80 | 80 | var parsedResult = _this.parseResult(result); |
81 | 81 | |
82 | 82 | if ( _this.doneCb && typeof _this.doneCb == 'function' ) { |
83 | | - mw.log( "call doneCb" ); |
| 83 | + mw.log( "mw.UploadApiProcessor::processResult> call doneCb" ); |
84 | 84 | _this.doneCb( parsedResult ); |
85 | 85 | |
86 | 86 | } |
— | — | @@ -130,7 +130,7 @@ |
131 | 131 | |
132 | 132 | if ( !error_code || error_code == 'unknown-error' ) { |
133 | 133 | if ( typeof JSON != 'undefined' ) { |
134 | | - mw.log( 'Error: result: ' + JSON.stringify( result ) ); |
| 134 | + mw.log( 'mw.UploadApiProcessor::parseResult> Error: result: ' + JSON.stringify( result ) ); |
135 | 135 | } |
136 | 136 | if ( result.upload.error == 'internal-error' ) { |
137 | 137 | // Do a remote message load |
— | — | @@ -172,14 +172,14 @@ |
173 | 173 | return false; |
174 | 174 | } |
175 | 175 | |
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 ] ); |
177 | 177 | mw.getRemoteMsg( _this.error_msg_key[ error_code ], function() { |
178 | 178 | _this.ui.setPrompt( |
179 | 179 | gM( 'mwe-uploaderror' ), |
180 | 180 | gM( _this.error_msg_key[ error_code ], errorReplaceArg ), |
181 | 181 | buttons ); |
182 | 182 | }); |
183 | | - mw.log( "api.error" ); |
| 183 | + mw.log( "mw.UploadApiProcessor::parseResult> api.error" ); |
184 | 184 | return false; |
185 | 185 | } |
186 | 186 | |
Index: trunk/extensions/UploadWizard/resources/mw.IframeTransport.js |
— | — | @@ -42,21 +42,21 @@ |
43 | 43 | * Ensure callback on completion of upload |
44 | 44 | */ |
45 | 45 | configureForm: function() { |
46 | | - mw.log( "configuring form for iframe transport" ); |
| 46 | + mw.log( "mw.IframeTransport::configureForm> configuring form for iframe transport" ); |
47 | 47 | // Set the form target to the iframe |
48 | 48 | this.$form.attr( 'target', this.iframeId ); |
49 | 49 | |
50 | 50 | // attach an additional handler to the form, so, when submitted, it starts showing the progress |
51 | 51 | // XXX this is lame .. there should be a generic way to indicate busy status... |
52 | 52 | this.$form.submit( function() { |
53 | | - mw.log( "submitting to iframe..." ); |
| 53 | + mw.log( "mw.IframeTransport::configureForm> submitting to iframe..." ); |
54 | 54 | return true; |
55 | 55 | } ); |
56 | 56 | |
57 | 57 | // Set up the completion callback |
58 | 58 | var _this = this; |
59 | 59 | $j( '#' + this.iframeId ).load( function() { |
60 | | - mw.log( "received result in iframe" ); |
| 60 | + mw.log( "mw.IframeTransport::configureForm> received result in iframe" ); |
61 | 61 | _this.progressCb( 1.0 ); |
62 | 62 | _this.processIframeResult( $j( this ).get( 0 ) ); |
63 | 63 | } ); |
— | — | @@ -73,13 +73,13 @@ |
74 | 74 | var doc = iframe.contentDocument ? iframe.contentDocument : frames[iframe.id].document; |
75 | 75 | // Fix for Opera 9.26 |
76 | 76 | if ( doc.readyState && doc.readyState != 'complete' ) { |
77 | | - mw.log( "not complete" ); |
| 77 | + mw.log( "mw.IframeTransport::processIframeResult> not complete" ); |
78 | 78 | return; |
79 | 79 | } |
80 | 80 | |
81 | 81 | // Fix for Opera 9.64 |
82 | 82 | if ( doc.body && doc.body.innerHTML == "false" ) { |
83 | | - mw.log( "no innerhtml" ); |
| 83 | + mw.log( "mw.IframeTransport::processIframeResult> innerhtml" ); |
84 | 84 | return; |
85 | 85 | } |
86 | 86 | var response; |
— | — | @@ -92,7 +92,7 @@ |
93 | 93 | // according to mdale we need to do this |
94 | 94 | // because IE does not load JSON properly in an iframe |
95 | 95 | json = $j( doc.body ).find( 'pre' ).text(); |
96 | | - mw.log( 'iframe:json::' + json ); |
| 96 | + mw.log( "mw.IframeTransport::processIframeResult> iframe:json::" + json ); |
97 | 97 | // check that the JSON is not an XML error message |
98 | 98 | // (this happens when user aborts upload, we get the API docs in XML wrapped in HTML) |
99 | 99 | if ( json && json.substring(0, 5) !== '<?xml' ) { |
Index: trunk/extensions/UploadWizard/UploadWizard.php |
— | — | @@ -30,18 +30,18 @@ |
31 | 31 | |
32 | 32 | |
33 | 33 | |
34 | | -$dir = dirname( __FILE__ ); |
| 34 | +$wgUpwizDir = dirname( __FILE__ ); |
35 | 35 | |
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'; |
38 | 38 | |
39 | | -# Require modules, includeing the special page |
| 39 | +# Require modules, including the special page |
40 | 40 | foreach ( array( 'SpecialUploadWizard', |
41 | 41 | 'UploadWizardMessages', |
42 | 42 | 'UploadWizardHooks', |
43 | 43 | 'UploadWizardTutorial', |
44 | 44 | 'UploadWizardDependencyLoader' ) as $module ) { |
45 | | - $wgAutoloadLocalClasses[$module] = $dir . "/" . $module . ".php"; |
| 45 | + $wgAutoloadLocalClasses[$module] = $wgUpwizDir . "/" . $module . ".php"; |
46 | 46 | } |
47 | 47 | |
48 | 48 | |
— | — | @@ -60,3 +60,8 @@ |
61 | 61 | // for ResourceLoader |
62 | 62 | $wgHooks['ResourceLoaderRegisterModules'][] = 'UploadWizardHooks::resourceLoaderRegisterModules'; |
63 | 63 | $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 @@ |
39 | 39 | */ |
40 | 40 | public function execute( $subPage ) { |
41 | 41 | global $wgLang, $wgUser, $wgOut, $wgExtensionAssetsPath, |
42 | | - $wgUploadWizardDebug, $wgUploadWizardDisableResourceLoader; |
| 42 | + $wgUploadWizardDisableResourceLoader; |
43 | 43 | |
44 | 44 | // side effects: if we can't upload, will print error page to wgOut |
45 | 45 | // and return false |
— | — | @@ -65,7 +65,7 @@ |
66 | 66 | } else { |
67 | 67 | $basepath = "$wgExtensionAssetsPath/UploadWizard"; |
68 | 68 | $dependencyLoader = new UploadWizardDependencyLoader( $wgLang->getCode() ); |
69 | | - if ( $wgUploadWizardDebug ) { |
| 69 | + if ( $wgUploadWizardConfig['debug'] ) { |
70 | 70 | // each file as an individual script or style |
71 | 71 | $dependencyLoader->outputHtmlDebug( $wgOut, $basepath ); |
72 | 72 | } else { |
— | — | @@ -82,35 +82,34 @@ |
83 | 83 | |
84 | 84 | /** |
85 | 85 | * 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 | + * |
86 | 91 | * @param subpage, e.g. the "foo" in Special:UploadWizard/foo |
87 | 92 | */ |
88 | 93 | public function addJsVars( $subPage ) { |
89 | | - global $wgUser, $wgOut, $wgUseAjax, $wgAjaxLicensePreview, $wgEnableAPI, |
90 | | - $wgEnableFirefogg, $wgFileExtensions,$wgUploadWizardDebug, $wgSitename, |
91 | | - $wgUploadWizardAutoCategory; |
| 94 | + global $wgOut, $wgUpwizDir, $wgUploadWizardConfig, $wgSitename; |
92 | 95 | |
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 | + ); |
97 | 113 | |
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 | | - |
115 | 114 | } |
116 | 115 | |
117 | 116 | /** |
Index: trunk/extensions/UploadWizard/UploadWizardPage.js |
— | — | @@ -9,72 +9,10 @@ |
10 | 10 | // create UploadWizard |
11 | 11 | mw.UploadWizardPage = function() { |
12 | 12 | |
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' ); |
76 | 14 | if ( !config.debug ) { |
77 | 15 | mw.log.level = mw.log.NONE; |
78 | | - } |
| 16 | + } |
79 | 17 | |
80 | 18 | var uploadWizard = new mw.UploadWizard( config ); |
81 | 19 | uploadWizard.createInterface( '#upload-wizard' ); |
— | — | @@ -84,7 +22,11 @@ |
85 | 23 | jQuery( document ).ready( function() { |
86 | 24 | // add "magic" to Language template parser for keywords |
87 | 25 | |
88 | | - var options = { magic: { 'SITENAME' : wgSitename } }; |
| 26 | + var options = { |
| 27 | + magic: { |
| 28 | + 'SITENAME' : mw.config.get('wgSitename') |
| 29 | + } |
| 30 | + }; |
89 | 31 | |
90 | 32 | window.gM = mediaWiki.language.getMessageFunction( options ); |
91 | 33 | $j.fn.msg = mediaWiki.language.getJqueryMessagePlugin( options ); |