|
Moodle
2.2.1
http://www.collinsharper.com
|
Public Member Functions | |
| __construct ($filedir, $trashdir, $tempdir, $dirpermissions, $filepermissions) | |
| file_exists ($contextid, $component, $filearea, $itemid, $filepath, $filename) | |
| file_exists_by_hash ($pathnamehash) | |
| get_file_instance (stdClass $file_record) | |
| get_file_by_id ($fileid) | |
| get_file_by_hash ($pathnamehash) | |
| get_file ($contextid, $component, $filearea, $itemid, $filepath, $filename) | |
| is_area_empty ($contextid, $component, $filearea, $itemid=false, $ignoredirs=true) | |
| get_area_files ($contextid, $component, $filearea, $itemid=false, $sort="sortorder, itemid, filepath, filename", $includedirs=true) | |
| get_area_tree ($contextid, $component, $filearea, $itemid) | |
| get_directory_files ($contextid, $component, $filearea, $itemid, $filepath, $recursive=false, $includedirs=true, $sort="filepath, filename") | |
| delete_area_files ($contextid, $component=false, $filearea=false, $itemid=false) | |
| delete_area_files_select ($contextid, $component, $filearea, $itemidstest, array $params=null) | |
| move_area_files_to_new_context ($oldcontextid, $newcontextid, $component, $filearea, $itemid=false) | |
| create_directory ($contextid, $component, $filearea, $itemid, $filepath, $userid=null) | |
| create_file_from_storedfile ($file_record, $fileorid) | |
| create_file_from_url ($file_record, $url, array $options=NULL, $usetempfile=false) | |
| create_file_from_pathname ($file_record, $pathname) | |
| create_file_from_string ($file_record, $content) | |
| convert_image ($file_record, $fid, $newwidth=NULL, $newheight=NULL, $keepaspectratio=true, $quality=NULL) | |
| add_file_to_pool ($pathname, $contenthash=NULL) | |
| add_string_to_pool ($content) | |
| try_content_recovery ($file) | |
| deleted_file_cleanup ($contenthash) | |
| cron () | |
Static Public Member Functions | |
| static | get_pathname_hash ($contextid, $component, $filearea, $itemid, $filepath, $filename) |
Protected Member Functions | |
| path_from_hash ($contenthash) | |
| trash_path_from_hash ($contenthash) | |
File storage class used for low level access to stored files.
Only owner of file area may use this class to access own files, for example only code in mod/assignment/* may access assignment attachments. When some other part of moodle needs to access files of modules it has to use file_browser class instead or there has to be some callback API.
Definition at line 45 of file file_storage.php.
| __construct | ( | $ | filedir, |
| $ | trashdir, | ||
| $ | tempdir, | ||
| $ | dirpermissions, | ||
| $ | filepermissions | ||
| ) |
Constructor - do not use directly use
| string | $filedir | full path to pool directory |
| string | $trashdir | temporary storage of deleted area |
| string | $tempdir | temporary storage of various files |
| int | $dirpermissions | new directory permissions |
| int | $filepermissions | new file permissions |
Definition at line 66 of file file_storage.php.

| add_file_to_pool | ( | $ | pathname, |
| $ | contenthash = NULL |
||
| ) |
Add file content to sha1 pool.
| string | $pathname | path to file |
| string | $contenthash | sha1 hash of content if known (performance only) |
Definition at line 1104 of file file_storage.php.


| add_string_to_pool | ( | $ | content | ) |
Add string content to sha1 pool.
| string | $content | file content - binary string |
Definition at line 1153 of file file_storage.php.


| convert_image | ( | $ | file_record, |
| $ | fid, | ||
| $ | newwidth = NULL, |
||
| $ | newheight = NULL, |
||
| $ | keepaspectratio = true, |
||
| $ | quality = NULL |
||
| ) |
Creates new image file from existing.
| mixed | $file_record | object or array describing new file |
| mixed | file id or stored file object | |
| int | $newwidth | in pixels |
| int | $newheight | in pixels |
| bool | $keepaspectratio | |
| int | $quality | depending on image type 0-100 for jpeg, 0-9 (0 means no compression) for png |
Definition at line 989 of file file_storage.php.

| create_directory | ( | $ | contextid, |
| $ | component, | ||
| $ | filearea, | ||
| $ | itemid, | ||
| $ | filepath, | ||
| $ | userid = null |
||
| ) |
Recursively creates directory.
| int | $contextid | |
| string | $component | |
| string | $filearea | |
| int | $itemid | |
| string | $filepath | |
| string | $filename |
Definition at line 514 of file file_storage.php.


| create_file_from_pathname | ( | $ | file_record, |
| $ | pathname | ||
| ) |
Add new local file.
| mixed | $file_record | object or array describing file |
| string | $path | path to file or content of file |
Definition at line 757 of file file_storage.php.


| create_file_from_storedfile | ( | $ | file_record, |
| $ | fileorid | ||
| ) |
Add new local file based on existing local file.
| mixed | $file_record | object or array describing changes |
| mixed | $fileorid | id or stored_file instance of the existing local file |
Definition at line 596 of file file_storage.php.


| create_file_from_string | ( | $ | file_record, |
| $ | content | ||
| ) |
Add new local file.
| mixed | $file_record | object or array describing file |
| string | $content | content of file |
Definition at line 871 of file file_storage.php.


| create_file_from_url | ( | $ | file_record, |
| $ | url, | ||
| array $ | options = NULL, |
||
| $ | usetempfile = false |
||
| ) |
Add new local file.
| mixed | $file_record | object or array describing file |
| string | $path | path to file or content of file |
| array | $options |
| bool | $usetempfile | use temporary file for download, may prevent out of memory problems |
Definition at line 704 of file file_storage.php.

| cron | ( | ) |
Cron cleanup job.
Definition at line 1291 of file file_storage.php.

| delete_area_files | ( | $ | contextid, |
| $ | component = false, |
||
| $ | filearea = false, |
||
| $ | itemid = false |
||
| ) |
Delete all area files (optionally limited by itemid).
| int | $contextid | |
| string | $component | |
| string | $filearea | (all areas in context if not specified) |
| int | $itemid | (all files if not specified) |
Definition at line 421 of file file_storage.php.


| delete_area_files_select | ( | $ | contextid, |
| $ | component, | ||
| $ | filearea, | ||
| $ | itemidstest, | ||
| array $ | params = null |
||
| ) |
Delete all the files from certain areas where itemid is limited by an arbitrary bit of SQL.
| int | $contextid | the id of the context the files belong to. Must be given. |
| string | $component | the owning component. Must be given. |
| string | $filearea | the file area name. Must be given. |
| string | $itemidstest | an SQL fragment that the itemid must match. Used in the query like WHERE itemid $itemidstest. Must used named parameters, and may not used named parameters called contextid, component or filearea. |
| array | $params | any query params used by $itemidstest. |
Definition at line 455 of file file_storage.php.

| deleted_file_cleanup | ( | $ | contenthash | ) |
Marks pool file as candidate for deleting.
DO NOT call directly - reserved for core!!
| string | $contenthash |
Definition at line 1257 of file file_storage.php.


| file_exists | ( | $ | contextid, |
| $ | component, | ||
| $ | filearea, | ||
| $ | itemid, | ||
| $ | filepath, | ||
| $ | filename | ||
| ) |
Does this file exist?
| int | $contextid | |
| string | $component | |
| string | $filearea | |
| int | $itemid | |
| string | $filepath | |
| string | $filename |
Definition at line 121 of file file_storage.php.


| file_exists_by_hash | ( | $ | pathnamehash | ) |
Does this file exist?
| string | $pathnamehash |
Definition at line 139 of file file_storage.php.

| get_area_files | ( | $ | contextid, |
| $ | component, | ||
| $ | filearea, | ||
| $ | itemid = false, |
||
| $ | sort = "sortorder, itemid, filepath, filename", |
||
| $ | includedirs = true |
||
| ) |
Returns all area files (optionally limited by itemid)
| int | $contextid | |
| string | $component | |
| string | $filearea | |
| int | $itemid | (all files if not specified) |
| string | $sort | |
| bool | $includedirs |
Definition at line 257 of file file_storage.php.


| get_area_tree | ( | $ | contextid, |
| $ | component, | ||
| $ | filearea, | ||
| $ | itemid | ||
| ) |
Returns array based tree structure of area files
| int | $contextid | |
| string | $component | |
| string | $filearea | |
| int | $itemid |
Definition at line 285 of file file_storage.php.

| get_directory_files | ( | $ | contextid, |
| $ | component, | ||
| $ | filearea, | ||
| $ | itemid, | ||
| $ | filepath, | ||
| $ | recursive = false, |
||
| $ | includedirs = true, |
||
| $ | sort = "filepath, filename" |
||
| ) |
Returns all files and optionally directories
| int | $contextid | |
| string | $component | |
| string | $filearea | |
| int | $itemid | |
| int | $filepath | directory path |
| bool | $recursive | include all subdirectories |
| bool | $includedirs | include files and directories |
| string | $sort |
Definition at line 340 of file file_storage.php.

| get_file | ( | $ | contextid, |
| $ | component, | ||
| $ | filearea, | ||
| $ | itemid, | ||
| $ | filepath, | ||
| $ | filename | ||
| ) |
Fetch locally stored file.
| int | $contextid | |
| string | $component | |
| string | $filearea | |
| int | $itemid | |
| string | $filepath | |
| string | $filename |
Definition at line 201 of file file_storage.php.


| get_file_by_hash | ( | $ | pathnamehash | ) |
Fetch file using local file full pathname hash
| string | $pathnamehash |
Definition at line 180 of file file_storage.php.


| get_file_by_id | ( | $ | fileid | ) |
Fetch file using local file id.
Please do not rely on file ids, it is usually easier to use pathname hashes instead.
| int | $fileid |
Definition at line 164 of file file_storage.php.


| get_file_instance | ( | stdClass $ | file_record | ) |
Create instance of file class from database record.
| stdClass | $file_record | record from the files table |
Definition at line 151 of file file_storage.php.

| static get_pathname_hash | ( | $ | contextid, |
| $ | component, | ||
| $ | filearea, | ||
| $ | itemid, | ||
| $ | filepath, | ||
| $ | filename | ||
| ) | [static] |
Calculates sha1 hash of unique full path name information.
This hash is a unique file identifier - it is used to improve performance and overcome db index size limits.
| int | $contextid | |
| string | $component | |
| string | $filearea | |
| int | $itemid | |
| string | $filepath | |
| string | $filename |
Definition at line 106 of file file_storage.php.

| is_area_empty | ( | $ | contextid, |
| $ | component, | ||
| $ | filearea, | ||
| $ | itemid = false, |
||
| $ | ignoredirs = true |
||
| ) |
Are there any files (or directories)
| int | $contextid | |
| string | $component | |
| string | $filearea | |
| bool | int | $itemid | tem id or false if all items |
| bool | $ignoredirs |
Definition at line 222 of file file_storage.php.
| move_area_files_to_new_context | ( | $ | oldcontextid, |
| $ | newcontextid, | ||
| $ | component, | ||
| $ | filearea, | ||
| $ | itemid = false |
||
| ) |
Move all the files in a file area from one context to another.
| integer | $oldcontextid | the context the files are being moved from. |
| integer | $newcontextid | the context the files are being moved to. |
| string | $component | the plugin that these files belong to. |
| string | $filearea | the name of the file area. |
Definition at line 482 of file file_storage.php.

| path_from_hash | ( | $ | contenthash | ) | [protected] |
Return path to file with given hash.
NOTE: must not be public, files in pool must not be modified
| string | $contenthash |
Definition at line 1195 of file file_storage.php.

| trash_path_from_hash | ( | $ | contenthash | ) | [protected] |
Return path to file with given hash.
NOTE: must not be public, files in pool must not be modified
| string | $contenthash |
Definition at line 1209 of file file_storage.php.

| try_content_recovery | ( | $ | file | ) |
Tries to recover missing content of file from trash.
| object | $file_record |
Definition at line 1221 of file file_storage.php.
