Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Tiny text editor integration - TinyMCE Loader.

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

Defines 1 class


Class: loader  - X-Ref

An anonymous class to handle loading and serving TinyMCE JavaScript.

__construct()   X-Ref
Initialise the class, parse the request and serve the content.


parse_file_information_from_url()   X-Ref
Parse the file information from the URL.


serve_file()   X-Ref
Serve the requested file from the most appropriate location, caching if possible.


get_filepath_from_dirroot()   X-Ref
Get the full filepath to the requested file.

return: string

load_content_from_dirroot()   X-Ref
Load the file content from the dirroot.

return: string

send_uncached_from_dirroot()   X-Ref
Send the file content from the dirroot.

If the file is not found, send the 404 response instead.

is_candidate_file_available()   X-Ref
Check whether the candidate file exists.

return: bool

send_cached_file_if_available()   X-Ref
Send the candidate file.


store_filepath_file()   X-Ref
Store the file content in the candidate file.


get_etag()   X-Ref
Get the eTag for the candidate file.

This is a unique hash based on the file arguments.
It does not need to consider the file content because we use a cache busting URL.

return: string The eTag content

send_cached()   X-Ref
Send the candidate file, with aggressive cachign headers.

This includdes eTags, a last-modified, and expiry approximately 90 days in the future.

send_uncached_file(string $filepath)   X-Ref
Sends the content directly without caching it.

No aggressive caching is used, and the expiry is set to the current time.

param: string $filepath

send_unmodified_headers(int $lastmodified)   X-Ref
Send headers to indicate that the file has not been modified at all

param: int $lastmodified

send_not_found()   X-Ref
Sends a 404 message to indicate that the content was not found.