Fix up r53308: fix up another parser test that I'd forgotten about
[lhc/web/wiklou.git] / js2 / mwEmbed / libAddMedia / mediaWikiUploadHelper.OFF.js
1 /* the upload javascript
2 presently does hackery to work with Special:Upload page...
3 will be replaced with upload API once that is ready
4 */
5
6 loadGM({
7 "upload-enable-converter" : "Enable video converter (to upload source video not yet converted to theora format) <a href=\"http://commons.wikimedia.org/wiki/Commons:Firefogg\">more info</a>",
8 "upload-fogg_not_installed": "If you want to upload video consider installing <a href=\"http://firefogg.org\">firefogg.org</a>, <a href=\"http://commons.wikimedia.org/wiki/Commons:Firefogg\">more info</a>",
9 "upload-transcode-in-progress":"Doing Transcode & Upload (do not close this window)",
10 "upload-in-progress": "Upload in Progress (do not close this window)",
11 "upload-transcoded-status": "Transcoded",
12 "uploaded-status": "Uploaded",
13 "upload-select-file": "Select File...",
14 "wgfogg_wrong_version": "You have firefogg installed but its outdated, <a href=\"http://firefogg.org\">please upgrade</a> ",
15 "wgfogg_waring_ogg_upload": "You have selected an ogg file for conversion to ogg (this is probably unnessesary). Maybe disable the video converter?",
16 "wgfogg_waring_bad_extension" : "You have selected a file with an unsuported extension. <a href=\"http://commons.wikimedia.org/wiki/Commons:Firefogg#Supported_File_Types\">More help</a>",
17 "upload-stats-fileprogres": "$1 of $2",
18
19 "mv_upload_done" : "Your upload <i>should be</i> accessible <a href=\"$1\">here</a>",
20 "upload-unknown-size": "Unknown size",
21
22 "successfulupload" : "Successful upload",
23 "uploaderror" : "Upload error",
24 "uploadwarning": "Upload warning",
25 "unknown-error": "Unknown Error",
26 "return-to-form": "Return to form",
27
28 "file-exists-duplicate" : "This file is a duplicate of the following file",
29 "fileexists" : "A file with this name exists already, please check <b><tt>$1</tt></b> if you are not sure if you want to change it.",
30 "fileexists-thumb": "<center><b>Existing file</b></center>",
31 "ignorewarning" : "Ignore warning and save file anyway",
32 "file-thumbnail-no" : "The filename begins with <b><tt>$1</tt></b>"
33 });
34
35 var default_upload_options = {
36 'target_div':'',
37 'upload_done_action':'redirect',
38 'api_url':false
39 }
40
41 var mediaWikiUploadHelper = function(iObj){
42 return this.init( iObj );
43 }
44 mediaWikiUploadHelper.prototype = {
45 init:function( iObj ){
46 var _this = this;
47 js_log('init uploader');
48 if(!iObj)
49 iObj = {};
50 for(var i in default_upload_options){
51 if(iObj[i]){
52 this[i] = iObj[i];
53 }else{
54 this[i] = default_upload_options[i];
55 }
56 }
57 //check if we are on the uplaod page:
58 this.on_upload_page = ( wgPageName== "Special:Upload")?true:false;
59 js_log('f:mvUploader: onuppage:' + this.on_upload_page);
60 //grab firefogg.js:
61 mvJsLoader.doLoad([
62 'mvFirefogg'
63 ],function(){
64 //if we are not on the upload page grab the upload html via ajax:
65 //@@todo refactor with
66 if( !_this.on_upload_page){
67 $j.get(wgArticlePath.replace(/\$1/, 'Special:Upload'), {}, function(data){
68 //add upload.js:
69 $j.getScript( stylepath + '/common/upload.js', function(){
70 //really _really_ need an "upload api"!
71 wgAjaxUploadDestCheck = true;
72 wgAjaxLicensePreview = false;
73 wgUploadAutoFill = true;
74 //strip out inline scripts:
75 sp = data.indexOf('<div id="content">');
76 se = data.indexOf('<!-- end content -->');
77 if(sp!=-1 && se !=-1){
78 result_data = data.substr(sp, (se-sp) ).replace('/\<script\s.*?\<\/script\>/gi',' ');
79 js_log("trying to set: " + result_data );
80 //$j('#'+_this.target_div).html( result_data );
81 }
82 _this.setupFirefogg();
83 });
84 });
85 }else{
86 //@@could check if firefogg is enabled here:
87 _this.setupFirefogg();
88 //if only want httpUploadFrom help enable it here:
89 }
90 }
91 );
92 },
93 /**
94 * setupBaseUpInterface supports intefaces for progress indication if the browser supports it
95 * also sets up ajax progress updates for http posts
96 * //pre
97 */
98 setupBaseUpInterface:function(){
99 //check if this feature is not false (we want it on by default (null) instances that don't have the upload api or any modifications)
100 this.upForm = new mvBaseUploadInterface( {
101 'api_url' : this.api_url,
102 'parent_uploader': this
103 }
104 );
105 this.upForm.setupForm();
106 },
107 setupFirefogg:function(){
108 var _this = this;
109 //add firefogg html if not already there: ( same as $wgEnableFirebug added in SpecialUpload.php )
110 if( $j('#fogg-video-file').length==0 ){
111 js_log('add addFirefoggHtml');
112 _this.addFirefoggHtml();
113 }else{
114 js_log('firefogg already init:');
115 }
116 //set up the upload_done action
117 //redirect if we are on the upload page
118 //do a callback if in called from gui)
119 var intFirefoggObj = ( this.on_upload_page )?
120 {'upload_done_action':'redirect'}:
121 {'upload_done_action':function( rTitle ){
122 js_log( 'add_done_action callback for uploader' );
123 //call the parent insert resource preview
124 _this.upload_done_action( rTitle );
125 }
126 };
127
128 if( _this.api_url )
129 intFirefoggObj['api_url'] = _this.api_url;
130
131 js_log('new mvFirefogg extends mvUploader (this)');
132 this.fogg = new mvFirefogg( intFirefoggObj );
133 this.fogg.setupForm();
134 },
135 //same add code as specialUpload if($wgEnableFirefogg){
136 addFirefoggHtml:function(){
137 var itd_html = $j('#mw-upload-table .mw-input:first').html();
138 $j('#mw-upload-table .mw-input').eq(0).html('<div id="wg-base-upload">' + itd_html + '</div>');
139 //add in firefogg control
140 $j('#wg-base-upload').after('<p id="fogg-enable-item" >' +
141 '<input style="display:none" id="fogg-video-file" name="fogg-video-file" type="button" value="' + gM('upload-select-file') + '">' +
142 "<span id='wgfogg_not_installed'>" +
143 gM('upload-fogg_not_installed') +
144 "</span>" +
145 "<span class='error' id='wgfogg_wrong_version' style='display:none;'><br>" +
146 gM('wgfogg_wrong_version') +
147 "<br>" +
148 "</span>" +
149 "<span class='error' id='wgfogg_waring_ogg_upload' style='display:none;'><br>"+
150 gM('wgfogg_waring_ogg_upload') +
151 "<br>" +
152 "</span>" +
153 "<span class='error' id='wgfogg_waring_bad_extension' style='display:none;'><br>"+
154 gM('wgfogg_waring_bad_extension') +
155 "<br>" +
156 "</span>" +
157 "<span id='wgfogg_installed' style='display:none' >"+
158 '<input id="wgEnableFirefogg" type="checkbox" name="wgEnableFirefogg" >' +
159 gM('upload-enable-converter') +
160 '</span><br></p>');
161 },
162
163 };