Moodle APIs
3.8
Moodle 3.8.6 (Build: 20201109)
|
Represents a course context in the tree navigated by file_browser. More...
Public Member Functions | |
__construct ($browser, $context, $course) | |
Constructor. More... | |
copy_to_pathname ($pathname) | |
Copy content of this file to local storage, overriding current file if needed. More... | |
copy_to_storage ($filerecord) | |
Copy content of this file to local storage, overriding current file if needed. More... | |
count_non_empty_children ($extensions=' *', $limit=1) | |
Returns the number of children which are either files matching the specified extensions or folders containing at least one such file. More... | |
create_directory ($newdirname, $userid=NULL) | |
Create new directory, may throw exception - make sure params are valid. More... | |
create_file_from_pathname ($newfilename, $pathname, $userid=NULL) | |
Create new file from pathname - make sure params are valid. More... | |
create_file_from_storedfile ($newfilename, $fid, $userid=NULL) | |
Create new file from stored file - make sure params are valid. More... | |
create_file_from_string ($newfilename, $content, $userid=NULL) | |
Create new file from string - make sure params are valid. More... | |
delete () | |
Delete file, make sure file is deletable first. More... | |
get_author () | |
Returns the author name of the file. More... | |
get_children () | |
Returns list of children. More... | |
get_file_info ($component, $filearea, $itemid, $filepath, $filename) | |
Return information about this specific context level. More... | |
get_filesize () | |
Returns file size in bytes, null for directories. More... | |
get_license () | |
Returns the license type of the file. More... | |
get_mimetype () | |
Returns mimetype. More... | |
get_non_empty_children ($extensions=' *') | |
Returns list of children which are either files matching the specified extensions or folders that contain at least one such file. More... | |
get_params () | |
Returns list of standard virtual file/directory identification. More... | |
get_params_rawencoded () | |
Returns array of url encoded params. More... | |
get_parent () | |
Returns parent file_info instance. More... | |
get_readable_fullname () | |
Returns the localised human-readable name of the file together with virtual path. More... | |
get_sortorder () | |
Returns the sort order of the file. More... | |
get_source () | |
Returns the source of the file. More... | |
get_status () | |
Returns file status flag. More... | |
get_timecreated () | |
Returns time created unix timestamp if known. More... | |
get_timemodified () | |
Returns time modified unix timestamp if known. More... | |
get_url ($forcedownload=false, $https=false) | |
Returns file download url. More... | |
get_visible_name () | |
Returns localised visible name. More... | |
is_directory () | |
Whether or not this is a directory. More... | |
is_empty_area () | |
Is this info area and is it "empty"? Are there any files in subfolders? More... | |
is_external_file () | |
Whether or not this is a external resource. More... | |
is_readable () | |
Whether or not I can read content of this file or enter directory. More... | |
is_writable () | |
Whether or not new files or directories can be added. More... | |
Protected Member Functions | |
build_search_files_sql ($extensions, $prefix=null) | |
Builds SQL sub query (WHERE clause) for selecting files with the specified extensions. More... | |
get_area_backup_automated ($itemid, $filepath, $filename) | |
Gets a stored file for the automated backup filearea directory. More... | |
get_area_backup_course ($itemid, $filepath, $filename) | |
Gets a stored file for the backup course filearea directory. More... | |
get_area_backup_section ($itemid, $filepath, $filename) | |
Gets a stored file for the backup section filearea directory. More... | |
get_area_course_legacy ($itemid, $filepath, $filename) | |
Gets a stored file for the course legacy filearea directory. More... | |
get_area_course_overviewfiles ($itemid, $filepath, $filename) | |
Gets a stored file for the course images filearea directory. More... | |
get_area_course_section ($itemid, $filepath, $filename) | |
Gets a stored file for the course section filearea directory. More... | |
get_area_course_summary ($itemid, $filepath, $filename) | |
Gets a stored file for the course summary filearea directory. More... | |
get_child_module ($cm) | |
Returns the child module if it is accessible by the current user. More... | |
get_course_areas ($extensions=' *', $returnemptyfolders=false) | |
Returns list of areas inside this course. More... | |
get_module_areas_with_files ($extensions=' *') | |
Returns list of areas inside the course modules that have files with the given extension. More... | |
Protected Attributes | |
file_browser | $browser |
File browser instance. | |
file_info_context_module[] | $childrenmodules = [] |
cached child modules. More... | |
stdClass | $context |
File context. | |
stdClass | $course |
course object | |
Represents a course context in the tree navigated by file_browser.
file_info_context_course::__construct | ( | $browser, | |
$context, | |||
$course | |||
) |
Constructor.
file_browser | $browser | file browser instance |
stdClass | $context | context object |
stdClass | $course | course object |
|
protectedinherited |
Builds SQL sub query (WHERE clause) for selecting files with the specified extensions.
If $extensions == '*' (any file), the result is array('', array()) otherwise the result is something like array('AND filename ...', array(...))
string | array | $extensions | - either '*' or array of lowercase extensions, i.e. array('.gif','.jpg') |
string | $prefix | prefix for DB table files in the query (empty by default) |
array | of two elements: $sql - sql where clause and $params - array of parameters |
|
inherited |
Copy content of this file to local storage, overriding current file if needed.
string | $pathname | real local full file name |
boolean | success |
Reimplemented in file_info_stored.
|
inherited |
Copy content of this file to local storage, overriding current file if needed.
array | stdClass | $filerecord | contains contextid, component, filearea, itemid, filepath, filename and optionally other attributes of the new file |
bool | success |
Reimplemented in file_info_stored.
file_info_context_course::count_non_empty_children | ( | $extensions = '*' , |
|
$limit = 1 |
|||
) |
Returns the number of children which are either files matching the specified extensions or folders containing at least one such file.
string | array | $extensions,for | example '*' or array('.gif','.jpg') |
int | $limit | stop counting after at least $limit non-empty children are found |
int |
Reimplemented from file_info.
|
inherited |
Create new directory, may throw exception - make sure params are valid.
string | $newdirname | name of new directory |
int | $userid | id of author, default $USER->id |
file_info | new directory |
Reimplemented in file_info_stored.
|
inherited |
Create new file from pathname - make sure params are valid.
string | $newfilename | name of new file |
string | $pathname | location of file |
int | $userid | id of author, default $USER->id |
file_info | new file |
Reimplemented in file_info_stored.
|
inherited |
Create new file from stored file - make sure params are valid.
string | $newfilename | name of new file |
int | stored_file | $fid | id or stored_file of file |
int | $userid | id of author, default $USER->id |
file_info | new file |
Reimplemented in file_info_stored.
|
inherited |
Create new file from string - make sure params are valid.
string | $newfilename | name of new file |
string | $content | of file |
int | $userid | id of author, default $USER->id |
file_info | new file |
Reimplemented in file_info_stored.
|
inherited |
Delete file, make sure file is deletable first.
bool | success |
Reimplemented in file_info_stored.
|
protected |
Gets a stored file for the automated backup filearea directory.
int | $itemid | item ID |
string | $filepath | file path |
string | $filename | file name |
file_info|null |
|
protected |
Gets a stored file for the backup course filearea directory.
int | $itemid | item ID |
string | $filepath | file path |
string | $filename | file name |
file_info|null | file_info instance or null if not found or access not allowed |
|
protected |
Gets a stored file for the backup section filearea directory.
int | $itemid | item ID |
string | $filepath | file path |
string | $filename | file name |
file_info|null | file_info instance or null if not found or access not allowed |
|
protected |
Gets a stored file for the course legacy filearea directory.
int | $itemid | item ID |
string | $filepath | file path |
string | $filename | file name |
file_info|null | file_info instance or null if not found or access not allowed |
|
protected |
Gets a stored file for the course images filearea directory.
int | $itemid | item ID |
string | $filepath | file path |
string | $filename | file name |
file_info|null | file_info instance or null if not found or access not allowed |
|
protected |
Gets a stored file for the course section filearea directory.
int | $itemid | item ID |
string | $filepath | file path |
string | $filename | file name |
file_info|null | file_info instance or null if not found or access not allowed |
|
protected |
Gets a stored file for the course summary filearea directory.
int | $itemid | item ID |
string | $filepath | file path |
string | $filename | file name |
file_info|null | file_info instance or null if not found or access not allowed |
|
inherited |
Returns the author name of the file.
string | author name or null |
Reimplemented in file_info_stored.
|
protected |
Returns the child module if it is accessible by the current user.
cm_info | int | $cm |
file_info_context_module|null |
file_info_context_course::get_children | ( | ) |
|
protected |
Returns list of areas inside this course.
string | $extensions | Only return areas that have files with these extensions |
bool | $returnemptyfolders | return all areas always, if true it will ignore the previous argument |
array |
file_info_context_course::get_file_info | ( | $component, | |
$filearea, | |||
$itemid, | |||
$filepath, | |||
$filename | |||
) |
Return information about this specific context level.
string | $component | component |
string | $filearea | file area |
int | $itemid | item ID |
string | $filepath | file path |
string | $filename | file name |
file_info|null | file_info instance or null if not found or access not allowed |
|
inherited |
Returns file size in bytes, null for directories.
int | bytes or null if not known |
Reimplemented in file_info_stored.
|
inherited |
Returns the license type of the file.
string | license short name or null |
Reimplemented in file_info_stored.
|
inherited |
Returns mimetype.
string | mimetype or null if not known |
Reimplemented in file_info_stored.
|
protected |
Returns list of areas inside the course modules that have files with the given extension.
string | $extensions |
array |
file_info_context_course::get_non_empty_children | ( | $extensions = '*' | ) |
Returns list of children which are either files matching the specified extensions or folders that contain at least one such file.
string | array | $extensions,either | '*' or array of lowercase extensions, i.e. array('.gif','.jpg') |
array | of file_info instances |
Reimplemented from file_info.
|
inherited |
Returns list of standard virtual file/directory identification.
The difference from stored_file parameters is that null values are allowed in all fields
array | with keys contextid, component, filearea, itemid, filepath and filename |
Reimplemented in workshop_file_info_overallfeedback_container, workshop_file_info_submissions_container, mod_lesson_file_info, imscp_file_info, glossary_file_info_container, forum_file_info_container, data_file_info_container, book_file_info, file_info_stored, file_info_area_backup_section, and file_info_area_course_section.
|
inherited |
Returns array of url encoded params.
array | with numeric keys |
file_info_context_course::get_parent | ( | ) |
|
inherited |
Returns the localised human-readable name of the file together with virtual path.
string |
Reimplemented in file_info_stored.
|
inherited |
|
inherited |
Returns the source of the file.
string | a source url or null |
Reimplemented in file_info_stored.
|
inherited |
Returns file status flag.
int | 0 means file OK, anything else is a problem and file can not be used |
Reimplemented in file_info_stored.
|
inherited |
Returns time created unix timestamp if known.
int | timestamp or null |
Reimplemented in file_info_stored.
|
inherited |
Returns time modified unix timestamp if known.
int | timestamp or null |
Reimplemented in file_info_stored.
|
inherited |
Returns file download url.
bool | $forcedownload | whether or not force download |
bool | $https | whether or not force https |
string | url |
Reimplemented in file_info_stored, and file_info_area_course_legacy.
file_info_context_course::get_visible_name | ( | ) |
file_info_context_course::is_directory | ( | ) |
|
inherited |
Is this info area and is it "empty"? Are there any files in subfolders?
This is used mostly in repositories to reduce the number of empty folders. This method may be very slow, use with care.
bool |
Reimplemented in file_info_stored, file_info_context_module, file_info_area_backup_section, and file_info_area_course_section.
|
inherited |
|
inherited |
Whether or not I can read content of this file or enter directory.
bool |
Reimplemented in file_info_stored.
file_info_context_course::is_writable | ( | ) |
Whether or not new files or directories can be added.
bool |
Reimplemented from file_info.
|
protected |
cached child modules.