* (bug 12935, 12981) Fully-qualify archive URLs in delete, revert messages
[lhc/web/wiklou.git] / includes / filerepo / File.php
index fbf4d25..5172ad0 100644 (file)
@@ -46,7 +46,7 @@ abstract class File {
        /**
         * The following member variables are not lazy-initialised
         */
-       var $repo, $title, $lastError;
+       var $repo, $title, $lastError, $redirected;
 
        /**
         * Call this constructor from child classes
@@ -135,15 +135,13 @@ abstract class File {
 
        /**
         * Return the associated title object
-        * @public
         */
-       function getTitle() { return $this->title; }
+       public function getTitle() { return $this->title; }
 
        /**
         * Return the URL of the file
-        * @public
         */
-       function getUrl() { 
+       public function getUrl() { 
                if ( !isset( $this->url ) ) {
                        $this->url = $this->repo->getZoneUrl( 'public' ) . '/' . $this->getUrlRel();
                }
@@ -157,12 +155,7 @@ abstract class File {
         * @return string
         */
        public function getFullUrl() {
-               $url = $this->getUrl();
-               if( substr( $url, 0, 1 ) == '/' ) {
-                       global $wgServer;
-                       return $wgServer . $url;
-               }
-               return $url;
+               return wfExpandUrl( $this->getUrl() );
        }
 
        function getViewURL() {
@@ -188,10 +181,8 @@ abstract class File {
        * or in hashed paths like /images/3/3c.
        *
        * May return false if the file is not locally accessible.
-       *
-       * @public
        */
-       function getPath() {
+       public function getPath() {
                if ( !isset( $this->path ) ) {
                        $this->path = $this->repo->getZonePath('public') . '/' . $this->getRel();
                }
@@ -200,9 +191,8 @@ abstract class File {
 
        /**
        * Alias for getPath()
-       * @public
        */
-       function getFullPath() {
+       public function getFullPath() {
                return $this->getPath();
        }
 
@@ -224,6 +214,14 @@ abstract class File {
         */
        public function getHeight( $page = 1 ) { return false; }
 
+       /**
+        * Returns ID or name of user who uploaded the file
+        * STUB
+        *
+        * @param $type string 'text' or 'id'
+        */
+       public function getUser( $type='text' ) { return null; }
+
        /**
         * Get the duration of a media file in seconds
         */
@@ -502,9 +500,11 @@ abstract class File {
 
                        $script = $this->getTransformScript();
                        if ( $script && !($flags & self::RENDER_NOW) ) {
-                               // Use a script to transform on client request
+                               // Use a script to transform on client request, if possible
                                $thumb = $this->handler->getScriptedTransform( $this, $script, $params );
-                               break;
+                               if( $thumb ) {
+                                       break;
+                               }
                        }
 
                        $normalisedParams = $params;
@@ -512,7 +512,7 @@ abstract class File {
                        $thumbName = $this->thumbName( $normalisedParams );     
                        $thumbPath = $this->getThumbPath( $thumbName );
                        $thumbUrl = $this->getThumbUrl( $thumbName );
-
+                       
                        if ( $this->repo->canTransformVia404() && !($flags & self::RENDER_NOW ) ) {
                                $thumb = $this->handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
                                break;
@@ -600,7 +600,7 @@ abstract class File {
         * STUB
         * Overridden by LocalFile
         */
-       function purgeCache( $archiveFiles = array() ) {}
+       function purgeCache() {}
 
        /**
         * Purge the file description page, but don't go after
@@ -632,6 +632,18 @@ abstract class File {
                }
        }
 
+       /**
+        * Return a fragment of the history of file.
+        *
+        * STUB
+        * @param $limit integer Limit of rows to return
+        * @param $start timestamp Only revisions older than $start will be returned
+        * @param $end timestamp Only revisions newer than $end will be returned
+        */
+       function getHistory($limit = null, $start = null, $end = null) {
+               return false;
+       }
+
        /**
         * Return the history of this file, line by line. Starts with current version, 
         * then old versions. Should return an object similar to an image/oldimage 
@@ -902,7 +914,7 @@ abstract class File {
         * STUB
         * Overridden by LocalFile
         */
-       function delete( $reason, $suppress=false ) {
+       function delete( $reason ) {
                $this->readOnlyError();
        }
 
@@ -998,6 +1010,14 @@ abstract class File {
                }
        }
 
+       /**
+        * Get discription of file revision
+        * STUB
+        */
+       function getDescription() {
+               return null;
+       }
+
        /**
         * Get the 14-character timestamp of the file upload, or false if
         * it doesn't exist 
@@ -1029,7 +1049,7 @@ abstract class File {
        }
 
        /**
-        * Get an associative array containing information about a file in the local filesystem\
+        * Get an associative array containing information about a file in the local filesystem.
         *
         * @param string $path Absolute local filesystem path
         * @param mixed $ext The file extension, or true to extract it from the filename. 
@@ -1136,6 +1156,14 @@ abstract class File {
                        return '';
                }
        }
+
+       function getRedirected() {
+               return $this->redirected;
+       }
+
+       function redirectedFrom( $from ) {
+               $this->redirected = $from;
+       }
 }
 /**
  * Aliases for backwards compatibility with 1.6