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.

The definition of a set of files in a filearea to be exported.

Copyright: 2020 Andrew Nicols <andrew@nicols.co.uk>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 179 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

exportable_filearea:: (4 methods):
  __construct()
  add_to_archive()
  get_filepath_for_file()
  get_pluginfile_url_for_stored_file()


Class: exportable_filearea  - X-Ref

The definition of a set of files in a filearea to be exported.

All files mustbe in a single filearea and itemid combination.

__construct(context $context,string $component,string $uservisiblename,string $filearea,int $itemid,?int $pluginfileitemid = null,string $folderpath = '')   X-Ref
Create a new exportable_item instance.

If no filearea or itemid  is specified the no attempt will be made to export files.

param: context $context The context that this content belongs to
param: string $component
param: string $uservisiblename The name displayed to the user when filtering
param: string $filearea The file area in the Files API where these files are located
param: int $itemid The itemid in the Files API where these files are located
param: null|int $pluginfileitemid The itemid as used in the Pluginfile URL
param: string $folderpath Any sub-directory to place files in

add_to_archive(zipwriter $archive)   X-Ref
Add the content to the archive.

param: zipwriter $archive

get_filepath_for_file(stored_file $file)   X-Ref
Get the filepath for the specified stored_file.

param: stored_file $file The file to get a filepath for
return: string The generated filepath

get_pluginfile_url_for_stored_file(stored_file $file, ?int $pluginfileitemid)   X-Ref
Get the pluginfile URL for a stored file.

Note: The itemid in the pluginfile may be omitted in some URLs, despite an itemid being present in the database.
Equally, the itemid in the URL may not match the itemid in the files table.

The pluginfileitemid argument provided to this function is the variant in the URL, and not the one in the files
table.

param: stored_file $file The file whose link will be generated
param: null|int $pluginfileitemid The itemid of the file in pluginfile URL.