This class represents a physical file. More...
Inherits ElggObject.
Inherited by FilePluginFile.
Public Member Functions | |
| __construct ($guid=null) | |
| Construct a new object entity, optionally from a given id value. | |
| setFilename ($name) | |
| Set the filename of this file. | |
| getFilename () | |
| Return the filename. | |
| getFilenameOnFilestore () | |
| Return the filename of this file as it is/will be stored on the filestore, which may be different to the filename. | |
| getFilestoreSize ($prefix='', $container_guid=0) | |
| getMimeType () | |
| Get the mime type of the file. | |
| setMimeType ($mimetype) | |
| Set the mime type of the file. | |
| setDescription ($description) | |
| Set the optional file description. | |
| open ($mode) | |
| Open the file with the given mode. | |
| write ($data) | |
| Write some data. | |
| read ($length, $offset=0) | |
| Read some data. | |
| grabFile () | |
| Gets the full contents of this file. | |
| close () | |
| Close the file and commit changes. | |
| delete () | |
| Delete this file. | |
| seek ($position) | |
| Seek a position in the file. | |
| tell () | |
| Return the current position of the file. | |
| size () | |
| Return the size of the file in bytes. | |
| eof () | |
| Return a boolean value whether the file handle is at the end of the file. | |
| exists () | |
| setFilestore (ElggFilestore $filestore) | |
| Set a filestore. | |
| save () | |
| Override the save function. | |
Protected Member Functions | |
| initialise_attributes () | |
| Initialise the attributes array. | |
| getFilestore () | |
| Return a filestore suitable for saving this file. | |
This class represents a physical file.
Usage: Create a new ElggFile object and specify a filename, and optionally a FileStore (if one isn't specified then the default is assumed.
Open the file using the appropriate mode, and you will be able to read and write to the file.
Optionally, you can also call the file's save() method, this will turn the file into an entity in the system and permit you to do things like attach tags to the file etc. This is not done automatically since there are many occasions where you may want access to file data on datastores using the ElggFile interface but do not want to create an Entity reference to it in the system (temporary files for example).
Definition at line 415 of file filestore.php.
| ElggFile.__construct | ( | $ | guid = null |
) |
Construct a new object entity, optionally from a given id value.
| mixed | $guid If an int, load that GUID. If a db row then will attempt to load the rest of the data. |
| Exception | if there was a problem creating the object. |
Reimplemented from ElggObject.
Reimplemented in FilePluginFile.
Definition at line 428 of file filestore.php.
References $guid, and getFilestore().
| ElggFile.close | ( | ) |
Close the file and commit changes.
Definition at line 570 of file filestore.php.
References getFilestore().
| ElggFile.delete | ( | ) |
Delete this file.
Reimplemented from ElggEntity.
Definition at line 585 of file filestore.php.
References getFilestore().
| ElggFile.eof | ( | ) |
Return a boolean value whether the file handle is at the end of the file.
Definition at line 624 of file filestore.php.
References getFilestore().
| ElggFile.exists | ( | ) |
Definition at line 630 of file filestore.php.
References getFilestore().
| ElggFile.getFilename | ( | ) |
Return the filename.
Definition at line 447 of file filestore.php.
Referenced by ElggDiskFilestore.getFilenameOnFilestore(), and open().
| ElggFile.getFilenameOnFilestore | ( | ) |
Return the filename of this file as it is/will be stored on the filestore, which may be different to the filename.
Definition at line 455 of file filestore.php.
Referenced by ElggDiskFilestore.grabFile().
| ElggFile.getFilestore | ( | ) | [protected] |
Return a filestore suitable for saving this file.
This filestore is either a pre-registered filestore, a filestore loaded from metatags saved along side this file, or the system default.
Definition at line 650 of file filestore.php.
References $name, elgg_echo(), get_default_filestore(), and get_metadata_for_entity().
Referenced by __construct(), close(), delete(), eof(), exists(), getFilestoreSize(), grabFile(), open(), read(), seek(), tell(), and write().
| ElggFile.getFilestoreSize | ( | $ | prefix = '', |
|
| $ | container_guid = 0 | |||
| ) |
Definition at line 463 of file filestore.php.
References $container_guid, $prefix, container_guid, and getFilestore().
| ElggFile.getMimeType | ( | ) |
Get the mime type of the file.
Definition at line 474 of file filestore.php.
| ElggFile.grabFile | ( | ) |
Gets the full contents of this file.
Definition at line 562 of file filestore.php.
References getFilestore().
| ElggFile.initialise_attributes | ( | ) | [protected] |
Initialise the attributes array.
This is vital to distinguish between metadata and base parameters.
Place your base parameters here.
Reimplemented from ElggObject.
Reimplemented in FilePluginFile.
Definition at line 422 of file filestore.php.
| ElggFile.open | ( | $ | mode | ) |
Open the file with the given mode.
| string | $mode Either read/write/append |
Definition at line 505 of file filestore.php.
References elgg_echo(), getFilename(), and getFilestore().
| ElggFile.read | ( | $ | length, | |
| $ | offset = 0 | |||
| ) |
Read some data.
| int | $length Amount to read. | |
| int | $offset The offset to start from. |
Definition at line 551 of file filestore.php.
References $offset, and getFilestore().
| ElggFile.save | ( | ) |
Override the save function.
Reimplemented from ElggObject.
Definition at line 697 of file filestore.php.
References $params, and ElggEntity.setMetaData().
| ElggFile.seek | ( | $ | position | ) |
Seek a position in the file.
| int | $position |
Definition at line 597 of file filestore.php.
References getFilestore().
| ElggFile.setDescription | ( | $ | description | ) |
Set the optional file description.
| string | $description The description. |
Definition at line 496 of file filestore.php.
References $description, and description.
| ElggFile.setFilename | ( | $ | name | ) |
Set the filename of this file.
| string | $name The filename. |
Definition at line 440 of file filestore.php.
References $name.
| ElggFile.setFilestore | ( | ElggFilestore $ | filestore | ) |
Set a filestore.
| ElggFilestore | $filestore The file store. |
Definition at line 641 of file filestore.php.
| ElggFile.setMimeType | ( | $ | mimetype | ) |
Set the mime type of the file.
| $mimetype | The mimetype |
Definition at line 487 of file filestore.php.
| ElggFile.size | ( | ) |
Return the size of the file in bytes.
Definition at line 617 of file filestore.php.
| ElggFile.tell | ( | ) |
Return the current position of the file.
Definition at line 608 of file filestore.php.
References getFilestore().
| ElggFile.write | ( | $ | data | ) |
Write some data.
| string | $data The data |
Definition at line 539 of file filestore.php.
References $data, and getFilestore().
1.6.3