23use BadMethodCallException;
69 return new static(
false,
false,
$path,
$mime );
92 throw new BadMethodCallException( __METHOD__ .
93 ': not enough parameters, must specify title and repo, or a full path' );
99 $this->name = basename(
$path );
113 $this->pageDims = [];
120 private function cachePageDimensions( $page = 1 ) {
126 if ( !isset( $this->pageDims[$page] ) ) {
130 if ( $this->
getHandler()->isMultiPage( $this ) ) {
131 $this->pageDims[$page] = $this->handler->getPageDimensions( $this, $page );
133 $info = $this->getSizeAndMetadata();
135 'width' => $info[
'width'],
136 'height' => $info[
'height']
141 return $this->pageDims[$page];
149 $dim = $this->cachePageDimensions( $page );
151 return $dim[
'width'] ?? 0;
159 $dim = $this->cachePageDimensions( $page );
161 return $dim[
'height'] ?? 0;
168 if ( $this->mime ===
null ) {
170 if ( $refPath !==
false ) {
172 $this->mime = $magic->guessMimeType( $refPath );
185 $info = $this->getSizeAndMetadata();
186 return $info[
'bits'] ?? 0;
193 $info = $this->getSizeAndMetadata();
194 return $info[
'metadata'] ? serialize( $info[
'metadata'] ) :
false;
198 $info = $this->getSizeAndMetadata();
199 return $info[
'metadata'];
202 private function getSizeAndMetadata(): array {
203 if ( $this->sizeAndMetadata === null ) {
204 if ( !$this->getHandler() ) {
205 $this->sizeAndMetadata = [
'width' => 0,
'height' => 0,
'metadata' => [] ];
207 $this->sizeAndMetadata = $this->getHandler()->getSizeAndMetadataWithFallback(
208 $this, $this->getLocalRefPath() );
212 return $this->sizeAndMetadata;
220 return $this->repo->getZoneUrl(
'public' ) .
'/' .
221 $this->repo->getHashPath( $this->name ) . rawurlencode( $this->name );
231 $this->assertRepoDefined();
233 return $this->repo->getFileSize( $this->path );
245 $this->fsFile = $fsFile;
250class_alias( UnregisteredLocalFile::class,
'UnregisteredLocalFile' );
if(!defined('MW_SETUP_CALLBACK'))