Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.
/lib/ -> csslib.php (source)

This file contains CSS file serving functions. NOTE: these functions are not expected to be used from any addons.

Copyright: 2012 Sam Hemelryk
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 209 lines (7 kb)
Included or required: 1 time
Referenced: 2 times
Includes or requires: 0 files

Defines 8 functions


Functions that are not part of a class:

css_store_css(theme_config $theme, $csspath, $csscontent)   X-Ref
Stores CSS in a file at the given path.

This function either succeeds or throws an exception.

param: theme_config $theme The theme that the CSS belongs to.
param: string $csspath The path to store the CSS at.
param: string $csscontent the complete CSS in one string.

css_write_file($filename, $content)   X-Ref
Writes a CSS file.

param: string $filename
param: string $content

css_send_cached_css($csspath, $etag)   X-Ref
Sends a cached CSS file

This function sends the cached CSS file. Remember it is generated on the first
request, then optimised/minified, and finally cached for serving.

param: string $csspath The path to the CSS file we want to serve.
param: string $etag The revision to make sure we utilise any caches.

css_send_cached_css_content($csscontent, $etag)   X-Ref
Sends a cached CSS content

param: string $csscontent The actual CSS markup.
param: string $etag The revision to make sure we utilise any caches.

css_send_temporary_css($css)   X-Ref
Sends CSS directly and disables all caching.
The Content-Length of the body is also included, but the script is not ended.

param: string $css The CSS content to send

css_send_uncached_css($css)   X-Ref
Sends CSS directly without caching it.

This function takes a raw CSS string, optimises it if required, and then
serves it.
Turning both themedesignermode and CSS optimiser on at the same time is awful
for performance because of the optimiser running here. However it was done so
that theme designers could utilise the optimised output during development to
help them optimise their CSS... not that they should write lazy CSS.

param: string $css

css_send_unmodified($lastmodified, $etag)   X-Ref
Send file not modified headers

param: int $lastmodified
param: string $etag

css_send_css_not_found()   X-Ref
Sends a 404 message about CSS not being found.