AnewtFormControlFileUpload Class Reference

Extended file upload form control with some automatic file and error handling. More...

List of all members.

Public Member Functions

 __construct ($name, $uploaddir)
 Create a new file upload control.
 build_widget ()
 Render the minimal HTML needed for this control to work.
 get_fileinfo ()
 Returns information about the upload.
 get_filename ()
 Returns the name of the file uploaded by the user.
 process ()
 Process this fileupload.
 fill ($values)
 Set the value by the filename of the uploaded file, but only if a file is uploaded.
Validation methods
 is_valid ()
 Check whether this form control is valid.

Static Public Member Functions

static make_unique ($path, $filename, $max=99)
 Returns a filename which is unique in the given path.


Detailed Description

Extended file upload form control with some automatic file and error handling.

Definition at line 14 of file fileupload.lib.php.


Constructor & Destructor Documentation

AnewtFormControlFileUpload::__construct ( name,
uploaddir 
)

Create a new file upload control.

Parameters:
$name The name of this control.
$uploaddir The directory to upload the files to.

Definition at line 25 of file fileupload.lib.php.


Member Function Documentation

AnewtFormControlFileUpload::build_widget (  ) 

Render the minimal HTML needed for this control to work.

Form control implementations should implement this method, e.g. for a checkbox a simple input HTML element should be returned.

Returns:
XHTML element with the minimal HTML markup needed for this control to function properly.

Reimplemented from AnewtFormControl.

Definition at line 45 of file fileupload.lib.php.

AnewtFormControlFileUpload::is_valid (  ) 

Check whether this form control is valid.

The default is to apply all validators added to this control. Subclasses could also override this method to do something more sensible than applying validators, since some controls don't accept validators, e.g. checkboxes.

Returns:
True if valid, false otherwise.

Reimplemented from AnewtFormControl.

Definition at line 147 of file fileupload.lib.php.

AnewtFormControlFileUpload::get_fileinfo (  ) 

Returns information about the upload.

This will be the contents of $_FILES[$control_name] or null if that does not exist.

Definition at line 195 of file fileupload.lib.php.

AnewtFormControlFileUpload::process (  ) 

Process this fileupload.

This will put the file in the $uploaddir directory.

Definition at line 226 of file fileupload.lib.php.

static AnewtFormControlFileUpload::make_unique ( path,
filename,
max = 99 
) [static]

Returns a filename which is unique in the given path.

FIXME: might not be the proper place for this function.

Parameters:
$path The path where to check the file.
$filename The base filename.
$max The maximum number of iterations to try. Defaults to 99.
Returns:
If the file doesn't already exist, it will return $filename, otherwise it will return basename.N.ext where N is the lowest value for which the a filename doesn't exist yet.
Will return false if N were to grow larger than $max.

Definition at line 307 of file fileupload.lib.php.


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

Generated on Sun Aug 2 22:54:37 2009 for Anewt by  doxygen 1.5.9