*
* ignoreRedirect: If true, do not follow file redirects
*
- * private: If true, return restricted (deleted) files if the current
+ * private: If true, return restricted (deleted) files if the current
* user is allowed to view them. Otherwise, such files will not
* be found.
*
}
# Check the cache
- if ( empty( $options['ignoreRedirect'] )
- && empty( $options['private'] )
- && empty( $options['bypassCache'] ) )
+ if ( empty( $options['ignoreRedirect'] )
+ && empty( $options['private'] )
+ && empty( $options['bypassCache'] ) )
{
$useCache = true;
$time = isset( $options['time'] ) ? $options['time'] : '';
foreach ( $images as $name => $image ) {
unset( $items[$name] );
}
-
+
$images = array_merge( $images, $repo->findFiles( $items ) );
}
return $images;
}
return false;
}
-
+
function findBySha1( $hash ) {
if ( !$this->reposInitialised ) {
$this->initialiseRepos();
}
-
+
$result = $this->localRepo->findBySha1( $hash );
foreach ( $this->foreignRepos as $repo )
$result = array_merge( $result, $repo->findBySha1( $hash ) );
- return $result;
+ return $result;
}
/**
}
/**
- * Call a function for each foreign repo, with the repo object as the
+ * Call a function for each foreign repo, with the repo object as the
* first parameter.
*
* @param $callback callback The function to call
<?php
/**
- * @file
+ * @file
* @ingroup upload
- *
+ *
* UploadBase and subclasses are the backend of MediaWiki's file uploads.
* The frontends are formed by ApiUpload and SpecialUpload.
- *
+ *
* See also includes/docs/upload.txt
- *
+ *
* @author Brion Vibber
* @author Bryan Tong Minh
* @author Michael Dale
*/
-
+
abstract class UploadBase {
protected $mTempPath;
protected $mDesiredDestName, $mDestName, $mRemoveTempFile, $mSourceType;
return true;
}
- // Upload handlers. Should probably just be a global
+ // Upload handlers. Should probably just be a global.
static $uploadHandlers = array( 'Stash', 'File', 'Url' );
/**
// Get the upload class
$type = ucfirst( $type );
-
+
// Give hooks the chance to handle this request
$className = null;
wfRunHooks( 'UploadCreateFromRequest', array( $type, &$className ) );
$this->mFileSize = $fileSize;
$this->mRemoveTempFile = $removeTempFile;
}
-
+
/**
* Initialize from a WebRequest. Override this in a subclass.
*/
public function isEmptyFile(){
return empty( $this->mFileSize );
}
-
+
/**
* getRealPath
* @param string $srcPath the source path
*/
if( $this->isEmptyFile() )
return array( 'status' => self::EMPTY_FILE );
-
+
/**
* Look at the contents of the file; if we can recognize the
* type but it's corrupt or data of the wrong type, we should
'details' => $verification );
}
-
+
$nt = $this->getTitle();
if( is_null( $nt ) ) {
$result = array( 'status' => $this->mTitleError );
#check mime type, if desired
global $wgVerifyMimeType;
- if ( $wgVerifyMimeType ) {
+ if ( $wgVerifyMimeType ) {
global $wgMimeTypeBlacklist;
if ( $this->checkFileExtension( $mime, $wgMimeTypeBlacklist ) )
return array( 'filetype-badmime', $mime );
/**
* Check whether the user can edit, upload and create the image.
- *
+ *
* @param User $user the user to verify the permissions against
* @return mixed An array as returned by getUserPermissionsErrors or true
* in case the user has proper permissions.
/**
* Check for non fatal problems with the file
- *
+ *
* @return array Array of warnings
*/
public function checkWarnings() {
}
/**
- * Really perform the upload. Stores the file in the local repo, watches
+ * Really perform the upload. Stores the file in the local repo, watches
* if necessary and runs the UploadComplete hook.
- *
+ *
* @return mixed Status indicating the whether the upload succeeded.
*/
public function performUpload( $comment, $pageText, $watch, $user ) {
/**
* Returns the title of the file to be uploaded. Sets mTitleError in case
* the name was illegal.
- *
+ *
* @return Title The title of the file or null in case the name was illegal
*/
public function getTitle() {
}
/**
- * Return the local file and initializes if necessary.
+ * Return the local file and initializes if necessary.
*/
public function getLocalFile() {
if( is_null( $this->mLocalFile ) ) {
'mFileSize' => $this->mFileSize,
'mFileProps' => $this->mFileProps,
'version' => self::SESSION_VERSION,
- );
+ );
return $key;
}
return true;
}
- /* Check shared conflicts: if the local file does not exist, but
- * wfFindFile finds a file, it exists in a shared repository.
- */
+ /* Check shared conflicts: if the local file does not exist, but
+ * wfFindFile finds a file, it exists in a shared repository.
+ */
$file = wfFindFile( $this->getTitle() );
if ( $file && !$wgUser->isAllowed( 'reupload-shared' ) )
return 'fileexists-shared-forbidden';
/**
* Helper function that does various existence checks for a file.
- * The following checks are performed:
+ * The following checks are performed:
* - The file exists
* - Article with the same name as the file exists
* - File exists with normalized extension
* - The file looks like a thumbnail and the original exists
- *
- * @param File $file The file to check
+ *
+ * @param File $file The file to check
* @return mixed False if the file does not exists, else an array
*/
public static function getExistsWarning( $file ) {
if( $file->getTitle()->getArticleID() )
return array( 'warning' => 'page-exists', 'file' => $file );
-
+
if ( $file->wasDeleted() && !$file->exists() )
- return array( 'warning' => 'was-deleted', 'file' => $file );
-
+ return array( 'warning' => 'was-deleted', 'file' => $file );
+
if( strpos( $file->getName(), '.' ) == false ) {
$partname = $file->getName();
$extension = '';
// File does not exist, but we just don't like the name
return array( 'warning' => 'thumb-name', 'file' => $file, 'thumbFile' => $file_thb );
}
-
+
foreach( self::getFilenamePrefixBlacklist() as $prefix ) {
if ( substr( $partname, 0, strlen( $prefix ) ) == $prefix )
return array( 'warning' => 'bad-prefix', 'file' => $file, 'prefix' => $prefix );
}
-
+
return false;