passing thumbnail params to getThumbType, as suggested by TimStarling in a comment...
[lhc/web/wiklou.git] / includes / filerepo / File.php
index fdd6153..1469668 100644 (file)
@@ -438,20 +438,15 @@ abstract class File {
        /**
         * Get a ThumbnailImage which is the same size as the source
         */
-       function getUnscaledThumb( $page = false ) {
+       function getUnscaledThumb( $handlerParams = array() ) {
+               $hp =& $handlerParams;
+               $page = isset( $hp['page'] ) ? $hp['page'] : false;
                $width = $this->getWidth( $page );
                if ( !$width ) {
                        return $this->iconThumb();
                }
-               if ( $page ) {
-                       $params = array(
-                               'page' => $page,
-                               'width' => $this->getWidth( $page )
-                       );
-               } else {
-                       $params = array( 'width' => $this->getWidth() );
-               }
-               return $this->transform( $params );
+               $hp['width'] = $width;
+               return $this->transform( $hp );
        }
 
        /**
@@ -465,7 +460,7 @@ abstract class File {
                        return null;
                }
                $extension = $this->getExtension();
-               list( $thumbExt, $thumbMime ) = $this->handler->getThumbType( $extension, $this->getMimeType() );
+               list( $thumbExt, $thumbMime ) = $this->handler->getThumbType( $extension, $this->getMimeType(), $params );
                $thumbName = $this->handler->makeParamString( $params ) . '-' . $this->getName();
                if ( $thumbExt != $extension ) {
                        $thumbName .= ".$thumbExt";
@@ -501,7 +496,7 @@ abstract class File {
        /**
         * As createThumb, but returns a ThumbnailImage object. This can
         * provide access to the actual file, the real size of the thumb,
-        * and can produce a convenient <img> tag for you.
+        * and can produce a convenient \<img\> tag for you.
         *
         * For non-image formats, this may return a filetype-specific icon.
         *
@@ -843,19 +838,18 @@ abstract class File {
 
        /**
         * Move or copy a file to its public location. If a file exists at the
-        * destination, move it to an archive. Returns the archive name on success
-        * or an empty string if it was a new file, and a wikitext-formatted
-        * WikiError object on failure.
+        * destination, move it to an archive. Returns a FileRepoStatus object with
+        * the archive name in the "value" member on success.
         *
         * The archive name should be passed through to recordUpload for database
         * registration.
         *
-        * @param $sourcePath String: local filesystem path to the source image
+        * @param $srcPath String: local filesystem path to the source image
         * @param $flags Integer: a bitwise combination of:
         *     File::DELETE_SOURCE    Delete the source file, i.e. move
         *         rather than copy
-        * @return The archive name on success or an empty string if it was a new
-        *     file, and a wikitext-formatted WikiError object on failure.
+        * @return FileRepoStatus object. On success, the value member contains the
+        *     archive name, or an empty string if it was a new file.
         *
         * STUB
         * Overridden by LocalFile
@@ -885,7 +879,7 @@ abstract class File {
 
                $encName = $db->addQuotes( $this->getName() );
                $res = $db->select( array( 'page', 'imagelinks'), 
-                                                       array( 'page_namespace', 'page_title', 'page_id', 'page_len', 'page_is_redirect' ),
+                                                       array( 'page_namespace', 'page_title', 'page_id', 'page_len', 'page_is_redirect', 'page_latest' ),
                                                        array( 'page_id' => 'il_from', 'il_to' => $encName ),
                                                        __METHOD__,
                                                        $options );
@@ -894,7 +888,7 @@ abstract class File {
                if ( $db->numRows( $res ) ) {
                        while ( $row = $db->fetchObject( $res ) ) {
                                if ( $titleObj = Title::newFromRow( $row ) ) {
-                                       $linkCache->addGoodLinkObj( $row->page_id, $titleObj, $row->page_len, $row->page_is_redirect );
+                                       $linkCache->addGoodLinkObj( $row->page_id, $titleObj, $row->page_len, $row->page_is_redirect, $row->page_latest );
                                        $retVal[] = $titleObj;
                                }
                        }
@@ -917,7 +911,8 @@ abstract class File {
         * @return bool
         */
        function isLocal() {
-               return $this->getRepoName() == 'local';
+               $repo = $this->getRepo();
+               return $repo && $repo->isLocal();
        }
 
        /**
@@ -1060,7 +1055,7 @@ abstract class File {
        }
 
        /**
-        * Get an image size array like that returned by getimagesize(), or false if it
+        * Get an image size array like that returned by getImageSize(), or false if it
         * can't be determined.
         *
         * @param $fileName String: The filename