* The convenience functions wfLocalFile() and wfFindFile() should be sufficient
* in most cases.
*
- * @addtogroup FileRepo
+ * @ingroup FileRepo
*/
abstract class File {
const DELETED_FILE = 1;
/**
* The following member variables are not lazy-initialised
*/
- var $repo, $title, $lastError, $redirected;
+ var $repo, $title, $lastError, $redirected, $redirectedTitle;
/**
* Call this constructor from child classes
'htm' => 'html',
'jpeg' => 'jpg',
'mpeg' => 'mpg',
- 'tiff' => 'tif' );
+ 'tiff' => 'tif',
+ 'ogv' => 'ogg' );
if( isset( $squish[$lower] ) ) {
return $squish[$lower];
} elseif( preg_match( '/^[0-9a-z]+$/', $lower ) ) {
* Return the associated title object
*/
public function getTitle() { return $this->title; }
+
+ /**
+ * Return the title used to find this file
+ */
+ public function getOriginalTitle() {
+ if ( $this->redirected )
+ return $this->getRedirectedTitle();
+ return $this->title;
+ }
/**
* Return the URL of the file
* Overridden by LocalFile, UnregisteredLocalFile
* STUB
*/
- function getMetadata() { return false; }
+ public function getMetadata() { return false; }
+
+ /**
+ * Return the bit depth of the file
+ * Overridden by LocalFile
+ * STUB
+ */
+ public function getBitDepth() { return 0; }
/**
* Return the size of the image file, in bytes
*
* @param integer $width maximum width of the generated thumbnail
* @param integer $height maximum height of the image (optional)
- * @param boolean $render True to render the thumbnail if it doesn't exist,
- * false to just return the URL
+ * @param boolean $render Deprecated
*
* @return ThumbnailImage or null on failure
*
if ( $height != -1 ) {
$params['height'] = $height;
}
- $flags = $render ? self::RENDER_NOW : 0;
- return $this->transform( $params, $flags );
+ return $this->transform( $params, 0 );
}
/**
// Purge. Useful in the event of Core -> Squid connection failure or squid
// purge collisions from elsewhere during failure. Don't keep triggering for
// "thumbs" which have the main image URL though (bug 13776)
- if ( $wgUseSquid && ($thumb->isError() || $thumb->getUrl() != $this->getURL()) ) {
+ if ( $wgUseSquid && ( !$thumb || $thumb->isError() || $thumb->getUrl() != $this->getURL()) ) {
SquidUpdate::purge( array( $thumbUrl ) );
}
} while (false);
* @param $end timestamp Only revisions newer than $end will be returned
*/
function getHistory($limit = null, $start = null, $end = null) {
- return false;
+ return array();
}
/**
function getRepoName() {
return $this->repo ? $this->repo->getName() : 'unknown';
}
+ /*
+ * Returns the repository
+ */
+ function getRepo() {
+ return $this->repo;
+ }
/**
* Returns true if the image is an old version
* Get the HTML text of the description page, if available
*/
function getDescriptionText() {
+ global $wgMemc;
if ( !$this->repo->fetchDescription ) {
return false;
}
$renderUrl = $this->repo->getDescriptionRenderUrl( $this->getName() );
if ( $renderUrl ) {
+ if ( $this->repo->descriptionCacheExpiry > 0 ) {
+ wfDebug("Attempting to get the description from cache...");
+ $key = wfMemcKey( 'RemoteFileDescription', 'url', md5($renderUrl) );
+ $obj = $wgMemc->get($key);
+ if ($obj) {
+ wfDebug("success!\n");
+ return $obj;
+ }
+ wfDebug("miss\n");
+ }
wfDebug( "Fetching shared description from $renderUrl\n" );
- return Http::get( $renderUrl );
+ $res = Http::get( $renderUrl );
+ if ( $res && $this->repo->descriptionCacheExpiry > 0 ) $wgMemc->set( $key, $res, $this->repo->descriptionCacheExpiry );
+ return $res;
} else {
return false;
}
function getRedirected() {
return $this->redirected;
}
+
+ function getRedirectedTitle() {
+ if ( $this->redirected ) {
+ if ( !$this->redirectTitle )
+ $this->redirectTitle = Title::makeTitle( NS_IMAGE, $this->redirected );
+ return $this->redirectTitle;
+ }
+ }
function redirectedFrom( $from ) {
$this->redirected = $from;