Elgg  Version 3.0
Namespaces | Functions | Variables
filestore.php File Reference

Go to the source code of this file.

Namespaces

 Elgg\Core
 Updates the advanced settings for the primary site object.
 

Functions

 get_dir_size ($dir, $total_size=0)
 Get the size of the specified directory. More...
 
 elgg_save_resized_image ($source, $destination=null, array $params=[])
 Crops and resizes an image. More...
 
 delete_directory ($directory)
 Delete a directory and all its contents. More...
 
 elgg_get_file_simple_type ($mime_type)
 Returns the category of a file from its MIME type. More...
 
 _elgg_filestore_init ()
 Register file-related handlers on "init, system" event. More...
 
 _elgg_filestore_detect_mimetype ($hook, $type, $mime_type, $params)
 Fix MIME type detection for Microsoft zipped formats. More...
 
 _elgg_filestore_parse_simpletype ($hook, $type, $simple_type, $params)
 Parse a file category of file from a MIME type. More...
 
 _elgg_filestore_test ($hook, $type, $value)
 Unit tests for files. More...
 
 elgg_get_download_url (\ElggFile $file, $use_cookie=true, $expires= '+2 hours')
 Returns file's download URL. More...
 
 elgg_get_inline_url (\ElggFile $file, $use_cookie=false, $expires= '')
 Returns file's URL for inline display Suitable for displaying cacheable resources, such as user avatars. More...
 
 elgg_get_embed_url (\ElggEntity $entity, $size)
 Returns a URL suitable for embedding entity's icon in a text editor. More...
 
 _elgg_filestore_serve_icon_handler ()
 Handler for /serve-icon resources /serve-icon/<entity_guid>/<size> More...
 
 _elgg_filestore_touch_icons ($event, $type, $entity)
 Reset icon URLs if access_id has changed. More...
 
 _elgg_filestore_move_icons ($event, $type, $entity)
 Listen to entity ownership changes and update icon ownership by moving icons to their new owner's directory on filestore. More...
 
 elgg_get_uploaded_files ($input_name)
 Returns an array of uploaded file objects regardless of upload status/errors. More...
 
 elgg_get_uploaded_file ($input_name, $check_for_validity=true)
 Returns a single valid uploaded file object. More...
 
 elgg_get_temp_file ()
 Returns a ElggTempFile which can handle writing/reading of data to a temporary file location. More...
 

Variables

return function (\Elgg\EventsService $events,\Elgg\HooksRegistrationService $hooks)
 

Function Documentation

_elgg_filestore_detect_mimetype (   $hook,
  $type,
  $mime_type,
  $params 
)

Fix MIME type detection for Microsoft zipped formats.

Parameters
string$hook"mime_type"
string$type"file"
string$mime_typeDetected MIME type
array$paramsHook parameters
Returns
string The MIME type

Definition at line 165 of file filestore.php.

_elgg_filestore_init ( )

Register file-related handlers on "init, system" event.

Returns
void

Definition at line 134 of file filestore.php.

_elgg_filestore_move_icons (   $event,
  $type,
  $entity 
)

Listen to entity ownership changes and update icon ownership by moving icons to their new owner's directory on filestore.

This will only transfer icons that have a custom location on filestore and are owned by the entity's owner (instead of the entity itself). Even though core icon service does not store icons in the entity's owner directory, there are plugins that do (e.g. file plugin) - this handler helps such plugins avoid ownership mismatch.

Parameters
string$event"update:after"
string$type"object"|"group"
ElggObject$entityEntity
Returns
void

Definition at line 330 of file filestore.php.

_elgg_filestore_parse_simpletype (   $hook,
  $type,
  $simple_type,
  $params 
)

Parse a file category of file from a MIME type.

Parameters
string$hook"simple_type"
string$type"file"
string$simple_typeThe category of file
array$paramsHook parameters
Returns
string 'document', 'audio', 'video', or 'general' if the MIME type is unrecognized

Definition at line 184 of file filestore.php.

_elgg_filestore_serve_icon_handler ( )

Handler for /serve-icon resources /serve-icon/<entity_guid>/<size>

Returns
void

Definition at line 281 of file filestore.php.

_elgg_filestore_test (   $hook,
  $type,
  $value 
)

Unit tests for files.

Parameters
string$hook'unit_test'
string$type'system'
mixed$valueArray of tests
Returns
array

Definition at line 220 of file filestore.php.

_elgg_filestore_touch_icons (   $event,
  $type,
  $entity 
)

Reset icon URLs if access_id has changed.

Parameters
string$event"update:after"
string$type"object"|"group"
ElggObject$entityEntity
Returns
void

Definition at line 296 of file filestore.php.

delete_directory (   $directory)

Delete a directory and all its contents.

Parameters
string$directoryDirectory to delete
Returns
bool

Definition at line 77 of file filestore.php.

elgg_get_download_url ( \ElggFile  $file,
  $use_cookie = true,
  $expires = '+2 hours' 
)

Returns file's download URL.

Note
This does not work for files with custom filestores.
Parameters
\ElggFile$fileFile object or entity (must have the default filestore)
bool$use_cookieLimit URL validity to current session only
string$expiresURL expiration, as a string suitable for strtotime()
Returns
string

Definition at line 235 of file filestore.php.

elgg_get_embed_url ( \ElggEntity  $entity,
  $size 
)

Returns a URL suitable for embedding entity's icon in a text editor.

We can not use elgg_get_inline_url() for these purposes due to a URL structure bound to user session and file modification time. This function returns a generic (permanent) URL that will then be resolved to an inline URL whenever requested.

Parameters
\ElggEntity$entityEntity
string$sizeSize
Returns
string
Since
2.2

Definition at line 266 of file filestore.php.

elgg_get_file_simple_type (   $mime_type)

Returns the category of a file from its MIME type.

Parameters
string$mime_typeThe MIME type
Returns
string 'document', 'audio', 'video', or 'general' if the MIME type was unrecognized
Since
1.10

Definition at line 123 of file filestore.php.

elgg_get_inline_url ( \ElggFile  $file,
  $use_cookie = false,
  $expires = '' 
)

Returns file's URL for inline display Suitable for displaying cacheable resources, such as user avatars.

Note
This does not work for files with custom filestores.
Parameters
\ElggFile$fileFile object or entity (must have the default filestore)
bool$use_cookieLimit URL validity to current session only
string$expiresURL expiration, as a string suitable for strtotime()
Returns
string

Definition at line 250 of file filestore.php.

elgg_get_temp_file ( )

Returns a ElggTempFile which can handle writing/reading of data to a temporary file location.

Returns
ElggTempFile
Since
3.0

Definition at line 406 of file filestore.php.

elgg_get_uploaded_file (   $input_name,
  $check_for_validity = true 
)

Returns a single valid uploaded file object.

Parameters
string$input_nameForm input name
bool$check_for_validityIf there is an uploaded file, is it required to be valid
Returns
UploadedFile|false

Definition at line 396 of file filestore.php.

elgg_get_uploaded_files (   $input_name)

Returns an array of uploaded file objects regardless of upload status/errors.

Parameters
string$input_nameForm input name
Returns
UploadedFile[]

Definition at line 384 of file filestore.php.

elgg_save_resized_image (   $source,
  $destination = null,
array  $params = [] 
)

Crops and resizes an image.

Parameters
string$sourcePath to source image
string$destinationPath to destination If not set, will modify the source image
array$paramsAn array of cropping/resizing parameters
  • INT 'w' represents the width of the new image With upscaling disabled, this is the maximum width of the new image (in case the source image is smaller than the expected width)
  • INT 'h' represents the height of the new image With upscaling disabled, this is the maximum height
  • INT 'x1', 'y1', 'x2', 'y2' represent optional cropping coordinates. The source image will first be cropped to these coordinates, and then resized to match width/height parameters
  • BOOL 'square' - square images will fill the bounding box (width x height). In Imagine's terms, this equates to OUTBOUND mode
  • BOOL 'upscale' - if enabled, smaller images will be upscaled to fit the bounding box.
Returns
bool
Since
2.3

Definition at line 66 of file filestore.php.

get_dir_size (   $dir,
  $total_size = 0 
)

Get the size of the specified directory.

Parameters
string$dirThe full path of the directory
int$total_sizeAdd to current dir size
Returns
int The size of the directory in bytes

Definition at line 20 of file filestore.php.

Variable Documentation

See also
::loadCore Do not do work here. Just register for events.

Definition at line 413 of file filestore.php.