35 parent::initializeAttributes();
37 $this->attributes[
'subtype'] =
"file";
46 parent::__construct(
$row);
60 $this->filename =
$name;
79 return $this->filestore->getFilenameOnFilestore($this);
105 if ($this->mimetype) {
106 return $this->mimetype;
120 return $this->mimetype = $mimetype;
137 if (!$file && isset($this) && $this instanceof
$class) {
141 if (!is_readable($file)) {
148 if (function_exists(
'finfo_file') && defined(
'FILEINFO_MIME_TYPE')) {
149 $resource = finfo_open(FILEINFO_MIME_TYPE);
151 $mime = finfo_file($resource, $file);
156 if (!$mime && function_exists(
'mime_content_type')) {
157 $mime = mime_content_type($file);
160 $original_filename = isset($this) && $this instanceof
$class ? $this->originalfilename : basename($file);
163 'original_filename' => $original_filename,
191 throw new \IOException(
"You must specify a name before opening a file.");
200 (
$mode !=
"write") &&
203 $msg =
"Unrecognized file mode '" .
$mode .
"'";
204 throw new \InvalidParameterException($msg);
216 return $this->handle;
253 return $fs->grabFile($this);
264 if ($fs->close($this->handle)) {
278 public function delete() {
312 return $fs->tell($this->
handle);
322 return $this->filestore->getFileSize($this);
344 return $fs->eof($this->
handle);
355 return $fs->exists($this);
366 $this->filestore = $filestore;
380 if ($this->filestore) {
381 return $this->filestore;
390 'guid' => $this->guid,
391 'where' => array(
"n.string LIKE 'filestore::%'"),
396 $parameters = array();
397 foreach ($mds as $md) {
398 list( ,
$name) = explode(
"::", $md->name);
399 if (
$name ==
'filestore') {
400 $filestore = $md->value;
402 $parameters[
$name] = $md->value;
408 if (isset($filestore)) {
409 if (!class_exists($filestore)) {
410 $msg =
"Unable to load filestore class " . $filestore .
" for file " .
$this->guid;
411 throw new \ClassNotFoundException($msg);
414 $this->filestore =
new $filestore();
415 $this->filestore->setParameters($parameters);
420 if (!$this->filestore) {
424 return $this->filestore;
443 $params = $this->filestore->getParameters();
444 foreach (
$params as $k => $v) {
449 $this->
setMetadata(
"filestore::filestore", get_class($this->filestore));
460 return array_diff(array_keys(get_object_vars($this)), array(
$mode
Configure site maintenance mode.
if(! $site) if(!($site instanceof ElggSite)) $site description
if($guid==elgg_get_logged_in_user_guid()) $name
if(isset($vars['id'])) $class
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.
setFilestore(\ElggFilestore $filestore)
Set a filestore.
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 ...
__sleep()
Get property names to serialize.
__wakeup()
Reestablish filestore property.
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.
__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_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log 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