Fixed spacing in context/installer/media/templates/upload folder
[lhc/web/wiklou.git] / includes / upload / UploadFromChunks.php
index 5a838ab..37db688 100644 (file)
@@ -31,7 +31,7 @@ class UploadFromChunks extends UploadFromFile {
        protected $mOffset, $mChunkIndex, $mFileKey, $mVirtualTempPath;
 
        /**
-        * Setup local pointers to stash, repo and user ( similar to UploadFromStash )
+        * Setup local pointers to stash, repo and user (similar to UploadFromStash)
         *
         * @param $user User
         * @param $stash UploadStash
@@ -41,16 +41,16 @@ class UploadFromChunks extends UploadFromFile {
                // user object. sometimes this won't exist, as when running from cron.
                $this->user = $user;
 
-               if( $repo ) {
+               if ( $repo ) {
                        $this->repo = $repo;
                } else {
                        $this->repo = RepoGroup::singleton()->getLocalRepo();
                }
 
-               if( $stash ) {
+               if ( $stash ) {
                        $this->stash = $stash;
                } else {
-                       if( $user ) {
+                       if ( $user ) {
                                wfDebug( __METHOD__ . " creating new UploadFromChunks instance for " . $user->getId() . "\n" );
                        } else {
                                wfDebug( __METHOD__ . " creating new UploadFromChunks instance with no user\n" );
@@ -66,13 +66,13 @@ class UploadFromChunks extends UploadFromFile {
         *
         * @return UploadStashFile stashed file
         */
-       public function stashFile() {
+       public function stashFile( User $user = null ) {
                // Stash file is the called on creating a new chunk session:
                $this->mChunkIndex = 0;
                $this->mOffset = 0;
                // Create a local stash target
                $this->mLocalFile = parent::stashFile();
-               // Update the initial file offset ( based on file size )
+               // Update the initial file offset (based on file size)
                $this->mOffset = $this->mLocalFile->getSize();
                $this->mFileKey = $this->mLocalFile->getFileKey();
 
@@ -112,7 +112,7 @@ class UploadFromChunks extends UploadFromFile {
                // Concatenate all the chunks to mVirtualTempPath
                $fileList = Array();
                // The first chunk is stored at the mVirtualTempPath path so we start on "chunk 1"
-               for( $i = 0; $i <= $this->getChunkIndex(); $i++ ) {
+               for ( $i = 0; $i <= $this->getChunkIndex(); $i++ ) {
                        $fileList[] = $this->getVirtualChunkLocation( $i );
                }
 
@@ -127,12 +127,12 @@ class UploadFromChunks extends UploadFromFile {
                $tStart = microtime( true );
                $status = $this->repo->concatenate( $fileList, $tmpPath, FileRepo::DELETE_SOURCE );
                $tAmount = microtime( true ) - $tStart;
-               if( !$status->isOk() ) {
+               if ( !$status->isOk() ) {
                        return $status;
                }
                wfDebugLog( 'fileconcatenate', "Combined $i chunks in $tAmount seconds.\n" );
                // Update the mTempPath and mLocalFile
-               // ( for FileUpload or normal Stash to take over )
+               // (for FileUpload or normal Stash to take over)
                $this->mTempPath = $tmpPath; // file system path
                $tStart = microtime( true );
                $this->mLocalFile = parent::stashFile( $this->user );
@@ -173,16 +173,16 @@ class UploadFromChunks extends UploadFromFile {
        /**
         * Add a chunk to the temporary directory
         *
-        * @param $chunkPath string path to temporary chunk file
-        * @param $chunkSize int size of the current chunk
-        * @param $offset int offset of current chunk ( mutch match database chunk offset )
+        * @param string $chunkPath path to temporary chunk file
+        * @param int $chunkSize size of the current chunk
+        * @param int $offset offset of current chunk ( mutch match database chunk offset )
         * @return Status
         */
        public function addChunk( $chunkPath, $chunkSize, $offset ) {
                // Get the offset before we add the chunk to the file system
                $preAppendOffset = $this->getOffset();
 
-               if ( $preAppendOffset + $chunkSize > $this->getMaxUploadSize()) {
+               if ( $preAppendOffset + $chunkSize > $this->getMaxUploadSize() ) {
                        $status = Status::newFatal( 'file-too-large' );
                } else {
                        // Make sure the client is uploading the correct chunk with a matching offset.
@@ -190,7 +190,7 @@ class UploadFromChunks extends UploadFromFile {
                                // Update local chunk index for the current chunk
                                $this->mChunkIndex++;
                                $status = $this->outputChunk( $chunkPath );
-                               if( $status->isGood() ) {
+                               if ( $status->isGood() ) {
                                        // Update local offset:
                                        $this->mOffset = $preAppendOffset + $chunkSize;
                                        // Update chunk table status db
@@ -257,7 +257,7 @@ class UploadFromChunks extends UploadFromFile {
         * @return Integer index of the current chunk
         */
        private function getChunkIndex() {
-               if( $this->mChunkIndex !== null ) {
+               if ( $this->mChunkIndex !== null ) {
                        return $this->mChunkIndex;
                }
                return 0;
@@ -307,7 +307,7 @@ class UploadFromChunks extends UploadFromFile {
        }
 
        private function getChunkFileKey( $index = null ) {
-               if( $index === null ) {
+               if ( $index === null ) {
                        $index = $this->getChunkIndex();
                }
                return $this->mFileKey . '.' . $index;