Comments and whitespace fixes only.
authorTim Starling <tstarling@users.mediawiki.org>
Thu, 10 Sep 2009 06:43:01 +0000 (06:43 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Thu, 10 Sep 2009 06:43:01 +0000 (06:43 +0000)
14 files changed:
includes/DefaultSettings.php
includes/EditPage.php
includes/GlobalFunctions.php
includes/HttpFunctions.php
includes/OutputPage.php
includes/QueryPage.php
includes/Skin.php
includes/SkinTemplate.php
includes/api/ApiFormatJson.php
includes/filerepo/FSRepo.php
includes/specials/SpecialUpload.php
skins/MonoBook.php
skins/common/upload.js
skins/common/wikibits.js

index 8b216f0..19bf3b7 100644 (file)
@@ -459,13 +459,11 @@ $wgMaxUploadSize = 1024*1024*100; # 100MB
 
 
 /**
-* Enable firefogg support
-* add support for in-browser transcoding to ogg theora
-* add support for chunk uploads for large image files
-* add support for client side hash checks
-*
-* (requires the js2 code for the interface)
-*/
+ * Enable Firefogg support. Adds support for in-browser transcoding to Ogg 
+ * Theora, chunked uploads for large image files and client side hash checks.
+ *
+ * Ignored unless $wgEnableJS2system is true.
+ */
 $wgEnableFirefogg = true;
 
 /**
@@ -2726,10 +2724,9 @@ $wgSpecialPages = array();
  */
 $wgAutoloadClasses = array();
 
-
 /*
- * Array mapping javascript class to web path for autoloading js
- * this var is populated in AutoLoader.php
+ * Array mapping JavaScript class to web path for use by the script loader.
+ * This is populated in AutoLoader.php.
  */
 $wgJSAutoloadClasses = array();
 
@@ -2761,17 +2758,20 @@ $wgScriptModifiedCheck = true;
 $wgEnableJS2system = false;
 
 /*
- * boolean; if relative file paths can be used (in addition to the autoload js classes listed in: $wgJSAutoloadClasses
+ * boolean; if relative file paths can be used (in addition to the autoload 
+ * js classes listed in: $wgJSAutoloadClasses)
  */
 $wgEnableScriptLoaderJsFile = false;
 
 /*
- * boolean; if we should minify the output. (note if you send ?debug=true in the page request it will automatically not group and not minify)
+ * boolean; if we should minify the output. (note if you send ?debug=true in 
+ * the page request it will automatically not group and not minify)
  */
 $wgEnableScriptMinify = true;
 
 /*
- * boolean; if we should enable javascript localization (it loads loadGM json call with mediaWiki msgs)
+ * boolean; if we should enable javascript localization (it loads loadGM json 
+ * call with mediaWiki msgs)
  */
 $wgEnableScriptLocalization = true;
 
@@ -2781,10 +2781,9 @@ $wgEnableScriptLocalization = true;
 $wgMwEmbedDirectory = "js2/mwEmbed/";
 
 /*
- * wgDebugJavaScript used to turn on debuging for the javascript script-loader
- * & forces fresh copies of javascript
+ * Turn on debugging for the javascript script-loader & forces fresh copies 
+ * of javascript
  */
-
 $wgDebugJavaScript = false;
 
 
@@ -3614,8 +3613,9 @@ $wgAllowSpecialInclusion = true;
  * default is (default php.ini script time 30s - 5s for everything else)
  */
 $wgSyncHTTPTimeout = 25;
+
 /**
-* Timeout for asynchronous http request that run in a background php proccess
+* Timeout for asynchronous HTTP requests that run in a background PHP process
 * default set to 20 min
 */
 $wgAsyncHTTPTimeout = 60*20;
@@ -3693,7 +3693,8 @@ $wgAjaxWatch = true;
 $wgAjaxUploadDestCheck = true;
 
 /**
- * Enable AJAX upload interface (need for large http uploads & to display progress on uploads for browsers that support it)
+ * Enable the AJAX upload interface (needed for large http uploads & to display 
+ * progress on uploads for browsers that support it)
  */
 $wgAjaxUploadInterface = true;
 
@@ -3758,7 +3759,7 @@ $wgMaxShellFileSize = 102400;
 $wgMaxShellTime = 180;
 
 /**
-* Executable Path of PHP cli client (php/php5)  (should be setup on install)
+* Executable path of the PHP cli binary (php/php5). Should be set up on install.
 */
 $wgPhpCli = '/usr/bin/php';
 
index 42c74c9..001e04b 100644 (file)
@@ -385,14 +385,14 @@ class EditPage {
                }
 
                if ( wfReadOnly() && $this->save ) {
-                               // Force preview
-                               $this->save = false;
-                               $this->preview = true;
+                       // Force preview
+                       $this->save = false;
+                       $this->preview = true;
                }
 
                $wgOut->addScriptFile( 'edit.js' );
 
-               if($wgEnableJS2system)
+               if( $wgEnableJS2system )
                    $wgOut->addScriptClass( 'editPage' );
 
                $permErrors = $this->getEditPermissionErrors();
index b6de6f0..8efa1f2 100644 (file)
@@ -2346,19 +2346,19 @@ function wfShellExec( $cmd, &$retval=null ) {
 }
 
 /**
- * Executes a shell command in the background. Returns true of successful. 
+ * Executes a shell command in the background. Returns true if successful.
  *
  * @param $cmd String
  */
-function wfShellBackgroundExec( $cmd ) {       
+function wfShellBackgroundExec( $cmd ) {
        wfDebug( "wfShellBackgroundExec: $cmd\n" );
-       
-       if ( ! wfShellExecEnabled() ) {
+
+       if ( !wfShellExecEnabled() ) {
                return false;
        }
-       
+
        if ( wfIsWindows() ) {
-               shell_exec( "start /b $cmd >nul");
+               shell_exec( "start /b $cmd >nul" );
                return true;
        } else {
                $pid = shell_exec( "nohup $cmd > /dev/null & echo $!" );
@@ -2367,10 +2367,9 @@ function wfShellBackgroundExec( $cmd ) {
 }
 
 /**
- * Checks if the current instance can execute a shell command
- *
+ * Return true if we can execute a shell command (i.e. not safe mode, etc.)
  */
-function wfShellExecEnabled(){                 
+function wfShellExecEnabled() {
        if( wfIniGetBool( 'safe_mode' ) ) {
                wfDebug( "wfShellExec can't run in safe_mode, PHP's exec functions are too broken.\n" );
                return false;
@@ -2809,7 +2808,7 @@ function wfHttpOnlySafe() {
                        }
                }
        }
-       
+
        return true;
 }
 
index 9393c86..8f15d19 100644 (file)
@@ -7,16 +7,17 @@
  */
 
 class Http {
-       const SYNC_DOWNLOAD = 1;  // syncronys upload (in a single request)
-       const ASYNC_DOWNLOAD = 2; // asynchronous upload we should spawn out another process and monitor progress if possible)
+       const SYNC_DOWNLOAD = 1;  // syncronous upload (in a single request)
+       const ASYNC_DOWNLOAD = 2; // asynchronous upload
 
        var $body = '';
 
-       public static function request( $method, $url, $opts = array() ){
-               $opts['method'] = ( strtoupper( $method ) == 'GET' || strtoupper( $method ) == 'POST' ) ? strtoupper( $method ) : null;
+       public static function request( $method, $url, $opts = array() ) {
+               $opts['method'] = ( strtoupper( $method ) == 'GET' || strtoupper( $method ) == 'POST' ) 
+                       ? strtoupper( $method ) : null;
                $req = HttpRequest::newRequest( $url, $opts );
                $status = $req->doRequest();
-               if( $status->isOK() ){
+               if( $status->isOK() ) {
                        return $status->value;
                } else {
                        wfDebug( 'http error: ' . $status->getWikiText() );
@@ -41,21 +42,24 @@ class Http {
                return Http::request( 'POST', $url, $opts );
        }
 
-       public static function doDownload( $url, $target_file_path, $dl_mode = self::SYNC_DOWNLOAD, $redirectCount = 0 ){
+       public static function doDownload( $url, $target_file_path, $dl_mode = self::SYNC_DOWNLOAD, 
+               $redirectCount = 0 )
+       {
                global $wgPhpCli, $wgMaxUploadSize, $wgMaxRedirects;
                // do a quick check to HEAD to insure the file size is not > $wgMaxUploadSize
                $headRequest = HttpRequest::newRequest( $url, array( 'headers_only' => true ) );
                $headResponse = $headRequest->doRequest();
-               if( !$headResponse->isOK() ){
+               if( !$headResponse->isOK() ) {
                        return $headResponse;
                }
                $head = $headResponse->value;
 
                // check for redirects:
-               if( isset( $head['Location'] ) && strrpos( $head[0], '302' ) !== false ){
-                       if( $redirectCount < $wgMaxRedirects ){
-                               if( self::isValidURI( $head['Location'] ) ){
-                                       return self::doDownload( $head['Location'], $target_file_path, $dl_mode, $redirectCount++ );
+               if( isset( $head['Location'] ) && strrpos( $head[0], '302' ) !== false ) {
+                       if( $redirectCount < $wgMaxRedirects ) { 
+                               if( self::isValidURI( $head['Location'] ) ) {
+                                       return self::doDownload( $head['Location'], $target_file_path, 
+                                               $dl_mode, $redirectCount++ );
                                } else {
                                        return Status::newFatal( 'upload-proto-error' );
                                }
@@ -64,20 +68,22 @@ class Http {
                        }
                }
                // we did not get a 200 ok response:
-               if( strrpos( $head[0], '200 OK' ) === false ){
+               if( strrpos( $head[0], '200 OK' ) === false ) {
                        return Status::newFatal( 'upload-http-error', htmlspecialchars( $head[0] ) );
                }
 
                $content_length = ( isset( $head['Content-Length'] ) ) ? $head['Content-Length'] : null;
-               if( $content_length ){
-                       if( $content_length > $wgMaxUploadSize ){
-                               return Status::newFatal( 'requested file length ' . $content_length . ' is greater than $wgMaxUploadSize: ' . $wgMaxUploadSize );
+               if( $content_length ) {
+                       if( $content_length > $wgMaxUploadSize ) {
+                               return Status::newFatal( 'requested file length ' . $content_length . 
+                                       ' is greater than $wgMaxUploadSize: ' . $wgMaxUploadSize );
                        }
                }
 
-               // check if we can find phpCliPath (for doing a background shell request to php to do the download:
-               if( $wgPhpCli && wfShellExecEnabled() && $dl_mode == self::ASYNC_DOWNLOAD ){
-                       wfDebug( __METHOD__ . "\ASYNC_DOWNLOAD\n" );
+               // check if we can find phpCliPath (for doing a background shell request to 
+               // php to do the download:
+               if( $wgPhpCli && wfShellExecEnabled() && $dl_mode == self::ASYNC_DOWNLOAD ) {
+                       wfDebug( __METHOD__ . "\nASYNC_DOWNLOAD\n" );
                        //setup session and shell call:
                        return self::initBackgroundDownload( $url, $target_file_path, $content_length );
                } else {
@@ -95,7 +101,9 @@ class Http {
         * should write to a file location and give updates
         *
         */
-       private static function initBackgroundDownload( $url, $target_file_path, $content_length = null ){
+       private static function initBackgroundDownload( $url, $target_file_path, 
+               $content_length = null ) 
+       {
                global $wgMaxUploadSize, $IP, $wgPhpCli, $wgServer;
                $status = Status::newGood();
 
@@ -116,20 +124,22 @@ class Http {
                $_SESSION['wsDownload'][$upload_session_key]['loaded'] = 0;
 
                // run the background download request:
-               $cmd = $wgPhpCli . ' ' . $IP . "/maintenance/http_session_download.php --sid {$session_id} --usk {$upload_session_key}";
+               $cmd = $wgPhpCli . ' ' . $IP . "/maintenance/http_session_download.php " . 
+                       "--sid {$session_id} --usk {$upload_session_key}";
                $pid = wfShellBackgroundExec( $cmd );
                // the pid is not of much use since we won't be visiting this same apache any-time soon.
                if( !$pid )
                        return Status::newFatal( 'could not run background shell exec' );
 
-               // update the status value with the $upload_session_key (for the user to check on the status of the upload)
+               // update the status value with the $upload_session_key (for the user to 
+               // check on the status of the upload)
                $status->value = $upload_session_key;
 
                // return good status
                return $status;
        }
 
-       static function getUploadSessionKey(){
+       static function getUploadSessionKey() {
                $key = mt_rand( 0, 0x7fffffff );
                $_SESSION['wsUploadData'][$key] = array();
                return $key;
@@ -142,7 +152,7 @@ class Http {
         * @param $upload_session_key String: the key of the given upload session
         *  (a given client could have started a few http uploads at once)
         */
-       public static function doSessionIdDownload( $session_id, $upload_session_key ){
+       public static function doSessionIdDownload( $session_id, $upload_session_key ) {
                global $wgUser, $wgEnableWriteAPI, $wgAsyncHTTPTimeout, $wgServer,
                                $wgSessionsInMemcached, $wgSessionHandler, $wgSessionStarted;
                wfDebug( __METHOD__ . "\n\n doSessionIdDownload :\n\n" );
@@ -152,11 +162,11 @@ class Http {
                wfSetupSession();
 
                // start the session
-               if( session_start() === false ){
+               if( session_start() === false ) {
                        wfDebug( __METHOD__ . ' could not start session' );
                }
                // get all the vars we need from session_id
-               if( !isset( $_SESSION[ 'wsDownload' ][$upload_session_key] ) ){
+               if( !isset( $_SESSION[ 'wsDownload' ][$upload_session_key] ) ) {
                        wfDebug(  __METHOD__ . ' Error:could not find upload session');
                        exit();
                }
@@ -166,11 +176,13 @@ class Http {
                // grab the session data to setup the request:
                $sd =& $_SESSION['wsDownload'][$upload_session_key];
 
-               // update the wgServer var ( since cmd line thinks we are localhost when we are really orgServer)
-               if( isset( $sd['orgServer'] ) && $sd['orgServer'] ){
+               // update the wgServer var ( since cmd line thinks we are localhost 
+               // when we are really orgServer)
+               if( isset( $sd['orgServer'] ) && $sd['orgServer'] ) {
                        $wgServer = $sd['orgServer'];
                }
-               // close down the session so we can other http queries can get session updates: (if not $wgSessionsInMemcached)
+               // close down the session so we can other http queries can get session 
+               // updates: (if not $wgSessionsInMemcached)
                if( !$wgSessionsInMemcached )
                        session_write_close();
 
@@ -181,18 +193,19 @@ class Http {
                        'do_close_session_update' => true
                ) );
                // run the actual request .. (this can take some time)
-               wfDebug( __METHOD__ . 'do Session Download :: ' . $sd['url'] . ' tf: ' . $sd['target_file_path'] . "\n\n");
+               wfDebug( __METHOD__ . 'do Session Download :: ' . $sd['url'] . ' tf: ' . 
+                       $sd['target_file_path'] . "\n\n");
                $status = $req->doRequest();
                //wfDebug("done with req status is: ". $status->isOK(). ' '.$status->getWikiText(). "\n");
 
                // start up the session again:
-               if( session_start() === false ){
+               if( session_start() === false ) {
                        wfDebug( __METHOD__ . ' ERROR:: Could not start session');
                }
                // grab the updated session data pointer
                $sd =& $_SESSION['wsDownload'][$upload_session_key];
                // if error update status:
-               if( !$status->isOK() ){
+               if( !$status->isOK() ) {
                        $sd['apiUploadResult'] = ApiFormatJson::getJsonEncode(
                                array( 'error' => $status->getWikiText() )
                        );
@@ -301,8 +314,10 @@ class HttpRequest {
                }
 
                $this->method = ( isset( $opt['method'] ) ) ? $opt['method'] : 'GET';
-               $this->target_file_path = ( isset( $opt['target_file_path'] ) ) ? $opt['target_file_path'] : false;
-               $this->upload_session_key = ( isset( $opt['upload_session_key'] ) ) ? $opt['upload_session_key'] : false;
+               $this->target_file_path = ( isset( $opt['target_file_path'] ) ) 
+                       ? $opt['target_file_path'] : false;
+               $this->upload_session_key = ( isset( $opt['upload_session_key'] ) ) 
+                       ? $opt['upload_session_key'] : false;
                $this->headers_only = ( isset( $opt['headers_only'] ) ) ? $opt['headers_only'] : false;
                $this->do_close_session_update = isset( $opt['do_close_session_update'] );
                $this->postData = isset( $opt['postdata'] ) ? $opt['postdata'] : '';
@@ -348,7 +363,7 @@ class curlHttpRequest extends HttpRequest {
                // proxy setup:
                if ( Http::isLocalURL( $this->url ) ) {
                        curl_setopt( $c, CURLOPT_PROXY, 'localhost:80' );
-               } else if ( $wgHTTPProxy ) {
+               } elseif ( $wgHTTPProxy ) {
                        curl_setopt( $c, CURLOPT_PROXY, $wgHTTPProxy );
                }
 
@@ -385,12 +400,12 @@ class curlHttpRequest extends HttpRequest {
                }
 
                // set the write back function (if we are writing to a file)
-               if( $this->target_file_path ){
+               if( $this->target_file_path ) {
                        $cwrite = new simpleFileWriter( $this->target_file_path,
                                $this->upload_session_key,
                                $this->do_close_session_update
                        );
-                       if( !$cwrite->status->isOK() ){
+                       if( !$cwrite->status->isOK() ) {
                                wfDebug( __METHOD__ . "ERROR in setting up simpleFileWriter\n" );
                                $status = $cwrite->status;
                                return $status;
@@ -413,14 +428,14 @@ class curlHttpRequest extends HttpRequest {
                        // do something with curl exec error?
                }
                // if direct request output the results to the stats value:
-               if( !$this->target_file_path && $status->isOK() ){
+               if( !$this->target_file_path && $status->isOK() ) {
                        $status->value = ob_get_contents();
                        ob_end_clean();
                }
                // if we wrote to a target file close up or return error
-               if( $this->target_file_path ){
+               if( $this->target_file_path ) {
                        $cwrite->close();
-                       if( !$cwrite->status->isOK() ){
+                       if( !$cwrite->status->isOK() ) {
                                return $cwrite->status;
                        }
                }
@@ -462,10 +477,10 @@ class curlHttpRequest extends HttpRequest {
        }
 }
 class phpHttpRequest extends HttpRequest {
-       public function doReq(){
+       public function doReq() {
                global $wgTitle, $wgHTTPProxy;
                # Check for php.ini allow_url_fopen
-               if( !ini_get( 'allow_url_fopen' ) ){
+               if( !ini_get( 'allow_url_fopen' ) ) {
                        return Status::newFatal( 'allow_url_fopen needs to be enabled for http copy to work' );
                }
 
@@ -497,22 +512,24 @@ class phpHttpRequest extends HttpRequest {
                $fh = fopen( $this->url, "r", false, $fcontext);
 
                // set the write back function (if we are writing to a file)
-               if( $this->target_file_path ){
-                       $cwrite = new simpleFileWriter( $this->target_file_path, $this->upload_session_key, $this->do_close_session_update );
-                       if( !$cwrite->status->isOK() ){
+               if( $this->target_file_path ) {
+                       $cwrite = new simpleFileWriter( $this->target_file_path, 
+                               $this->upload_session_key, $this->do_close_session_update );
+                       if( !$cwrite->status->isOK() ) {
                                wfDebug( __METHOD__ . "ERROR in setting up simpleFileWriter\n" );
                                $status = $cwrite->status;
                                return $status;
                        }
 
-                       // read $fh into the simpleFileWriter (grab in 64K chunks since its likely a ~large~ media file)
+                       // read $fh into the simpleFileWriter (grab in 64K chunks since 
+                       // it's likely a ~large~ media file)
                        while ( !feof( $fh ) ) {
                                $contents = fread( $fh, 65536 );
                                $cwrite->callbackWriteBody( $fh, $contents );
                        }
                        $cwrite->close();
                        // check for simpleFileWriter error:
-                       if( !$cwrite->status->isOK() ){
+                       if( !$cwrite->status->isOK() ) {
                                return $cwrite->status;
                        }
                } else {
@@ -523,7 +540,7 @@ class phpHttpRequest extends HttpRequest {
                fclose( $fh );
 
                // check for "false"
-               if( $status->value === false ){
+               if( $status->value === false ) {
                        $status->error( 'file_get_contents-failed' );
                }
                return $status;
@@ -540,25 +557,27 @@ class simpleFileWriter {
        var $session_id = null;
        var $session_update_interval = 0; // how often to update the session while downloading
 
-       function simpleFileWriter( $target_file_path, $upload_session_key, $do_close_session_update = false ){
+       function simpleFileWriter( $target_file_path, $upload_session_key, 
+               $do_close_session_update = false ) 
+       {
                $this->target_file_path = $target_file_path;
                $this->upload_session_key = $upload_session_key;
                $this->status = Status::newGood();
                $this->do_close_session_update = $do_close_session_update;
                // open the file:
                $this->fp = fopen( $this->target_file_path, 'w' );
-               if( $this->fp === false ){
+               if( $this->fp === false ) {
                        $this->status = Status::newFatal( 'HTTP::could-not-open-file-for-writing' );
                }
                // true start time
                $this->prevTime = time();
        }
 
-       public function callbackWriteBody( $ch, $data_packet ){
+       public function callbackWriteBody( $ch, $data_packet ) {
                global $wgMaxUploadSize, $wgLang;
 
                // write out the content
-               if( fwrite( $this->fp, $data_packet ) === false ){
+               if( fwrite( $this->fp, $data_packet ) === false ) {
                        wfDebug( __METHOD__ ." ::could-not-write-to-file\n" );
                        $this->status = Status::newFatal( 'HTTP::could-not-write-to-file' );
                        return 0;
@@ -568,9 +587,10 @@ class simpleFileWriter {
                clearstatcache();
                $this->current_fsize = filesize( $this->target_file_path );
 
-               if( $this->current_fsize > $wgMaxUploadSize ){
+               if( $this->current_fsize > $wgMaxUploadSize ) {
                        wfDebug( __METHOD__ . " ::http download too large\n" );
-                       $this->status = Status::newFatal( 'HTTP::file-has-grown-beyond-upload-limit-killing: downloaded more than ' .
+                       $this->status = Status::newFatal( 'HTTP::file-has-grown-beyond-upload-limit-killing: ' . 
+                               'downloaded more than ' .
                                $wgLang->formatSize( $wgMaxUploadSize ) . ' ' );
                        return 0;
                }
@@ -579,7 +599,7 @@ class simpleFileWriter {
                        ( ( time() - $this->prevTime ) > $this->session_update_interval ) ) {
                                $this->prevTime = time();
                                $session_status = $this->update_session_progress();
-                               if( !$session_status->isOK() ){
+                               if( !$session_status->isOK() ) {
                                        $this->status = $session_status;
                                        wfDebug( __METHOD__ . ' update session failed or was canceled');
                                        return 0;
@@ -588,13 +608,13 @@ class simpleFileWriter {
                return strlen( $data_packet );
        }
 
-       public function update_session_progress(){
+       public function update_session_progress() {
                global $wgSessionsInMemcached;
                $status = Status::newGood();
                // start the session (if necessary)
-               if( !$wgSessionsInMemcached ){
+               if( !$wgSessionsInMemcached ) {
                        wfSuppressWarnings();
-                       if( session_start() === false ){
+                       if( session_start() === false ) {
                                wfDebug( __METHOD__ . ' could not start session' );
                                exit( 0 );
                        }
@@ -602,7 +622,7 @@ class simpleFileWriter {
                }
                $sd =& $_SESSION['wsDownload'][ $this->upload_session_key ];
                // check if the user canceled the request:
-               if( isset( $sd['user_cancel'] ) && $sd['user_cancel'] == true ){
+               if( isset( $sd['user_cancel'] ) && $sd['user_cancel'] == true ) {
                        //@@todo kill the download
                        return Status::newFatal( 'user-canceled-request' );
                }
@@ -616,13 +636,13 @@ class simpleFileWriter {
                return $status;
        }
 
-       public function close(){
+       public function close() {
                // do a final session update:
-               if( $this->do_close_session_update ){
+               if( $this->do_close_session_update ) {
                        $this->update_session_progress();
                }
                // close up the file handle:
-               if( false === fclose( $this->fp ) ){
+               if( false === fclose( $this->fp ) ) {
                        $this->status = Status::newFatal( 'HTTP::could-not-close-file' );
                }
        }
index ebdbcc6..de839bf 100644 (file)
@@ -15,7 +15,8 @@ class OutputPage {
        var $mCategoryLinks = array(), $mLanguageLinks = array();
 
        var $mScriptLoaderClassList = array();
-       // the most recent id of any script that is grouped in the script request
+
+       // The most recent revision ID of any script that is grouped in the script request
        var $mLatestScriptRevID = 0;
 
        var $mScripts = '', $mLinkColours, $mPageLinkTitle = '', $mHeadItems = array();
@@ -126,25 +127,27 @@ class OutputPage {
                        $path = "{$wgStylePath}/common/{$file}";
                }
 
-               if( $wgEnableScriptLoader ){
-                       if( strpos( $path, $wgScript ) !== false ){
+               if( $wgEnableScriptLoader ) {
+                       if( strpos( $path, $wgScript ) !== false ) {
                                $reqPath = str_replace( $wgScript . '?', '', $path );
                                $reqArgs = explode( '&', $reqPath );
                                $reqSet = array();
 
-                               foreach( $reqArgs as $arg ){
+                               foreach( $reqArgs as $arg ) {
                                        list( $key, $var ) = explode( '=', $arg );
                                        $reqSet[$key] = $var;
                                }
 
                                if( isset( $reqSet['title'] ) && $reqSet != '' ) {
-                                       // extract any extra param (for now just skin)
-                                       $ext_param = ( isset( $reqSet['useskin'] ) && $reqSet['useskin'] != '' ) ? '|useskin=' . ucfirst( $reqSet['useskin'] ) : '';
+                                       // Extract any extra parameters (for now just skin)
+                                       $ext_param = ( isset( $reqSet['useskin'] ) && $reqSet['useskin'] != '' )
+                                               ? '|useskin=' . ucfirst( $reqSet['useskin'] ) : '';
                                        $this->mScriptLoaderClassList[] = 'WT:' . $reqSet['title'] . $ext_param ;
-                                       // add the title revision to the key
+                                       // Add the title revision to the key.
+                                       // If there is no title, we will just use $wgStyleVersion, 
+                                       // which should be updated on the relevant commits.
                                        $t = Title::newFromText( $reqSet['title'] );
-                                       // if there is no title (don't worry we just use the $wgStyleVersion var (which should be updated on relevant commits)
-                                       if( $t && $t->exists() ){
+                                       if( $t && $t->exists() ) {
                                                if( $t->getLatestRevID() > $this->mLatestScriptRevID  )
                                                        $this->mLatestScriptRevID = $t->getLatestRevID();
                                        }
@@ -152,27 +155,24 @@ class OutputPage {
                                }
                        }
 
-                       // check for class from path:
+                       // If the class can be determined, add it to the class list to be loaded later
                        $js_class = $this->getJsClassFromPath( $path );
-                       if( $js_class ){
-                               // add to the class list:
+                       if( $js_class ) {
                                $this->mScriptLoaderClassList[] = $js_class;
                                return true;
                        }
                }
 
-               // if the script loader did not find a way to add the script than add using addScript
+               // If the script loader could not be used, just add the script to the header
                $this->addScript( Html::linkedScript( wfAppendQuery( $path, $this->getURIDparam() ) ) );
        }
 
        /**
-        * This is the core script that is included on every page
-        * (they are requested separately to improve caching across
-        *  different page load types (edit, upload, view, etc)
+        * Add the core scripts that are included on every page, for later output into the header
         */
        function addCoreScripts2Top(){
                global $wgEnableScriptLoader, $wgJSAutoloadLocalClasses, $wgScriptPath, $wgEnableJS2system;
-               //@@todo we should deprecate wikibits in favor of mv_embed and native jQuery functions
+               // @todo We should deprecate wikibits in favor of mv_embed and jQuery
 
                if( $wgEnableJS2system ){
                        $core_classes = array( 'window.jQuery', 'mv_embed', 'wikibits' );
@@ -194,25 +194,28 @@ class OutputPage {
        }
 
        /**
-        * @param $js_class String: name of JavaScript class
-        * @return Boolean: false if class wasn't found, true on success
+        * @param $js_class string Name of the JavaScript class
+        * @return boolean False if the class wasn't found, true on success
         */
        function addScriptClass( $js_class ){
                global $wgDebugJavaScript, $wgJSAutoloadLocalClasses, $wgJSAutoloadClasses,
                                $wgEnableScriptLoader, $wgStyleVersion, $wgScriptPath;
 
-               if( isset( $wgJSAutoloadClasses[$js_class] ) || isset( $wgJSAutoloadLocalClasses[$js_class] ) ){
-                       if( $wgEnableScriptLoader ){
-                               if( !in_array( $js_class, $this->mScriptLoaderClassList ) ){
+               if( isset( $wgJSAutoloadClasses[$js_class] ) 
+                       || isset( $wgJSAutoloadLocalClasses[$js_class] ) ) 
+               {
+                       if( $wgEnableScriptLoader ) {
+                               // Register it with the script loader
+                               if( !in_array( $js_class, $this->mScriptLoaderClassList ) ) {
                                        $this->mScriptLoaderClassList[] = $js_class;
                                }
                        } else {
-                               // do a normal load of without the script-loader:
+                               // Source the script directly
                                $path = $wgScriptPath . '/';
-                               if( isset( $wgJSAutoloadClasses[$js_class] ) ){
-                                       $path.= $wgJSAutoloadClasses[$js_class];
-                               }else if( isset( $wgJSAutoloadLocalClasses[$js_class] ) ){
-                                       $path.= $wgJSAutoloadLocalClasses[$js_class];
+                               if( isset( $wgJSAutoloadClasses[$js_class] ) ) {
+                                       $path .= $wgJSAutoloadClasses[$js_class];
+                               } elseif( isset( $wgJSAutoloadLocalClasses[$js_class] ) ) {
+                                       $path .= $wgJSAutoloadLocalClasses[$js_class];
                                }
                                $urlAppend = ( $wgDebugJavaScript ) ? time() : $wgStyleVersion;
                                $this->addScript( Html::linkedScript( "$path?$urlAppend" ) );
@@ -224,48 +227,52 @@ class OutputPage {
        }
 
        /**
-        * gets the scriptLoader javascript include
-        * @param $forcClassAry Boolean: false by default
+        * Get the <script> tag which will invoke the script loader
+        * @param $classAry A class array which, if given, overrides $this->mScriptLoaderClassList
         */
-       function getScriptLoaderJs( $classAry = array() ){
+       function getScriptLoaderJs( $classAry = array() ) {
                global $wgRequest, $wgDebugJavaScript;
-               //if no class array provided use the mScriptLoaderClassList var
-               if( !count($classAry) ){
+               // If no class array was provided, use mScriptLoaderClassList
+               if( !count( $classAry ) ) {
                        $classAry = $this->mScriptLoaderClassList;
                }
-               $class_list = implode(',', $classAry);
+               $class_list = implode( ',', $classAry );
 
                $debug_param = ( $wgDebugJavaScript ||
                                                 $wgRequest->getVal( 'debug' ) == 'true' ||
                                                 $wgRequest->getVal( 'debug' ) == '1' )
                                         ? '&debug=true' : '';
 
-               return Html::linkedScript( wfScript( 'mwScriptLoader' ) . "?class={$class_list}{$debug_param}&" . $this->getURIDparam( $classAry) );
+               return Html::linkedScript( wfScript( 'mwScriptLoader' ) . 
+                       "?class={$class_list}{$debug_param}&" . $this->getURIDparam( $classAry) );
        }
 
-       function getURIDparam( $classAry=array() ){
+       /**
+        * Get the unique request ID parameter for the script-loader request
+        */
+       function getURIDparam( $classAry = array() ) {
                global $wgDebugJavaScript, $wgStyleVersion, $IP, $wgScriptModifiedCheck;
-               if( $wgDebugJavaScript ){
+               if( $wgDebugJavaScript ) {
                        return 'urid=' . time();
                } else {
                        $ftime=0;
-                       if($wgScriptModifiedCheck){
-                               foreach( $classAry as $class ){
+                       if($wgScriptModifiedCheck) {
+                               foreach( $classAry as $class ) {
                                        $js_path =  jsScriptLoader::getJsPathFromClass( $class );
-                                       if( $js_path ){
+                                       if( $js_path ) {
                                                $cur_ftime = filemtime ( $IP ."/". $js_path );
                                                if( $cur_ftime > $ftime )
                                                        $ftime = $cur_ftime;
                                        }
                                }
                        }
-                       //set up the urid:
                        $urid = "urid={$wgStyleVersion}";
 
-                       //if we have a $this->mLatestScriptRevID (wiki page revision ids)
+                       // Add the latest revision ID if we have it
                        if($this->mLatestScriptRevID != 0 )
                                $urid .= "_{$this->mLatestScriptRevID}";
 
+                       // Add the file modification time
                        if( $ftime != 0 )
                                $urid .= "_".$ftime;
 
@@ -273,11 +280,15 @@ class OutputPage {
                }
        }
 
-       function getJsClassFromPath( $path ){
+       /**
+        * Given a script path, get the JS class name, or false if no such path is registered.
+        * @param $path string
+        */
+       function getJsClassFromPath( $path ) {
                global $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses, $wgScriptPath;
 
                $scriptLoaderPaths = array_merge( $wgJSAutoloadClasses,  $wgJSAutoloadLocalClasses );
-               foreach( $scriptLoaderPaths as $js_class => $js_path ){
+               foreach( $scriptLoaderPaths as $js_class => $js_path ) {
                        $js_path = "{$wgScriptPath}/{$js_path}";
                        if( $path == $js_path )
                                return $js_class;
@@ -293,10 +304,12 @@ class OutputPage {
                $this->mScripts .= Html::inlineScript( "\n$script\n" ) . "\n";
        }
 
+       /**
+        * Get all registered JS and CSS tags for the header.
+        */
        function getScript() {
                global $wgEnableScriptLoader;
                if( $wgEnableScriptLoader ){
-                       //include $this->mScripts (for anything that we could not package into the scriptloader
                        return $this->mScripts . "\n" . $this->getScriptLoaderJs() . $this->getHeadItems();
                } else {
                        return $this->mScripts . $this->getHeadItems();
@@ -1110,7 +1123,7 @@ class OutputPage {
 
                $sk = $wgUser->getSkin();
 
-               // add our core scripts to output
+               // Add our core scripts to output
                $this->addCoreScripts2Top();
 
                if ( $wgUseAjax ) {
@@ -1130,7 +1143,7 @@ class OutputPage {
                if( $wgUser->getBoolOption( 'editsectiononrightclick' ) ) {
                        $this->addScriptFile( 'rightclickedit.js' );
                }
-               
+
                global $wgUseAJAXCategories;
                if ($wgUseAJAXCategories) {
                        $this->addScriptClass( 'ajaxCategories' );
index cc96076..86a988e 100644 (file)
@@ -616,4 +616,4 @@ abstract class WantedQueryPage extends QueryPage {
                $wgLang->formatNum( $result->value ) );
                return $skin->link( $wlh, $label, array(), array( 'target' => $title->getPrefixedText() ) );
        }
-}
\ No newline at end of file
+}
index 4b5cdc0..74d9fa0 100644 (file)
@@ -417,9 +417,9 @@ class Skin extends Linker {
                }
 
                //if on upload page output the extension list & js_upload
-               if( SpecialPage::resolveAlias( $wgTitle->getDBkey() ) ==  "Upload" ){
+               if( SpecialPage::resolveAlias( $wgTitle->getDBkey() ) ==  "Upload" ) {
                        global $wgFileExtensions, $wgAjaxUploadInterface;
-                       $vars['wgFileExtensions']        = $wgFileExtensions;
+                       $vars['wgFileExtensions'] = $wgFileExtensions;
                        $vars['wgAjaxUploadInterface'] = $wgAjaxUploadInterface;
                }
 
@@ -470,8 +470,6 @@ class Skin extends Linker {
 
                $vars = self::makeGlobalVariablesScript( $this->getSkinName() );
 
-               //moved wikibits to be called earlier on
-               //$out->addScriptFile( "{$wgStylePath}/common/wikibits.js" );
                if( $wgUseSiteJs ) {
                        $jsCache = $wgUser->isLoggedIn() ? '&smaxage=0' : '';
                        $wgOut->addScriptFile(  self::makeUrl( '-',
@@ -482,9 +480,9 @@ class Skin extends Linker {
                }
                if( $out->isUserJsAllowed() && $wgUser->isLoggedIn() ) {
                        $userpage = $wgUser->getUserPage();
-                       $userjs =  self::makeUrl(
-                               $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
-                               'action=raw&ctype='.$wgJsMimeType );
+                       $userjs = self::makeUrl(
+                               $userpage->getPrefixedText() . '/' . $this->getSkinName() . '.js',
+                               'action=raw&ctype=' . $wgJsMimeType );
                        $wgOut->addScriptFile( $userjs );
                }
                return $vars . "\n" . $out->mScripts;
@@ -527,15 +525,15 @@ class Skin extends Linker {
         * top.  For now Monobook.js will be maintained, but it should be consi-
         * dered deprecated.
         *
-        * @param force_skin  lets you override the skin name
+        * @param $force_skin string If set, overrides the skin name
         *
         * @return string
         */
-       public function generateUserJs( $skinName = null) {
+       public function generateUserJs( $skinName = null ) {
                global $wgStylePath;
 
                wfProfileIn( __METHOD__ );
-               if(!$skinName){
+               if( !$skinName ) {
                        $skinName =     $this->getSkinName();
                }
 
@@ -551,7 +549,7 @@ class Skin extends Linker {
                $s .= "\n\n/* MediaWiki:".ucfirst( $skinName ).".js */\n";
                // avoid inclusion of non defined user JavaScript (with custom skins only)
                // by checking for default message content
-               $msgKey = ucfirst( $skinName ).'.js';
+               $msgKey = ucfirst( $skinName ) . '.js';
                $userJS = wfMsgForContent( $msgKey );
                if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
                        $s .= $userJS;
index 2161962..d943c0b 100644 (file)
@@ -98,15 +98,17 @@ class SkinTemplate extends Skin {
                $out->addStyle( 'common/shared.css', 'screen' );
                $out->addStyle( 'common/commonPrint.css', 'print' );
        }
-       /* add specific javascript the base Skin class */
-       function setupSkinUserJs( OutputPage $out ){
+
+       /**
+        * Add specific JavaScript the base Skin class.
+        * FIXME: not called from anywhere
+        */
+       function setupSkinUserJs( OutputPage $out ) {
                global $wgUseSiteJs;
-               //use site js:
                if( $wgUseSiteJs ) {
                        $jsCache = $this->loggedin ? '&smaxage=0' : '';
-                       $siteGenScriptFile =  self::makeUrl( '-',
-                                       "action=raw$jsCache&gen=js&useskin=" .
-                                               urlencode( $this->getSkinName() ) ) ;
+                       $siteGenScriptFile = self::makeUrl( '-',
+                               "action=raw$jsCache&gen=js&useskin=" . urlencode( $this->getSkinName() ) );
                        $this->jsvarurl = $siteGenScriptFile;
                }
        }
@@ -248,9 +250,6 @@ class SkinTemplate extends Skin {
                $tpl->setRef( 'jsmimetype', $wgJsMimeType );
                $tpl->setRef( 'charset', $wgOutputEncoding );
                $tpl->set( 'headlinks', $out->getHeadLinks() );
-
-               //moved headscripts to near end of template header output
-
                $tpl->set( 'csslinks', $out->buildCssLinks() );
                $tpl->setRef( 'wgScript', $wgScript );
                $tpl->setRef( 'skinname', $this->skinname );
@@ -472,7 +471,7 @@ class SkinTemplate extends Skin {
                $tpl->set( 'sidebar', $this->buildSidebar() );
                $tpl->set( 'nav_urls', $this->buildNavUrls() );
 
-               //set the head script near the end (in case above actions result in adding scripts)
+               // Set the head scripts near the end, in case the above actions resulted in added scripts
                $tpl->set( 'headscripts', $out->getScript() );
 
                // original version by hansm
index d831810..fa3a1e2 100644 (file)
@@ -67,7 +67,10 @@ class ApiFormatJson extends ApiFormatBase {
                        $prefix = preg_replace("/[^][.\\'\\\"_A-Za-z0-9]/", "", $callback ) . "(";
                        $suffix = ")";
                }
-               $this->printText( $prefix . FormatJson::encode( $this->getResultData(),   $this->getIsHtml() )  . $suffix);
+               $this->printText( 
+                       $prefix . 
+                       FormatJson::encode( $this->getResultData(),     $this->getIsHtml() ) . 
+                       $suffix );
        }
 
        public function getAllowedParams() {
index 5bc6034..c6b9801 100644 (file)
@@ -226,32 +226,34 @@ class FSRepo extends FileRepo {
                }
                return $status;
        }
-       function append( $srcPath, $toAppendPath ){
+
+       function append( $srcPath, $toAppendPath ) {
                $status = $this->newGood();
 
-               //resolve the virtual url:
+               // Resolve the virtual URL
                if ( self::isVirtualUrl( $srcPath ) ) {
-                               $srcPath = $this->resolveVirtualUrl( $srcPath );
+                       $srcPath = $this->resolveVirtualUrl( $srcPath );
                }
-               //make sure files are there: 
-               if ( !is_file( $srcPath ) )                             
+               // Make sure the files are there
+               if ( !is_file( $srcPath ) )
                        $status->fatal( 'append-src-filenotfound', $srcPath );
-                       
-               if ( !is_file( $toAppendPath ) )                                
+
+               if ( !is_file( $toAppendPath ) )
                        $status->fatal( 'append-toappend-filenotfound', $toAppendPath );
-                       
-               //do the append: 
-               if( file_put_contents( $srcPath, file_get_contents( $toAppendPath ), FILE_APPEND ) ){
+
+               // Do the append
+               if( file_put_contents( $srcPath, file_get_contents( $toAppendPath ), FILE_APPEND ) ) {
                        $status->value = $srcPath;
-               }else{
+               } else {
                        $status->fatal( 'fileappenderror', $toAppendPath,  $srcPath);
                }
-               
-               //either way remove the append chunk as we have no use for it now:
-               unlink($toAppendPath);
-                       
-               return $status;         
+
+               // Remove the source file
+               unlink( $toAppendPath );
+
+               return $status;
        }
+
        /**
         * Checks existence of specified array of files.
         *
index 8820ff2..d46633d 100644 (file)
@@ -23,8 +23,8 @@ class UploadForm extends SpecialPage {
        # extensions should take care to _append_ to the present value
        var $uploadFormTextTop;
        var $uploadFormTextAfterSummary;
-    var $mTokenOk = false;
-    var $mForReUpload = false;
+       var $mTokenOk = false;
+       var $mForReUpload = false;
        /**#@-*/
 
        /**
@@ -129,10 +129,10 @@ class UploadForm extends SpecialPage {
                }
                //check token if uploading or reUploading
                if( !$this->mTokenOk && !$this->mReUpload && ($this->mUpload && (
-                                               'submit' == $this->mAction || $this->mUploadClicked ) )
-               ){
-                   $this->mainUploadForm ( wfMsg( 'session_fail_preview' ) );
-                   return ;
+                                               'submit' == $this->mAction || $this->mUploadClicked ) ) )
+               {
+                       $this->mainUploadForm ( wfMsg( 'session_fail_preview' ) );
+                       return ;
                }
 
 
@@ -167,7 +167,7 @@ class UploadForm extends SpecialPage {
         *
         * @access private
         */
-       function processUpload(){
+       function processUpload() {
                global $wgOut, $wgFileExtensions, $wgLang;
                $details = $this->internalProcessUpload();
                switch( $details['status'] ) {
@@ -277,8 +277,8 @@ class UploadForm extends SpecialPage {
 
                // Fetch the file if required
                $status = $this->mUpload->fetchFile();
-               if( !$status->isOK() ){
-                       return array( 'status' =>UploadBase::BEFORE_PROCESSING, 'error'=>$status->getWikiText() );
+               if( !$status->isOK() ) {
+                       return array( 'status' => UploadBase::BEFORE_PROCESSING, 'error'=> $status->getWikiText() );
                }
 
                // Check whether this is a sane upload
@@ -656,9 +656,9 @@ wgEnableFirefogg = {$uef};
 wgUploadAutoFill = {$autofill};
 </script>" );
 
-               if( $wgEnableJS2system ){
+               if( $wgEnableJS2system ) {
                        //js2version of upload page:
-                   $wgOut->addScriptClass( 'uploadPage' );
+                       $wgOut->addScriptClass( 'uploadPage' );
                }else{
                        //legacy upload code:
                        $wgOut->addScriptFile( 'upload.js' );
@@ -746,7 +746,7 @@ wgUploadAutoFill = {$autofill};
                                $wgLang->formatSize( $val ) ) .
                                "</div>\n";
                //add a hidden filed for upload by url (uses the $wgMaxUploadSize var)
-               if( UploadFromUrl::isEnabled() ){
+               if( UploadFromUrl::isEnabled() ) {
                        $maxUploadSize.='<div id="mw-upload-maxfilesize-url" style="display:none">' .
                        wfMsgExt( 'upload-maxfilesize', array( 'parseinline', 'escapenoentities' ),
                                $wgLang->formatSize( $wgMaxUploadSize ) ) .
@@ -754,7 +754,7 @@ wgUploadAutoFill = {$autofill};
                }
 
                $sourcefilename = wfMsgExt( 'sourcefilename', array( 'parseinline', 'escapenoentities' ) );
-        $destfilename = wfMsgExt( 'destfilename', array( 'parseinline', 'escapenoentities' ) );
+               $destfilename = wfMsgExt( 'destfilename', array( 'parseinline', 'escapenoentities' ) );
 
                $msg = ( $this->mForReUpload )  ? 'filereuploadsummary' : 'fileuploadsummary';
                $summary = wfMsgExt( $msg, 'parseinline' );
@@ -778,17 +778,21 @@ wgUploadAutoFill = {$autofill};
                // Prepare form for upload or upload/copy
                //javascript moved from inline calls to setup:
                if( UploadFromUrl::isEnabled() && $wgUser->isAllowed( 'upload_by_url' ) ) {
-                   if($wgEnableJS2system){
-                       $filename_form =
-                               Xml::input( 'wpSourceType', false, 'file', array( 'id'=>'wpSourceTypeFile', 'type' => 'radio', 'checked' => 'checked' ) ) .
-                               Xml::input( 'wpUploadFile', 60, false, array( 'id'=>'wpUploadFile', 'type'=>'file', 'tabindex' => '1' ) ) .
-                                               wfMsgHTML( 'upload_source_file' ) . "<br/>" .
-                                       Xml::input( 'wpSourceType', false, 'Url', array( 'id'=>'wpSourceTypeURL', 'type' => 'radio' )) .
-                                       Xml::input( 'wpUploadFileURL', 60, false, array( 'id'=>'wpUploadFileURL', 'type' => 'text', 'tabindex' => '1')) .
+                       if( $wgEnableJS2system ) {
+                               $filename_form =
+                                       Xml::input( 'wpSourceType', false, 'file', 
+                                               array( 'id' => 'wpSourceTypeFile', 'type' => 'radio', 'checked' => 'checked' ) ) .
+                                       Xml::input( 'wpUploadFile', 60, false, 
+                                               array( 'id' => 'wpUploadFile', 'type' => 'file', 'tabindex' => '1' ) ) .
+                                       wfMsgHTML( 'upload_source_file' ) . "<br/>" .
+                                       Xml::input( 'wpSourceType', false, 'Url', 
+                                               array( 'id' => 'wpSourceTypeURL', 'type' => 'radio' ) ) .
+                                       Xml::input( 'wpUploadFileURL', 60, false, 
+                                               array( 'id' => 'wpUploadFileURL', 'type' => 'text', 'tabindex' => '1' ) ) .
                                wfMsgHtml( 'upload_source_url' ) ;
-                   }else{
-                        //@@todo depreciate (not needed once $wgEnableJS2system is turned on)
-               $filename_form =
+                       } else {
+                               //@@todo deprecate (not needed once $wgEnableJS2system is turned on)
+                               $filename_form =
                                "<input type='radio' id='wpSourceTypeFile' name='wpSourceType' value='file' " .
                                   "onchange='toggle_element_activation(\"wpUploadFileURL\",\"wpUploadFile\")' checked='checked' />" .
                                 "<input tabindex='1' type='file' name='wpUploadFile' id='wpUploadFile' " .
@@ -806,13 +810,14 @@ wgUploadAutoFill = {$autofill};
                                    "onchange='fillDestFilename(\"wpUploadFileURL\")' size='60' disabled='disabled' />" .
                                wfMsgHtml( 'upload_source_url' ) ;
 
-                   }
+                       }
                } else {
-                       if($wgEnableJS2system){
+                       if( $wgEnableJS2system ) {
                                $filename_form =
-                                       Xml::input( 'wpUploadFile', 60, false, array( 'id'=>'wpUploadFile', 'type'=>'file', 'tabindex' => '1' ) ) .
+                                       Xml::input( 'wpUploadFile', 60, false, 
+                                               array( 'id' => 'wpUploadFile', 'type' => 'file', 'tabindex' => '1' ) ) .
                                        Xml::hidden( 'wpSourceType', 'file');
-                       }else{
+                       } else {
                                $filename_form =
                                "<input tabindex='1' type='file' name='wpUploadFile' id='wpUploadFile' size='60' ".
                                "onchange='fillDestFilename(\"wpUploadFile\")' />" .
@@ -821,9 +826,9 @@ wgUploadAutoFill = {$autofill};
                }
                $warningRow = '';
                $destOnkeyup = '';
-               if($wgEnableJS2system){
+               if( $wgEnableJS2system ) {
                        $warningRow = "<tr><td colspan='2' id='wpDestFile-warning'>&nbsp;</td></tr>";
-               }else{
+               } else {
                        if ( $useAjaxDestCheck ) {
                                $warningRow = "<tr><td colspan='2' id='wpDestFile-warning'>&nbsp;</td></tr>";
                                $destOnkeyup = 'onchange=\'wgUploadWarningObj.checkNow(this.value);\'';
@@ -834,15 +839,16 @@ wgUploadAutoFill = {$autofill};
 
                $encComment = htmlspecialchars( $this->mComment );
 
-           //add the wpEditToken
+               //add the wpEditToken
                $wgOut->addHTML(
-                        Xml::openElement( 'form', array( 'method' => 'post', 'action' => $titleObj->getLocalURL( 'action=submit' ),
+                       Xml::openElement( 'form', 
+                       array( 'method' => 'post', 'action' => $titleObj->getLocalURL( 'action=submit' ),
                                 'enctype' => 'multipart/form-data', 'id' => 'mw-upload-form' ) ) .
-                        Xml::hidden('wpEditToken', $wgUser->editToken(), array('id' => 'wpEditToken')) .
-                        Xml::openElement( 'fieldset' ) .
-                        Xml::element( 'legend', null, wfMsg( 'upload' ) ) .
-                        Xml::openElement( 'table', array( 'border' => '0', 'id' => 'mw-upload-table' ) ) .
-                        "<tr>
+                       Xml::hidden( 'wpEditToken', $wgUser->editToken(), array( 'id' => 'wpEditToken' ) ) .
+                       Xml::openElement( 'fieldset' ) .
+                       Xml::element( 'legend', null, wfMsg( 'upload' ) ) .
+                       Xml::openElement( 'table', array( 'border' => '0', 'id' => 'mw-upload-table' ) ) .
+                       "<tr>
                                {$this->uploadFormTextTop}
                                <td class='mw-label'>
                                        <label for='wpUploadFile'>{$sourcefilename}</label>
@@ -1020,7 +1026,7 @@ wgUploadAutoFill = {$autofill};
                }
        }
 
-        /**
+       /**
         * Check if a user is the last uploader
         *
         * @param User $user
@@ -1062,7 +1068,7 @@ wgUploadAutoFill = {$autofill};
        /**
         * Get the initial image page text based on a comment and optional file status information
         */
-       static function getInitialPageText( $comment='', $license='', $copyStatus='', $source='' ) {
+       static function getInitialPageText( $comment = '', $license = '', $copyStatus = '', $source = '' ) {
                global $wgUseCopyrightUpload;
                if ( $wgUseCopyrightUpload ) {
                        $licensetxt = '';
index 3b35c40..5c3996e 100644 (file)
@@ -43,26 +43,27 @@ class SkinMonoBook extends SkinTemplate {
                $out->addStyle( 'monobook/rtl.css', 'screen', '', 'rtl' );
 
 
-               //@@todo we can move this to the parent once we update all skins
-               if( isset( $this->pagecss ) &&  $this->pagecss)
+               // @todo We can move this to the parent once we update all the skins
+               if( isset( $this->pagecss ) &&  $this->pagecss )
                        $out->addInlineStyle( $this->pagecss );
 
-               if( isset( $this->usercss ) &&  $this->usercss)
+               if( isset( $this->usercss ) &&  $this->usercss )
                        $out->addInlineStyle( $this->usercss );
 
        }
+
        function setupSkinUserJs( OutputPage $out ) {
                parent::setupSkinUserJs( $out );
                $out->addScriptFile( 'wikibits.js' );
 
-               //@@todo can move to parent once we update all skins (to not include things twice
-               if( isset( $this->jsvarurl ) && $this->jsvarurl)
+               // @todo We can move to parent once we update all the skins (to avoid including things twice)
+               if( isset( $this->jsvarurl ) && $this->jsvarurl )
                        $out->addScriptFile( $this->jsvarurl );
 
-               if( isset( $this->userjs ) && $this->userjs)
+               if( isset( $this->userjs ) && $this->userjs )
                        $out->addScriptFile( $this->userjs );
 
-               if( isset( $this->userjsprev ) && $this->userjsprev)
+               if( isset( $this->userjsprev ) && $this->userjsprev )
                        $out->addInlineScript( $this->userjsprev );
        }
 }
@@ -88,6 +89,7 @@ class MonoBookTemplate extends QuickTemplate {
 
                // Suppress warnings to prevent notices about missing indexes in $this->data
                wfSuppressWarnings();
+
                # FIXME: What is this?  Should it apply to all skins?
                $path = htmlspecialchars( $wgStylePath );
                $wgOut->addScript( <<<HTML
index d4cff53..3e91e06 100644 (file)
@@ -12,18 +12,18 @@ function licenseSelectorCheck() {
 }
 
 function wgUploadSetup() {
-       //disable source type if not checked: 
-       var e = document.getElementById('wpSourceTypeURL');
-       if(e){
-               if(!e.checked){
-                       var ein = document.getElementById('wpUploadFileURL');
+       // Disable URL box if the URL copy upload source type is not selected
+       var e = document.getElementById( 'wpSourceTypeURL' );
+       if( e ) {
+               if( !e.checked ) {
+                       var ein = document.getElementById( 'wpUploadFileURL' );
                        if(ein)
-                               ein.setAttribute('disabled', 'disabled');
+                               ein.setAttribute( 'disabled', 'disabled' );
                }
        }
-       
-       // for MSIE/Mac; non-breaking spaces cause the <option> not to render
-       // but, for some reason, setting the text to itself works
+
+       // For MSIE/Mac: non-breaking spaces cause the <option> not to render.
+       // But for some reason, setting the text to itself works
        var selector = document.getElementById("wpLicense");
        if (selector) {
                var ua = navigator.userAgent;
@@ -53,7 +53,7 @@ var wgUploadWarningObj = {
 
                this.nameToCheck = destFile.value ;
 
-               // Clear timer 
+               // Clear timer
                if ( this.timeoutID ) {
                        window.clearTimeout( this.timeoutID );
                }
@@ -76,18 +76,18 @@ var wgUploadWarningObj = {
                this.nameToCheck = fname;
                this.timeout();
        },
-       
+
        'timeout' : function() {
                if ( !wgAjaxUploadDestCheck || !sajax_init_object() ) return;
                injectSpinner( document.getElementById( 'wpDestFile' ), 'destcheck' );
 
-               // Get variables into local scope so that they will be preserved for the 
-               // anonymous callback. fileName is copied so that multiple overlapping 
+               // Get variables into local scope so that they will be preserved for the
+               // anonymous callback. fileName is copied so that multiple overlapping
                // ajax requests can be supported.
                var obj = this;
-               var fileName = this.nameToCheck;                
-               sajax_do_call( 'UploadForm::ajaxGetExistsWarning', [this.nameToCheck], 
-                       function (result) {                             
+               var fileName = this.nameToCheck;
+               sajax_do_call( 'UploadForm::ajaxGetExistsWarning', [this.nameToCheck],
+                       function (result) {
                                obj.processResult(result, fileName)
                        }
                );
@@ -104,7 +104,7 @@ var wgUploadWarningObj = {
                var ackElt = document.getElementById( 'wpDestFileWarningAck' );
                this.setInnerHTML(warningElt, warning);
 
-               // Set a value in the form indicating that the warning is acknowledged and 
+               // Set a value in the form indicating that the warning is acknowledged and
                // doesn't need to be redisplayed post-upload
                if ( warning == '' || warning == '&nbsp;' ) {
                        ackElt.value = '';
@@ -127,13 +127,13 @@ function fillDestFilename(id) {
        if (!document.getElementById) {
                return;
        }
-       //remove any previously flagged errors
-       var e = document.getElementById('mw-upload-permitted');
-       if(e) e. className = '';
-       
-       var e = document.getElementById('mw-upload-prohibited');
-       if(e) e.className = '';
-       
+       // Remove any previously flagged errors
+       var e = document.getElementById( 'mw-upload-permitted' );
+       if( e ) e.className = '';
+
+       var e = document.getElementById( 'mw-upload-prohibited' );
+       if( e ) e.className = '';
+
        var path = document.getElementById(id).value;
        // Find trailing part
        var slash = path.lastIndexOf('/');
@@ -146,36 +146,39 @@ function fillDestFilename(id) {
        } else {
                fname = path.substring(backslash+1, 10000);
        }
-       //check for the wgFileExtensions and clear if not a valid fname extension
-       
-       //urls are less likely to have a usefull extension don't include them in the extention check
-       if( wgFileExtensions && id != 'wpUploadFileURL' ){              
-               var found = false;              
-               if( fname.lastIndexOf('.')!=-1 ){               
-                       var ext = fname.substr( fname.lastIndexOf('.')+1 );                     
-                       for(var i=0; i < wgFileExtensions.length; i++){                                         
-                               if(  wgFileExtensions[i].toLowerCase()   ==  ext.toLowerCase() )
+
+       // Clear the filename if it does not have a valid extension.
+       // URLs are less likely to have a useful extension, so don't include them in the 
+       // extension check.
+       if( wgFileExtensions && id != 'wpUploadFileURL' ) {
+               var found = false;
+               if( fname.lastIndexOf( '.' ) != -1 ) {
+                       var ext = fname.substr( fname.lastIndexOf( '.' ) + 1 );
+                       for( var i = 0; i < wgFileExtensions.length; i++ ) {
+                               if( wgFileExtensions[i].toLowerCase() == ext.toLowerCase() ) {
                                        found = true;
+                                       break;
+                               }
                        }
                }
-               if(!found){
-                       //clear the upload set mw-upload-permitted to error
+               if( !found ) {
+                       // Not a valid extension
+                       // Clear the upload and set mw-upload-permitted to error
                        document.getElementById(id).value = '';
-                       var e = document.getElementById('mw-upload-permitted');
-                       if(e) e. className = 'error';
-                       
-                       var e = document.getElementById('mw-upload-prohibited');
-                       if(e) e.className = 'error';
-                       
-                       //clear the wpDestFile as well: 
-                       var e = document.getElementById('wpDestFile')
-                       if(e) e.value = '';
-                       
-                       //return false
+                       var e = document.getElementById( 'mw-upload-permitted' );
+                       if( e ) e.className = 'error';
+
+                       var e = document.getElementById( 'mw-upload-prohibited' );
+                       if( e ) e.className = 'error';
+
+                       // Clear wpDestFile as well
+                       var e = document.getElementById( 'wpDestFile' )
+                       if( e ) e.value = '';
+
                        return false;
-               }               
-       }       
-               
+               }
+       }
+
        // Capitalise first letter and replace spaces by underscores
        fname = fname.charAt(0).toUpperCase().concat(fname.substring(1,10000)).replace(/ /g, '_');
 
@@ -199,7 +202,7 @@ function toggleFilenameFiller() {
 }
 
 var wgUploadLicenseObj = {
-       
+
        'responseCache' : { '' : '' },
 
        'fetchPreview': function( license ) {
@@ -229,7 +232,7 @@ var wgUploadLicenseObj = {
                if( previewPanel.innerHTML != preview )
                        previewPanel.innerHTML = preview;
        }
-       
+
 }
 
-addOnloadHook( wgUploadSetup );
\ No newline at end of file
+addOnloadHook( wgUploadSetup );
index 1097837..94753da 100644 (file)
@@ -21,8 +21,8 @@ if (clientPC.indexOf('opera') != -1) {
        var is_opera_preseven = window.opera && !document.childNodes;
        var is_opera_seven = window.opera && document.childNodes;
        var is_opera_95 = /opera\/(9\.[5-9]|[1-9][0-9])/.test( clientPC );
-       var opera6_bugs = is_opera_preseven;    
-       var opera7_bugs = is_opera_seven && !is_opera_95;       
+       var opera6_bugs = is_opera_preseven;
+       var opera7_bugs = is_opera_seven && !is_opera_95;
        var opera95_bugs = /opera\/(9\.5)/.test( clientPC );
 }
 
@@ -467,26 +467,26 @@ function checkboxClickHandler(e) {
 }
 
 function toggle_element_activation(ida,idb) {
-       if (!document.getElementById) {
+       if ( !document.getElementById ) {
                return;
        }
-       //hide and show appropriate upload sizes
-       if(idb == 'wpUploadFileURL'){
-               var e = document.getElementById('mw-upload-maxfilesize');
-               if(e) e.style.display = "none";         
-               
-               var e = document.getElementById('mw-upload-maxfilesize-url');
-               if(e) e.style.display = "block";                
+       // Show the appropriate upload size limit message
+       if( idb == 'wpUploadFileURL' ) {
+               var e = document.getElementById( 'mw-upload-maxfilesize' );
+               if( e ) e.style.display = "none";
+
+               var e = document.getElementById( 'mw-upload-maxfilesize-url' );
+               if( e ) e.style.display = "block";
        }
-       if(idb == 'wpUploadFile'){
-               var e = document.getElementById('mw-upload-maxfilesize-url');
-               if(e) e.style.display =  "none";
-                                       
-               var e = document.getElementById('mw-upload-maxfilesize');
-               if(e) e.style.display =  "block";
+       if( idb == 'wpUploadFile' ) {
+               var e = document.getElementById( 'mw-upload-maxfilesize-url' );
+               if( e ) e.style.display =  "none";
+
+               var e = document.getElementById( 'mw-upload-maxfilesize' );
+               if( e ) e.style.display =  "block";
        }
-       document.getElementById(ida).disabled = true;
-       document.getElementById(idb).disabled = false;
+       document.getElementById( ida ).disabled = true;
+       document.getElementById( idb ).disabled = false;
 }
 
 function toggle_element_check(ida,idb) {
@@ -797,7 +797,7 @@ function ts_toLowerCase( s ) {
        return s.toLowerCase();
 }
 
-function ts_dateToSortKey(date) {      
+function ts_dateToSortKey(date) {
        // y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX
        if (date.length == 11) {
                switch (date.substr(3,3).toLowerCase()) {
@@ -844,7 +844,7 @@ function ts_parseFloat( s ) {
        }
        if (ts_number_transform_table != false) {
                var newNum = '', c;
-               
+
                for ( var p = 0; p < s.length; p++ ) {
                        c = s.charAt( p );
                        if (c in ts_number_transform_table) {
@@ -938,7 +938,7 @@ function jsMsg( message, className ) {
        if( className ) {
                messageDiv.setAttribute( 'class', 'mw-js-message-'+className );
        }
-       
+
        if (typeof message === 'object') {
                while (messageDiv.hasChildNodes()) // Remove old content
                        messageDiv.removeChild(messageDiv.firstChild);