Index: trunk/extensions/Push/Push.i18n.php |
— | — | @@ -81,6 +81,13 @@ |
82 | 82 | 'push-special-obtaining-fileinfo' => '$1: Obtaining file information...', |
83 | 83 | 'push-special-pushing-file' => '$1: Pushing file $2...', |
84 | 84 | 'push-special-return' => 'Push more pages', |
| 85 | + |
| 86 | + // API |
| 87 | + 'push-api-err-nocurl' => 'cURL is not installed. |
| 88 | +Set $egPushDirectFileUploads to false on public wikis, or install cURL for private wikis', |
| 89 | + 'push-api-err-nofilesupport' => 'The local MediaWiki does not have support for posting files. |
| 90 | +On public wikis, set $egPushDirectFileUploads to false. |
| 91 | +On private wikis, apply the patch linkd from the Push documentation or update MediaWiki itself.', |
85 | 92 | ); |
86 | 93 | |
87 | 94 | /** Message documentation (Message documentation) |
Index: trunk/extensions/Push/specials/Push_Body.php |
— | — | @@ -81,7 +81,7 @@ |
82 | 82 | if ( $catpages ) $pages .= "\n" . implode( "\n", $catpages ); |
83 | 83 | } |
84 | 84 | } |
85 | | - } |
| 85 | + } |
86 | 86 | else if( $wgRequest->getCheck( 'addns' ) ) { |
87 | 87 | $pages = $wgRequest->getText( 'pages' ); |
88 | 88 | $nsindex = $wgRequest->getText( 'nsindex', '' ); |
Index: trunk/extensions/Push/specials/ext.push.special.js |
— | — | @@ -173,18 +173,24 @@ |
174 | 174 | function( data ) { |
175 | 175 | var fail = false; |
176 | 176 | |
177 | | - for ( i in data ) { |
178 | | - if ( data[i].error ) { |
179 | | - handleError( listItem, pageName, { info: mediaWiki.msg( 'push-tab-err-filepush', data[i].error.info ) } ); |
180 | | - fail = true; |
181 | | - break; |
182 | | - } |
183 | | - else if ( !data[i].upload ) { |
184 | | - handleError( listItem, pageName, { info: mediaWiki.msg( 'push-tab-err-filepush-unknown' ) } ); |
185 | | - fail = true; |
186 | | - break; |
187 | | - } |
| 177 | + if ( data.error ) { |
| 178 | + handleError( listItem, pageName, { info: mediaWiki.msg( 'push-tab-err-filepush', data.error.info ) } ); |
| 179 | + fail = true; |
188 | 180 | } |
| 181 | + else { |
| 182 | + for ( i in data ) { |
| 183 | + if ( data[i].error ) { |
| 184 | + handleError( listItem, pageName, { info: mediaWiki.msg( 'push-tab-err-filepush', data[i].error.info ) } ); |
| 185 | + fail = true; |
| 186 | + break; |
| 187 | + } |
| 188 | + else if ( !data[i].upload ) { |
| 189 | + handleError( listItem, pageName, { info: mediaWiki.msg( 'push-tab-err-filepush-unknown' ) } ); |
| 190 | + fail = true; |
| 191 | + break; |
| 192 | + } |
| 193 | + } |
| 194 | + } |
189 | 195 | |
190 | 196 | if ( !fail ) { |
191 | 197 | startFilePush( pageName, images, targetOffset, listItem, fileName ); |
Index: trunk/extensions/Push/Push.php |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | die( 'Not an entry point.' ); |
27 | 27 | } |
28 | 28 | |
29 | | -define( 'Push_VERSION', '0.8 alpha' ); |
| 29 | +define( 'Push_VERSION', '0.8 rc' ); |
30 | 30 | |
31 | 31 | $wgExtensionCredits['other'][] = array( |
32 | 32 | 'path' => __FILE__, |
Index: trunk/extensions/Push/Push_Settings.php |
— | — | @@ -65,3 +65,8 @@ |
66 | 66 | |
67 | 67 | # The maximum amount of targets to push a page to in one go. |
68 | 68 | $egPushBatchSize = 3; |
| 69 | + |
| 70 | +# Use direct file uploads (requires patch to MW 1.16 and 1.17). |
| 71 | +# This is needed when pushing to a wiki that cannot access the source file |
| 72 | +# (for example from a private wiki to a wiki on the internet). |
| 73 | +$egPushDirectFileUploads = !$wgAllowCopyUploads; |
Index: trunk/extensions/Push/RELEASE-NOTES |
— | — | @@ -5,9 +5,9 @@ |
6 | 6 | |
7 | 7 | |
8 | 8 | === Version 0.8 === |
9 | | -2011-xx-xx |
| 9 | +2011-0x-xx |
10 | 10 | |
11 | | -* |
| 11 | +* Fixed issue with pushing files from private wikis. |
12 | 12 | |
13 | 13 | === Version 0.7 === |
14 | 14 | 2011-01-14 |
Index: trunk/extensions/Push/includes/Push_Functions.php |
— | — | @@ -131,7 +131,7 @@ |
132 | 132 | $flipped[$egPushTargets[$key]] = $value; |
133 | 133 | } |
134 | 134 | } |
135 | | - |
| 135 | + |
136 | 136 | $arr = $flipped; |
137 | 137 | } |
138 | 138 | } |
Index: trunk/extensions/Push/includes/ext.push.tab.js |
— | — | @@ -301,20 +301,27 @@ |
302 | 302 | function( data ) { |
303 | 303 | var fail = false; |
304 | 304 | |
305 | | - for ( i in data ) { |
306 | | - if ( data[i].error ) { |
307 | | - data[i].error.info = mediaWiki.msg( 'push-tab-err-filepush', data[i].error.info ); |
308 | | - handleError( sender, targetUrl, data[i].error ); |
309 | | - fail = true; |
310 | | - break; |
311 | | - } |
312 | | - else if ( !data[i].upload ) { |
313 | | - data[i].error.info = mediaWiki.msg( 'push-tab-err-filepush-unknown' ); |
314 | | - handleError( sender, targetUrl, data[i].error ); |
315 | | - fail = true; |
316 | | - break; |
317 | | - } |
| 305 | + if ( data.error ) { |
| 306 | + data.error.info = mediaWiki.msg( 'push-tab-err-filepush', data.error.info ); |
| 307 | + handleError( sender, targetUrl, data.error ); |
| 308 | + fail = true; |
318 | 309 | } |
| 310 | + else { |
| 311 | + for ( i in data ) { |
| 312 | + if ( data[i].error ) { |
| 313 | + data[i].error.info = mediaWiki.msg( 'push-tab-err-filepush', data[i].error.info ); |
| 314 | + handleError( sender, targetUrl, data[i].error ); |
| 315 | + fail = true; |
| 316 | + break; |
| 317 | + } |
| 318 | + else if ( !data[i].upload ) { |
| 319 | + data[i].error.info = mediaWiki.msg( 'push-tab-err-filepush-unknown' ); |
| 320 | + handleError( sender, targetUrl, data[i].error ); |
| 321 | + fail = true; |
| 322 | + break; |
| 323 | + } |
| 324 | + } |
| 325 | + } |
319 | 326 | |
320 | 327 | if ( !fail ) { |
321 | 328 | sender.innerHTML = mediaWiki.msg( 'push-button-completed' ); |
Index: trunk/extensions/Push/api/ApiPush.php |
— | — | @@ -107,6 +107,8 @@ |
108 | 108 | 'lgpassword' => $password |
109 | 109 | ); |
110 | 110 | |
| 111 | + //static $fail = 0;$fail++; |
| 112 | + |
111 | 113 | if ( !is_null( $token ) ) { |
112 | 114 | $requestData['lgtoken'] = $token; |
113 | 115 | } |
Index: trunk/extensions/Push/api/ApiPushImages.php |
— | — | @@ -243,25 +243,46 @@ |
244 | 244 | * @param string $token |
245 | 245 | */ |
246 | 246 | protected function pushToTarget( Title $title, $target, $token ) { |
| 247 | + global $egPushDirectFileUploads; |
| 248 | + |
247 | 249 | $imagePage = new ImagePage( $title ); |
248 | | - |
| 250 | + |
249 | 251 | $requestData = array( |
250 | 252 | 'action' => 'upload', |
251 | 253 | 'format' => 'json', |
252 | 254 | 'token' => $token, |
253 | | - 'url' => $imagePage->getDisplayedFile()->getFullUrl(), |
254 | 255 | 'filename' => $title->getText(), |
255 | 256 | 'ignorewarnings' => '1' |
256 | 257 | ); |
257 | | - |
258 | | - $req = PushFunctions::getHttpRequest( $target, |
259 | | - array( |
260 | | - 'method' => 'POST', |
261 | | - 'timeout' => 'default', |
262 | | - 'postData' => $requestData, |
263 | | - ) |
| 258 | + |
| 259 | + if ( $egPushDirectFileUploads ) { |
| 260 | + $requestData['file'] = '@' . $imagePage->getFile()->getFullPath(); |
| 261 | + } |
| 262 | + else { |
| 263 | + $requestData['url'] = $imagePage->getDisplayedFile()->getFullUrl(); |
| 264 | + } |
| 265 | + |
| 266 | + $reqArgs = array( |
| 267 | + 'method' => 'POST', |
| 268 | + 'timeout' => 'default', |
| 269 | + 'postData' => $requestData |
264 | 270 | ); |
265 | 271 | |
| 272 | + if ( $egPushDirectFileUploads ) { |
| 273 | + if ( !function_exists( 'curl_init' ) ) { |
| 274 | + $this->dieUsage( wfMsg( 'push-api-err-nocurl' ), 'image-push-nocurl' ); |
| 275 | + } |
| 276 | + else if ( !defined( 'CurlHttpRequest::SUPPORTS_FILE_POSTS' ) || !CurlHttpRequest::SUPPORTS_FILE_POSTS ) { |
| 277 | + $this->dieUsage( wfMsg( 'push-api-err-nofilesupport' ), 'image-push-nofilesupport' ); |
| 278 | + } |
| 279 | + else { |
| 280 | + $req = new CurlHttpRequest( $target, $reqArgs ); |
| 281 | + } |
| 282 | + } |
| 283 | + else { |
| 284 | + $req = PushFunctions::getHttpRequest( $target, $reqArgs ); |
| 285 | + } |
| 286 | + |
266 | 287 | if ( array_key_exists( $target, $this->cookieJars ) ) { |
267 | 288 | $req->setCookieJar( $this->cookieJars[$target] ); |
268 | 289 | } |