ElggFile Class Reference

This class represents a physical file. More...

Inheritance diagram for ElggFile:
ElggObject ElggEntity Notable Locatable Exportable Importable Loggable

List of all members.

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.

Detailed Description

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).

Author:
Curverider Ltd

Definition at line 384 of file filestore.php.


Constructor & Destructor Documentation

ElggFile::__construct ( guid = null  ) 

Construct a new object entity, optionally from a given id value.

Parameters:
mixed $guid If an int, load that GUID. If a db row then will attempt to load the rest of the data.
Exceptions:
Exception if there was a problem creating the object.

Reimplemented from ElggObject.

Definition at line 399 of file filestore.php.


Member Function Documentation

ElggFile::close (  ) 

Close the file and commit changes.

Definition at line 535 of file filestore.php.

ElggFile::delete (  ) 

Delete this file.

Reimplemented from ElggEntity.

Definition at line 552 of file filestore.php.

ElggFile::eof (  ) 

Return a boolean value whether the file handle is at the end of the file.

Definition at line 595 of file filestore.php.

ElggFile::exists (  ) 

Definition at line 602 of file filestore.php.

ElggFile::getFilename (  ) 

Return the filename.

Definition at line 417 of file filestore.php.

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 423 of file filestore.php.

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 624 of file filestore.php.

ElggFile::getFilestoreSize ( prefix = '',
container_guid = 0 
)

Definition at line 429 of file filestore.php.

ElggFile::getMimeType (  ) 

Get the mime type of the file.

Definition at line 440 of file filestore.php.

ElggFile::grabFile (  ) 

Gets the full contents of this file.

Returns:
mixed The file contents.

Definition at line 525 of file filestore.php.

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.

Definition at line 392 of file filestore.php.

ElggFile::open ( mode  ) 

Open the file with the given mode.

Parameters:
string $mode Either read/write/append

Definition at line 467 of file filestore.php.

ElggFile::read ( length,
offset = 0 
)

Read some data.

Parameters:
int $length Amount to read.
int $offset The offset to start from.

Definition at line 513 of file filestore.php.

ElggFile::save (  ) 

Override the save function.

Returns:
true|false

Reimplemented from ElggObject.

Definition at line 668 of file filestore.php.

ElggFile::seek ( position  ) 

Seek a position in the file.

Parameters:
int $position

Definition at line 565 of file filestore.php.

ElggFile::setDescription ( description  ) 

Set the optional file description.

Parameters:
string $description The description.

Definition at line 460 of file filestore.php.

ElggFile::setFilename ( name  ) 

Set the filename of this file.

Parameters:
string $name The filename.

Definition at line 412 of file filestore.php.

ElggFile::setFilestore ( ElggFilestore filestore  ) 

Set a filestore.

Parameters:
ElggFilestore $filestore The file store.

Definition at line 614 of file filestore.php.

ElggFile::setMimeType ( mimetype  ) 

Set the mime type of the file.

Parameters:
$mimetype The mimetype

Definition at line 453 of file filestore.php.

ElggFile::size (  ) 

Return the size of the file in bytes.

Definition at line 587 of file filestore.php.

ElggFile::tell (  ) 

Return the current position of the file.

Returns:
int The file position

Definition at line 577 of file filestore.php.

ElggFile::write ( data  ) 

Write some data.

Parameters:
string $data The data

Definition at line 500 of file filestore.php.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations
Generated on Wed May 22 00:01:33 2013 for Elgg by  doxygen 1.6.3