MediaWiki  REL1_20
StreamFile Class Reference

Functions related to the output of file content. More...

List of all members.

Static Public Member Functions

static contentTypeFromPath ($filename, $safe=true)
 Determine the file type of a file based on the path.
static prepareForStream ($path, $info, $headers=array(), $sendErrors=true)
 Call this function used in preparation before streaming a file.
static stream ($fname, $headers=array(), $sendErrors=true)
 Stream a file to the browser, adding all the headings and fun stuff.

Public Attributes

const NOT_MODIFIED = 2
const READY_STREAM = 1

Detailed Description

Functions related to the output of file content.

Definition at line 26 of file StreamFile.php.


Member Function Documentation

static StreamFile::contentTypeFromPath ( filename,
safe = true 
) [static]

Determine the file type of a file based on the path.

Parameters:
$filenamestring Storage path or file system path
$safebool Whether to do retroactive upload blacklist checks
Returns:
null|string

Definition at line 149 of file StreamFile.php.

References $ext, $wgFileExtensions, UploadBase\checkFileExtensionList(), MimeMagic\singleton(), and UploadBase\splitExtensions().

Referenced by SwiftFileBackend\doCreateInternal(), SwiftFileBackend\doStoreInternal(), and prepareForStream().

static StreamFile::prepareForStream ( path,
info,
headers = array(),
sendErrors = true 
) [static]

Call this function used in preparation before streaming a file.

This function does the following: (a) sends Last-Modified, Content-type, and Content-Disposition headers (b) cancels any PHP output buffering and automatic gzipping of output (c) sends Content-Length header based on HTTP_IF_MODIFIED_SINCE check

Parameters:
$pathstring Storage path or file system path
$infoArray|bool File stat info with 'mtime' and 'size' fields
$headersArray Additional headers to send
$sendErrorsbool Send error messages if errors occur (like 404)
Returns:
int|bool READY_STREAM, NOT_MODIFIED, or false on failure

Definition at line 79 of file StreamFile.php.

References $path, contentTypeFromPath(), echo, NOT_MODIFIED, READY_STREAM, wfResetOutputBuffers(), and wfTimestamp().

Referenced by stream().

static StreamFile::stream ( fname,
headers = array(),
sendErrors = true 
) [static]

Stream a file to the browser, adding all the headings and fun stuff.

Headers sent include: Content-type, Content-Length, Last-Modified, and Content-Disposition.

Parameters:
$fnamestring Full name and path of the file to stream
$headersarray Any additional headers to send
$sendErrorsbool Send error messages if errors occur (like 404)
Returns:
bool Success

Definition at line 40 of file StreamFile.php.

References $fname, $ok, $res, FileBackend\isStoragePath(), prepareForStream(), wfProfileIn(), wfProfileOut(), wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by wfStreamFile().


Member Data Documentation

Definition at line 28 of file StreamFile.php.

Referenced by prepareForStream().

Definition at line 27 of file StreamFile.php.

Referenced by prepareForStream().


The documentation for this class was generated from the following file: