From d9022f63880ce039446fba8364f68e656b7bf4cb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 3 May 2012 13:01:35 +0200 Subject: Update to MediaWiki 1.19.0 --- includes/filerepo/file/UnregisteredLocalFile.php | 145 +++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 includes/filerepo/file/UnregisteredLocalFile.php (limited to 'includes/filerepo/file/UnregisteredLocalFile.php') diff --git a/includes/filerepo/file/UnregisteredLocalFile.php b/includes/filerepo/file/UnregisteredLocalFile.php new file mode 100644 index 00000000..cd9d3d02 --- /dev/null +++ b/includes/filerepo/file/UnregisteredLocalFile.php @@ -0,0 +1,145 @@ +title = File::normalizeTitle( $title, 'exception' ); + $this->name = $repo->getNameFromTitle( $title ); + } else { + $this->name = basename( $path ); + $this->title = File::normalizeTitle( $this->name, 'exception' ); + } + $this->repo = $repo; + if ( $path ) { + $this->path = $path; + } else { + $this->assertRepoDefined(); + $this->path = $repo->getRootDirectory() . '/' . + $repo->getHashPath( $this->name ) . $this->name; + } + if ( $mime ) { + $this->mime = $mime; + } + $this->dims = array(); + } + + private function cachePageDimensions( $page = 1 ) { + if ( !isset( $this->dims[$page] ) ) { + if ( !$this->getHandler() ) { + return false; + } + $this->dims[$page] = $this->handler->getPageDimensions( $this, $page ); + } + return $this->dims[$page]; + } + + function getWidth( $page = 1 ) { + $dim = $this->cachePageDimensions( $page ); + return $dim['width']; + } + + function getHeight( $page = 1 ) { + $dim = $this->cachePageDimensions( $page ); + return $dim['height']; + } + + function getMimeType() { + if ( !isset( $this->mime ) ) { + $magic = MimeMagic::singleton(); + $this->mime = $magic->guessMimeType( $this->getLocalRefPath() ); + } + return $this->mime; + } + + function getImageSize( $filename ) { + if ( !$this->getHandler() ) { + return false; + } + return $this->handler->getImageSize( $this, $this->getLocalRefPath() ); + } + + function getMetadata() { + if ( !isset( $this->metadata ) ) { + if ( !$this->getHandler() ) { + $this->metadata = false; + } else { + $this->metadata = $this->handler->getMetadata( $this, $this->getLocalRefPath() ); + } + } + return $this->metadata; + } + + function getURL() { + if ( $this->repo ) { + return $this->repo->getZoneUrl( 'public' ) . '/' . + $this->repo->getHashPath( $this->name ) . rawurlencode( $this->name ); + } else { + return false; + } + } + + function getSize() { + $this->assertRepoDefined(); + $props = $this->repo->getFileProps( $this->path ); + if ( isset( $props['size'] ) ) { + return $props['size']; + } + return false; // doesn't exist + } +} -- cgit v1.2.3-54-g00ecf