MediaWiki  REL1_22
SpecialUploadStash Class Reference

Web access for files temporarily stored by UploadStash. More...

Inheritance diagram for SpecialUploadStash:
Collaboration diagram for SpecialUploadStash:

List of all members.

Public Member Functions

 __construct ()
 execute ($subPage)
 Execute page -- can output a file directly or show a listing of them.
 showUpload ($key)
 If file available in stash, cats it out to the client as a simple HTTP response.

Static Public Member Functions

static tryClearStashedUploads ($formData)
 Static callback for the HTMLForm in showUploads, to process Note the stash has to be recreated since this is being called in a static context.

Public Attributes

const MAX_SERVE_BYTES = 1048576

Private Member Functions

 outputContents ($content, $contentType)
 Output HTTP response of raw content Side effect: writes HTTP response to STDOUT.
 outputLocalFile (File $file)
 Output HTTP response for file Side effect: writes HTTP response to STDOUT.
 outputLocallyScaledThumb ($file, $params, $flags)
 Scale a file (probably with a locally installed imagemagick, or similar) and output it to STDOUT.
 outputRemoteScaledThumb ($file, $params, $flags)
 Scale a file with a remote "scaler", as exists on the Wikimedia Foundation cluster, and output it to STDOUT.
 outputThumbFromStash ($file, $params)
 Get a thumbnail for file, either generated locally or remotely, and stream it out.
 parseKey ($key)
 Parse the key passed to the SpecialPage.
 showUploads ()
 Default action when we don't have a subpage -- just show links to the uploads we have, Also show a button to clear stashed files.

Static Private Member Functions

static outputFileHeaders ($contentType, $size)
 Output headers for streaming XXX unsure about encoding as binary; if we received from HTTP perhaps we should use that encoding, concatted with semicolon to mimeType as it usually is.

Private Attributes

 $stash

Detailed Description

Web access for files temporarily stored by UploadStash.

For example -- files that were uploaded with the UploadWizard extension are stored temporarily before committing them to the db. But we want to see their thumbnails and get other information about them.

Since this is based on the user's session, in effect this creates a private temporary file area. However, the URLs for the files cannot be shared.

Definition at line 35 of file SpecialUploadStash.php.


Constructor & Destructor Documentation


Member Function Documentation

Execute page -- can output a file directly or show a listing of them.

Parameters:
string$subPagesubpage, e.g. in http://example.com/wiki/Special:UploadStash/foo.jpg, the "foo.jpg" part
Returns:
Boolean: success

Reimplemented from SpecialPage.

Definition at line 63 of file SpecialUploadStash.php.

References SpecialPage\checkPermissions(), showUpload(), and showUploads().

SpecialUploadStash::outputContents ( content,
contentType 
) [private]

Output HTTP response of raw content Side effect: writes HTTP response to STDOUT.

Parameters:
string$contentcontent
string$contentTypemime type
Exceptions:
SpecialUploadStashTooLargeException
Returns:
bool

Definition at line 290 of file SpecialUploadStash.php.

References $size, outputFileHeaders(), and print.

Referenced by outputRemoteScaledThumb().

static SpecialUploadStash::outputFileHeaders ( contentType,
size 
) [static, private]

Output headers for streaming XXX unsure about encoding as binary; if we received from HTTP perhaps we should use that encoding, concatted with semicolon to mimeType as it usually is.

Side effect: preps PHP to write headers to STDOUT.

Parameters:
string$contentType: string suitable for content-type header
string$size,:length in bytes

Definition at line 307 of file SpecialUploadStash.php.

Referenced by outputContents().

Output HTTP response for file Side effect: writes HTTP response to STDOUT.

Parameters:
$fileFile object with a local path (e.g. UnregisteredLocalFile, LocalFile. Oddly these don't share an ancestor!)
Exceptions:
SpecialUploadStashTooLargeException
Returns:
bool

Definition at line 272 of file SpecialUploadStash.php.

References array(), File\getPath(), File\getRepo(), File\getSize(), and MAX_SERVE_BYTES.

Referenced by outputLocallyScaledThumb(), and showUpload().

SpecialUploadStash::outputLocallyScaledThumb ( file,
params,
flags 
) [private]

Scale a file (probably with a locally installed imagemagick, or similar) and output it to STDOUT.

Parameters:
$fileFile
array$paramsScaling parameters ( e.g. array( width => '50' ) );
int$flagsScaling flags ( see File:: constants )
Exceptions:
MWException
UploadStashFileNotFoundException
Returns:
boolean success

Definition at line 181 of file SpecialUploadStash.php.

References $file, $flags, $params, false, outputLocalFile(), and File\RENDER_NOW.

Referenced by outputThumbFromStash().

SpecialUploadStash::outputRemoteScaledThumb ( file,
params,
flags 
) [private]

Scale a file with a remote "scaler", as exists on the Wikimedia Foundation cluster, and output it to STDOUT.

Note: unlike the usual thumbnail process, the web client never sees the cluster URL; we do the whole HTTP transaction to the scaler ourselves and cat the results out. Note: We rely on NFS to have propagated the file contents to the scaler. However, we do not rely on the thumbnail being created in NFS and then propagated back to our filesystem. Instead we take the results of the HTTP request instead. Note: no caching is being done here, although we are instructing the client to cache it forever.

Parameters:
$file,:File object
$params,:scaling parameters ( e.g. array( width => '50' ) );
$flags,:scaling flags ( see File:: constants )
Exceptions:
MWException
Returns:
boolean success

Definition at line 223 of file SpecialUploadStash.php.

References $file, $params, array(), MWHttpRequest\factory(), global, outputContents(), and wfExpandUrl().

Referenced by outputThumbFromStash().

SpecialUploadStash::outputThumbFromStash ( file,
params 
) [private]

Get a thumbnail for file, either generated locally or remotely, and stream it out.

Parameters:
$file
$paramsarray
Returns:
boolean success

Definition at line 157 of file SpecialUploadStash.php.

References $file, $flags, $params, global, outputLocallyScaledThumb(), and outputRemoteScaledThumb().

Referenced by showUpload().

SpecialUploadStash::parseKey ( key) [private]

Parse the key passed to the SpecialPage.

Returns an array containing the associated file object, the type ('file' or 'thumb') and if application the transform parameters

Parameters:
string$key
Exceptions:
UploadStashBadPathException
Returns:
array

Definition at line 120 of file SpecialUploadStash.php.

References $file, $key, $params, and array().

Referenced by showUpload().

If file available in stash, cats it out to the client as a simple HTTP response.

n.b. Most sanity checking done in UploadStashLocalFile, so this is straightforward.

Parameters:
string$keythe key of a particular requested file
Exceptions:
HttpError
Returns:
bool

Definition at line 80 of file SpecialUploadStash.php.

References $key, $params, SpecialPage\getOutput(), outputLocalFile(), outputThumbFromStash(), and parseKey().

Referenced by execute().

Default action when we don't have a subpage -- just show links to the uploads we have, Also show a button to clear stashed files.

Returns:
bool

Definition at line 340 of file SpecialUploadStash.php.

References $file, $files, $form, array(), as, Html\element(), SpecialPage\getContext(), SpecialPage\getOutput(), SpecialPage\getTitle(), SpecialPage\msg(), SpecialPage\outputHeader(), Html\rawElement(), SpecialPage\setHeaders(), and text.

Referenced by execute().

static SpecialUploadStash::tryClearStashedUploads ( formData) [static]

Static callback for the HTMLForm in showUploads, to process Note the stash has to be recreated since this is being called in a static context.

This works, because there really is only one stash per logged-in user, despite appearances.

Parameters:
array$formData
Returns:
Status

Definition at line 324 of file SpecialUploadStash.php.

References $stash, Status\newFatal(), Status\newGood(), RepoGroup\singleton(), true, and wfDebug().


Member Data Documentation

SpecialUploadStash::$stash [private]

Definition at line 37 of file SpecialUploadStash.php.

Referenced by tryClearStashedUploads().

Definition at line 47 of file SpecialUploadStash.php.

Referenced by outputLocalFile().


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