Revert "merged master"
[lhc/web/wiklou.git] / includes / filerepo / file / File.php
index 2d6b218..133a956 100644 (file)
@@ -63,6 +63,11 @@ abstract class File {
 
        const DELETE_SOURCE = 1;
 
+       // Audience options for File::getDescription()
+       const FOR_PUBLIC = 1;
+       const FOR_THIS_USER = 2;
+       const RAW = 3;
+
        /**
         * Some member variables can be lazy-initialised using __get(). The
         * initialisation function for these variables is always a function named
@@ -240,6 +245,18 @@ abstract class File {
                }
        }
 
+       /**
+        * Callback for usort() to do file sorts by name
+        *
+        * @param $a File
+        * @param $b File
+        *
+        * @return Integer: result of name comparison
+        */
+       public static function compare( File $a, File $b ) {
+               return strcmp( $a->getName(), $b->getName() );
+       }
+
        /**
         * Return the name of this file
         *
@@ -787,7 +804,7 @@ abstract class File {
                        return $this->handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
                } else {
                        return new MediaTransformError( 'thumbnail_error',
-                               $params['width'], 0, wfMsg( 'thumbnail-dest-create' ) );
+                               $params['width'], 0, wfMessage( 'thumbnail-dest-create' )->text() );
                }
        }
 
@@ -877,7 +894,9 @@ abstract class File {
                        $tmpThumbPath = $tmpFile->getPath(); // path of 0-byte temp file
 
                        // Actually render the thumbnail...
+                       wfProfileIn( __METHOD__ . '-doTransform' );
                        $thumb = $this->handler->doTransform( $this, $tmpThumbPath, $thumbUrl, $params );
+                       wfProfileOut( __METHOD__ . '-doTransform' );
                        $tmpFile->bind( $thumb ); // keep alive with $thumb
 
                        if ( !$thumb ) { // bad params?
@@ -1565,12 +1584,18 @@ abstract class File {
        }
 
        /**
-        * Get discription of file revision
+        * Get description of file revision
         * STUB
         *
+        * @param $audience Integer: one of:
+        *      File::FOR_PUBLIC       to be displayed to all users
+        *      File::FOR_THIS_USER    to be displayed to the given user
+        *      File::RAW              get the description regardless of permissions
+        * @param $user User object to check for, only if FOR_THIS_USER is passed
+        *              to the $audience parameter
         * @return string
         */
-       function getDescription() {
+       function getDescription( $audience = self::FOR_PUBLIC, User $user = null ) {
                return null;
        }
 
@@ -1595,7 +1620,7 @@ abstract class File {
        }
 
        /**
-        * Get the deletion archive key, <sha1>.<ext>
+        * Get the deletion archive key, "<sha1>.<ext>"
         *
         * @return string
         */