|
Moodle
2.2.1
http://www.collinsharper.com
|
Public Member Functions | |
| __construct (file_storage $fs, stdClass $file_record, $filedir) | |
| is_directory () | |
| delete () | |
| add_to_curl_request (&$curlrequest, $key) | |
| get_content_file_handle () | |
| readfile () | |
| get_content () | |
| copy_content_to ($pathname) | |
| list_files (file_packer $packer) | |
| extract_to_pathname (file_packer $packer, $pathname) | |
| extract_to_storage (file_packer $packer, $contextid, $component, $filearea, $itemid, $pathbase, $userid=NULL) | |
| archive_file (file_archive $filearch, $archivepath) | |
| get_imageinfo () | |
| is_valid_image () | |
| get_parent_directory () | |
| get_contextid () | |
| get_component () | |
| get_filearea () | |
| get_itemid () | |
| get_filepath () | |
| get_filename () | |
| get_userid () | |
| get_filesize () | |
| get_mimetype () | |
| get_timecreated () | |
| get_timemodified () | |
| get_status () | |
| get_id () | |
| get_contenthash () | |
| get_pathnamehash () | |
| get_license () | |
| get_author () | |
| get_source () | |
| get_sortorder () | |
Protected Member Functions | |
| get_content_file_location () | |
Class representing local files stored in a sha1 file pool.
Since Moodle 2.0 file contents are stored in sha1 pool and all other file information is stored in new "files" database table.
Definition at line 42 of file stored_file.php.
| __construct | ( | file_storage $ | fs, |
| stdClass $ | file_record, | ||
| $ | filedir | ||
| ) |
Constructor, this constructor should be called ONLY from the file_storage class!
| file_storage | $fs | file storage instance |
| object | $file_record | description of file |
| string | $filepool | location of file directory with sh1 named content files |
Definition at line 57 of file stored_file.php.
| add_to_curl_request | ( | &$ | curlrequest, |
| $ | key | ||
| ) |
adds this file path to a curl request (POST only)
| curl | $curlrequest | the curl request object |
| string | $key | what key to use in the POST request |
Definition at line 113 of file stored_file.php.

| archive_file | ( | file_archive $ | filearch, |
| $ | archivepath | ||
| ) |
Add file/directory into archive.
| file_archive | $filearch | |
| string | $archivepath | pathname in archive |
Definition at line 227 of file stored_file.php.

| copy_content_to | ( | $ | pathname | ) |
Copy content of file to given pathname.
| string | $pathname | real path to the new file |
Definition at line 170 of file stored_file.php.

| delete | ( | ) |
Delete file from files table.
The content of files stored in sha1 pool is reclaimed later - the occupied disk space is reclaimed much later.
Definition at line 84 of file stored_file.php.
| extract_to_pathname | ( | file_packer $ | packer, |
| $ | pathname | ||
| ) |
Extract file to given file path (real OS filesystem), existing files are overwritten.
| file_packer | $file_packer | |
| string | $pathname | target directory |
Definition at line 198 of file stored_file.php.

| extract_to_storage | ( | file_packer $ | packer, |
| $ | contextid, | ||
| $ | component, | ||
| $ | filearea, | ||
| $ | itemid, | ||
| $ | pathbase, | ||
| $ | userid = NULL |
||
| ) |
Extract file to given file path (real OS filesystem), existing files are overwritten.
| file_packer | $file_packer | |
| int | $contextid | |
| string | $component | |
| string | $filearea | |
| int | $itemid | |
| string | $pathbase | |
| int | $userid |
Definition at line 215 of file stored_file.php.

| get_author | ( | ) |
| get_component | ( | ) |
Returns component name - this is the owner of the areas, nothing else is allowed to read or modify the files directly!!
Definition at line 318 of file stored_file.php.

| get_content | ( | ) |
Returns file content as string.
Definition at line 154 of file stored_file.php.

Returns file handle - read only mode, no writing allowed into pool files!
When you want to modify a file, create a new file and delete the old one.
Definition at line 124 of file stored_file.php.

| get_content_file_location | ( | ) | [protected] |
Protected - developers must not gain direct access to this function.
NOTE: do not make this public, we must not modify or delete the pool files directly! ;-)
Definition at line 99 of file stored_file.php.

| get_contenthash | ( | ) |
| get_contextid | ( | ) |
Returns context id of the file-
Definition at line 308 of file stored_file.php.

| get_filearea | ( | ) |
Returns file area name, this divides files of one component into groups with different access control. All files in one area have the same access control.
Definition at line 328 of file stored_file.php.

| get_filename | ( | ) |
Returns file name or '.' in case of directories.
Definition at line 355 of file stored_file.php.

| get_filepath | ( | ) |
Returns file path - starts and ends with /, \ are not allowed.
Definition at line 346 of file stored_file.php.

| get_filesize | ( | ) |
Returns the size of file in bytes.
Definition at line 373 of file stored_file.php.
| get_id | ( | ) |
Returns file id.
Definition at line 418 of file stored_file.php.

| get_imageinfo | ( | ) |
Returns information about image, information is determined from the file content
Definition at line 244 of file stored_file.php.


| get_itemid | ( | ) |
Returns returns item id of file.
Definition at line 337 of file stored_file.php.

| get_license | ( | ) |
Returns the license type of the file, it is a short name referred from license table.
Definition at line 445 of file stored_file.php.
| get_mimetype | ( | ) |
Returns mime type of file.
Definition at line 382 of file stored_file.php.

Returns parent directory, creates missing parents if needed.
Definition at line 283 of file stored_file.php.
| get_pathnamehash | ( | ) |
Returns sha1 hash of all file path components sha1("contextid/component/filearea/itemid/dir/dir/filename.ext").
Definition at line 436 of file stored_file.php.
| get_sortorder | ( | ) |
| get_source | ( | ) |
Returns the source of the file, usually it is a url.
Definition at line 463 of file stored_file.php.
| get_status | ( | ) |
Returns file status flag.
Definition at line 409 of file stored_file.php.
| get_timecreated | ( | ) |
Returns unix timestamp of file creation date.
Definition at line 391 of file stored_file.php.
| get_timemodified | ( | ) |
Returns unix timestamp of last file modification.
Definition at line 400 of file stored_file.php.
| get_userid | ( | ) |
Returns id of user who created the file.
Definition at line 364 of file stored_file.php.
| is_directory | ( | ) |
Is this a directory?
Directories are only emulated, internally they are stored as empty files with a "." instead of name - this means empty directory contains exactly one empty file with name dot.
Definition at line 72 of file stored_file.php.

| is_valid_image | ( | ) |
Verifies the file is a valid web image - gif, png and jpeg only.
It should be ok to serve this image from server without any other security workarounds.
Definition at line 263 of file stored_file.php.

| list_files | ( | file_packer $ | packer | ) |
List contents of archive.
| file_packer | $file_packer |
Definition at line 186 of file stored_file.php.

| readfile | ( | ) |
Dumps file content to page.
Definition at line 139 of file stored_file.php.
