Redo r41164 with less breakage.
authorChad Horohoe <demon@users.mediawiki.org>
Tue, 23 Sep 2008 00:07:24 +0000 (00:07 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Tue, 23 Sep 2008 00:07:24 +0000 (00:07 +0000)
includes/filerepo/ForeignAPIFile.php
includes/filerepo/ForeignAPIRepo.php

index 42bd7e1..336c928 100644 (file)
@@ -31,7 +31,7 @@ class ForeignAPIFile extends File {
        }
 
        function transform( $params, $flags = 0 ) {
-               if ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->apiThumbCacheDir ) {
+               if ( $this->repo->canCacheThumbs() ) {
                        $thumbUrl = $this->repo->getThumbUrlFromCache(
                                $this->getName(),
                                isset( $params['width'] ) ? $params['width'] : -1,
@@ -110,7 +110,7 @@ class ForeignAPIFile extends File {
         */
        function getThumbPath( $suffix = '' ) {
                $ret = null;
-               if ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->apiThumbCacheDir ) {
+               if ( $this->repo->canCacheThumbs() ) {
                        global $wgUploadDirectory;
                        $path = $wgUploadDirectory . '/' . $this->repo->apiThumbCacheDir . '/' . $this->repo->name . '/';
                        if ( $suffix ) {
index bd53686..2ba72fb 100644 (file)
@@ -112,7 +112,6 @@ class ForeignAPIRepo extends FileRepo {
        
        function getThumbUrlFromCache( $name, $width, $height ) {
                global $wgMemc, $wgUploadPath, $wgServer, $wgUploadDirectory;
-;
                
                $key = wfMemcKey( 'ForeignAPIRepo', 'ThumbUrl', $name );
                if ( $thumbUrl = $wgMemc->get($key) ) {
@@ -135,4 +134,12 @@ class ForeignAPIRepo extends FileRepo {
                        return $localUrl;
                }
        }
+       
+       /**
+        * Are we locally caching the thumbnails?
+        * @return bool
+        */
+       public function canCacheThumbs() {
+               return ( $this->apiThumbCacheExpiry > 0 && $this->apiThumbCacheDir );
+       }
 }