fORMFilestatic classv1.0.0b19
Provides file manipulation functionality for fActiveRecord classes
| 1.0.0b19 | Fixed a few missed instances of old fFile method names 12/16/09 |
|---|---|
| 1.0.0b18 | Updated code for the new fFile API 12/16/09 |
| 1.0.0b17 | Updated code for the new fORMDatabase and fORMSchema APIs 10/28/09 |
| 1.0.0b16 | fImage method calls for file upload columns will no longer cause notices due to a missing image type 9/9/09 |
| 1.0.0b15 | addFImageMethodCall() no longer requires column be an image upload column, inheritance to an image column now only happens for fImage objects 7/29/09 |
| 1.0.0b14 | Updated to use new fORM::registerInspectCallback() method 7/13/09 |
| 1.0.0b13 | Updated code for new fORM API 6/15/09 |
| 1.0.0b12 | Changed replacement values in preg_replace() calls to be properly escaped 6/11/09 |
| 1.0.0b11 | Updated code to use new fValidationException::formatField() method 6/4/09 |
| 1.0.0b10 | Fixed a bug where an inherited file upload column would not be properly re-set with an existing- input 5/26/09 |
| 1.0.0b9 | upload() and set() now set the $values entry to NULL for filenames that are empty 3/2/09 |
| 1.0.0b8 | Changed set() to accept objects and reject directories 1/21/09 |
| 1.0.0b7 | Changed the class to use the new fFilesystem::createObject() method 1/21/09 |
| 1.0.0b6 | Old files are now checked against the current file to prevent removal of an in-use file 12/23/08 |
| 1.0.0b5 | Fixed replicate() to ensure the temp directory exists and set() to use the temp directory 12/23/08 |
| 1.0.0b4 | objectify() no longer throws an exception when a file can't be found 12/18/08 |
| 1.0.0b3 | Added replicate() so that replicated files get pu in the temp directory 12/12/08 |
| 1.0.0b2 | Fixed a bug with objectifying file columns 11/24/08 |
| 1.0.0b | The initial implementation 5/28/08 |
Constants
::TEMP_DIRECTORYinternal
Please note: this constant is primarily intended for internal use by Flourish and will normally not be useful in site/application code
The temporary directory to use for various tasks
Static Methods
::addFImageMethodCall() public
Adds an fImage method call to the image manipulation for a column if an image file is uploaded
Signature
void addFImageMethodCall( mixed $class, string $column, string $method, array $parameters=array() )
Parameters
| mixed | $class | The class name or instance of the class |
| string | $column | The column to call the method for |
| string | $method | The fImage method to call |
| array | $parameters | The parameters to pass to the method |
::addFUploadMethodCall() public
Signature
void addFUploadMethodCall( mixed $class, string $column, string $method, array $parameters=array() )
Parameters
| mixed | $class | The class name or instance of the class |
| string | $column | The column to call the method for |
| string | $method | The fUpload method to call |
| array | $parameters | The parameters to pass to the method |
::begin() internal public
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Begins a transaction, or increases the level
Signature
void begin( )
::commit() internal public
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Commits a transaction, or decreases the level
Signature
void commit( )
::configureColumnInheritance() public
Takes one file or image upload columns and sets it to inherit any uploaded/set files from another column
Signature
void configureColumnInheritance( mixed $class, string $column, string $inherit_from_column )
Parameters
| mixed | $class | The class name or instance of the class |
| string | $column | The column that will inherit the uploaded file |
| string | $inherit_from_column | The column to inherit the uploaded file from |
::configureFileUploadColumn() public
Sets a column to be a file upload column
Configuring a column to be a file upload column means that whenever fActiveRecord::populate() is called for an fActiveRecord object, any appropriately named file uploads (via $_FILES) will be moved into the directory for this column.
Setting the column to a file path will cause the specified file to be copied into the directory for this column.
Signature
void configureFileUploadColumn( mixed $class, string $column, fDirectory|string $directory )
Parameters
| mixed | $class | The class name or instance of the class |
| string | $column | The column to set as a file upload column |
| fDirectory|string | $directory | The directory to upload/move to |
::configureImageUploadColumn() public
Sets a column to be an image upload column
This method works exactly the same as configureFileUploadColumn() except that only image files are accepted.
Signature
void configureImageUploadColumn( mixed $class, string $column, fDirectory|string $directory, string $image_type=NULL )
Parameters
| mixed | $class | The class name or instance of the class |
| string | $column | The column to set as a file upload column |
| fDirectory|string | $directory | The directory to upload to |
| string | $image_type | The image type to save the image as: NULL, 'gif', 'jpg', 'png' |
::delete() internal public
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Deletes the files for this record
Signatures
void delete( fActiveRecord $object )
void delete( array $values, array $old_values, array $related_records, array $cache )
Parameters
| fActiveRecord | $object | The fActiveRecord instance |
| array | &$values | The current values |
| array | &$old_values | The old values |
| array | &$related_records | Any records related to this record |
| array | &$cache | The cache array for the record |
::deleteOld() internal public
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Deletes old files for this record that have been replaced by new ones
Signatures
void deleteOld( fActiveRecord $object )
void deleteOld( array $values, array $old_values, array $related_records, array $cache )
Parameters
| fActiveRecord | $object | The fActiveRecord instance |
| array | &$values | The current values |
| array | &$old_values | The old values |
| array | &$related_records | Any records related to this record |
| array | &$cache | The cache array for the record |
::encode() internal public
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Encodes a file for output into an HTML input tag
Signatures
void encode( fActiveRecord $object, string $method_name, array $parameters )
void encode( array $values, array $old_values, array $related_records, array $cache )
Parameters
| fActiveRecord | $object | The fActiveRecord instance |
| array | &$values | The current values |
| array | &$old_values | The old values |
| array | &$related_records | Any records related to this record |
| array | &$cache | The cache array for the record |
| string | $method_name | The method that was called |
| array | $parameters | The parameters passed to the method |
::inspect() internal public
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Adds metadata about features added by this class
Signatures
void inspect( string $class, string $column )
void inspect( array $metadata )
Parameters
| string | $class | The class being inspected |
| string | $column | The column being inspected |
| array | &$metadata | The array of metadata about a column |
::moveFromTemp() internal public
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Moves uploaded files from the temporary directory to the permanent directory
Signatures
void moveFromTemp( fActiveRecord $object )
void moveFromTemp( array $values, array $old_values, array $related_records, array $cache )
Parameters
| fActiveRecord | $object | The fActiveRecord instance |
| array | &$values | The current values |
| array | &$old_values | The old values |
| array | &$related_records | Any records related to this record |
| array | &$cache | The cache array for the record |
::objectify() internal public
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Signature
mixed objectify( string $class, string $column, mixed $value )
Parameters
| string | $class | The class this value is for |
| string | $column | The column the value is in |
| mixed | $value | The value |
Returns
::populate() internal public
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Performs the upload action for file uploads during fActiveRecord::populate()
Signatures
void populate( fActiveRecord $object )
void populate( array $values, array $old_values, array $related_records, array $cache )
Parameters
| fActiveRecord | $object | The fActiveRecord instance |
| array | &$values | The current values |
| array | &$old_values | The old values |
| array | &$related_records | Any records related to this record |
| array | &$cache | The cache array for the record |
::prepare() internal public
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Prepares a file for output into HTML by returning filename or the web server path to the file
Signatures
void prepare( fActiveRecord $object, string $method_name, array $parameters )
void prepare( array $values, array $old_values, array $related_records, array $cache )
Parameters
| fActiveRecord | $object | The fActiveRecord instance |
| array | &$values | The current values |
| array | &$old_values | The old values |
| array | &$related_records | Any records related to this record |
| array | &$cache | The cache array for the record |
| string | $method_name | The method that was called |
| array | $parameters | The parameters passed to the method |
::process() internal public
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Handles re-processing an existing image file
Signatures
void process( fActiveRecord $object, string $method_name, array $parameters )
void process( array $values, array $old_values, array $related_records, array $cache )
Parameters
| fActiveRecord | $object | The fActiveRecord instance |
| array | &$values | The current values |
| array | &$old_values | The old values |
| array | &$related_records | Any records related to this record |
| array | &$cache | The cache array for the record |
| string | $method_name | The method that was called |
| array | $parameters | The parameters passed to the method |
::processImage() internal public
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Performs image manipulation on an uploaded/set image
Signature
void processImage( string $class, string $column, fFile $image )
Parameters
| string | $class | The name of the class we are manipulating the image for |
| string | $column | The column the image is assigned to |
| fFile | $image | The image object to manipulate |
::reflect() internal public
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Adjusts the fActiveRecord::reflect() signatures of columns that have been configured in this class
Signatures
void reflect( string $class, boolean $include_doc_comments )
void reflect( array $signatures )
Parameters
| string | $class | The class to reflect |
| array | &$signatures | The associative array of {method name} => {signature} |
| boolean | $include_doc_comments | If doc comments should be included with the signature |
::replicate() internal public
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Creates a copy of an uploaded file in the temp directory for the newly cloned record
Signature
mixed replicate( string $class, string $column, mixed $value )
Parameters
| string | $class | The class this value is for |
| string | $column | The column the value is in |
| mixed | $value | The value |
Returns
The cloned fFile object
::reset() internal public
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Resets the configuration of the class
Signature
void reset( )
::rollback() internal public
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Rolls back a transaction, or decreases the level
Signature
void rollback( )
::set() internal public
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Copies a file from the filesystem to the file upload directory and sets it as the file for the specified column
This method will perform the fImage calls defined for the column.
Signatures
void set( fActiveRecord $object, string $method_name, array $parameters )
void set( array $values, array $old_values, array $related_records, array $cache )
Parameters
| fActiveRecord | $object | The fActiveRecord instance |
| array | &$values | The current values |
| array | &$old_values | The old values |
| array | &$related_records | Any records related to this record |
| array | &$cache | The cache array for the record |
| string | $method_name | The method that was called |
| array | $parameters | The parameters passed to the method |
::upload() internal public
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Uploads a file
Signatures
void upload( fActiveRecord $object, string $method_name, array $parameters )
void upload( array $values, array $old_values, array $related_records, array $cache )
Parameters
| fActiveRecord | $object | The fActiveRecord instance |
| array | &$values | The current values |
| array | &$old_values | The old values |
| array | &$related_records | Any records related to this record |
| array | &$cache | The cache array for the record |
| string | $method_name | The method that was called |
| array | $parameters | The parameters passed to the method |
::validate() internal public
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Validates uploaded files to ensure they match all of the criteria defined
Signatures
void validate( fActiveRecord $object )
void validate( array $values, array $old_values, array $related_records, array $cache, array $validation_messages )
Parameters
| fActiveRecord | $object | The fActiveRecord instance |
| array | &$values | The current values |
| array | &$old_values | The old values |
| array | &$related_records | Any records related to this record |
| array | &$cache | The cache array for the record |
| array | &$validation_messages | The existing validation messages |
