Merge "Add option to expose original sha1 in thumb url"
[lhc/web/wiklou.git] / includes / filerepo / file / File.php
index f40d216..cde5e6a 100644 (file)
@@ -383,7 +383,7 @@ abstract class File implements IDBAccessObject {
                                wfDebug( __METHOD__ . ': supposed to render ' . $this->getName() .
                                        ' (' . $this->getMimeType() . "), but can't!\n" );
 
-                               return $this->getURL(); #hm... return NULL?
+                               return $this->getURL(); # hm... return NULL?
                        }
                } else {
                        return $this->getURL();
@@ -806,17 +806,17 @@ abstract class File implements IDBAccessObject {
 
                $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
+                       return false; # unknown type, not trusted
                }
                if ( in_array( $type, $wgTrustedMediaFormats ) ) {
                        return true;
                }
 
                if ( $mime === "unknown/unknown" ) {
-                       return false; #unknown type, not trusted
+                       return false; # unknown type, not trusted
                }
                if ( in_array( $mime, $wgTrustedMediaFormats ) ) {
                        return true;
@@ -839,8 +839,8 @@ abstract class File implements IDBAccessObject {
         * @return bool
         */
        function isTrustedFile() {
-               #this could be implemented to check a flag in the database,
-               #look for signatures, etc
+               # this could be implemented to check a flag in the database,
+               # look for signatures, etc
                return false;
        }
 
@@ -946,9 +946,16 @@ abstract class File implements IDBAccessObject {
                $extension = $this->getExtension();
                list( $thumbExt, ) = $this->getHandler()->getThumbType(
                        $extension, $this->getMimeType(), $params );
-               $thumbName = $this->getHandler()->makeParamString( $params ) . '-' . $name;
-               if ( $thumbExt != $extension ) {
-                       $thumbName .= ".$thumbExt";
+               $thumbName = $this->getHandler()->makeParamString( $params );
+
+               if ( $this->repo->supportsSha1URLs() ) {
+                       $thumbName .= '-' . $this->getSha1() . '.' . $thumbExt;
+               } else {
+                       $thumbName .= '-' . $name;
+
+                       if ( $thumbExt != $extension ) {
+                               $thumbName .= ".$thumbExt";
+                       }
                }
 
                return $thumbName;