r53284 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53283‎ | r53284 | r53285 >
Date:00:55, 15 July 2009
Author:ashley
Status:deferred
Tags:
Comment:
follow-up to r53282:
*coding style tweaks
*added __METHOD__ to some wfDebug calls
*removed php ending tag from mwScriptLoader.php
*some doxygen docs added
Modified paths:
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/HttpFunctions.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/api/ApiUpload.php (modified) (history)
  • /trunk/phase3/mwScriptLoader.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/HttpFunctions.php
@@ -1,83 +1,86 @@
22 <?php
33 /**
44 * HTTP handling class
5 - *
 5+ * @defgroup HTTP HTTP
 6+ * @file
 7+ * @ingroup HTTP
68 */
79
8 -
910 class Http {
10 - const SYNC_DOWNLOAD = 1; //syncronys upload (in a single request)
11 - const ASYNC_DOWNLOAD = 2; //asynchronous upload we should spawn out another process and monitor progress if possible)
 11+ const SYNC_DOWNLOAD = 1; // syncronys upload (in a single request)
 12+ const ASYNC_DOWNLOAD = 2; // asynchronous upload we should spawn out another process and monitor progress if possible)
1213
1314 var $body = '';
1415 public static function request( $url, $opts = array() ) {
15 - $req = new HttpRequest( $url, $opts );
16 - $status = $req->doRequest();
17 - if( $status->isOK() ){
18 - return $status->value;
19 - }else{
20 - return false;
21 - }
22 - }
 16+ $req = new HttpRequest( $url, $opts );
 17+ $status = $req->doRequest();
 18+ if( $status->isOK() ){
 19+ return $status->value;
 20+ } else {
 21+ return false;
 22+ }
 23+ }
 24+
2325 /**
2426 * Simple wrapper for Http::request( 'GET' )
2527 */
2628 public static function get( $url, $opts = array() ) {
2729 $opt['method'] = 'GET';
28 - return Http::request($url, $opts);
 30+ return Http::request( $url, $opts );
2931 }
 32+
3033 /**
3134 * Simple wrapper for Http::request( 'POST' )
3235 */
3336 public static function post( $url, $opts = array() ) {
34 - $opts['method']='POST';
35 - return Http::request($url, $opts);
 37+ $opts['method'] = 'POST';
 38+ return Http::request( $url, $opts );
3639 }
3740
38 - public static function doDownload( $url, $target_file_path , $dl_mode = self::SYNC_DOWNLOAD , $redirectCount=0){
 41+ public static function doDownload( $url, $target_file_path , $dl_mode = self::SYNC_DOWNLOAD , $redirectCount = 0 ){
3942 global $wgPhpCliPath, $wgMaxUploadSize, $wgMaxRedirects;
40 - //do a quick check to HEAD to insure the file size is not > $wgMaxUploadSize
41 - $head = get_headers($url, 1);
 43+ // do a quick check to HEAD to insure the file size is not > $wgMaxUploadSize
 44+ $head = get_headers( $url, 1 );
4245
43 - //check for redirects:
44 - if( isset( $head['Location'] ) && strrpos($head[0], '302')!==false ){
45 - if($redirectCount < $wgMaxRedirects){
46 - if( UploadFromUrl::isValidURI( $head['Location'] )){
47 - return self::doDownload ( $head['Location'], $target_file_path , $dl_mode, $redirectCount++);
48 - }else{
49 - return Status::newFatal('upload-proto-error');
 46+ // check for redirects:
 47+ if( isset( $head['Location'] ) && strrpos( $head[0], '302' ) !== false ){
 48+ if( $redirectCount < $wgMaxRedirects ){
 49+ if( UploadFromUrl::isValidURI( $head['Location'] ) ){
 50+ return self::doDownload( $head['Location'], $target_file_path , $dl_mode, $redirectCount++ );
 51+ } else {
 52+ return Status::newFatal( 'upload-proto-error' );
5053 }
51 - }else{
52 - return Status::newFatal('upload-too-many-redirects');
 54+ } else {
 55+ return Status::newFatal( 'upload-too-many-redirects' );
5356 }
5457 }
55 - //we did not get a 200 ok response:
56 - if( strrpos($head[0], '200 OK') === false){
57 - return Status::newFatal( 'upload-http-error', htmlspecialchars($head[0]) );
 58+ // we did not get a 200 ok response:
 59+ if( strrpos( $head[0], '200 OK' ) === false ){
 60+ return Status::newFatal( 'upload-http-error', htmlspecialchars( $head[0] ) );
5861 }
5962
60 -
61 - $content_length = (isset($head['Content-Length']))?$head['Content-Length']:null;
62 - if($content_length){
63 - if($content_length > $wgMaxUploadSize){
64 - return Status::newFatal('requested file length ' . $content_length . ' is greater than $wgMaxUploadSize: ' . $wgMaxUploadSize);
 63+ $content_length = ( isset( $head['Content-Length'] ) ) ? $head['Content-Length'] : null;
 64+ if( $content_length ){
 65+ if( $content_length > $wgMaxUploadSize ){
 66+ return Status::newFatal( 'requested file length ' . $content_length . ' is greater than $wgMaxUploadSize: ' . $wgMaxUploadSize );
6567 }
6668 }
6769
68 - //check if we can find phpCliPath (for doing a background shell request to php to do the download:
69 - if( $wgPhpCliPath && wfShellExecEnabled() && $dl_mode == self::ASYNC_DOWNLOAD){
70 - wfDebug("\ASYNC_DOWNLOAD\n");
71 - //setup session and shell call:
 70+ // check if we can find phpCliPath (for doing a background shell request to php to do the download:
 71+ if( $wgPhpCliPath && wfShellExecEnabled() && $dl_mode == self::ASYNC_DOWNLOAD ){
 72+ wfDebug( __METHOD__ . "\ASYNC_DOWNLOAD\n" );
 73+ // setup session and shell call:
7274 return self::initBackgroundDownload( $url, $target_file_path, $content_length );
73 - }else if( $dl_mode== self::SYNC_DOWNLOAD ){
74 - wfDebug("\nSYNC_DOWNLOAD\n");
75 - //SYNC_DOWNLOAD download as much as we can in the time we have to execute
76 - $opts['method']='GET';
 75+ } else if( $dl_mode == self::SYNC_DOWNLOAD ){
 76+ wfDebug( __METHOD__ . "\nSYNC_DOWNLOAD\n" );
 77+ // SYNC_DOWNLOAD download as much as we can in the time we have to execute
 78+ $opts['method'] = 'GET';
7779 $opts['target_file_path'] = $target_file_path;
78 - $req = new HttpRequest($url, $opts );
 80+ $req = new HttpRequest( $url, $opts );
7981 return $req->doRequest();
8082 }
8183 }
 84+
8285 /**
8386 * a non blocking request (generally an exit point in the application)
8487 * should write to a file location and give updates
@@ -87,66 +90,67 @@
8891 global $wgMaxUploadSize, $IP, $wgPhpCliPath;
8992 $status = Status::newGood();
9093
91 - //generate a session id with all the details for the download (pid, target_file_path )
 94+ // generate a session id with all the details for the download (pid, target_file_path )
9295 $upload_session_key = self::getUploadSessionKey();
9396 $session_id = session_id();
9497
95 - //store the url and target path:
96 - $_SESSION[ 'wsDownload' ][$upload_session_key]['url'] = $url;
97 - $_SESSION[ 'wsDownload' ][$upload_session_key]['target_file_path'] = $target_file_path;
 98+ // store the url and target path:
 99+ $_SESSION['wsDownload'][$upload_session_key]['url'] = $url;
 100+ $_SESSION['wsDownload'][$upload_session_key]['target_file_path'] = $target_file_path;
98101
99 - if($content_length)
100 - $_SESSION[ 'wsDownload' ][$upload_session_key]['content_length'] = $content_length;
 102+ if( $content_length )
 103+ $_SESSION['wsDownload'][$upload_session_key]['content_length'] = $content_length;
101104
102 - //set initial loaded bytes:
103 - $_SESSION[ 'wsDownload' ][$upload_session_key]['loaded'] = 0;
 105+ // set initial loaded bytes:
 106+ $_SESSION['wsDownload'][$upload_session_key]['loaded'] = 0;
104107
105 -
106 - //run the background download request:
 108+ // run the background download request:
107109 $cmd = $wgPhpCliPath . ' ' . $IP . "/maintenance/http_session_download.php --sid {$session_id} --usk {$upload_session_key}";
108 - $pid = wfShellBackgroundExec($cmd , $retval);
109 - //the pid is not of much use since we won't be visiting this same apache any-time soon.
110 - if(!$pid)
111 - return Status::newFatal('could not run background shell exec');
 110+ $pid = wfShellBackgroundExec( $cmd, $retval );
 111+ // the pid is not of much use since we won't be visiting this same apache any-time soon.
 112+ if( !$pid )
 113+ return Status::newFatal( 'could not run background shell exec' );
112114
113 - //update the status value with the $upload_session_key (for the user to check on the status of the upload)
 115+ // update the status value with the $upload_session_key (for the user to check on the status of the upload)
114116 $status->value = $upload_session_key;
115117
116 - //return good status
 118+ // return good status
117119 return $status;
118120 }
 121+
119122 function getUploadSessionKey(){
120123 $key = mt_rand( 0, 0x7fffffff );
121124 $_SESSION['wsUploadData'][$key] = array();
122125 return $key;
123126 }
 127+
124128 /**
125129 * used to run a session based download. Is initiated via the shell.
126130 *
127 - * @param string $session_id // the session id to grab download details from
128 - * @param string $upload_session_key //the key of the given upload session
 131+ * @param $session_id String: the session id to grab download details from
 132+ * @param $upload_session_key String: the key of the given upload session
129133 * (a given client could have started a few http uploads at once)
130134 */
131135 public static function doSessionIdDownload( $session_id, $upload_session_key ){
132136 global $wgUser, $wgEnableWriteAPI, $wgAsyncHTTPTimeout;
133 - wfDebug("\n\ndoSessionIdDownload\n\n");
134 - //set session to the provided key:
135 - session_id($session_id);
136 - //start the session
137 - if( session_start() === false){
138 - wfDebug( __METHOD__ . ' could not start session');
 137+ wfDebug( __METHOD__ . "\n\ndoSessionIdDownload\n\n" );
 138+ // set session to the provided key:
 139+ session_id( $session_id );
 140+ // start the session
 141+ if( session_start() === false ){
 142+ wfDebug( __METHOD__ . ' could not start session' );
139143 }
140144 //get all the vars we need from session_id
141145 if(!isset($_SESSION[ 'wsDownload' ][$upload_session_key])){
142146 wfDebug( __METHOD__ .' Error:could not find upload session');
143147 exit();
144148 }
145 - //setup the global user from the session key we just inherited
 149+ // setup the global user from the session key we just inherited
146150 $wgUser = User::newFromSession();
147151
148 - //grab the session data to setup the request:
149 - $sd =& $_SESSION[ 'wsDownload' ][$upload_session_key];
150 - //close down the session so we can other http queries can get session updates:
 152+ // grab the session data to setup the request:
 153+ $sd =& $_SESSION['wsDownload'][$upload_session_key];
 154+ // close down the session so we can other http queries can get session updates:
151155 session_write_close();
152156
153157 $req = new HttpRequest( $sd['url'], array(
@@ -154,49 +158,49 @@
155159 'upload_session_key'=> $upload_session_key,
156160 'timeout' => $wgAsyncHTTPTimeout
157161 ) );
158 - //run the actual request .. (this can take some time)
159 - wfDebug("do Request: " . $sd['url'] . ' tf: ' . $sd['target_file_path'] );
 162+ // run the actual request .. (this can take some time)
 163+ wfDebug( __METHOD__ . "do Request: " . $sd['url'] . ' tf: ' . $sd['target_file_path'] );
160164 $status = $req->doRequest();
161165 //wfDebug("done with req status is: ". $status->isOK(). ' '.$status->getWikiText(). "\n");
162166
163 - //start up the session again:
164 - if( session_start() === false){
 167+ // start up the session again:
 168+ if( session_start() === false ){
165169 wfDebug( __METHOD__ . ' ERROR:: Could not start session');
166170 }
167 - //grab the updated session data pointer
168 - $sd =& $_SESSION[ 'wsDownload' ][$upload_session_key];
169 - //if error update status:
 171+ // grab the updated session data pointer
 172+ $sd =& $_SESSION['wsDownload'][$upload_session_key];
 173+ // if error update status:
170174 if( !$status->isOK() ){
171 - $sd['apiUploadResult']= ApiFormatJson::getJsonEncode(
172 - array( 'error' => $status->getWikiText() )
173 - );
 175+ $sd['apiUploadResult'] = ApiFormatJson::getJsonEncode(
 176+ array( 'error' => $status->getWikiText() )
 177+ );
174178 }
175 - //if status oky process upload using fauxReq to api:
 179+ // if status okay process upload using fauxReq to api:
176180 if( $status->isOK() ){
177 - //setup the faxRequest
 181+ // setup the FauxRequest
178182 $fauxReqData = $sd['mParams'];
179183 $fauxReqData['action'] = 'upload';
180184 $fauxReqData['format'] = 'json';
181185 $fauxReqData['internalhttpsession'] = $upload_session_key;
182 - //evil but no other clean way about it:
183186
184 - $faxReq = new FauxRequest($fauxReqData, true);
185 - $processor = new ApiMain($faxReq, $wgEnableWriteAPI);
 187+ // evil but no other clean way about it:
 188+ $faxReq = new FauxRequest( $fauxReqData, true );
 189+ $processor = new ApiMain( $faxReq, $wgEnableWriteAPI );
186190
187191 //init the mUpload var for the $processor
188192 $processor->execute();
189193 $processor->getResult()->cleanUpUTF8();
190 - $printer = $processor->createPrinterByName('json');
191 - $printer->initPrinter(false);
 194+ $printer = $processor->createPrinterByName( 'json' );
 195+ $printer->initPrinter( false );
192196 ob_start();
193197 $printer->execute();
194198 $apiUploadResult = ob_get_clean();
195199
196 - wfDebug("\n\n got api result:: $apiUploadResult \n" );
197 - //the status updates runner will grab the result form the session:
 200+ wfDebug( __METHOD__ . "\n\n got api result:: $apiUploadResult \n" );
 201+ // the status updates runner will grab the result form the session:
198202 $sd['apiUploadResult'] = $apiUploadResult;
199203 }
200 - //close the session:
 204+ // close the session:
201205 session_write_close();
202206 }
203207
@@ -245,16 +249,18 @@
246250 class HttpRequest{
247251 var $target_file_path;
248252 var $upload_session_key;
249 - function __construct($url, $opt){
 253+
 254+ function __construct( $url, $opt ){
250255 global $wgSyncHTTPTimeout;
251256 $this->url = $url;
252 - //set the timeout to default sync timeout (unless the timeout option is provided)
253 - $this->timeout = (isset($opt['timeout']))?$opt['timeout']:$wgSyncHTTPTimeout;
254 - $this->method = (isset($opt['method']))?$opt['method']:'GET';
255 - $this->target_file_path = (isset($opt['target_file_path']))?$opt['target_file_path']:false;
256 - $this->upload_session_key = (isset($opt['upload_session_key']))?$opt['upload_session_key']:false;
 257+ // set the timeout to default sync timeout (unless the timeout option is provided)
 258+ $this->timeout = ( isset( $opt['timeout'] ) ) ? $opt['timeout'] : $wgSyncHTTPTimeout;
 259+ $this->method = ( isset( $opt['method'] ) ) ? $opt['method'] : 'GET';
 260+ $this->target_file_path = ( isset( $opt['target_file_path'] ) ) ? $opt['target_file_path'] : false;
 261+ $this->upload_session_key = ( isset( $opt['upload_session_key'] ) ) ? $opt['upload_session_key'] : false;
257262 }
258 -/**
 263+
 264+ /**
259265 * Get the contents of a file by HTTP
260266 * @param $url string Full URL to act on
261267 * @param $Opt associative array Optional array of options:
@@ -262,36 +268,35 @@
263269 * 'target_file_path' => if curl should output to a target file
264270 * 'adapter' => 'curl', 'soket'
265271 */
266 - public function doRequest() {
 272+ public function doRequest() {
267273 # Use curl if available
268274 if ( function_exists( 'curl_init' ) ) {
269275 return $this->doCurlReq();
270 - }else{
 276+ } else {
271277 return $this->doPhpReq();
272278 }
273 - }
274 - private function doCurlReq(){
 279+ }
 280+
 281+ private function doCurlReq(){
275282 global $wgHTTPProxy, $wgTitle;
276283
277284 $status = Status::newGood();
278285 $c = curl_init( $this->url );
279286
280 - //proxy setup:
 287+ // proxy setup:
281288 if ( Http::isLocalURL( $this->url ) ) {
282289 curl_setopt( $c, CURLOPT_PROXY, 'localhost:80' );
283 - } else if ($wgHTTPProxy) {
284 - curl_setopt($c, CURLOPT_PROXY, $wgHTTPProxy);
 290+ } else if ( $wgHTTPProxy ) {
 291+ curl_setopt( $c, CURLOPT_PROXY, $wgHTTPProxy );
285292 }
286293
287294 curl_setopt( $c, CURLOPT_TIMEOUT, $this->timeout );
288 -
289 -
290295 curl_setopt( $c, CURLOPT_USERAGENT, Http::userAgent() );
291296
292297 if ( $this->method == 'POST' ) {
293298 curl_setopt( $c, CURLOPT_POST, true );
294299 curl_setopt( $c, CURLOPT_POSTFIELDS, '' );
295 - }else{
 300+ } else {
296301 curl_setopt( $c, CURLOPT_CUSTOMREQUEST, $this->method );
297302 }
298303
@@ -304,39 +309,39 @@
305310 curl_setopt( $c, CURLOPT_REFERER, $wgTitle->getFullURL() );
306311 }
307312
308 - //set the write back function (if we are writing to a file)
 313+ // set the write back function (if we are writing to a file)
309314 if( $this->target_file_path ){
310315 $cwrite = new simpleFileWriter( $this->target_file_path, $this->upload_session_key );
311 - if(!$cwrite->status->isOK()){
312 - wfDebug("ERROR in setting up simpleFileWriter\n");
 316+ if( !$cwrite->status->isOK() ){
 317+ wfDebug( __METHOD__ . "ERROR in setting up simpleFileWriter\n" );
313318 $status = $cwrite->status;
314319 }
315 - curl_setopt( $c, CURLOPT_WRITEFUNCTION, array($cwrite, 'callbackWriteBody') );
 320+ curl_setopt( $c, CURLOPT_WRITEFUNCTION, array( $cwrite, 'callbackWriteBody' ) );
316321 }
317322
318 - //start output grabber:
319 - if(!$this->target_file_path)
 323+ // start output grabber:
 324+ if( !$this->target_file_path )
320325 ob_start();
321326
322327 //run the actual curl_exec:
323328 try {
324 - if (false === curl_exec($c)) {
325 - $error_txt ='Error sending request: #' . curl_errno($c) .' '. curl_error($c);
326 - wfDebug($error_txt . "\n");
327 - $status = Status::newFatal( $error_txt);
328 - }
329 - } catch (Exception $e) {
330 - //do something with curl exec error?
331 - }
332 - //if direct request output the results to the stats value:
 329+ if ( false === curl_exec( $c ) ) {
 330+ $error_txt ='Error sending request: #' . curl_errno( $c ) .' '. curl_error( $c );
 331+ wfDebug( __METHOD__ . $error_txt . "\n" );
 332+ $status = Status::newFatal( $error_txt );
 333+ }
 334+ } catch ( Exception $e ) {
 335+ // do something with curl exec error?
 336+ }
 337+ // if direct request output the results to the stats value:
333338 if( !$this->target_file_path && $status->isOK() ){
334 - $status->value = ob_get_contents();
 339+ $status->value = ob_get_contents();
335340 ob_end_clean();
336341 }
337 - //if we wrote to a target file close up or return error
 342+ // if we wrote to a target file close up or return error
338343 if( $this->target_file_path ){
339344 $cwrite->close();
340 - if( ! $cwrite->status->isOK() ){
 345+ if( !$cwrite->status->isOK() ){
341346 return $cwrite->status;
342347 }
343348 }
@@ -356,9 +361,10 @@
357362 }
358363 curl_close( $c );
359364
360 - //return the result obj
 365+ // return the result obj
361366 return $status;
362367 }
 368+
363369 public function doPhpReq(){
364370 #$use file_get_contents...
365371 # This doesn't have local fetch capabilities...
@@ -376,57 +382,59 @@
377383 $ctx = stream_context_create( $opts );
378384
379385 $status->value = file_get_contents( $url, false, $ctx );
380 - if(!$status->value){
381 - $status->error('file_get_contents-failed');
 386+ if( !$status->value ){
 387+ $status->error( 'file_get_contents-failed' );
382388 }
383389 return $status;
384390 }
 391+
385392 }
 393+
386394 /**
387395 * a simpleFileWriter with session id updates
388 - *
389396 */
390 -class simpleFileWriter{
 397+class simpleFileWriter {
391398 var $target_file_path;
392399 var $status = null;
393400 var $session_id = null;
394 - var $session_update_interval = 0; //how offten to update the session while downloading
 401+ var $session_update_interval = 0; // how often to update the session while downloading
395402
396 - function simpleFileWriter($target_file_path, $upload_session_key){
 403+ function simpleFileWriter( $target_file_path, $upload_session_key ){
397404 $this->target_file_path = $target_file_path;
398405 $this->upload_session_key = $upload_session_key;
399406 $this->status = Status::newGood();
400 - //open the file:
401 - $this->fp = fopen( $this->target_file_path, 'w');
 407+ // open the file:
 408+ $this->fp = fopen( $this->target_file_path, 'w' );
402409 if( $this->fp === false ){
403 - $this->status = Status::newFatal('HTTP::could-not-open-file-for-writing');
 410+ $this->status = Status::newFatal( 'HTTP::could-not-open-file-for-writing' );
404411 }
405 - //true start time
 412+ // true start time
406413 $this->prevTime = time();
407414 }
 415+
408416 public function callbackWriteBody($ch, $data_packet){
409417 global $wgMaxUploadSize;
410418
411 - //write out the content
412 - if( fwrite($this->fp, $data_packet) === false){
413 - wfDebug(__METHOD__ ." ::could-not-write-to-file\n");
414 - $this->status = Status::newFatal('HTTP::could-not-write-to-file');
 419+ // write out the content
 420+ if( fwrite( $this->fp, $data_packet ) === false ){
 421+ wfDebug( __METHOD__ ." ::could-not-write-to-file\n" );
 422+ $this->status = Status::newFatal( 'HTTP::could-not-write-to-file' );
415423 return 0;
416424 }
417425
418 - //check file size:
 426+ // check file size:
419427 clearstatcache();
420 - $this->current_fsize = filesize( $this->target_file_path);
 428+ $this->current_fsize = filesize( $this->target_file_path );
421429
422 - if( $this->current_fsize > $wgMaxUploadSize){
423 - wfDebug( __METHOD__ . " ::http download too large\n");
424 - $this->status = Status::newFatal('HTTP::file-has-grown-beyond-upload-limit-killing: downloaded more than ' .
425 - Language::formatSize($wgMaxUploadSize) . ' ');
 430+ if( $this->current_fsize > $wgMaxUploadSize ){
 431+ wfDebug( __METHOD__ . " ::http download too large\n" );
 432+ $this->status = Status::newFatal( 'HTTP::file-has-grown-beyond-upload-limit-killing: downloaded more than ' .
 433+ Language::formatSize( $wgMaxUploadSize ) . ' ' );
426434 return 0;
427435 }
428436
429 - //if more than session_update_interval second have passed update_session_progress
430 - if($this->upload_session_key && ( (time() - $this->prevTime) > $this->session_update_interval )) {
 437+ // if more than session_update_interval second have passed update_session_progress
 438+ if( $this->upload_session_key && ( ( time() - $this->prevTime ) > $this->session_update_interval ) ) {
431439 $this->prevTime = time();
432440 $session_status = $this->update_session_progress();
433441 if( !$session_status->isOK() ){
@@ -437,32 +445,35 @@
438446 }
439447 return strlen( $data_packet );
440448 }
 449+
441450 public function update_session_progress(){
442451 $status = Status::newGood();
443 - //start the session
 452+ // start the session
444453 if( session_start() === false){
445 - wfDebug( __METHOD__ . ' could not start session');
446 - exit(0);
 454+ wfDebug( __METHOD__ . ' could not start session' );
 455+ exit( 0 );
447456 }
448 - $sd =& $_SESSION[ 'wsDownload' ][ $this->upload_session_key ];
449 - //check if the user canceled the request:
 457+ $sd =& $_SESSION['wsDownload'][$this->upload_session_key];
 458+ // check if the user canceled the request:
450459 if( $sd['user_cancel'] == true ){
451 - //kill the download
452 - return Status::newFatal('user-canceled-request');
 460+ // kill the download
 461+ return Status::newFatal( 'user-canceled-request' );
453462 }
454 - //update the progress bytes download so far:
 463+ // update the progress bytes download so far:
455464 $sd['loaded'] = $this->current_fsize;
456 - wfDebug('set session loaded amount to: ' . $sd['loaded'] . "\n");
457 - //close down the session so we can other http queries can get session updates:
 465+ wfDebug( __METHOD__ . ': set session loaded amount to: ' . $sd['loaded'] . "\n");
 466+ // close down the session so we can other http queries can get session updates:
458467 session_write_close();
459468 return $status;
460469 }
 470+
461471 public function close(){
462 - //do a final session update:
 472+ // do a final session update:
463473 $this->update_session_progress();
464 - //close up the file handle:
465 - if(false === fclose( $this->fp )){
466 - $this->status = Status::newFatal('HTTP::could-not-close-file');
 474+ // close up the file handle:
 475+ if( false === fclose( $this->fp ) ){
 476+ $this->status = Status::newFatal( 'HTTP::could-not-close-file' );
467477 }
468478 }
 479+
469480 }
\ No newline at end of file
Index: trunk/phase3/includes/OutputPage.php
@@ -15,7 +15,7 @@
1616 var $mCategoryLinks = array(), $mLanguageLinks = array();
1717
1818 var $mScriptLoaderClassList = array();
19 - //the most recent id of any script that is grouped in the script request
 19+ // the most recent id of any script that is grouped in the script request
2020 var $mLatestScriptRevID = 0;
2121
2222 var $mScripts = '', $mLinkColours, $mPageLinkTitle = '', $mHeadItems = array();
@@ -93,8 +93,7 @@
9494 function addKeyword( $text ) {
9595 if( is_array( $text )) {
9696 $this->mKeywords = array_merge( $this->mKeywords, $text );
97 - }
98 - else {
 97+ } else {
9998 array_push( $this->mKeywords, $text );
10099 }
101100 }
@@ -116,26 +115,27 @@
117116 if( substr( $file, 0, 1 ) == '/' ) {
118117 $path = $file;
119118 } else {
120 - $path = "{$wgStylePath}/common/{$file}";
 119+ $path = "{$wgStylePath}/common/{$file}";
121120 }
 121+
122122 if( $wgEnableScriptLoader ){
123 - if( strpos($path, $wgScript) !== false ){
124 - $reqPath = str_replace($wgScript.'?', '', $path);
125 - $reqArgs = split('&', $reqPath);
 123+ if( strpos( $path, $wgScript ) !== false ){
 124+ $reqPath = str_replace( $wgScript . '?', '', $path );
 125+ $reqArgs = split( '&', $reqPath );
126126 $reqSet = array();
127127
128 - foreach($reqArgs as $arg){
129 - list($key, $var) = split('=', $arg);
130 - $reqSet[$key]= $var;
 128+ foreach( $reqArgs as $arg ){
 129+ list( $key, $var ) = split( '=', $arg );
 130+ $reqSet[$key] = $var;
131131 }
132132
133 - if( isset( $reqSet['title'] ) && $reqSet != '' ) {
134 - //extract any extra param (for now just skin)
135 - $ext_param = ( isset( $reqSet['useskin'] ) && $reqSet['useskin'] != '') ? '|useskin=' . ucfirst( $reqSet['useskin'] ) : '';
 133+ if( isset( $reqSet['title'] ) && $reqSet != '' ) {
 134+ // extract any extra param (for now just skin)
 135+ $ext_param = ( isset( $reqSet['useskin'] ) && $reqSet['useskin'] != '' ) ? '|useskin=' . ucfirst( $reqSet['useskin'] ) : '';
136136 $this->mScriptLoaderClassList[] = 'WT:' . $reqSet['title'] . $ext_param ;
137 - //add the title revision to the key
 137+ // add the title revision to the key
138138 $t = Title::newFromText( $reqSet['title'] );
139 - //if there is no title (don't worry we just use the $wgStyleVersion var (which should be updated on relevant commits)
 139+ // if there is no title (don't worry we just use the $wgStyleVersion var (which should be updated on relevant commits)
140140 if( $t->exists() ){
141141 if( $t->getLatestRevID() > $this->mLatestScriptRevID )
142142 $this->mLatestScriptRevID = $t->getLatestRevID();
@@ -143,16 +143,17 @@
144144 return true;
145145 }
146146 }
147 - //check for class from path:
 147+
 148+ // check for class from path:
148149 $js_class = $this->getJsClassFromPath( $path );
149150 if( $js_class ){
150 - //add to the class list:
 151+ // add to the class list:
151152 $this->mScriptLoaderClassList[] = $js_class;
152153 return true;
153154 }
154155 }
155 - //die();
156 - //if the script loader did not find a way to add the script than add using AddScript
 156+
 157+ // if the script loader did not find a way to add the script than add using addScript
157158 $this->addScript(
158159 Xml::element( 'script',
159160 array(
@@ -163,49 +164,57 @@
164165 )
165166 );
166167 }
167 - /*
 168+
 169+ /**
168170 * This is the core script that is included on every page
169171 * (they are requested separately to improve caching across
170172 * different page load types (edit, upload, view, etc)
171173 */
172174 function addCoreScripts2Top(){
173 - global $wgEnableScriptLoader, $wgStyleVersion,$wgJSAutoloadLocalClasses, $wgJsMimeType, $wgScriptPath, $wgEnableJS2system ;
174 - //@@todo we should depricate wikibits in favor of mv_embed and native jQuery functions
 175+ global $wgEnableScriptLoader, $wgStyleVersion, $wgJSAutoloadLocalClasses, $wgJsMimeType, $wgScriptPath, $wgEnableJS2system;
 176+ //@@todo we should deprecate wikibits in favor of mv_embed and native jQuery functions
175177
176178 if( $wgEnableJS2system ){
177 - $core_classes = array('window.jQuery', 'mv_embed', 'wikibits');
178 - }else{
179 - $core_classes = array('wikibits');
 179+ $core_classes = array( 'window.jQuery', 'mv_embed', 'wikibits' );
 180+ } else {
 181+ $core_classes = array( 'wikibits' );
180182 }
 183+
181184 if( $wgEnableScriptLoader ){
182185 $this->mScripts = $this->getScriptLoaderJs( $core_classes ) . $this->mScripts;
183 - }else{
 186+ } else {
184187 $so = '';
185 - foreach($core_classes as $s){
186 - if(isset( $wgJSAutoloadLocalClasses[$s] )){
187 - $so.= Xml::element( 'script', array(
188 - 'type' => $wgJsMimeType,
189 - 'src' => "{$wgScriptPath}/{$wgJSAutoloadLocalClasses[$s]}?" . $this->getURIDparam()
190 - ),
191 - '', false
192 - );
 188+ foreach( $core_classes as $s ){
 189+ if( isset( $wgJSAutoloadLocalClasses[$s] ) ){
 190+ $so.= Xml::element( 'script', array(
 191+ 'type' => $wgJsMimeType,
 192+ 'src' => "{$wgScriptPath}/{$wgJSAutoloadLocalClasses[$s]}?" . $this->getURIDparam()
 193+ ),
 194+ '', false
 195+ );
193196 }
194197 }
195198 $this->mScripts = $so . $this->mScripts;
196199 }
197200 }
 201+
 202+ /**
 203+ * @param $js_class String: name of JavaScript class
 204+ * @return Boolean: false if class wasn't found, true on success
 205+ */
198206 function addScriptClass( $js_class ){
199207 global $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses, $wgJsMimeType,
200208 $wgEnableScriptLoader, $wgStyleVersion, $wgScriptPath;
201 - if(isset($wgJSAutoloadClasses[ $js_class ] ) || isset( $wgJSAutoloadLocalClasses[$js_class]) ){
202 - if($wgEnableScriptLoader){
203 - if( ! in_array( $js_class, $this->mScriptLoaderClassList ) ){
 209+
 210+ if( isset( $wgJSAutoloadClasses[$js_class] ) || isset( $wgJSAutoloadLocalClasses[$js_class] ) ){
 211+ if( $wgEnableScriptLoader ){
 212+ if( !in_array( $js_class, $this->mScriptLoaderClassList ) ){
204213 $this->mScriptLoaderClassList[] = $js_class;
205214 }
206 - }else{
207 - //do a normal load of without the script-loader:
 215+ } else {
 216+ // do a normal load of without the script-loader:
208217 $path = $wgScriptPath . '/';
209 - $path.= isset($wgJSAutoloadClasses[ $js_class ] )?$wgJSAutoloadClasses[ $js_class ]:
 218+ $path.= isset( $wgJSAutoloadClasses[$js_class] ) ? $wgJSAutoloadClasses[$js_class]:
210219 $wgJSAutoloadLocalClasses[$js_class];
211220 $this->addScript(
212221 Xml::element( 'script',
@@ -219,25 +228,26 @@
220229 }
221230 return true;
222231 }
223 - wfDebug( __METHOD__ . " could not find js_class: " . $js_class );
224 - return false; //could not find the class
 232+ wfDebug( __METHOD__ . ' could not find js_class: ' . $js_class );
 233+ return false; // could not find the class
225234 }
 235+
226236 /**
227237 * gets the scriptLoader javascript include
228 - *
 238+ * @param $forcClassAry Boolean: false by default
229239 */
230 - function getScriptLoaderJs( $forceClassAry=false ){
 240+ function getScriptLoaderJs( $forceClassAry = false ){
231241 global $wgScriptPath, $wgJsMimeType, $wgStyleVersion, $wgRequest, $wgDebugJavaScript;
232242
233 - if(!$forceClassAry){
234 - $class_list = implode(',', $this->mScriptLoaderClassList );
235 - }else{
236 - $class_list = implode(',', $forceClassAry );
 243+ if( !$forceClassAry ){
 244+ $class_list = implode( ',', $this->mScriptLoaderClassList );
 245+ } else {
 246+ $class_list = implode( ',', $forceClassAry );
237247 }
238248
239249 $debug_param = ( $wgDebugJavaScript ||
240 - $wgRequest->getVal('debug')=='true' ||
241 - $wgRequest->getVal('debug')=='1' )
 250+ $wgRequest->getVal( 'debug' ) == 'true' ||
 251+ $wgRequest->getVal( 'debug' ) == '1' )
242252 ? '&debug=true' : '';
243253
244254 //@@todo intelligent unique id generation based on svn version of file (rather than just grabbing the $wgStyleVersion var)
@@ -254,25 +264,28 @@
255265 '', false
256266 );
257267 }
 268+
258269 function getURIDparam(){
259 - global $wgDebugJavaScript,$wgStyleVersion;
 270+ global $wgDebugJavaScript, $wgStyleVersion;
260271 if( $wgDebugJavaScript ){
261 - return "urid=". time();
262 - }else{
 272+ return 'urid=' . time();
 273+ } else {
263274 return "urid={$wgStyleVersion}_{$this->mLatestScriptRevID}";
264275 }
265276 }
 277+
266278 function getJsClassFromPath( $path ){
267279 global $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses, $wgScriptPath;
268280
269281 $scriptLoaderPaths = array_merge( $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses );
270282 foreach( $scriptLoaderPaths as $js_class => $js_path ){
271283 $js_path = "{$wgScriptPath}/{$js_path}";
272 - if($path == $js_path)
 284+ if( $path == $js_path )
273285 return $js_class;
274286 }
275287 return false;
276288 }
 289+
277290 /**
278291 * Add a self-contained script tag with the given contents
279292 * @param string $script JavaScript text, no <script> tags
@@ -285,9 +298,9 @@
286299 function getScript() {
287300 global $wgEnableScriptLoader;
288301 if( $wgEnableScriptLoader ){
289 - //include $this->mScripts (for anything that we could not package into the scriptloader
290 - return $this->mScripts ."\n". $this->getScriptLoaderJs() . $this->getHeadItems();
291 - }else{
 302+ //include $this->mScripts (for anything that we could not package into the scriptloader
 303+ return $this->mScripts . "\n" . $this->getScriptLoaderJs() . $this->getHeadItems();
 304+ } else {
292305 return $this->mScripts . $this->getHeadItems();
293306 }
294307 }
@@ -1117,7 +1130,7 @@
11181131
11191132 $sk = $wgUser->getSkin();
11201133
1121 - //add our core scripts to output
 1134+ // add our core scripts to output
11221135 $this->addCoreScripts2Top();
11231136
11241137 if ( $wgUseAjax ) {
@@ -1915,9 +1928,15 @@
19161929 $options['dir'] = $dir;
19171930 $this->styles[$style] = $options;
19181931 }
 1932+
 1933+ /**
 1934+ * Adds inline CSS styles
 1935+ * @param $style_css Mixed: inline CSS
 1936+ */
19191937 public function addInlineStyle( $style_css ){
19201938 $this->mScripts .= "<style type=\"text/css\">$style_css</style>";
19211939 }
 1940+
19221941 /**
19231942 * Build a set of <link>s for the stylesheets specified in the $this->styles array.
19241943 * These will be applied to various media & IE conditionals.
Index: trunk/phase3/includes/AutoLoader.php
@@ -580,12 +580,12 @@
581581
582582 );
583583
584 -//autoloader for javascript files (path is from the mediawiki folder
 584+// Autoloader for JavaScript files (path is from the MediaWiki folder)
585585 global $wgJSAutoloadLocalClasses;
586586 $wgJSAutoloadLocalClasses = array(
587 - 'ajax' => 'skins/common/ajax.js',
588 - 'ajaxwatch' => 'skins/common/ajaxwatch.js',
589 - 'allmessages' => 'skins/common/allmessages.js',
 587+ 'ajax' => 'skins/common/ajax.js',
 588+ 'ajaxwatch' => 'skins/common/ajaxwatch.js',
 589+ 'allmessages' => 'skins/common/allmessages.js',
590590 'block' => 'skins/common/block.js',
591591 'changepassword' => 'skins/common/changepassword.js',
592592 'diff' => 'skins/common/diff.js',
@@ -599,13 +599,13 @@
600600 'preview' => 'skins/common/preview.js',
601601 'protect' => 'skins/common/protect.js',
602602 'rightclickedit' => 'skins/common/rightclickedit.js',
603 - 'sticky' => 'skins/common/sticky.js',
 603+ 'sticky' => 'skins/common/sticky.js',
604604 'upload' => 'skins/common/upload.js',
605605 'wikibits' => 'skins/common/wikibits.js',
606606
607 - //phase 2 javascript:
 607+ // phase 2 javascript:
608608 'uploadPage' => 'js2/uploadPage.js',
609 - 'editPage' => 'js2/editPage.js',
 609+ 'editPage' => 'js2/editPage.js',
610610 );
611611
612612 //Include the js2 autoLoadClasses
Index: trunk/phase3/includes/api/ApiUpload.php
@@ -22,35 +22,33 @@
2323 * http://www.gnu.org/copyleft/gpl.html
2424 */
2525
26 -if (!defined('MEDIAWIKI')) {
 26+if ( !defined( 'MEDIAWIKI' ) ) {
2727 // Eclipse helper - will be ignored in production
28 - require_once ("ApiBase.php");
 28+ require_once("ApiBase.php");
2929 }
3030
31 -
3231 /**
3332 * @ingroup API
3433 */
3534 class ApiUpload extends ApiBase {
3635 var $mUpload = null;
3736
38 - public function __construct($main, $action) {
39 - parent :: __construct($main, $action);
 37+ public function __construct( $main, $action ) {
 38+ parent::__construct( $main, $action );
4039 }
4140
4241 public function execute() {
4342 global $wgUser;
4443
45 -
4644 $this->getMain()->isWriteMode();
4745 $this->mParams = $this->extractRequestParams();
4846 $request = $this->getMain()->getRequest();
4947
50 - //do token checks:
51 - if(is_null($this->mParams['token']))
52 - $this->dieUsageMsg(array('missingparam', 'token'));
53 - if(!$wgUser->matchEditToken($this->mParams['token']))
54 - $this->dieUsageMsg(array('sessionfailure'));
 48+ // do token checks:
 49+ if( is_null( $this->mParams['token'] ) )
 50+ $this->dieUsageMsg( array( 'missingparam', 'token' ) );
 51+ if( !$wgUser->matchEditToken( $this->mParams['token'] ) )
 52+ $this->dieUsageMsg( array( 'sessionfailure' ) );
5553
5654
5755 // Add the uploaded file to the params array
@@ -60,24 +58,24 @@
6159 if( !UploadBase::isEnabled() )
6260 $this->dieUsageMsg( array( 'uploaddisabled' ) );
6361
64 - wfDebug("running require param\n");
 62+ wfDebug( __METHOD__ . "running require param\n" );
6563 // One and only one of the following parameters is needed
6664 $this->requireOnlyOneParameter( $this->mParams,
6765 'sessionkey', 'file', 'url', 'enablechunks' );
6866
6967 if( $this->mParams['enablechunks'] ){
70 - //chunks upload enabled
 68+ // chunks upload enabled
7169 $this->mUpload = new UploadFromChunks();
7270 $this->mUpload->initializeFromParams( $this->mParams, $request );
7371
7472 //if getAPIresult did not exit report the status error:
75 - if( isset( $this->mUpload->status[ 'error' ] ) )
76 - $this->dieUsageMsg( $this->mUpload->status[ 'error' ] );
 73+ if( isset( $this->mUpload->status['error'] ) )
 74+ $this->dieUsageMsg( $this->mUpload->status['error'] );
7775
78 - }else if( $this->mParams['internalhttpsession'] ){
79 - $sd = & $_SESSION['wsDownload'][ $this->mParams['internalhttpsession'] ];
 76+ } else if( $this->mParams['internalhttpsession'] ){
 77+ $sd = & $_SESSION['wsDownload'][$this->mParams['internalhttpsession']];
8078
81 - //get the params from the init session:
 79+ // get the params from the init session:
8280 $this->mUpload = new UploadFromFile();
8381
8482 $this->mUpload->initialize( $this->mParams['filename'],
@@ -88,32 +86,32 @@
8987 if( !isset( $this->mUpload ) )
9088 $this->dieUsage( 'No upload module set', 'nomodule' );
9189
92 - }else if( $this->mParams['httpstatus'] && $this->mParams['sessionkey']){
93 - //return the status of the given upload session_key:
94 - if(!isset($_SESSION['wsDownload'][ $this->mParams['sessionkey'] ])){
 90+ } else if( $this->mParams['httpstatus'] && $this->mParams['sessionkey'] ){
 91+ // return the status of the given upload session_key:
 92+ if( !isset( $_SESSION['wsDownload'][ $this->mParams['sessionkey'] ] ) ){
9593 return $this->getResult()->addValue( null, $this->getModuleName(),
9694 array( 'error' => 'invalid-session-key'
9795 ));
9896 }
99 - $sd = & $_SESSION['wsDownload'][ $this->mParams['sessionkey'] ];
100 - //keep passing down the upload sessionkey
 97+ $sd = & $_SESSION['wsDownload'][$this->mParams['sessionkey']];
 98+ // keep passing down the upload sessionkey
10199 $statusResult = array(
102100 'upload_session_key' => $this->mParams['sessionkey']
103101 );
104102
105 - //put values into the final apiResult if available
106 - if( isset($sd['apiUploadResult'])) $statusResult['apiUploadResult'] = $sd['apiUploadResult'];
107 - if( isset($sd['loaded']) ) $statusResult['loaded'] = $sd['loaded'];
108 - if( isset($sd['content_length']) ) $statusResult['content_length'] = $sd['content_length'];
 103+ // put values into the final apiResult if available
 104+ if( isset( $sd['apiUploadResult'] ) ) $statusResult['apiUploadResult'] = $sd['apiUploadResult'];
 105+ if( isset( $sd['loaded'] ) ) $statusResult['loaded'] = $sd['loaded'];
 106+ if( isset( $sd['content_length'] ) ) $statusResult['content_length'] = $sd['content_length'];
109107
110108 return $this->getResult()->addValue( null, $this->getModuleName(),
111109 $statusResult
112110 );
113 - }else if( $this->mParams['sessionkey'] ) {
 111+ } else if( $this->mParams['sessionkey'] ) {
114112 // Stashed upload
115113 $this->mUpload = new UploadFromStash();
116114 $this->mUpload->initialize( $this->mParams['filename'], $_SESSION['wsUploadData'][$this->mParams['sessionkey']] );
117 - }else{
 115+ } else {
118116 // Upload from url or file
119117 // Parameter filename is required
120118 if( !isset( $this->mParams['filename'] ) )
@@ -130,7 +128,7 @@
131129 } elseif( isset( $this->mParams['url'] ) ) {
132130
133131 $this->mUpload = new UploadFromUrl();
134 - $this->mUpload->initialize( $this->mParams['filename'], $this->mParams['url'], $this->mParams['asyncdownload']);
 132+ $this->mUpload->initialize( $this->mParams['filename'], $this->mParams['url'], $this->mParams['asyncdownload'] );
135133
136134 $status = $this->mUpload->fetchFile();
137135 if( !$status->isOK() ){
@@ -139,13 +137,13 @@
140138 //check if we doing a async request set session info and return the upload_session_key)
141139 if( $this->mUpload->isAsync() ){
142140 $upload_session_key = $status->value;
143 - //update the session with anything with the params we will need to finish up the upload later on:
144 - if(!isset($_SESSION['wsDownload'][$upload_session_key]))
 141+ // update the session with anything with the params we will need to finish up the upload later on:
 142+ if( !isset( $_SESSION['wsDownload'][$upload_session_key] ) )
145143 $_SESSION['wsDownload'][$upload_session_key] = array();
146144
147145 $sd =& $_SESSION['wsDownload'][$upload_session_key];
148146
149 - //copy mParams for finishing up after:
 147+ // copy mParams for finishing up after:
150148 $sd['mParams'] = $this->mParams;
151149
152150 return $this->getResult()->addValue( null, $this->getModuleName(),
@@ -162,12 +160,12 @@
163161 //finish up the exec command:
164162 $this->doExecUpload();
165163 }
 164+
166165 function doExecUpload(){
167166 global $wgUser;
168 - //Check whether the user has the appropriate permissions to upload anyway
 167+ // Check whether the user has the appropriate permissions to upload anyway
169168 $permission = $this->mUpload->isAllowed( $wgUser );
170169
171 -
172170 if( $permission !== true ) {
173171 if( !$wgUser->isLoggedIn() )
174172 $this->dieUsageMsg( array( 'mustbeloggedin', 'upload' ) );
@@ -180,6 +178,7 @@
181179 $this->mUpload->cleanupTempFile();
182180 $this->getResult()->addValue( null, $this->getModuleName(), $result );
183181 }
 182+
184183 private function performUpload() {
185184 global $wgUser;
186185 $result = array();
@@ -235,6 +234,7 @@
236235 }
237236 return $result;
238237 }
 238+
239239 if( !$this->mParams['ignorewarnings'] ) {
240240 $warnings = $this->mUpload->checkWarnings();
241241 if( $warnings ) {
@@ -251,7 +251,8 @@
252252 return $result;
253253 }
254254 }
255 - //do the upload
 255+
 256+ // do the upload
256257 $status = $this->mUpload->performUpload( $this->mParams['comment'],
257258 $this->mParams['comment'], $this->mParams['watch'], $wgUser );
258259
@@ -267,17 +268,16 @@
268269 $result['result'] = 'Success';
269270 $result['filename'] = $file->getName();
270271
271 -
272272 // Append imageinfo to the result
273273
274 - //might be a cleaner way to call this:
 274+ // might be a cleaner way to call this:
275275 $imParam = ApiQueryImageInfo::getAllowedParams();
276 - $imProp = $imParam['prop'][ApiBase :: PARAM_TYPE];
 276+ $imProp = $imParam['prop'][ApiBase::PARAM_TYPE];
277277 $result['imageinfo'] = ApiQueryImageInfo::getInfo( $file,
278278 array_flip( $imProp ),
279279 $this->getResult() );
280280
281 - wfDebug("\n\n return result: " . print_r($result, true));
 281+ wfDebug( "\n\n return result: " . print_r( $result, true ) );
282282
283283 return $result;
284284 }
@@ -287,35 +287,35 @@
288288 }
289289
290290 public function getAllowedParams() {
291 - return array (
 291+ return array(
292292 'filename' => null,
293293 'file' => null,
294294 'chunk' => null,
295295 'url' => null,
296 - 'token' => null,
 296+ 'token' => null,
297297 'enablechunks' => null,
298298 'comment' => array(
299 - ApiBase :: PARAM_DFLT => ''
 299+ ApiBase::PARAM_DFLT => ''
300300 ),
301 - 'asyncdownload'=>false,
 301+ 'asyncdownload' => false,
302302 'watch' => false,
303303 'ignorewarnings' => false,
304 - 'done' => false,
 304+ 'done' => false,
305305 'sessionkey' => null,
306306 'httpstatus' => null,
307 - 'chunksessionkey'=> null,
308 - 'internalhttpsession'=> null,
 307+ 'chunksessionkey' => null,
 308+ 'internalhttpsession' => null,
309309 );
310310 }
311311
312312 public function getParamDescription() {
313 - return array (
 313+ return array(
314314 'filename' => 'Target filename',
315315 'file' => 'File contents',
316316 'chunk'=> 'Chunk File Contents',
317317 'url' => 'Url to upload from',
318318 'comment' => 'Upload comment or initial page text',
319 - 'token' => 'Edit token. You can get one of these through prop=info (this helps avoid remote ajax upload requests with your credentials)',
 319+ 'token' => 'Edit token. You can get one of these through prop=info (this helps avoid remote ajax upload requests with your credentials)',
320320 'enablechunks' => 'Boolean If we are in chunk mode; accepts many small file POSTs',
321321 'asyncdownload' => 'If we should download the url asyncrously usefull for large http downloads (returns a upload session key to get status updates in subquent calls)',
322322 'watch' => 'Watch the page',
@@ -330,12 +330,12 @@
331331
332332 public function getDescription() {
333333 return array(
334 - 'Upload an File'
 334+ 'Upload a file'
335335 );
336336 }
337337
338338 protected function getExamples() {
339 - return array (
 339+ return array(
340340 'api.php?action=upload&filename=Wiki.png&url=http%3A//upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png&ignorewarnings'
341341 );
342342 }
Index: trunk/phase3/mwScriptLoader.php
@@ -1,38 +1,33 @@
22 <?php
3 -/*
4 - * mvwScriptLoader.php
5 -* Script Loading Library for MediaWiki
6 -*
7 -* @author Michael Dale mdale@wikimedia.org
8 -* @date feb, 2009
9 -*
10 -* This program is free software; you can redistribute it and/or modify
11 -* it under the terms of the GNU General Public License as published by
12 -* the Free Software Foundation; either version 2 of the License, or
13 -* (at your option) any later version.
14 -*
15 -* This program is distributed in the hope that it will be useful,
16 -* but WITHOUT ANY WARRANTY; without even the implied warranty of
17 -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 -* GNU General Public License for more details.
19 -*
20 -* You should have received a copy of the GNU General Public License along
21 -* with this program; if not, write to the Free Software Foundation, Inc.,
22 -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 -* http://www.gnu.org/copyleft/gpl.html
24 -*/
25 -
26 -/*
27 - * mvwScriptLoader:
 3+/**
 4+ * mvwScriptLoader.php
 5+ * Script Loading Library for MediaWiki
286 *
29 - * some documentation about script-loader:
30 - * http://www.mediawiki.org/wiki/ScriptLoader
 7+ * @file
 8+ * @author Michael Dale mdale@wikimedia.org
 9+ * @date feb, 2009
 10+ * @link http://www.mediawiki.org/wiki/ScriptLoader Documentation
 11+ *
 12+ * This program is free software; you can redistribute it and/or modify
 13+ * it under the terms of the GNU General Public License as published by
 14+ * the Free Software Foundation; either version 2 of the License, or
 15+ * (at your option) any later version.
 16+ *
 17+ * This program is distributed in the hope that it will be useful,
 18+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 19+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 20+ * GNU General Public License for more details.
 21+ *
 22+ * You should have received a copy of the GNU General Public License along
 23+ * with this program; if not, write to the Free Software Foundation, Inc.,
 24+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 25+ * http://www.gnu.org/copyleft/gpl.html
3126 */
3227
33 -//include WebStart.php
 28+// include WebStart.php
3429 require_once('includes/WebStart.php');
3530
36 -wfProfileIn('mvwScriptLoader.php');
 31+wfProfileIn( 'mvwScriptLoader.php' );
3732
3833 if( isset( $_SERVER['SCRIPT_URL'] ) ) {
3934 $url = $_SERVER['SCRIPT_URL'];
@@ -40,27 +35,26 @@
4136 $url = $_SERVER['PHP_SELF'];
4237 }
4338
44 -if( strpos($url, "mwScriptLoader$wgScriptExtension") === false){
 39+if( strpos( $url, "mwScriptLoader$wgScriptExtension" ) === false ){
4540 wfHttpError( 403, 'Forbidden',
4641 'mvwScriptLoader must be accessed through the primary script entry point.' );
47 - return ;
 42+ return;
4843 }
49 -//Verify the script loader is on:
50 -if (!$wgEnableScriptLoader) {
 44+// Verify the script loader is on:
 45+if ( !$wgEnableScriptLoader ) {
5146 echo '/*ScriptLoader is not enabled for this site. To enable add the following line to your LocalSettings.php';
5247 echo '<pre><b>$wgEnableScriptLoader=true;</b></pre>*/';
5348 echo 'alert(\'Script loader is disabled\');';
54 - die(1);
 49+ die( 1 );
5550 }
5651
57 -//load the mwEmbed language file:
 52+// load the mwEmbed language file:
5853 $wgExtensionMessagesFiles['mwEmbed'] = "{$IP}/js2/mwEmbed/php/languages/mwEmbed.i18n.php";
59 -//enable the msgs before we go on:
 54+// enable the msgs before we go on:
6055 wfLoadExtensionMessages( 'mwEmbed' );
6156
62 -//run jsScriptLoader action:
 57+// run jsScriptLoader action:
6358 $myScriptLoader = new jsScriptLoader();
6459 $myScriptLoader->doScriptLoader();
6560
66 -wfProfileOut();
67 -?>
\ No newline at end of file
 61+wfProfileOut( 'mvwScriptLoader.php' );
\ No newline at end of file

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r53282here it is ... the upload-api, script-server, js2 (javascript phase2) branch ...dale23:52, 14 July 2009

Status & tagging log