|
Moodle
2.2.1
http://www.collinsharper.com
|
Go to the source code of this file.
Data Structures | |
| class | curl |
| class | curl_cache |
| class | filetype_parser |
Namespaces | |
| namespace | core |
Enumerations | |
| enum | BYTESERVING_BOUNDARY |
Functions | |
| file_encode_url ($urlbase, $path, $forcedownload=false, $https=false) | |
| file_prepare_standard_editor ($data, $field, array $options, $context=null, $component=null, $filearea=null, $itemid=null) | |
| file_postupdate_standard_editor ($data, $field, array $options, $context, $component=null, $filearea=null, $itemid=null) | |
| file_prepare_standard_filemanager ($data, $field, array $options, $context=null, $component=null, $filearea=null, $itemid=null) | |
| file_postupdate_standard_filemanager ($data, $field, array $options, $context, $component, $filearea, $itemid) | |
| file_get_unused_draft_itemid () | |
| file_prepare_draft_area (&$draftitemid, $contextid, $component, $filearea, $itemid, array $options=null, $text=null) | |
| file_rewrite_pluginfile_urls ($text, $file, $contextid, $component, $filearea, $itemid, array $options=null) | |
| file_get_draft_area_info ($draftitemid) | |
| file_get_user_used_space () | |
| file_correct_filepath ($str) | |
| file_get_drafarea_folders ($draftitemid, $filepath, &$data) | |
| file_get_drafarea_files ($draftitemid, $filepath= '/') | |
| file_get_submitted_draft_itemid ($elname) | |
| file_save_draft_area_files ($draftitemid, $contextid, $component, $filearea, $itemid, array $options=null, $text=null, $forcehttps=false) | |
| file_rewrite_urls_to_pluginfile ($text, $draftitemid, $forcehttps=false) | |
| file_set_sortorder ($contextid, $component, $filearea, $itemid, $filepath, $filename, $sortorder) | |
| file_reset_sortorder ($contextid, $component, $filearea, $itemid=false) | |
| file_get_upload_error ($errorcode) | |
| format_array_postdata_for_curlcall ($arraydata, $currentdata, &$data) | |
| format_postdata_for_curlcall ($postdata) | |
| download_file_content ($url, $headers=null, $postdata=null, $fullresponse=false, $timeout=300, $connecttimeout=20, $skipcertverify=false, $tofile=NULL, $calctimeout=false) | |
| download_file_content_header_handler ($received, $ch, $header) | |
| download_file_content_write_handler ($received, $ch, $data) | |
| get_mimetypes_array () | |
| mimeinfo ($element, $filename) | |
| mimeinfo_from_type ($element, $mimetype) | |
| mimeinfo_from_icon ($element, $icon, $all=false) | |
| file_mimetype_icon ($mimetype, $size=NULL) | |
| file_extension_icon ($filename, $size=NULL) | |
| get_mimetype_description ($mimetype, $capitalise=false) | |
| send_file_not_found () | |
| send_temp_file ($path, $filename, $pathisstring=false) | |
| send_temp_file_finished ($path) | |
| send_file ($path, $filename, $lifetime= 'default', $filter=0, $pathisstring=false, $forcedownload=false, $mimetype='', $dontdie=false) | |
| send_stored_file ($stored_file, $lifetime=86400, $filter=0, $forcedownload=false, $filename=null, $dontdie=false) | |
| get_records_csv ($file, $table) | |
| put_records_csv ($file, $records, $table=NULL) | |
| fulldelete ($location) | |
| byteserving_send_file ($handle, $mimetype, $ranges, $filesize) | |
| file_modify_html_header ($text) | |
| file_pluginfile ($relativepath, $forcedownload) | |
| enum BYTESERVING_BOUNDARY |
Definition at line 30 of file filelib.php.
| byteserving_send_file | ( | $ | handle, |
| $ | mimetype, | ||
| $ | ranges, | ||
| $ | filesize | ||
| ) |
Send requested byterange of file.
| object | $handle | A file handle |
| string | $mimetype | The mimetype for the output |
| array | $ranges | An array of ranges to send |
| string | $filesize | The size of the content if only one range is used |
Definition at line 2279 of file filelib.php.

| download_file_content | ( | $ | url, |
| $ | headers = null, |
||
| $ | postdata = null, |
||
| $ | fullresponse = false, |
||
| $ | timeout = 300, |
||
| $ | connecttimeout = 20, |
||
| $ | skipcertverify = false, |
||
| $ | tofile = NULL, |
||
| $ | calctimeout = false |
||
| ) |
Fetches content of file from Internet (using proxy if defined). Uses cURL extension if present. Due to security concerns only downloads from http(s) sources are supported.
| string | $url | file url starting with http(s):// |
| array | $headers | http headers, null if none. If set, should be an associative array of header name => value pairs. |
| array | $postdata | array means use POST request with given parameters |
| bool | $fullresponse | return headers, responses, etc in a similar way snoopy does (if false, just returns content) |
| int | $timeout | timeout for complete download process including all file transfer (default 5 minutes) |
| int | $connecttimeout | timeout for connection to server; this is the timeout that usually happens if the remote server is completely down (default 20 seconds); may not work when using proxy |
| bool | $skipcertverify | If true, the peer's SSL certificate will not be checked. Only use this when already in a trusted location. |
| string | $tofile | store the downloaded content to file instead of returning it. |
| bool | $calctimeout | false by default, true enables an extra head request to try and determine filesize and appropriately larger timeout based on $CFG->curltimeoutkbitrate |
Definition at line 951 of file filelib.php.


| download_file_content_header_handler | ( | $ | received, |
| $ | ch, | ||
| $ | header | ||
| ) |
internal implementation
Definition at line 1164 of file filelib.php.
| download_file_content_write_handler | ( | $ | received, |
| $ | ch, | ||
| $ | data | ||
| ) |
internal implementation
Definition at line 1172 of file filelib.php.
| file_correct_filepath | ( | $ | str | ) |
Convert any string to a valid filepath
| string | $str |
Definition at line 479 of file filelib.php.

| file_encode_url | ( | $ | urlbase, |
| $ | path, | ||
| $ | forcedownload = false, |
||
| $ | https = false |
||
| ) |
Encodes file serving url
object
| string | $urlbase | |
| string | $path | /filearea/itemid/dir/dir/file.exe |
| bool | $forcedownload | |
| bool | $https | https url required |
Definition at line 49 of file filelib.php.

| file_extension_icon | ( | $ | filename, |
| $ | size = NULL |
||
| ) |
Returns the relative icon path for a given file name
This function should be used in conjunction with $OUTPUT->pix_url to produce a return the full path to an icon.
$filename = 'jpg'; $icon = $OUTPUT->pix_url(file_extension_icon($filename)); echo '
';
When an $OUTPUT->icon method is available this function should be altered to conform with that.
Implement $size
| string | filename The filename to get the icon for | |
| int | $size | The size of the icon. Defaults to null can also be 32 |
Definition at line 1528 of file filelib.php.


| file_get_drafarea_files | ( | $ | draftitemid, |
| $ | filepath = '/' |
||
| ) |
Listing all files (including folders) in current path (draft area) used by file manager
| int | $draftitemid | |
| string | $filepath |
Definition at line 525 of file filelib.php.


| file_get_drafarea_folders | ( | $ | draftitemid, |
| $ | filepath, | ||
| &$ | data | ||
| ) |
Generate a folder tree of draft area of current USER recursively
| int | $itemid | |
| string | $filepath | |
| mixed | $data | //TODO: use normal return value instead, this does not fit the rest of api here (skodak) |
Definition at line 493 of file filelib.php.

| file_get_draft_area_info | ( | $ | draftitemid | ) |
Returns information about files in a draft area.
object object
| integer | $draftitemid | the draft area item id. |
Definition at line 437 of file filelib.php.


| file_get_submitted_draft_itemid | ( | $ | elname | ) |
Returns draft area itemid for a given element.
| string | $elname | name of formlib editor element, or a hidden form field that stores the draft area item id, etc. |
Definition at line 593 of file filelib.php.


object object
Definition at line 305 of file filelib.php.


| file_get_upload_error | ( | $ | errorcode | ) |
Returns description of upload error
| int | $errorcode | found in $_FILES['filename.ext']['error'] |
Definition at line 843 of file filelib.php.
Get used space of files
Definition at line 460 of file filelib.php.

| file_mimetype_icon | ( | $ | mimetype, |
| $ | size = NULL |
||
| ) |
Returns the relative icon path for a given mime type
This function should be used in conjunction with $OUTPUT->pix_url to produce a return the full path to an icon.
$mimetype = 'image/jpg'; $icon = $OUTPUT->pix_url(file_mimetype_icon($mimetype)); echo '
';
| string | $mimetype | The mimetype to fetch an icon for |
| int | $size | The size of the icon. Not yet implemented |
Definition at line 1496 of file filelib.php.


| file_modify_html_header | ( | $ | text | ) |
add includes (js and css) into uploaded files before returning them, useful for themes and utf.js includes
object
| string | $text | text to search and replace |
Definition at line 2348 of file filelib.php.


| file_pluginfile | ( | $ | relativepath, |
| $ | forcedownload | ||
| ) |
| file_postupdate_standard_editor | ( | $ | data, |
| $ | field, | ||
| array $ | options, | ||
| $ | context, | ||
| $ | component = null, |
||
| $ | filearea = null, |
||
| $ | itemid = null |
||
| ) |
Prepares the content of the 'editor' form element with embedded media files to be saved in database
This function moves files from draft area to the destination area and encodes URLs to the draft files so they can be safely saved into DB. The form has to contain the 'editor' element named foobar_editor, where 'foobar' is the name of the database field to hold the wysiwyg editor content. The editor data comes as an array with text, format and itemid properties. This function automatically adds $data properties foobar, foobarformat and foobartrust, where foobar has URL to embedded files encoded.
| object | $data | raw data submitted by the form |
| string | $field | name of the database field containing the html with embedded media files |
| array | $options | editor options (trusttext, subdirs, maxfiles, maxbytes etc.) |
| object | $context | context, required for existing data |
| string | component | |
| string | $filearea | file area name |
| int | $itemid | item id, required if item exists |
Definition at line 190 of file filelib.php.


| file_postupdate_standard_filemanager | ( | $ | data, |
| $ | field, | ||
| array $ | options, | ||
| $ | context, | ||
| $ | component, | ||
| $ | filearea, | ||
| $ | itemid | ||
| ) |
Saves files modified by File manager formslib element
| object | $data | $database entry field |
| string | $field | name of data field |
| array | $options | various options |
| object | $context | context - must already exist |
| string | $component | |
| string | $filearea | file area name |
| int | $itemid | must already exist, usually means data is in db |
Definition at line 269 of file filelib.php.

| file_prepare_draft_area | ( | &$ | draftitemid, |
| $ | contextid, | ||
| $ | component, | ||
| $ | filearea, | ||
| $ | itemid, | ||
| array $ | options = null, |
||
| $ | text = null |
||
| ) |
Initialise a draft file area from a real one by copying the files. A draft area will be created if one does not already exist. Normally you should get $draftitemid by calling file_get_submitted_draft_itemid('elementname');
object object
| int | &$draftitemid | the id of the draft area to use, or 0 to create a new one, in which case this parameter is updated. |
| integer | $contextid | This parameter and the next two identify the file area to copy files from. |
| string | $component | |
| string | $filearea | helps indentify the file area. |
| integer | $itemid | helps identify the file area. Can be null if there are no files yet. |
| array | $options | text and file options ('subdirs'=>false, 'forcehttps'=>false) |
| string | $text | some html content that needs to have embedded links rewritten to point to the draft area. |
Definition at line 340 of file filelib.php.


| file_prepare_standard_editor | ( | $ | data, |
| $ | field, | ||
| array $ | options, | ||
| $ | context = null, |
||
| $ | component = null, |
||
| $ | filearea = null, |
||
| $ | itemid = null |
||
| ) |
Prepares 'editor' formslib element from data in database
The passed $data record must contain field foobar, foobarformat and optionally foobartrust. This function then copies the embedded files into draft area (assigning itemids automatically), creates the form element foobar_editor and rewrites the URLs so the embedded images can be displayed. In your mform definition, you must have an 'editor' element called foobar_editor. Then you call your mform's set_data() supplying the object returned by this function.
| object | $data | database field that holds the html text with embedded media |
| string | $field | the name of the database field that holds the html text with embedded media |
| array | $options | editor options (like maxifiles, maxbytes etc.) |
| object | $context | context of the editor |
| string | $component | |
| string | $filearea | file area name |
| int | $itemid | item id, required if item exists |
Definition at line 96 of file filelib.php.


| file_prepare_standard_filemanager | ( | $ | data, |
| $ | field, | ||
| array $ | options, | ||
| $ | context = null, |
||
| $ | component = null, |
||
| $ | filearea = null, |
||
| $ | itemid = null |
||
| ) |
Saves text and files modified by Editor formslib element
| object | $data | $database entry field |
| string | $field | name of data field |
| array | $options | various options |
| object | $context | context - must already exist |
| string | $component | |
| string | $filearea | file area name |
| int | $itemid | must already exist, usually means data is in db |
Definition at line 238 of file filelib.php.


| file_reset_sortorder | ( | $ | contextid, |
| $ | component, | ||
| $ | filearea, | ||
| $ | itemid = false |
||
| ) |
reset file sort order number to 0 object $DB
| integer | $contextid | the context id |
| string | $component | |
| string | $filearea | file area. |
| integer | $itemid | itemid. |
Definition at line 821 of file filelib.php.
| file_rewrite_pluginfile_urls | ( | $ | text, |
| $ | file, | ||
| $ | contextid, | ||
| $ | component, | ||
| $ | filearea, | ||
| $ | itemid, | ||
| array $ | options = null |
||
| ) |
Convert encoded URLs in $text from the @PLUGINFILE@/... form to an actual URL.
object
| string | $text | The content that may contain ULRs in need of rewriting. |
| string | $file | The script that should be used to serve these files. pluginfile.php, draftfile.php, etc. |
| integer | $contextid | This parameter and the next two identify the file area to use. |
| string | $component | |
| string | $filearea | helps identify the file area. |
| integer | $itemid | helps identify the file area. |
| array | $options | text and file options ('forcehttps'=>false) |
Definition at line 402 of file filelib.php.

| file_rewrite_urls_to_pluginfile | ( | $ | text, |
| $ | draftitemid, | ||
| $ | forcehttps = false |
||
| ) |
Convert the draft file area URLs in some content to @PLUGINFILE@ tokens ready to be saved in the database. Normally, this is done automatically by file_save_draft_area_files().
| string | $text | the content to process. |
| int | $draftitemid | the draft file area the content was using. |
| bool | $forcehttps | whether the content contains https URLs. Default false. |
Definition at line 760 of file filelib.php.


| file_save_draft_area_files | ( | $ | draftitemid, |
| $ | contextid, | ||
| $ | component, | ||
| $ | filearea, | ||
| $ | itemid, | ||
| array $ | options = null, |
||
| $ | text = null, |
||
| $ | forcehttps = false |
||
| ) |
Saves files from a draft file area to a real one (merging the list of files). Can rewrite URLs in some content at the same time if desired.
object object
| integer | $draftitemid | the id of the draft area to use. Normally obtained from file_get_submitted_draft_itemid('elementname') or similar. |
| integer | $contextid | This parameter and the next two identify the file area to save to. |
| string | $component | |
| string | $filearea | indentifies the file area. |
| integer | $itemid | helps identifies the file area. |
| array | $options | area options (subdirs=>false, maxfiles=-1, maxbytes=0) |
| string | $text | some html content that needs to have embedded links rewritten to the @PLUGINFILE@ form for saving in the database. |
| boolean | $forcehttps | force https urls. |
Definition at line 636 of file filelib.php.


| file_set_sortorder | ( | $ | contextid, |
| $ | component, | ||
| $ | filearea, | ||
| $ | itemid, | ||
| $ | filepath, | ||
| $ | filename, | ||
| $ | sortorder | ||
| ) |
Set file sort order object $DB
| integer | $contextid | the context id |
| string | $component | |
| string | $filearea | file area. |
| integer | $itemid | itemid. |
| string | $filepath | file path. |
| string | $filename | file name. |
| integer | $sortorer | the sort order of file. |
Definition at line 800 of file filelib.php.

| format_array_postdata_for_curlcall | ( | $ | arraydata, |
| $ | currentdata, | ||
| &$ | data | ||
| ) |
Recursive function formating an array in POST parameter
| array | $arraydata | - the array that we are going to format and add into &$data array |
| string | $currentdata | - a row of the final postdata array at instant T when finish, it's assign to $data under this format: name[keyname][][]...[]='value' |
| array | $data | - the final data array containing all POST parameters : 1 row = 1 parameter |
Definition at line 894 of file filelib.php.

| format_postdata_for_curlcall | ( | $ | postdata | ) |
Transform a PHP array into POST parameter (see the recursive function format_array_postdata_for_curlcall)
| array | $postdata |
Definition at line 912 of file filelib.php.


| fulldelete | ( | $ | location | ) |
Recursively delete the file or folder with path $location. That is, if it is a file delete it. If it is a folder, delete all its content then delete it. If $location does not exist to start, that is not considered an error.
| string | $location | the path to remove. |
Definition at line 2237 of file filelib.php.

| get_mimetype_description | ( | $ | mimetype, |
| $ | capitalise = false |
||
| ) |
Obtains descriptions for file types (e.g. 'Microsoft Word document') from the mimetypes.php language file.
| string | $mimetype | MIME type (can be obtained using the mimeinfo function) |
| bool | $capitalise | If true, capitalises first character of result |
Definition at line 1548 of file filelib.php.

Definition at line 1193 of file filelib.php.

| get_records_csv | ( | $ | file, |
| $ | table | ||
| ) |
Retrieves an array of records from a CSV file and places them into a given table structure
object object
| string | $file | The path to a CSV file |
| string | $table | The table to retrieve columns from |
Definition at line 2119 of file filelib.php.

| mimeinfo | ( | $ | element, |
| $ | filename | ||
| ) |
Obtains information about a filetype based on its extension. Will use a default if no information is present about that particular extension.
| string | $element | Desired information (usually 'icon' for icon filename or 'type' for MIME type) |
| string | $filename | Filename we're looking up |
Definition at line 1380 of file filelib.php.


| mimeinfo_from_icon | ( | $ | element, |
| $ | icon, | ||
| $ | all = false |
||
| ) |
Get information about a filetype based on the icon file.
| string | $element | Desired information (usually 'icon') |
| string | $icon | Icon file name without extension |
| boolean | $all | return all matching entries (defaults to false - best (by ext)/last match) |
Definition at line 1442 of file filelib.php.


| mimeinfo_from_type | ( | $ | element, |
| $ | mimetype | ||
| ) |
Obtains information about a filetype based on the MIME type rather than the other way around.
| string | $element | Desired information (usually 'icon') |
| string | $mimetype | MIME type we're looking up |
Definition at line 1420 of file filelib.php.


| put_records_csv | ( | $ | file, |
| $ | records, | ||
| $ | table = NULL |
||
| ) |
object object
| string | $file | The file to put the CSV content into |
| array | $records | An array of records to write to a CSV file |
| string | $table | The table to get columns from |
Definition at line 2168 of file filelib.php.

| send_file | ( | $ | path, |
| $ | filename, | ||
| $ | lifetime = 'default', |
||
| $ | filter = 0, |
||
| $ | pathisstring = false, |
||
| $ | forcedownload = false, |
||
| $ | mimetype = '', |
||
| $ | dontdie = false |
||
| ) |
Handles the sending of file data to the user's browser, including support for byteranges etc.
object object object
| string | $path | Path of file on disk (including real filename), or actual content of file as string |
| string | $filename | Filename to send |
| int | $lifetime | Number of seconds before the file should expire from caches (default 24 hours) |
| int | $filter | 0 (default)=no filtering, 1=all files, 2=html files only |
| bool | $pathisstring | If true (default false), $path is the content to send and not the pathname |
| bool | $forcedownload | If true (default false), forces download of file rather than view in browser/plugin |
| string | $mimetype | Include to specify the MIME type; leave blank to have it guess the type from $filename |
| bool | $dontdie | - return control to caller afterwards. this is not recommended and only used for cleanup tasks. if this is passed as true, ignore_user_abort is called. if you don't want your processing to continue on cancel, you must detect this case when control is returned using connection_aborted. Please not that session is closed and should not be reopened. |
Do not byteserve (disabled, strings, text and html files).
Definition at line 1694 of file filelib.php.


Requested file is not found or not accessible
Definition at line 1565 of file filelib.php.


| send_stored_file | ( | $ | stored_file, |
| $ | lifetime = 86400, |
||
| $ | filter = 0, |
||
| $ | forcedownload = false, |
||
| $ | filename = null, |
||
| $ | dontdie = false |
||
| ) |
Handles the sending of file data to the user's browser, including support for byteranges etc.
object object object
| object | $stored_file | local file object |
| int | $lifetime | Number of seconds before the file should expire from caches (default 24 hours) |
| int | $filter | 0 (default)=no filtering, 1=all files, 2=html files only |
| bool | $forcedownload | If true (default false), forces download of file rather than view in browser/plugin |
| string | $filename | Override filename |
| bool | $dontdie | - return control to caller afterwards. this is not recommended and only used for cleanup tasks. if this is passed as true, ignore_user_abort is called. if you don't want your processing to continue on cancel, you must detect this case when control is returned using connection_aborted. Please not that session is closed and should not be reopened. |
Do not byteserve (disabled, strings, text and html files).
Definition at line 1924 of file filelib.php.


| send_temp_file | ( | $ | path, |
| $ | filename, | ||
| $ | pathisstring = false |
||
| ) |
Handles the sending of temporary file to user, download is forced. File is deleted after abort or successful sending.
| string | $path | path to file, preferably from moodledata/temp/something; or content of file itself |
| string | $filename | proposed file name when saving file |
| bool | $path | is content of file |
Definition at line 1616 of file filelib.php.


| send_temp_file_finished | ( | $ | path | ) |
Internal callback function used by send_temp_file()
Definition at line 1668 of file filelib.php.