fix some spacing
[lhc/web/wiklou.git] / includes / filerepo / file / File.php
index bfb9197..bccbe64 100644 (file)
@@ -40,7 +40,7 @@
  * never name a file class explictly outside of the repo class. Instead use the
  * repo's factory functions to generate file objects, for example:
  *
- * RepoGroup::singleton()->getLocalRepo()->newFile($title);
+ * RepoGroup::singleton()->getLocalRepo()->newFile( $title );
  *
  * The convenience functions wfLocalFile() and wfFindFile() should be sufficient
  * in most cases.
@@ -54,7 +54,7 @@ abstract class File {
        const DELETED_RESTRICTED = 8;
 
        /** Force rendering in the current process */
-       const RENDER_NOW   = 1;
+       const RENDER_NOW = 1;
        /**
         * Force rendering even if thumbnail already exist and using RENDER_NOW
         * I.e. you have to pass both flags: File::RENDER_NOW | File::RENDER_FORCE
@@ -348,7 +348,7 @@ abstract class File {
                        if ( $this->canRender() ) {
                                return $this->createThumb( $this->getWidth() );
                        } else {
-                               wfDebug( __METHOD__.': supposed to render ' . $this->getName() .
+                               wfDebug( __METHOD__ . ': supposed to render ' . $this->getName() .
                                        ' (' . $this->getMimeType() . "), but can't!\n" );
                                return $this->getURL(); #hm... return NULL?
                        }
@@ -663,13 +663,13 @@ abstract class File {
                if ( $this->allowInlineDisplay() ) {
                        return true;
                }
-               if ($this->isTrustedFile()) {
+               if ( $this->isTrustedFile() ) {
                        return true;
                }
 
                $type = $this->getMediaType();
                $mime = $this->getMimeType();
-               #wfDebug("LocalFile::isSafeFile: type= $type, mime= $mime\n");
+               #wfDebug( "LocalFile::isSafeFile: type= $type, mime= $mime\n" );
 
                if ( !$type || $type === MEDIATYPE_UNKNOWN ) {
                        return false; #unknown type, not trusted
@@ -842,7 +842,7 @@ abstract class File {
                global $wgIgnoreImageErrors;
 
                if ( $wgIgnoreImageErrors && !( $flags & self::RENDER_NOW ) ) {
-                       return $this->handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
+                       return $this->getHandler()->getTransform( $this, $thumbPath, $thumbUrl, $params );
                } else {
                        return new MediaTransformError( 'thumbnail_error',
                                $params['width'], 0, wfMessage( 'thumbnail-dest-create' )->text() );
@@ -873,17 +873,18 @@ abstract class File {
                                $params['descriptionUrl'] = wfExpandUrl( $descriptionUrl, PROTO_CANONICAL );
                        }
 
+                       $handler = $this->getHandler();
                        $script = $this->getTransformScript();
                        if ( $script && !( $flags & self::RENDER_NOW ) ) {
                                // Use a script to transform on client request, if possible
-                               $thumb = $this->handler->getScriptedTransform( $this, $script, $params );
+                               $thumb = $handler->getScriptedTransform( $this, $script, $params );
                                if ( $thumb ) {
                                        break;
                                }
                        }
 
                        $normalisedParams = $params;
-                       $this->handler->normaliseParams( $this, $normalisedParams );
+                       $handler->normaliseParams( $this, $normalisedParams );
 
                        $thumbName = $this->thumbName( $normalisedParams );
                        $thumbUrl = $this->getThumbUrl( $thumbName );
@@ -896,20 +897,20 @@ abstract class File {
                                        // XXX: Pass in the storage path even though we are not rendering anything
                                        // and the path is supposed to be an FS path. This is due to getScalerType()
                                        // getting called on the path and clobbering $thumb->getUrl() if it's false.
-                                       $thumb = $this->handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
+                                       $thumb = $handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
                                        break;
                                }
                                // Clean up broken thumbnails as needed
                                $this->migrateThumbFile( $thumbName );
                                // Check if an up-to-date thumbnail already exists...
-                               wfDebug( __METHOD__.": Doing stat for $thumbPath\n" );
+                               wfDebug( __METHOD__ . ": Doing stat for $thumbPath\n" );
                                if ( !( $flags & self::RENDER_FORCE ) && $this->repo->fileExists( $thumbPath ) ) {
                                        $timestamp = $this->repo->getFileTimestamp( $thumbPath );
                                        if ( $timestamp !== false && $timestamp >= $wgThumbnailEpoch ) {
                                                // XXX: Pass in the storage path even though we are not rendering anything
                                                // and the path is supposed to be an FS path. This is due to getScalerType()
                                                // getting called on the path and clobbering $thumb->getUrl() if it's false.
-                                               $thumb = $this->handler->getTransform(
+                                               $thumb = $handler->getTransform(
                                                        $this, $thumbPath, $thumbUrl, $params );
                                                $thumb->setStoragePath( $thumbPath );
                                                break;
@@ -937,7 +938,7 @@ abstract class File {
 
                        // Actually render the thumbnail...
                        wfProfileIn( __METHOD__ . '-doTransform' );
-                       $thumb = $this->handler->doTransform( $this, $tmpThumbPath, $thumbUrl, $params );
+                       $thumb = $handler->doTransform( $this, $tmpThumbPath, $thumbUrl, $params );
                        wfProfileOut( __METHOD__ . '-doTransform' );
                        $tmpFile->bind( $thumb ); // keep alive with $thumb
 
@@ -947,7 +948,7 @@ abstract class File {
                                $this->lastError = $thumb->toText();
                                // Ignore errors if requested
                                if ( $wgIgnoreImageErrors && !( $flags & self::RENDER_NOW ) ) {
-                                       $thumb = $this->handler->getTransform( $this, $tmpThumbPath, $thumbUrl, $params );
+                                       $thumb = $handler->getTransform( $this, $tmpThumbPath, $thumbUrl, $params );
                                }
                        } elseif ( $this->repo && $thumb->hasFile() && !$thumb->fileIsSource() ) {
                                // Copy the thumbnail from the file system into storage...
@@ -1365,7 +1366,7 @@ abstract class File {
         * @throws MWException
         */
        function readOnlyError() {
-               throw new MWException( get_class($this) . ': write operations are not supported' );
+               throw new MWException( get_class( $this ) . ': write operations are not supported' );
        }
 
        /**
@@ -1499,9 +1500,9 @@ abstract class File {
         * @param $target Title New file name
         * @return FileRepoStatus object.
         */
-        function move( $target ) {
+       function move( $target ) {
                $this->readOnlyError();
-        }
+       }
 
        /**
         * Delete all versions of the file.
@@ -1626,15 +1627,15 @@ abstract class File {
                $renderUrl = $this->repo->getDescriptionRenderUrl( $this->getName(), $wgLang->getCode() );
                if ( $renderUrl ) {
                        if ( $this->repo->descriptionCacheExpiry > 0 ) {
-                               wfDebug("Attempting to get the description from cache...");
+                               wfDebug( "Attempting to get the description from cache..." );
                                $key = $this->repo->getLocalCacheKey( 'RemoteFileDescription', 'url', $wgLang->getCode(),
                                                                        $this->getName() );
-                               $obj = $wgMemc->get($key);
-                               if ($obj) {
-                                       wfDebug("success!\n");
+                               $obj = $wgMemc->get( $key );
+                               if ( $obj ) {
+                                       wfDebug( "success!\n" );
                                        return $obj;
                                }
-                               wfDebug("miss\n");
+                               wfDebug( "miss\n" );
                        }
                        wfDebug( "Fetching shared description from $renderUrl\n" );
                        $res = Http::get( $renderUrl );
@@ -1720,7 +1721,7 @@ abstract class File {
         * @return array
         */
        static function getPropsFromPath( $path, $ext = true ) {
-               wfDebug( __METHOD__.": Getting file info for $path\n" );
+               wfDebug( __METHOD__ . ": Getting file info for $path\n" );
                wfDeprecated( __METHOD__, '1.19' );
 
                $fsFile = new FSFile( $path );