silverorange Code


Swat.SwatFileEntry
/Swat/SwatFileEntry.php at line 22

Class SwatFileEntry

SwatObject
└─SwatUIObject
└─SwatWidget
└─SwatControl
└─SwatInputControl
└─SwatFileEntry

public class SwatFileEntry
extends SwatInputControl

A file upload widget

Note: Mime-type detection is done with the Fileinfo extension if avaiable. Mime-type detection falls back to the mime_content_type() function if Fileinfo is not available but Fileinfo is highly recommended.

Copyright:
2005-2006 silverorange
License:
http://www.gnu.org/copyleft/lesser.html LGPL License 2.1

Field Summary
array

$accept_mime_types

Array of mime-types to accept as uploads.

string

$access_key

Access key.

boolean

$display_maximum_upload_size

Display maximum file upload size.

boolean

$display_mime_types

Display acceptable mime-types as a note in this entry's parent.

integer

$size

The size in characters of the XHTML form input, or null if no width is specified.

Fields inherited from Swat.SwatInputControl
required
Method Summary
void

display()

Displays this entry widget.

private void

generateUniqueFileName(mixed path, mixed count)

protected array

getCSSClassNames()

Gets the array of CSS classes that are applied to this file entry widget.

mixed

getFileName()

Gets the original file name of the uploaded file.

string

getFocusableHtmlId()

Gets the id attribute of the XHTML element displayed by this widget that should receive focus.

static integer

getMaximumFileUploadSize()

Returns the size (in bytes) of the upload size limit of the PHP configuration.

mixed

getMimeType()

Gets the mime type of the uploaded file.

SwatMessage

getNote()

Gets a note specifying the mime types this file entry accepts.

mixed

getSize()

Gets the size of the uploaded file in bytes.

mixed

getTempFileName()

Gets the temporary name of the uploaded file.

string

getUniqueFileName(string path)

Gets a unique file name for the uploaded file for the given path.

protected SwatMessage

getValidationMessage(string id)

Gets a validation message for this file entry.

boolean

isUploaded()

Is file uploaded.

private static void

parseFileUploadSize(mixed ini_value)

void

process()

Processes this file entry widget.

boolean

saveFile(string dst_dir, string dst_filename)

Saves the uploaded file to the server.

Methods inherited from Swat.SwatInputControl
getForm, init
Methods inherited from Swat.SwatControl
addMessage, getNote, printWidgetTree
Methods inherited from Swat.SwatWidget
addCompositeWidget, addMessage, confirmCompositeWidgets, copy, createCompositeWidgets, display, displayHtmlHeadEntries, getCSSClassNames, getCompositeWidget, getCompositeWidgets, getFocusableHtmlId, getHtmlHeadEntrySet, getMessages, hasMessage, init, isDisplayed, isInitialized, isProcessed, isSensitive, printWidgetTree, process, replaceWithContainer
Methods inherited from Swat.SwatUIObject
addComment, addJavaScript, addStyleSheet, addTangoAttribution, copy, getCSSClassNames, getCSSClassString, getFirstAncestor, getHtmlHeadEntrySet, getInlineJavaScript, getUniqueId, isVisible

Field Detail

/Swat/SwatFileEntry.php at line 39

accept_mime_types

public array $accept_mime_types = null

Array of mime-types to accept as uploads


/Swat/SwatFileEntry.php at line 55

access_key

public string $access_key = null

Access key

Access key for this file entry control, for keyboard nagivation.


/Swat/SwatFileEntry.php at line 62

display_maximum_upload_size

public boolean $display_maximum_upload_size = false

Display maximum file upload size


/Swat/SwatFileEntry.php at line 46

display_mime_types

public boolean $display_mime_types = true

Display acceptable mime-types as a note in this entry's parent


/Swat/SwatFileEntry.php at line 32

size

public integer $size = 40

The size in characters of the XHTML form input, or null if no width is specified


Method Detail

/Swat/SwatFileEntry.php at line 95

display

public void display()

Displays this entry widget

Outputs an appropriate XHTML tag.


/Swat/SwatFileEntry.php at line 440

generateUniqueFileName

private void generateUniqueFileName(mixed path, mixed count)

/Swat/SwatFileEntry.php at line 430

getCSSClassNames

protected array getCSSClassNames()

Gets the array of CSS classes that are applied to this file entry widget

Returns:
the array of CSS classes that are applied to this file entry widget.
See Also:
SwatUIObject::getCSSClassString()

/Swat/SwatFileEntry.php at line 226

getFileName

public mixed getFileName()

Gets the original file name of the uploaded file

Returns:
the original filename of the uploaded file or null if no file was uploaded.
See Also:
SwatFileEntry::getTempFileName()

/Swat/SwatFileEntry.php at line 364

getFocusableHtmlId

public string getFocusableHtmlId()

Gets the id attribute of the XHTML element displayed by this widget that should receive focus

Returns:
the id attribute of the XHTML element displayed by this widget that should receive focus or null if there is no such element.
See Also:
SwatWidget::getFocusableHtmlId()

/Swat/SwatFileEntry.php at line 383

getMaximumFileUploadSize

public static integer getMaximumFileUploadSize()

Returns the size (in bytes) of the upload size limit of the PHP configuration

The maximum upload size is calculated based on the php ini values for upload_max_filesize and post_max_size. Be aware that web server and POST data settings can also affect the maximum upload size limit.

Returns:
the maximum upload size in bytes.

/Swat/SwatFileEntry.php at line 294

getMimeType

public mixed getMimeType()

Gets the mime type of the uploaded file

Returns:
the mime type of the uploaded file or null if no file was uploaded.

/Swat/SwatFileEntry.php at line 187

getNote

public SwatMessage getNote()

Gets a note specifying the mime types this file entry accepts

The file types are only returned if SwatFileEntry::$display_mimetypes is set to true and SwatFileEntry::$accept_mime_types has entries.

Returns:
a note listing the accepted mime-types for this file entry widget or null if any mime-type is accepted.
See Also:
SwatControl::getNote()

/Swat/SwatFileEntry.php at line 280

getSize

public mixed getSize()

Gets the size of the uploaded file in bytes

Returns:
the size of the uploaded file in bytes or null if no file was uploaded.

/Swat/SwatFileEntry.php at line 266

getTempFileName

public mixed getTempFileName()

Gets the temporary name of the uploaded file

Returns:
the temporary name of the uploaded file or null if no file was uploaded.
See Also:
SwatFileEntry::getFileName()

/Swat/SwatFileEntry.php at line 246

getUniqueFileName

public string getUniqueFileName(string path)

Gets a unique file name for the uploaded file for the given path.

If the original file name is already unqiue, it will be used, otherwise a number will be appended to the end of the file name to make it unique.

Parameters:
path - where the file is to be saved
Returns:
the unique file name
See Also:
SwatFileEntry::getFileName()

/Swat/SwatFileEntry.php at line 401

getValidationMessage

protected SwatMessage getValidationMessage(string id)

Gets a validation message for this file entry

Can be used by sub-classes to change the validation messages.

Parameters:
id - the string identifier of the validation message.
Returns:
the validation message.

/Swat/SwatFileEntry.php at line 210

isUploaded

public boolean isUploaded()

Is file uploaded

Returns:
whether or not a file was uploaded with this file entry.

/Swat/SwatFileEntry.php at line 463

parseFileUploadSize

private static void parseFileUploadSize(mixed ini_value)

/Swat/SwatFileEntry.php at line 136

process

public void process()

Processes this file entry widget

If any validation type errors occur, an error message is attached to this entry widget.


/Swat/SwatFileEntry.php at line 335

saveFile

public boolean saveFile(string dst_dir, string dst_filename)

Saves the uploaded file to the server

Parameters:
dst_dir - the directory on the server to save the uploaded file in.
dst_filename - an optional filename to save the file under. If no filename is specified, the file is saved with the original filename.
Returns:
true if the file was saved correctly and false if there was an error or no file was uploaded.
Throws:
if the destination directory does not exist.

silverorange Code