Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Provides code used during file browsing

Copyright: 2009 David Mudrak <david.mudrak@gmail.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 342 lines (12 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

workshop_file_info_submissions_container:: (10 methods):
  __construct()
  get_params()
  get_visible_name()
  is_writable()
  is_directory()
  get_children()
  get_filtered_children()
  get_non_empty_children()
  count_non_empty_children()
  get_parent()

workshop_file_info_overallfeedback_container:: (10 methods):
  __construct()
  get_params()
  get_visible_name()
  is_writable()
  is_directory()
  get_children()
  get_filtered_children()
  get_non_empty_children()
  count_non_empty_children()
  get_parent()


Class: workshop_file_info_submissions_container  - X-Ref

Represents virtual root node for all submissions

Workshop submission uses two fileareas: submission_content for editor's embeded media
and submission_attachment for attachments. In both, the itemid represents the submission id.
This container is used to display the list of all submissions in these areas (ie when
these areas are browsed with itemid == null).
__construct($browser, $course, $cm, $context, $areas, $filearea)   X-Ref
No description

get_params()   X-Ref
Returns list of standard virtual file/directory identification.
The difference from stored_file parameters is that null values
are allowed in all fields

return: array with keys contextid, filearea, itemid, filepath and filename

get_visible_name()   X-Ref
Returns localised visible name.

return: string

is_writable()   X-Ref
Can I add new files or directories?

return: bool

is_directory()   X-Ref
Is directory?

return: bool

get_children()   X-Ref
Returns list of children nodes

return: array of file_info instances

get_filtered_children($extensions = '*', $countonly = false, $returnemptyfolders = false)   X-Ref
Helper function to return files matching extensions or their count

param: string|array $extensions, either '*' or array of lowercase extensions, i.e. array('.gif','.jpg')
param: bool|int $countonly if false returns the children, if an int returns just the
param: bool $returnemptyfolders if true returns items that don't have matching files inside
return: array|int array of file_info instances or the count

get_non_empty_children($extensions = '*')   X-Ref
Returns list of children which are either files matching the specified extensions
or folders that contain at least one such file.

param: string|array $extensions, either '*' or array of lowercase extensions, i.e. array('.gif','.jpg')
return: array of file_info instances

count_non_empty_children($extensions = '*', $limit = 1)   X-Ref
Returns the number of children which are either files matching the specified extensions
or folders containing at least one such file.

NOTE: We don't need the exact number of non empty children if it is >=2
In this function 1 is never returned to avoid skipping the single subfolder

param: string|array $extensions, for example '*' or array('.gif','.jpg')
param: int $limit stop counting after at least $limit non-empty children are found
return: int

get_parent()   X-Ref
Returns parent file_info instance

return: file_info or null for root

Class: workshop_file_info_overallfeedback_container  - X-Ref

Represents virtual root node for all files in overall feedbacks

Overall feedback uses two fileareas: overallfeedback_content for editor's embeded media
and overallfeedback_attachment for attachments. In both, the itemid represents the assessment id.
This container is used to display the list of all submissions in these areas (ie when
these areas are browsed with itemid == null).
__construct($browser, $course, $cm, $context, $areas, $filearea)   X-Ref
No description

get_params()   X-Ref
Returns list of standard virtual file/directory identification

The difference from stored_file parameters is that null values
are allowed in all fields.

return: array with keys contextid, filearea, itemid, filepath and filename

get_visible_name()   X-Ref
Returns localised visible name

return: string

is_writable()   X-Ref
Can I add new files or directories?

return: bool

is_directory()   X-Ref
Is directory?

return: bool

get_children()   X-Ref
Returns list of children nodes

return: array of file_info instances

get_filtered_children($extensions = '*', $countonly = false, $returnemptyfolders = false)   X-Ref
Helper function to return files matching extensions or their count

param: string|array $extensions, either '*' or array of lowercase extensions, i.e. array('.gif','.jpg')
param: bool|int $countonly if false returns the children, if an int returns just the
param: bool $returnemptyfolders if true returns items that don't have matching files inside
return: array|int array of file_info instances or the count

get_non_empty_children($extensions = '*')   X-Ref
Returns list of children which are either files matching the specified extensions
or folders that contain at least one such file.

param: string|array $extensions, either '*' or array of lowercase extensions, i.e. array('.gif','.jpg')
return: array of file_info instances

count_non_empty_children($extensions = '*', $limit = 1)   X-Ref
Returns the number of children which are either files matching the specified extensions
or folders containing at least one such file.

NOTE: We don't need the exact number of non empty children if it is >=2
In this function 1 is never returned to avoid skipping the single subfolder

param: string|array $extensions, for example '*' or array('.gif','.jpg')
param: int $limit stop counting after at least $limit non-empty children are found
return: int

get_parent()   X-Ref
Returns parent file_info instance

return: file_info or null for root