Index: branches/new-upload/phase3/includes/UploadFromUrl.php |
— | — | @@ -15,18 +15,21 @@ |
16 | 16 | return $wgAllowCopyUploads && parent::isEnabled(); |
17 | 17 | } |
18 | 18 | /*entry point for Api upload:: ASYNC_DOWNLOAD (if possible) */ |
19 | | - function initialize( $name, $url, $asyncdownload = Http::SYNC_DOWNLOAD ) { |
| 19 | + function initialize( $name, $url, $asyncdownload = false) { |
20 | 20 | global $wgTmpDirectory, $wgPhpCliPath; |
21 | | - |
22 | | - if($asyncdownload && $wgPhpCliPath && wfShellExecEnabled() ){ |
23 | | - $this->dl_mode = Http::ASYNC_DOWNLOAD; |
24 | | - }else{ |
25 | | - $this->dl_mode = Http::SYNC_DOWNLOAD; |
| 21 | + |
| 22 | + //check for $asyncdownload request: |
| 23 | + if($asyncdownload !== false){ |
| 24 | + if($wgPhpCliPath && wfShellExecEnabled() ){ |
| 25 | + $this->dl_mode = Http::ASYNC_DOWNLOAD; |
| 26 | + }else{ |
| 27 | + $this->dl_mode = Http::SYNC_DOWNLOAD; |
| 28 | + } |
26 | 29 | } |
27 | 30 | |
28 | 31 | $local_file = tempnam( $wgTmpDirectory, 'WEBUPLOAD' ); |
29 | 32 | parent::initialize( $name, $local_file, 0, true ); |
30 | | - |
| 33 | + |
31 | 34 | $this->mUrl = trim( $url ); |
32 | 35 | } |
33 | 36 | public function isAsync(){ |
— | — | @@ -34,6 +37,7 @@ |
35 | 38 | } |
36 | 39 | /*entry point for SpecialUpload no ASYNC_DOWNLOAD possible: */ |
37 | 40 | function initializeFromRequest( &$request ) { |
| 41 | + |
38 | 42 | //set dl mode if not set: |
39 | 43 | if(!$this->dl_mode) |
40 | 44 | $this->dl_mode = Http::SYNC_DOWNLOAD; |
— | — | @@ -49,18 +53,16 @@ |
50 | 54 | /** |
51 | 55 | * Do the real fetching stuff |
52 | 56 | */ |
53 | | - function fetchFile( ) { |
| 57 | + function fetchFile( ) { |
54 | 58 | //entry point for SpecialUplaod |
55 | 59 | if( self::isValidURI($this->mUrl) === false) { |
56 | 60 | return Status::newFatal('upload-proto-error'); |
57 | | - } |
58 | | - //print "fetchFile:: $this->dl_mode"; |
| 61 | + } |
| 62 | + //now do the actual download to the target file: |
| 63 | + $status = Http::doDownload ( $this->mUrl, $this->mTempPath, $this->dl_mode ); |
59 | 64 | |
60 | | - //now do the actual download to the target file: |
61 | | - $status = Http::doDownload ( $this->mUrl, $this->mTempPath, $this->dl_mode ); |
62 | | - |
63 | 65 | //update the local filesize var: |
64 | | - $this->mFileSize = filesize( $this->mTempPath ); |
| 66 | + $this->mFileSize = filesize( $this->mTempPath ); |
65 | 67 | |
66 | 68 | return $status; |
67 | 69 | } |
Index: branches/new-upload/phase3/includes/OutputPage.php |
— | — | @@ -1020,9 +1020,7 @@ |
1021 | 1021 | if( $this->mDoNothing ){ |
1022 | 1022 | return; |
1023 | 1023 | } |
1024 | | - |
1025 | | - wfProfileIn( __METHOD__ ); |
1026 | | - |
| 1024 | + wfProfileIn( __METHOD__ ); |
1027 | 1025 | if ( '' != $this->mRedirect ) { |
1028 | 1026 | # Standards require redirect URLs to be absolute |
1029 | 1027 | $this->mRedirect = wfExpandUrl( $this->mRedirect ); |
— | — | @@ -1031,8 +1029,7 @@ |
1032 | 1030 | $wgRequest->response()->header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently"); |
1033 | 1031 | } |
1034 | 1032 | $this->mLastModified = wfTimestamp( TS_RFC2822 ); |
1035 | | - } |
1036 | | - |
| 1033 | + } |
1037 | 1034 | $this->sendCacheControl(); |
1038 | 1035 | |
1039 | 1036 | $wgRequest->response()->header("Content-Type: text/html; charset=utf-8"); |
Index: branches/new-upload/phase3/includes/UploadFromStash.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | class UploadFromStash extends UploadBase { |
4 | | - static function isValidSessionKey( $key, $sessionData ) { |
| 4 | + static function isValidSessionKey( $key, $sessionData ) { |
5 | 5 | return !empty( $key ) && |
6 | 6 | is_array( $sessionData ) && |
7 | 7 | isset( $sessionData[$key] ) && |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | ; |
11 | 11 | } |
12 | 12 | static function isValidRequest(& $request ) { |
13 | | - $sessionData = $request->getSessionData('wsUploadData'); |
| 13 | + $sessionData = $request->getSessionData('wsUploadData'); |
14 | 14 | return self::isValidSessionKey( |
15 | 15 | $request->getInt( 'wpSessionKey' ), |
16 | 16 | $sessionData |
— | — | @@ -30,14 +30,13 @@ |
31 | 31 | |
32 | 32 | $this->mFileProps = $sessionData['mFileProps']; |
33 | 33 | } |
34 | | - function initializeFromRequest( &$request ) { |
| 34 | + function initializeFromRequest( &$request ) { |
35 | 35 | $sessionKey = $request->getInt( 'wpSessionKey' ); |
36 | 36 | $sessionData = $request->getSessionData('wsUploadData'); |
37 | 37 | |
38 | 38 | $desiredDestName = $request->getText( 'wpDestFile' ); |
39 | 39 | if( !$desiredDestName ) |
40 | | - $desiredDestName = $request->getText( 'wpUploadFile' ); |
41 | | - |
| 40 | + $desiredDestName = $request->getText( 'wpUploadFile' ); |
42 | 41 | return $this->initialize( $desiredDestName, $sessionData[$sessionKey] ); |
43 | 42 | } |
44 | 43 | |
Index: branches/new-upload/phase3/includes/HttpFunctions.php |
— | — | @@ -31,12 +31,8 @@ |
32 | 32 | public static function doDownload( $url, $target_file_path , $dl_mode = self::SYNC_DOWNLOAD , $redirectCount=0){ |
33 | 33 | global $wgPhpCliPath, $wgMaxUploadSize, $wgMaxRedirects; |
34 | 34 | //do a quick check to HEAD to insure the file size is not > $wgMaxUploadSize |
35 | | - $head = get_headers($url, 1); |
| 35 | + $head = get_headers($url, 1); |
36 | 36 | |
37 | | - //check for non-valid result: |
38 | | - |
39 | | - wfDebug("\n head: " . print_r($head, true). "\n"); |
40 | | - |
41 | 37 | //check for redirects: |
42 | 38 | if( isset( $head['Location'] ) && strrpos($head[0], '302')!==false ){ |
43 | 39 | if($redirectCount < $wgMaxRedirects){ |
Index: branches/new-upload/phase3/includes/specials/SpecialUpload.php |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | * Get data POSTed through the form and assign them to the object |
43 | 43 | * @param $request Data posted. |
44 | 44 | */ |
45 | | - function __construct( &$request ) { |
| 45 | + function __construct( &$request ) { |
46 | 46 | // Guess the desired name from the filename if not provided |
47 | 47 | $this->mDesiredDestName = $request->getText( 'wpDestFile' ); |
48 | 48 | if( !$this->mDesiredDestName ) |
— | — | @@ -82,8 +82,8 @@ |
83 | 83 | * @access public |
84 | 84 | */ |
85 | 85 | function execute() { |
86 | | - global $wgUser, $wgOut; |
87 | | - |
| 86 | + global $wgUser, $wgOut; |
| 87 | + |
88 | 88 | # Check uploading enabled |
89 | 89 | if( !UploadBase::isEnabled() ) { |
90 | 90 | $wgOut->showErrorPage( 'uploaddisabled', 'uploaddisabledtext' ); |
— | — | @@ -258,10 +258,10 @@ |
259 | 259 | $status = $this->mUpload->fetchFile(); |
260 | 260 | if( !$status->isOK() ){ |
261 | 261 | return array( 'status' =>UploadBase::BEFORE_PROCESSING, 'error'=>$status->getWikiText() ); |
262 | | - } |
| 262 | + } |
263 | 263 | |
264 | 264 | // Check whether this is a sane upload |
265 | | - $result = $this->mUpload->verifyUpload(); |
| 265 | + $result = $this->mUpload->verifyUpload(); |
266 | 266 | if( $result != UploadBase::OK ) |
267 | 267 | return $result; |
268 | 268 | |
Index: branches/new-upload/phase3/includes/UploadBase.php |
— | — | @@ -57,12 +57,12 @@ |
58 | 58 | * Create a form of UploadBase depending on wpSourceType and initializes it |
59 | 59 | */ |
60 | 60 | static function createFromRequest( &$request, $type = null ) { |
61 | | - $type = $type ? $type : $request->getVal( 'wpSourceType' ); |
62 | | - |
| 61 | + $type = $type ? $type : $request->getVal( 'wpSourceType' ); |
| 62 | + |
63 | 63 | if( !$type ) |
64 | | - return null; |
65 | | - |
66 | | - $type = ucfirst($type); |
| 64 | + return null; |
| 65 | + |
| 66 | + $type = ucfirst($type); |
67 | 67 | $className = 'UploadFrom'.$type; |
68 | 68 | if( !in_array( $type, self::$uploadHandlers ) ) |
69 | 69 | return null; |
— | — | @@ -70,8 +70,9 @@ |
71 | 71 | if( !call_user_func( array( $className, 'isEnabled' ) ) ) |
72 | 72 | return null; |
73 | 73 | |
| 74 | + |
74 | 75 | if( !call_user_func( array( $className, 'isValidRequest' ), $request ) ) |
75 | | - return null; |
| 76 | + return null; |
76 | 77 | |
77 | 78 | $handler = new $className; |
78 | 79 | |
— | — | @@ -279,7 +280,7 @@ |
280 | 281 | |
281 | 282 | $exists = self::getExistsWarning( $this->mLocalFile ); |
282 | 283 | if( $exists !== false ) |
283 | | - $warning['exists'] = $exists; |
| 284 | + $warning['exists'] = $exists; |
284 | 285 | |
285 | 286 | // Check whether this may be a thumbnail |
286 | 287 | if( $exists !== false && $exists[0] != 'thumb' |
— | — | @@ -455,16 +456,17 @@ |
456 | 457 | # Couldn't save the file. |
457 | 458 | return false; |
458 | 459 | } |
459 | | - $mTempPath = $status->value; |
460 | | - |
461 | | - $key = $this->getSessionKey (); |
| 460 | + $mTempPath = $status->value; |
| 461 | + session_start();//start up the session (might have been previously closed to prevent php session locking) |
| 462 | + $key = $this->getSessionKey (); |
462 | 463 | $_SESSION['wsUploadData'][$key] = array( |
463 | 464 | 'mTempPath' => $mTempPath, |
464 | 465 | 'mFileSize' => $this->mFileSize, |
465 | 466 | 'mSrcName' => $this->mSrcName, |
466 | 467 | 'mFileProps' => $this->mFileProps, |
467 | 468 | 'version' => self::SESSION_VERSION, |
468 | | - ); |
| 469 | + ); |
| 470 | + session_write_close(); |
469 | 471 | return $key; |
470 | 472 | } |
471 | 473 | //pull session Key gen from stash in cases where we want to start an upload without much information |
Index: branches/new-upload/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js |
— | — | @@ -8,10 +8,9 @@ |
9 | 9 | 'fogg-save_local_file' : 'Save Ogg', |
10 | 10 | 'fogg-check_for_fogg' : 'Checking for Firefogg <blink>...</blink>', |
11 | 11 | 'fogg-installed' : 'Firefogg is Installed', |
12 | | - 'fogg-please_install' : 'You don\'t have firefogg, please <a href="$1">install firefogg</a>', |
| 12 | + 'fogg-please_install' : 'You don\'t have firefogg installed, please <a href="$1">install firefogg</a>', |
13 | 13 | 'fogg-use_latest_fox' : 'You need a <a href="http://www.mozilla.com/en-US/firefox/all-beta.html">Firefox 3.5</a> to use Firefogg', |
14 | | - 'passthrough_mode' : 'Your selected file is already ogg or not a video file', |
15 | | - |
| 14 | + 'passthrough_mode' : 'Your selected file is already ogg or not a video file', |
16 | 15 | }); |
17 | 16 | |
18 | 17 | var firefogg_install_links = { |
— | — | @@ -132,11 +131,11 @@ |
133 | 132 | }, |
134 | 133 | getTargetHtml:function(target){ |
135 | 134 | if( target.substr(7,3)=='btn'){ |
136 | | - return '<input class="' + target + '" type="button" value="' + gM( 'fogg-' + target.substring(11)) + '"/> '; |
| 135 | + return '<input style="" class="' + target + '" type="button" value="' + gM( 'fogg-' + target.substring(11)) + '"/> '; |
137 | 136 | }else if(target.substr(7,5)=='input'){ |
138 | | - return '<input class="' + target + '" type="text" value="' + gM( 'fogg-' + target.substring(11)) + '"/> '; |
| 137 | + return '<input style="" class="' + target + '" type="text" value="' + gM( 'fogg-' + target.substring(11)) + '"/> '; |
139 | 138 | }else{ |
140 | | - return '<div class="' + target + '">'+ gM('fogg-'+ target.substring(7)) + '</div> '; |
| 139 | + return '<div style="" class="' + target + '" >'+ gM('fogg-'+ target.substring(7)) + '</div> '; |
141 | 140 | } |
142 | 141 | }, |
143 | 142 | doControlBindings: function(){ |
— | — | @@ -145,21 +144,28 @@ |
146 | 145 | //hide all targets: |
147 | 146 | var hide_target_list=''; |
148 | 147 | var coma=''; |
149 | | - $j.each(default_firefogg_options, function(target, na){ |
| 148 | + $j.each(default_firefogg_options, function(target, na){ |
150 | 149 | if(target.substring(0, 6)=='target'){ |
151 | 150 | hide_target_list+=coma + _this[target]; |
152 | 151 | coma=','; |
153 | 152 | } |
154 | | - }); |
155 | | - $j( hide_target_list ).hide(); |
| 153 | + }); |
| 154 | + $j( hide_target_list ).hide(); |
| 155 | + //if rewriting the form lets keep the text input around: |
| 156 | + if(_this.form_rewrite) |
| 157 | + $j('#target_input_file_name').show(); |
156 | 158 | |
157 | 159 | //hide all but check-for-fogg |
158 | 160 | //check for firefogg |
159 | 161 | if( _this.firefoggCheck() ){ |
160 | 162 | //show select file: |
161 | | - $j(this.target_btn_select_file).click(function(){ |
162 | | - _this.select_fogg(); |
163 | | - }).show().attr('disabled', false); |
| 163 | + $j(this.target_btn_select_file).unbind( |
| 164 | + ).attr('disabled', false |
| 165 | + ).css({'display':'inline'} |
| 166 | + ).click(function(){ |
| 167 | + _this.select_fogg(); |
| 168 | + }); |
| 169 | + |
164 | 170 | }else{ |
165 | 171 | var os_link = false; |
166 | 172 | if(navigator.oscpu){ |
— | — | @@ -169,11 +175,11 @@ |
170 | 176 | os_link = firefogg_install_links['macosx']; |
171 | 177 | else if(navigator.oscpu.search('Win') >= 0) |
172 | 178 | os_link = firefogg_install_links['win32']; |
173 | | - } |
174 | | - $j(_this.target_please_install).html( gM('fogg-please_install',os_link )).show(); |
| 179 | + } |
| 180 | + $j(_this.target_please_install).html( gM('fogg-please_install',os_link )).css('padding', '10px').show(); |
175 | 181 | } |
176 | 182 | //setup the target save local file bindins: |
177 | | - $j( _this.target_btn_save_local_file ).click(function(){ |
| 183 | + $j( _this.target_btn_save_local_file ).unbind().click(function(){ |
178 | 184 | //update the output target |
179 | 185 | if(_this.fogg){ |
180 | 186 | //if(_this.fogg.saveVideoAs()){ |
— | — | @@ -194,26 +200,42 @@ |
195 | 201 | //assume input target |
196 | 202 | setupForm: function(){ |
197 | 203 | js_log('firefogg::setupForm::'); |
198 | | - |
199 | | - //call the parent form setup |
200 | | - this.pe_setupForm(); |
201 | | - <input type="file" size="60" id="wpUploadFile" name="wpUploadFile" tabindex="1"/> |
202 | | - //change the file browser to type text: |
203 | | - $j(this.selector).replaceWith('<input type="text" ' + |
204 | | - 'size="' + $j(this.selector).attr('size') + '" ' + |
205 | | - 'id="' + $j(this.selector).attr('id') + '" ' + |
206 | | - 'name="' + $j(this.selector).attr("name") + '" ' + |
207 | | - 'tabindex="' + $j(this.selector).attr('tabindex') + '" '+ |
208 | | - 'class="' + $j(this.selector).attr('class') + '" ' + |
209 | | - '>'); |
210 | 204 | |
| 205 | + //check if we have firefogg (if not just add a link and stop proccessing) |
| 206 | + if( !this.firefoggCheck() ){ |
| 207 | + //add some status indicators if not provided: |
| 208 | + if(!this.target_please_install){ |
| 209 | + $j(this.selector).after ( this.getTargetHtml('target_please_install') ); |
| 210 | + //match the first sibling of our input type selector: |
| 211 | + this.target_please_install = this.selector + ' ~ .target_please_install'; |
| 212 | + } |
| 213 | + //update download link: |
| 214 | + this.doControlBindings(); |
| 215 | + return false; |
| 216 | + } |
| 217 | + //else do form setup: |
| 218 | + this.pe_setupForm(); |
| 219 | + //change the file browser to type text: (can't directly change input from "file" to "text" so longer way: |
| 220 | + var inTag = '<input '; |
| 221 | + $j.each($j(this.selector).get(0).attributes, function(i, attr){ |
| 222 | + var val = attr.value; |
| 223 | + if( attr.name == 'type') |
| 224 | + val = 'text'; |
| 225 | + inTag += attr.name + '="' + val + '" '; |
| 226 | + }); |
| 227 | + if(!$j(this.selector).attr('style')) |
| 228 | + inTag += 'style="display:inline" '; |
| 229 | + inTag+= '>'; |
| 230 | + |
| 231 | + js_log('set input: ' + inTag); |
| 232 | + $j(this.selector).replaceWith(inTag); |
| 233 | + |
211 | 234 | this.target_input_file_name = this.selector; |
212 | 235 | |
213 | 236 | $j(this.selector).after( |
214 | 237 | this.getTargetHtml('target_btn_select_file') |
215 | 238 | ); |
216 | | - //check for the other inline status indicator targets: |
217 | | - |
| 239 | + //check for the other inline status indicator targets: |
218 | 240 | //update the bindings: |
219 | 241 | this.doControlBindings(); |
220 | 242 | }, |
— | — | @@ -228,7 +250,7 @@ |
229 | 251 | js_log('videoSelectReady'); |
230 | 252 | //if not already hidden hide select file and show "select new": |
231 | 253 | $j(_this.target_btn_select_file).hide(); |
232 | | - //show and setup binding for new file: |
| 254 | + //show and setup binding for select new file: |
233 | 255 | $j(_this.target_btn_select_new_file).show().click(function(){ |
234 | 256 | _this.select_fogg(); |
235 | 257 | }); |
— | — | @@ -255,12 +277,12 @@ |
256 | 278 | $j(_this.target_input_file_name).val(_this.fogg.sourceFilename).show(); |
257 | 279 | |
258 | 280 | if(_this.new_source_cb){ |
259 | | - new_source_cb( _this.fogg.sourceFilename ); |
| 281 | + _this.new_source_cb( _this.fogg.sourceFilename ); |
260 | 282 | } |
261 | 283 | } |
262 | 284 | } |
263 | 285 | //wait 100ms to get video info: |
264 | | - setTimeout(videoSelectReady, 200); |
| 286 | + setTimeout(videoSelectReady, 100); |
265 | 287 | } |
266 | 288 | }, |
267 | 289 | //simple auto encoder settings just enable passthough if file is not video or > 480 pixles tall |