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(
setDescription($description)
Set the optional file description.
getSize()
Return the size of the file in bytes.
__construct($row=null)
Loads an 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.
__wakeup()
Reestablish filestore property.
if(isset($vars['id'])) $class
setFilestore(\ElggFilestore $filestore)
Set a filestore.
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'.
if(!$site) if(!($site instanceof ElggSite)) $site description
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.
getMimeType()
Get the mime type of the file.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
elgg river item elgg form comment save
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.
__sleep()
Get property names to serialize.