Index: trunk/extensions/UploadWizard/UploadWizardHooks.php |
— | — | @@ -59,7 +59,8 @@ |
60 | 60 | 'resources/mw.IframeTransport.js', |
61 | 61 | 'resources/mw.ApiUploadHandler.js', |
62 | 62 | 'resources/mw.DestinationChecker.js', |
63 | | - 'resources/mw.UploadWizardUtil.js', |
| 63 | + 'resources/mw.UploadWizardUtil.js', |
| 64 | + 'resources/mw.FlickrChecker.js', |
64 | 65 | |
65 | 66 | // interface libraries |
66 | 67 | 'resources/mw.GroupProgressBar.js', |
— | — | @@ -309,6 +310,8 @@ |
310 | 311 | 'mwe-upwiz-license-none-applicable', |
311 | 312 | 'mwe-upwiz-license-confirm-remove', |
312 | 313 | 'mwe-upwiz-license-confirm-remove-title', |
| 314 | + 'mwe-upwiz-license-external', |
| 315 | + 'mwe-upwiz-license-external-invalid', |
313 | 316 | 'mwe-upwiz-categories', |
314 | 317 | 'mwe-upwiz-categories-add', |
315 | 318 | 'mwe-upwiz-category-remove', |
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php |
— | — | @@ -258,6 +258,9 @@ |
259 | 259 | 'mwe-upwiz-license-none-applicable' => 'Abandon {{PLURAL:$1|this upload|these uploads}} without publishing', |
260 | 260 | 'mwe-upwiz-license-confirm-remove' => 'Are you sure you want to remove {{PLURAL:$1|this upload|these uploads}}?', |
261 | 261 | 'mwe-upwiz-license-confirm-remove-title' => 'Confirm remove', |
| 262 | + |
| 263 | + 'mwe-upwiz-license-external' => 'This file is under the following license on $1: <b>$2</b>.', |
| 264 | + 'mwe-upwiz-license-external-invalid' => 'This file is under the following license on $1: <b>$2</b>. Unfortunately, this license is not appropriate for use on {{SITENAME}}.', |
262 | 265 | |
263 | 266 | |
264 | 267 | 'mwe-upwiz-categories' => 'Categories', |
Index: trunk/extensions/UploadWizard/resources/mw.FlickrChecker.js |
— | — | @@ -8,14 +8,15 @@ |
9 | 9 | |
10 | 10 | // Map each Flickr license name to the equivalent templates. |
11 | 11 | // These are the current Flickr license names as of April 26, 2011. |
| 12 | + // Live list at http://api.flickr.com/services/rest/?&method=flickr.photos.licenses.getInfo&api_key=e9d8174a79c782745289969a45d350e8 |
12 | 13 | licenseMaps: { |
13 | 14 | 'All Rights Reserved': 'invalid', |
| 15 | + 'Attribution License': 'invalid', |
| 16 | + 'Attribution-NoDerivs License': 'invalid', |
| 17 | + 'Attribution-NonCommercial-NoDerivs License': 'invalid', |
| 18 | + 'Attribution-NonCommercial License': 'invalid', |
14 | 19 | 'Attribution-NonCommercial-ShareAlike License': 'invalid', |
15 | | - 'Attribution-NonCommercial License': 'invalid', |
16 | | - 'Attribution-NonCommercial-NoDerivs License': 'invalid', |
17 | | - 'Attribution License': '{{flickrreview}}{{cc-by-2.0}}', |
18 | 20 | 'Attribution-ShareAlike License': '{{flickrreview}}{{cc-by-sa-2.0}}', |
19 | | - 'Attribution-NoDerivs License': 'invalid', |
20 | 21 | 'No known copyright restrictions': '{{flickrreview}}{{Flickr-no known copyright restrictions}}', |
21 | 22 | 'United States Government Work': '{{flickrreview}}{{PD-USGov}}' |
22 | 23 | }, |
— | — | @@ -24,7 +25,9 @@ |
25 | 26 | * If a photo is from flickr, retrieve its license. If the license is valid, display the license |
26 | 27 | * to the user, hide the normal license selection interface, and set it as the deed for the upload. |
27 | 28 | * If the license is not valid, alert the user with an error message. If no recognized license is |
28 | | - * retrieved, do nothing. |
| 29 | + * retrieved, do nothing. Note that the license look-up system is fragile on purpose. If Flickr |
| 30 | + * changes the name associated with a license ID, it's better for the lookup to fail than to use |
| 31 | + * an incorrect license. |
29 | 32 | * @param url - the source URL to check |
30 | 33 | * @param $selector - the element to insert the license name into |
31 | 34 | * @param upload - the upload object to set the deed for |
— | — | @@ -36,9 +39,16 @@ |
37 | 40 | $.getJSON(this.apiUrl+'&method=flickr.photos.getInfo&api_key='+this.apiKey+'&photo_id='+photoId+'&format=json&jsoncallback=?', |
38 | 41 | function( data ) { |
39 | 42 | if ( typeof data.photo != 'undefined' ) { |
40 | | - // XXX do all the work here |
41 | 43 | // The returned data.photo.license is just an ID that we use to look up the license name |
42 | | - console.debug( mw.FlickrChecker.licenseList[data.photo.license] ); |
| 44 | + var licenseName = mw.FlickrChecker.licenseList[data.photo.license]; |
| 45 | + // Use the license name to retrieve the template values |
| 46 | + var licenseValue = mw.FlickrChecker.licenseMaps[licenseName]; |
| 47 | + // Set the license message to show the user. |
| 48 | + if ( licenseValue == 'invalid' ) { |
| 49 | + var licenseMessage = gM( 'mwe-upwiz-license-external-invalid', 'Flickr', licenseName ); |
| 50 | + } else { |
| 51 | + var licenseMessage = gM( 'mwe-upwiz-license-external', 'Flickr', licenseName ); |
| 52 | + } |
43 | 53 | } |
44 | 54 | } |
45 | 55 | ); |