35 parent::initializeAttributes();
37 $this->attributes[
'subtype'] =
"file";
46 parent::__construct(
$row);
60 $this->filename =
$name;
79 return $this->filestore->getFilenameOnFilestore($this);
91 if (!$container_guid) {
92 $container_guid = $this->container_guid;
96 return $fs->getSize($prefix, $container_guid);
105 if ($this->mimetype) {
106 return $this->mimetype;
120 return $this->mimetype = $mimetype;
135 if (isset($this) && $this->filename) {
145 if (function_exists(
'finfo_file') && defined(
'FILEINFO_MIME_TYPE')) {
146 $resource = finfo_open(FILEINFO_MIME_TYPE);
148 $mime = finfo_file($resource, $file);
153 if (!$mime && function_exists(
'mime_content_type')) {
154 $mime = mime_content_type($file);
159 'original_filename' => $file->originalfilename,
187 throw new IOException(
"You must specify a name before opening a file.");
196 (
$mode !=
"write") &&
199 $msg =
"Unrecognized file mode '" .
$mode .
"'";
212 return $this->handle;
249 return $fs->grabFile($this);
260 if ($fs->close($this->handle)) {
274 public function delete() {
308 return $fs->tell($this->
handle);
318 return $this->filestore->getFileSize($this);
340 return $fs->eof($this->
handle);
351 return $fs->exists($this);
362 $this->filestore = $filestore;
376 if ($this->filestore) {
377 return $this->filestore;
386 'guid' => $this->guid,
387 'where' => array(
"n.string LIKE 'filestore::%'"),
392 $parameters = array();
393 foreach ($mds as $md) {
394 list( ,
$name) = explode(
"::", $md->name);
395 if (
$name ==
'filestore') {
396 $filestore = $md->value;
398 $parameters[
$name] = $md->value;
404 if (isset($filestore)) {
405 if (!class_exists($filestore)) {
406 $msg =
"Unable to load filestore class " . $filestore .
" for file " .
$this->guid;
410 $this->filestore =
new $filestore();
411 $this->filestore->setParameters($parameters);
416 if (!$this->filestore) {
420 return $this->filestore;
439 $params = $this->filestore->getParameters();
440 foreach (
$params as $k => $v) {
445 $this->
setMetadata(
"filestore::filestore", get_class($this->filestore));
setDescription($description)
Set the optional file description.
getSize()
Return the size of the file in bytes.
__construct($row=null)
Loads an ElggFile entity.
$mode
Configure site maintenance mode.
if($guid==elgg_get_logged_in_user_guid()) $name
elgg module widget elgg state draggable elgg widget handle
getFilestoreSize($prefix= '', $container_guid=0)
Return the size of the filestore associated with this file.
close()
Close the file and commit changes.
seek($position)
Seek a position in the file.
setMetadata($name, $value, $value_type= '', $multiple=false, $owner_guid=0, $access_id=null)
Set metadata on this entity.
eof()
Return a boolean value whether the file handle is at the end of the file.
if($screenshots) $description
exists()
Returns if the file exists.
getGUID()
Returns the guid.
$guid
Removes an admin notice.
get_default_filestore()
Return the default filestore.
getFilenameOnFilestore()
Return the filename of this file as it is/will be stored on the filestore, which may be different to ...
grabFile()
Gets the full contents of this file.
getFilestore()
Return a filestore suitable for saving this file.
initializeAttributes()
Set subtype to 'file'.
setMimeType($mimetype)
Set the mime type of the file.
getFilename()
Return the filename.
elgg menu widget elgg menu item delete
detectMimeType($file=null, $default=null)
Detects mime types based on filename or actual file.
read($length, $offset=0)
Read data.
tell()
Return the current position of the file.
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Trigger a Plugin Hook and run all handler callbacks registered to that hook:type. ...
getMimeType()
Get the mime type of the file.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Sends a notice about deprecated use of a function, view, etc.
elgg river item elgg form comment save
setFilestore(ElggFilestore $filestore)
Set a filestore.
setFilename($name)
Set the filename of this file.
size()
Return the size of the file in bytes.
open($mode)
Open the file with the given mode.