Movatterモバイル変換


[0]ホーム

URL:


MediaWiki master
UploadStashFile.php
Go to the documentation of this file.
1<?php
7useMediaWiki\FileRepo\File\UnregisteredLocalFile;
8useMediaWiki\FileRepo\FileRepo;
9useMediaWiki\FileRepo\LocalRepo;
10useMediaWiki\SpecialPage\SpecialPage;
11
15classUploadStashFileextendsUnregisteredLocalFile {
17private $fileKey;
19private $urlName;
21protected$url;
23private $sha1;
24
39publicfunction__construct( $repo,$path, $key, $sha1 =null, $mime =false ) {
40 $this->fileKey = $key;
41 $this->sha1 = $sha1;
42
43// resolve mwrepo:// urls
44if ( FileRepo::isVirtualUrl($path ) ) {
46 }else {
47// check if path appears to be correct, no parent traversals,
48// and is in this repo's temp zone.
49 $repoTempPath =$repo->getZonePath('temp' );
50if ( ( !$repo->validateFilename($path ) ) ||
51 !str_starts_with($path, $repoTempPath )
52 ) {
53wfDebug("UploadStash: tried to construct an UploadStashFile "
54 ."from a file that should already exist at '$path', but path is not valid" );
56wfMessage('uploadstash-bad-path-invalid' )
57 );
58 }
59
60// check if path exists! and is a plain file.
61if ( !$repo->fileExists($path ) ) {
62wfDebug("UploadStash: tried to construct an UploadStashFile from "
63 ."a file that should already exist at '$path', but path is not found" );
65wfMessage('uploadstash-file-not-found-not-exists' )
66 );
67 }
68 }
69
70 parent::__construct(false,$repo,$path,$mime );
71
72 $this->name = basename( $this->path );
73 }
74
81publicfunctiongetSha1() {
82if ( !$this->sha1 ) {
83 $this->sha1 = parent::getSha1();
84 }
85return $this->sha1;
86 }
87
96publicfunctiongetDescriptionUrl() {
97return $this->getUrl();
98 }
99
110publicfunctiongetThumbPath( $thumbName =false ) {
111$path = dirname( $this->path );
112if ( $thumbName !==false ) {
113$path .="/$thumbName";
114 }
115
116return$path;
117 }
118
128publicfunctionthumbName( $params, $flags = 0 ) {
129return $this->generateThumbName( $this->getUrlName(), $params );
130 }
131
138privatefunction getSpecialUrl( $subPage ) {
139return SpecialPage::getTitleFor('UploadStash', $subPage )->getLocalURL();
140 }
141
152publicfunctiongetThumbUrl( $thumbName =false ) {
153wfDebug( __METHOD__ ." getting for $thumbName" );
154
155return $this->getSpecialUrl('thumb/' . $this->getUrlName() .'/' . $thumbName );
156 }
157
164publicfunctiongetUrlName() {
165if ( !$this->urlName ) {
166 $this->urlName = $this->fileKey;
167 }
168
169return $this->urlName;
170 }
171
178publicfunctiongetUrl() {
179if ( $this->url ===null ) {
180 $this->url = $this->getSpecialUrl('file/' . $this->getUrlName() );
181 }
182
183return$this->url;
184 }
185
193publicfunctiongetFullUrl() {
194return $this->getUrl();
195 }
196
203publicfunctiongetFileKey() {
204return $this->fileKey;
205 }
206
211publicfunctionremove() {
212if ( !$this->repo->fileExists( $this->path ) ) {
213// Maybe the file's already been removed? This could totally happen in UploadBase.
214returntrue;
215 }
216
217return $this->repo->freeTemp( $this->path );
218 }
219
221publicfunctionexists() {
222return $this->repo->fileExists( $this->path );
223 }
224}
wfDebug
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
DefinitionGlobalFunctions.php:632
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
DefinitionGlobalFunctions.php:820
$path
$path
DefinitionNoLocalSettings.php:14
MediaWiki\FileRepo\FileRepo
Base class for file repositories.
DefinitionFileRepo.php:52
MediaWiki\FileRepo\FileRepo\resolveVirtualUrl
resolveVirtualUrl( $url)
Get the backend storage path corresponding to a virtual URL.
DefinitionFileRepo.php:358
MediaWiki\FileRepo\FileRepo\fileExists
fileExists( $file)
Checks existence of a file.
DefinitionFileRepo.php:1432
MediaWiki\FileRepo\FileRepo\getZonePath
getZonePath( $zone)
Get the storage path corresponding to one of the zones.
DefinitionFileRepo.php:398
MediaWiki\FileRepo\FileRepo\validateFilename
validateFilename( $filename)
Determine if a relative path is valid, i.e.
DefinitionFileRepo.php:1754
MediaWiki\FileRepo\File\File\$repo
FileRepo LocalRepo ForeignAPIRepo false $repo
Some member variables can be lazy-initialised using __get().
DefinitionFile.php:126
MediaWiki\FileRepo\File\File\generateThumbName
generateThumbName( $name, $params)
Generate a thumbnail file name from a name and specified parameters.
DefinitionFile.php:1115
MediaWiki\FileRepo\File\UnregisteredLocalFile
File without associated database record.
DefinitionUnregisteredLocalFile.php:30
MediaWiki\FileRepo\File\UnregisteredLocalFile\$mime
string false null $mime
DefinitionUnregisteredLocalFile.php:38
MediaWiki\FileRepo\LocalRepo
Local repository that stores files in the local filesystem and registers them in the wiki's own datab...
DefinitionLocalRepo.php:45
MediaWiki\SpecialPage\SpecialPage
Parent class for all special pages.
DefinitionSpecialPage.php:51
UploadStashBadPathException
DefinitionUploadStashBadPathException.php:11
UploadStashFileNotFoundException
DefinitionUploadStashFileNotFoundException.php:11
UploadStashFile
DefinitionUploadStashFile.php:15
UploadStashFile\__construct
__construct( $repo, $path, $key, $sha1=null, $mime=false)
A LocalFile wrapper around a file that has been temporarily stashed, so we can do things like create ...
DefinitionUploadStashFile.php:39
UploadStashFile\exists
exists()
Returns true if file exists in the repository.Overridden by LocalFile to avoid unnecessary stat calls...
DefinitionUploadStashFile.php:221
UploadStashFile\getThumbPath
getThumbPath( $thumbName=false)
Get the path for the thumbnail (actually any transformation of this file) The actual argument is the ...
DefinitionUploadStashFile.php:110
UploadStashFile\getDescriptionUrl
getDescriptionUrl()
A method needed by the file transforming and scaling routines in File.php We do not necessarily care ...
DefinitionUploadStashFile.php:96
UploadStashFile\getUrl
getUrl()
Return the URL of the file, if for some reason we wanted to download it We tend not to do this for th...
DefinitionUploadStashFile.php:178
UploadStashFile\$url
string null $url
Lazy set as in-memory cache.
DefinitionUploadStashFile.php:21
UploadStashFile\getThumbUrl
getThumbUrl( $thumbName=false)
Get a URL to access the thumbnail This is required because the model of how files work requires that ...
DefinitionUploadStashFile.php:152
UploadStashFile\getFullUrl
getFullUrl()
Parent classes use this method, for no obvious reason, to return the path (relative to wiki root,...
DefinitionUploadStashFile.php:193
UploadStashFile\getUrlName
getUrlName()
The basename for the URL, which we want to not be related to the filename.
DefinitionUploadStashFile.php:164
UploadStashFile\getSha1
getSha1()
Get the SHA-1 base 36 hash.
DefinitionUploadStashFile.php:81
UploadStashFile\getFileKey
getFileKey()
Getter for file key (the unique id by which this file's location & metadata is stored in the db)
DefinitionUploadStashFile.php:203
UploadStashFile\thumbName
thumbName( $params, $flags=0)
Return the file/url base name of a thumbnail with the specified parameters.
DefinitionUploadStashFile.php:128
$url
$url
Definitionopensearch_desc.php:23

[8]ページ先頭

©2009-2025 Movatter.jp