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));
$mode
Configure site maintenance mode.
if($guid==elgg_get_logged_in_user_guid()) $name
getGUID()
Returns the guid.
setMetadata($name, $value, $value_type='', $multiple=false, $owner_guid=0, $access_id=null)
Set metadata on this entity.
setDescription($description)
Set the optional file description.
initializeAttributes()
Set subtype to 'file'.
setFilename($name)
Set the filename of this file.
getSize()
Return the size of the file in bytes.
seek($position)
Seek a position in the file.
read($length, $offset=0)
Read data.
grabFile()
Gets the full contents of this file.
setMimeType($mimetype)
Set the mime type of the file.
getFilenameOnFilestore()
Return the filename of this file as it is/will be stored on the filestore, which may be different to ...
exists()
Returns if the file exists.
open($mode)
Open the file with the given mode.
getMimeType()
Get the mime type of the file.
getFilestoreSize($prefix='', $container_guid=0)
Return the size of the filestore associated with this file.
getFilestore()
Return a filestore suitable for saving this file.
getFilename()
Return the filename.
setFilestore(ElggFilestore $filestore)
Set a filestore.
__construct($row=null)
Loads an ElggFile entity.
detectMimeType($file=null, $default=null)
Detects mime types based on filename or actual file.
eof()
Return a boolean value whether the file handle is at the end of the file.
close()
Close the file and commit changes.
tell()
Return the current position of the file.
size()
Return the size of the file in bytes.
elgg river item elgg form comment save
$guid
Removes an admin notice.
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Trigger a Plugin Hook and run all handler callbacks registered to that hook:type.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Sends a notice about deprecated use of a function, view, etc.
get_default_filestore()
Return the default filestore.
elgg module widget elgg state draggable elgg widget handle
if($screenshots) $description
elgg menu widget elgg menu item delete