CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Public Attributes | Static Protected Member Functions | List of all members
File Class Reference

Class representing a stored (usually uploaded) file. More...

Inheritance diagram for File:
[legend]
Collaboration diagram for File:
[legend]

## Public Member Functions
| CreateCopy ()
| Create copy of File object. More...
| GetLength ()
| Gets the length of the file. More...
| GetType ()
| Gets the file's type. More...
| Comment ($NewValue=DB_NOVALUE)
| Gets or sets the comment on the file. More...
| FieldId ($NewValue=DB_NOVALUE)
| Gets or sets the field ID of the File. More...
| ResourceId ($NewValue=DB_NOVALUE)
| Gets or sets the resource ID of the File. More...
| GetMimeType ()
| Gets the MIME type of the file. More...
| GetLink ()
| Returns the relative download link to download the file. More...
| Destroy ()
| Deletes the file and removes its entry from the database. More...
| Delete ()
| Deprecated method to delete file and remove entry from database. More...
| GetNameOfStoredFile ()
| Returns the relative link to the stored file. More...
Public Member Functions inherited from Item
| __construct ($Id)
| Constructor, used to load existing items. More...
| Destroy ()
| Destroy item. More...
| Delete ()
| Destroy item. More...
| Id ()
| Get item ID. More...
| Name ($NewValue=DB_NOVALUE)
| Get/set name of item. More...
| DateCreated ($NewValue=DB_NOVALUE)
| Get/set when item was created. More...
| CreatedBy ($NewValue=DB_NOVALUE)
| Get/set ID of user who created the item. More...
| DateLastModified ($NewValue=DB_NOVALUE)
| Get/set when item was last modified. More...
| LastModifiedBy ($NewValue=DB_NOVALUE)
| Get/set ID of user who last modified the item. More...

## Static Public Member Functions
static | Create ($SourceFile, $DesiredFileName=NULL)
| Create a new File object using an existing file. More...
static | GetStorageDirectory ()
| Get file storage directory. More...
Static Public Member Functions inherited from Item
static | GetCanonicalId ($Id)
| Normalize item ID to canonical form. More...
static | ItemExists ($Id)
| Check whether an item exists with the specified ID. More...

## Public Attributes
const | FILESTAT_OK = 0
const | FILESTAT_COPYERROR = 1
const | FILESTAT_PARAMERROR = 2
const | FILESTAT_ZEROLENGTH = 3
const | FILESTAT_DOESNOTEXIST = 4
const | FILESTAT_UNREADABLE = 5
Public Attributes inherited from Item
const | NO_ITEM = -2123456789
| ID value used to indicate no item. More...

## Static Protected Member Functions
static | DetermineFileType ($FileName)
| Get MIME type for specified file, if possible. More...
Static Protected Member Functions inherited from Item
static | CreateWithValues ($Values)
| Create a new item, using specified initial database values. More...
static | SetDatabaseAccessValues ($ClassName)
| Set the database access values (table name, ID column name, name column name) for specified class. More...

## Additional Inherited Members
Protected Member Functions inherited from Item
| UpdateValue ($ColumnName, $NewValue=DB_NOVALUE)
| Convenience function to supply parameters to Database::UpdateValue(). More...
| UpdateDateValue ($ColumnName, $NewValue=DB_NOVALUE)
| Convenience function to supply parameters to Database::UpdateValue(), with preprocessing of new values to convert them into an SQL-compatible date format. More...
Protected Attributes inherited from Item
| $DB
| $Id
| $ItemIdColumnName
| $ItemNameColumnName
| $ItemTableName
| $ValueCache = array()
Static Protected Attributes inherited from Item
static | $ItemIdColumnNames
static | $ItemNameColumnNames
static | $ItemTableNames

## Detailed Description

Class representing a stored (usually uploaded) file.

Definition at line 13 of file File.php.

## Member Function Documentation

File::Comment | ( |  | $NewValue = `DB_NOVALUE` | ) |

Gets or sets the comment on the file.

Parameters

  string | $NewValue | The new comment on the file. (OPTIONAL)

Returns
  The comment on the file.

Definition at line 137 of file File.php.

References Item\UpdateValue().

static File::Create | ( |  | $SourceFile,
|  |  | $DesiredFileName = `NULL`
| ) |  |
| static

Create a new File object using an existing file.

Parameters

  string | $SourceFile | Name of existing file, with absolute or relative leading path, if needed.
  string | $DesiredFileName | Desired name for file (if not the same as the existing name). (OPTIONAL).

Returns
  mixed New File object or error code if creation failed.

Definition at line 34 of file File.php.

References Item\$DB.

Referenced by FormUI_Base\HandleUploads().

Here is the caller graph for this function:

File::CreateCopy | ( |  | ) |

Create copy of File object.

The copy will have a new ID, but will otherwise be identical.

Returns
  object Copy of object.

Definition at line 102 of file File.php.

References FieldId(), GetNameOfStoredFile(), Item\Name(), and ResourceId().

File::Delete | ( |  | ) |

Deprecated method to delete file and remove entry from database.

See also
  Destroy()

Deprecated:

Definition at line 216 of file File.php.

References Destroy().

File::Destroy | ( |  | ) |

Deletes the file and removes its entry from the database.

Other methods are invalid after calling this.

Definition at line 198 of file File.php.

References GetNameOfStoredFile().

Referenced by Delete().

Here is the caller graph for this function:

static File::DetermineFileType | ( |  | $FileName | ) |
| static protected

Get MIME type for specified file, if possible.

Parameters

  string | $FileName | Name of file, with absolute or relative leading path, if needed.

Returns
  string MIME type, or empty string if unable to determine type.

Definition at line 286 of file File.php.

File::FieldId | ( |  | $NewValue = `DB_NOVALUE` | ) |

Gets or sets the field ID of the File.

Parameters

  int | $NewValue | The new field ID of the File. (OPTIONAL)

Returns
  The field ID of the File.

Definition at line 147 of file File.php.

References Item\UpdateValue().

Referenced by CreateCopy().

Here is the caller graph for this function:

File::GetLength | ( |  | ) |

Gets the length of the file.

Returns
  The length of the file.

Definition at line 118 of file File.php.

File::GetLink | ( |  | ) |

Returns the relative download link to download the file.

If .htaccess files are supported, the redirect that includes the file name is used.

Returns
  The relative link to download the file.

Definition at line 177 of file File.php.

References Item\Name().

File::GetMimeType | ( |  | ) |

Gets the MIME type of the file.

Returns
  The MIME type of the file.

Definition at line 166 of file File.php.

References GetType().

File::GetNameOfStoredFile | ( |  | ) |

Returns the relative link to the stored file.

Returns
  The relative link to the stored file

Definition at line 225 of file File.php.

References Item\Id(), and Item\Name().

Referenced by CreateCopy(), and Destroy().

Here is the caller graph for this function:

static File::GetStorageDirectory | ( |  | ) |
| static

Get file storage directory.

Returns
  string Relative directory path (with no trailing slash).

Definition at line 254 of file File.php.

File::GetType | ( |  | ) |

Gets the file's type.

Returns
  The file's type.

Definition at line 127 of file File.php.

Referenced by GetMimeType().

Here is the caller graph for this function:

File::ResourceId | ( |  | $NewValue = `DB_NOVALUE` | ) |

Gets or sets the resource ID of the File.

Parameters

  int | $NewValue | The new resource ID of the File. (OPTIONAL)

Returns
  The resource ID of the File.

Definition at line 157 of file File.php.

References Item\UpdateValue().

Referenced by CreateCopy().

Here is the caller graph for this function:

## Member Data Documentation

const File::FILESTAT_COPYERROR = 1

Definition at line 20 of file File.php.

const File::FILESTAT_DOESNOTEXIST = 4

Definition at line 23 of file File.php.

const File::FILESTAT_OK = 0

Definition at line 19 of file File.php.

Referenced by UserEditingUI\UploadFiles().

const File::FILESTAT_PARAMERROR = 2

Definition at line 21 of file File.php.

const File::FILESTAT_UNREADABLE = 5

Definition at line 24 of file File.php.

const File::FILESTAT_ZEROLENGTH = 3

Definition at line 22 of file File.php.

Referenced by FormUI_Base\HandleUploads(), and UserEditingUI\UploadFiles().

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

- objects/File.php