Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
Public Member Functions | |
css_urls (moodle_page $page) | |
Get the stylesheet URL of this theme. More... | |
editor_css_files () | |
Returns the content of the CSS to be used in editor content. More... | |
editor_css_url ($encoded=true) | |
Returns the stylesheet URL of this editor content. More... | |
editor_scss_to_css () | |
Compiles and returns the content of the SCSS to be used in editor content. More... | |
font_url ($font, $component) | |
Return the URL for a font. More... | |
force_svg_use ($setting) | |
Forces the usesvg setting to either true or false, avoiding any decision making. More... | |
get_all_block_regions () | |
Get the list of all block regions known to this theme in all templates. More... | |
get_block_render_method () | |
Returns the block render method. More... | |
get_css_cache_key () | |
Generate the css content cache key. More... | |
get_css_cached_content () | |
Return cached post processed CSS content. More... | |
get_css_content () | |
Get the whole css stylesheet for production mode. More... | |
get_css_content_debug ($type, $subtype, $sheet) | |
Get the theme designer css markup, the parameters are coming from css_urls(). More... | |
get_css_content_editor () | |
Get the whole css stylesheet for editor iframe. More... | |
get_css_tree_post_processor () | |
Get the callable for CSS tree post processing. More... | |
get_extra_scss_code () | |
Return extra SCSS code to add when compiling. More... | |
get_icon_system () | |
Get the icon system to use. More... | |
get_pre_scss_code () | |
SCSS code to prepend when compiling. More... | |
get_precompiled_css_content () | |
Return the precompiled CSS if the precompiledcsscallback exists. More... | |
get_renderer (moodle_page $page, $component, $subtype=null, $target=null) | |
Get the renderer for a part of Moodle for this theme. More... | |
get_rtl_mode () | |
Whether the theme is being served in RTL mode. More... | |
get_scss_property () | |
Get the SCSS property. More... | |
get_theme_name () | |
Returns the human readable name of the theme. More... | |
has_css_cached_content () | |
Return whether the post processed CSS content has been cached. More... | |
image_url ($imagename, $component) | |
Return the direct URL for an image from the pix folder. More... | |
init_page (moodle_page $page) | |
Let the theme initialise the page object (usually $PAGE). More... | |
javascript_content ($type) | |
Returns the content of the one huge javascript file merged from all theme javascript files. More... | |
javascript_files ($type) | |
Get the URL's for the JavaScript files used by this theme. More... | |
javascript_url ($inhead) | |
Generate a URL to the file that serves theme JavaScript files. More... | |
layout_file ($pagelayout) | |
Given the settings of this theme, and the page pagelayout, return the full path of the page layout file to use. More... | |
pagelayout_options ($pagelayout) | |
Returns auxiliary page layout options specified in layout configuration array. More... | |
pix_url ($imagename, $component) | |
Return the direct URL for an image from the pix folder. More... | |
post_process ($css) | |
Post processes CSS. More... | |
renderer_prefixes () | |
Returns output renderer prefixes, these are used when looking for the overridden renderers in themes. More... | |
resolve_font_location ($font, $component) | |
Resolves the real font location. More... | |
resolve_image_location ($image, $component, $svg=false) | |
Resolves the real image location. More... | |
set_css_content_cache ($csscontent) | |
Set post processed CSS content cache. More... | |
set_rtl_mode ($inrtl=true) | |
Set to be in RTL mode. More... | |
setting_file_serve ($filearea, $args, $forcedownload, $options) | |
Serve the theme setting file. More... | |
setting_file_url ($setting, $filearea) | |
Returns URL to the stored file via pluginfile.php. More... | |
setup_blocks ($pagelayout, $blockmanager) | |
Inform a block_manager about the block regions this theme wants on this page layout. More... | |
use_svg_icons () | |
Return true if we should look for SVG images as well. More... | |
Static Public Member Functions | |
static | diagnose ($themename) |
Theme diagnostic code. More... | |
static | load ($themename) |
Load the config.php file for a particular theme, and return an instance of this class. More... | |
Public Attributes | |
string | $blockrendermethod = null |
Sets the render method that should be used for rendering custom block regions by scripts such as my/index.php Defaults to core_renderer::blocks_for_region(). | |
array | $blockrtlmanipulations = array() |
An associative array of block manipulations that should be made if the user is using an rtl language. More... | |
string | $csspostprocess = null |
Function to do custom CSS post-processing. More... | |
string | $csstreepostprocessor = null |
Function to do custom CSS post-processing on a parsed CSS tree. More... | |
string | $darrow = null |
Accessibility: Down arrow-like character. More... | |
string | $dir |
The folder where this themes files are stored. More... | |
string | $doctype = 'html5' |
Determines served document types. More... | |
array | $editor_sheets = array() |
List of style sheets that are included in the text editor bodies. More... | |
bool | $enable_dock = false |
If set to true and the theme enables the dock then blocks will be able to be moved to the special dock. | |
bool | $enablecourseajax = true |
Some themes may want to disable ajax course editing. | |
string | $extrascsscallback = null |
The name of the function to call to get the SCSS code to inject. | |
bool | $hidefromselector = false |
If set to true then this theme will not be shown in the theme selector unless theme designer mode is turned on. | |
array | $javascripts = array() |
The names of all the javascript files this theme that you would like included from head, in order. More... | |
array | $javascripts_footer = array() |
The names of all the javascript files this theme that you would like included from footer, in order. More... | |
string | $larrow = null |
Accessibility: Left arrow-like character is used in the breadcrumb trail, course navigation menu (previous/next activity), calendar, and search forum block. More... | |
array | $layouts = array() |
Which file to use for each page layout. More... | |
string | $name |
The name of this theme. More... | |
array | $parents |
You can base your theme on other themes by linking to the other theme as parents. More... | |
array | $parents_exclude_javascripts = null |
The names of all the javascript files from parents that should be excluded. More... | |
array | $parents_exclude_sheets = null |
The names of all the stylesheets from parents that should be excluded. More... | |
array | $plugins_exclude_sheets = null |
List of plugin sheets to be excluded. More... | |
string | $precompiledcsscallback = null |
The name of the function to call to get precompiled CSS. | |
string | $prescsscallback = null |
The name of the function to call to get SCSS to prepend. | |
string | $rarrow = null |
Accessibility: Right arrow-like character is used in the breadcrumb trail, course navigation menu (previous/next activity), calendar, and search forum block. More... | |
array | $remapiconcache = [] |
Remember the results of icon remapping for the current page. | |
string | $rendererfactory = 'standard_renderer_factory' |
Name of the renderer factory class to use. More... | |
string | $requiredblocks = false |
requiredblocks If set to a string, will list the block types that cannot be deleted. More... | |
string Closure | $scss = false |
The SCSS file to compile (without .scss), located in the scss/ folder of the theme. More... | |
stdClass | $settings = null |
Theme settings stored in config_plugins table. More... | |
array | $sheets = array() |
The names of all the stylesheets from this theme that you would like included, in order. More... | |
string | $uarrow = null |
Accessibility: Up arrow-like character is used in the book heirarchical navigation. More... | |
bool | $usefallback = false |
Whether a fallback version of the stylesheet will be used whilst the final version is generated. | |
array | $yuicssmodules = array('cssreset', 'cssfonts', 'cssgrids', 'cssbase') |
list of YUI CSS modules to be included on each page. More... | |
string const | DEFAULT_THEME = 'boost' |
Default theme, used when requested theme not found. | |
const | SCSS_KEY = '__SCSS__' |
The key under which the SCSS file is stored amongst the CSS files. | |
Protected Member Functions | |
get_css_content_from_scss ($themedesigner) | |
Return the CSS content generated from the SCSS file. More... | |
get_css_files ($themedesigner) | |
Returns an array of organised CSS files required for this output. More... | |
get_region_name ($region, $theme) | |
Gets the visible name for the requested block region. More... | |
layout_info_for_page ($pagelayout) | |
Get the information from $layouts for this type of page. More... | |
resolve_excludes ($variable, $default=null) | |
Resolves an exclude setting to the themes setting is applicable or the setting of its closest parent. More... | |
rtlize ($csstree) | |
Flip a stylesheet to RTL. More... | |
Protected Attributes | |
array | $parent_configs = array() |
List of parent config objects. | |
renderer_factory | $rf = null |
Instance of the renderer_factory implementation we are using. More... | |
bool | $rtlmode = false |
Whether in RTL mode or not. | |
false array | $scsscache = null |
Local cache of the SCSS property. | |
theme_config::css_urls | ( | moodle_page | $page | ) |
Get the stylesheet URL of this theme.
moodle_page | $page | Not used... deprecated? |
moodle_url[] |
|
static |
Theme diagnostic code.
It is very problematic to send debug output to the actual CSS file, instead this functions is supposed to diagnose given theme and highlights all potential problems. This information should be available from the theme selection page or some other debug page for theme designers.
string | $themename |
array | description of problems |
theme_config::editor_css_files | ( | ) |
Returns the content of the CSS to be used in editor content.
array |
theme_config::editor_css_url | ( | $encoded = true | ) |
Returns the stylesheet URL of this editor content.
bool | $encoded | false means use & and true use & in URLs |
moodle_url |
theme_config::editor_scss_to_css | ( | ) |
Compiles and returns the content of the SCSS to be used in editor content.
string | Compiled CSS from the editor SCSS |
theme_config::font_url | ( | $font, | |
$component | |||
) |
Return the URL for a font.
string | $font | the name of the font (including extension). |
string | $component | specification of one plugin like in get_string() |
moodle_url |
theme_config::force_svg_use | ( | $setting | ) |
Forces the usesvg setting to either true or false, avoiding any decision making.
This function should only ever be used when absolutely required, and before any generation of image URL's has occurred. DO NOT ABUSE THIS FUNCTION... not that you'd want to right ;)
bool | $setting | True to force the use of svg when available, null otherwise. |
theme_config::get_all_block_regions | ( | ) |
Get the list of all block regions known to this theme in all templates.
array | internal region name => human readable name. |
theme_config::get_block_render_method | ( | ) |
Returns the block render method.
It is set by the theme via: $THEME->blockrendermethod = '...';
It can be one of two values, blocks or blocks_for_region. It should be set to the method being used by the theme layouts.
string |
theme_config::get_css_cache_key | ( | ) |
Generate the css content cache key.
string | The post processed css cache key. |
theme_config::get_css_cached_content | ( | ) |
Return cached post processed CSS content.
bool|string | The cached css content or false if not found. |
theme_config::get_css_content | ( | ) |
Get the whole css stylesheet for production mode.
NOTE: this method is not expected to be used from any addons.
string | CSS markup compressed |
theme_config::get_css_content_debug | ( | $type, | |
$subtype, | |||
$sheet | |||
) |
Get the theme designer css markup, the parameters are coming from css_urls().
NOTE: this method is not expected to be used from any addons.
string | $type | |
string | $subtype | |
string | $sheet |
string | CSS markup |
theme_config::get_css_content_editor | ( | ) |
Get the whole css stylesheet for editor iframe.
NOTE: this method is not expected to be used from any addons.
string | CSS markup |
|
protected |
Return the CSS content generated from the SCSS file.
bool | $themedesigner | True if theme designer is enabled. |
bool|string | Return false when the compilation failed. Else the compiled string. |
|
protected |
Returns an array of organised CSS files required for this output.
bool | $themedesigner |
array | nested array of file paths |
theme_config::get_css_tree_post_processor | ( | ) |
Get the callable for CSS tree post processing.
string|null |
theme_config::get_extra_scss_code | ( | ) |
Return extra SCSS code to add when compiling.
This is intended to be used by themes to inject some SCSS code before it gets compiled. If you want to inject variables you should use self::get_scss_variables().
string | The SCSS code to inject. |
theme_config::get_icon_system | ( | ) |
Get the icon system to use.
string |
theme_config::get_pre_scss_code | ( | ) |
SCSS code to prepend when compiling.
This is intended to be used by themes to inject SCSS code before it gets compiled.
string | The SCSS code to inject. |
theme_config::get_precompiled_css_content | ( | ) |
Return the precompiled CSS if the precompiledcsscallback exists.
string | Return compiled css. |
|
protected |
Gets the visible name for the requested block region.
string | $region | The region name to get |
string | $theme | The theme the region belongs to (may come from the parent theme) |
string |
theme_config::get_renderer | ( | moodle_page | $page, |
$component, | |||
$subtype = null , |
|||
$target = null |
|||
) |
Get the renderer for a part of Moodle for this theme.
moodle_page | $page | the page we are rendering |
string | $component | the name of part of moodle. E.g. 'core', 'quiz', 'qtype_multichoice'. |
string | $subtype | optional subtype such as 'news' resulting to 'mod_forum_news' |
string | $target | one of rendering target constants |
renderer_base | the requested renderer. |
theme_config::get_rtl_mode | ( | ) |
Whether the theme is being served in RTL mode.
bool | True when in RTL mode. |
theme_config::get_scss_property | ( | ) |
Get the SCSS property.
This resolves whether a SCSS file (or content) has to be used when generating the stylesheet for the theme. It will look at parents themes and check the SCSS properties there.
False | when SCSS is not used. An array with the import paths, and the path to the SCSS file or Closure as second. |
theme_config::get_theme_name | ( | ) |
Returns the human readable name of the theme.
string |
theme_config::has_css_cached_content | ( | ) |
Return whether the post processed CSS content has been cached.
bool | Whether the post-processed CSS is available in the cache. |
theme_config::image_url | ( | $imagename, | |
$component | |||
) |
Return the direct URL for an image from the pix folder.
Use this function sparingly and never for icons. For icons use pix_icon or the pix helper in a mustache template.
string | $imagename | the name of the icon. |
string | $component | specification of one plugin like in get_string() |
moodle_url |
theme_config::init_page | ( | moodle_page | $page | ) |
Let the theme initialise the page object (usually $PAGE).
This may be used for example to request jQuery in add-ons.
moodle_page | $page |
theme_config::javascript_content | ( | $type | ) |
Returns the content of the one huge javascript file merged from all theme javascript files.
bool | $type |
string |
theme_config::javascript_files | ( | $type | ) |
Get the URL's for the JavaScript files used by this theme.
They won't be served directly, instead they'll be mediated through theme/javascript.php.
string | $type | Either javascripts_footer, or javascripts |
array |
theme_config::javascript_url | ( | $inhead | ) |
Generate a URL to the file that serves theme JavaScript files.
If we determine that the theme has no relevant files, then we return early with a null value.
bool | $inhead | true means head url, false means footer |
moodle_url|null |
theme_config::layout_file | ( | $pagelayout | ) |
Given the settings of this theme, and the page pagelayout, return the full path of the page layout file to use.
Used by core_renderer::header().
string | $pagelayout | the the page layout name. |
string | Full path to the lyout file to use |
|
protected |
|
static |
Load the config.php file for a particular theme, and return an instance of this class.
(That is, this is a factory method.)
string | $themename | the name of the theme. |
theme_config | an instance of this class. |
theme_config::pagelayout_options | ( | $pagelayout | ) |
Returns auxiliary page layout options specified in layout configuration array.
string | $pagelayout |
array |
theme_config::pix_url | ( | $imagename, | |
$component | |||
) |
Return the direct URL for an image from the pix folder.
Use this function sparingly and never for icons. For icons use pix_icon or the pix helper in a mustache template.
string | $imagename | the name of the icon. |
string | $component | specification of one plugin like in get_string() |
moodle_url |
theme_config::post_process | ( | $css | ) |
Post processes CSS.
This method post processes all of the CSS before it is served for this theme. This is done so that things such as image URL's can be swapped in and to run any specific CSS post process method the theme has requested. This allows themes to use CSS settings.
string | $css | The CSS to process. |
string | The processed CSS. |
theme_config::renderer_prefixes | ( | ) |
Returns output renderer prefixes, these are used when looking for the overridden renderers in themes.
array |
|
protected |
Resolves an exclude setting to the themes setting is applicable or the setting of its closest parent.
string | $variable | The name of the setting the exclude setting to resolve |
string | $default |
mixed |
theme_config::resolve_font_location | ( | $font, | |
$component | |||
) |
Resolves the real font location.
string | $font | name of font file |
string | $component |
string | full file path |
theme_config::resolve_image_location | ( | $image, | |
$component, | |||
$svg = false |
|||
) |
Resolves the real image location.
$svg was introduced as an arg in 2.4. It is important because not all supported browsers support the use of SVG and we need a way in which to turn it off. By default SVG won't be used unless asked for. This is done for two reasons:
string | $image | name of image, may contain relative path |
string | $component | |
bool | $svg,|null | Should SVG images also be looked for? If null, resorts to $CFG->svgicons if that is set; falls back to auto-detection of browser support otherwise |
string | full file path |
|
protected |
Flip a stylesheet to RTL.
Object | $csstree | The parsed CSS tree structure to flip. |
void |
theme_config::set_css_content_cache | ( | $csscontent | ) |
Set post processed CSS content cache.
string | $csscontent | The post processed CSS content. |
bool | True if the content was successfully cached. |
theme_config::set_rtl_mode | ( | $inrtl = true | ) |
Set to be in RTL mode.
This will likely be used when post processing the CSS before serving it.
bool | $inrtl | True when in RTL mode. |
theme_config::setting_file_serve | ( | $filearea, | |
$args, | |||
$forcedownload, | |||
$options | |||
) |
Serve the theme setting file.
string | $filearea | |
array | $args | |
bool | $forcedownload | |
array | $options |
bool | may terminate if file not found or donotdie not specified |
theme_config::setting_file_url | ( | $setting, | |
$filearea | |||
) |
Returns URL to the stored file via pluginfile.php.
Note the theme must also implement pluginfile.php handler, theme revision is used instead of the itemid.
string | $setting | |
string | $filearea |
string | protocol relative URL or null if not present |
theme_config::setup_blocks | ( | $pagelayout, | |
$blockmanager | |||
) |
Inform a block_manager about the block regions this theme wants on this page layout.
string | $pagelayout | the general type of the page. |
block_manager | $blockmanager | the block_manger to set up. |
theme_config::use_svg_icons | ( | ) |
Return true if we should look for SVG images as well.
bool |
array theme_config::$blockrtlmanipulations = array() |
An associative array of block manipulations that should be made if the user is using an rtl language.
The key is the original block region, and the value is the block region to change to. This is used when displaying blocks for regions only.
string theme_config::$csspostprocess = null |
Function to do custom CSS post-processing.
This is an advanced feature. If you want to do custom post-processing on the CSS before it is output (for example, to replace certain variable names with particular values) you can give the name of a function here.
string theme_config::$csstreepostprocessor = null |
Function to do custom CSS post-processing on a parsed CSS tree.
This is an advanced feature. If you want to do custom post-processing on the CSS before it is output, you can provide the name of the function here. The function will receive a CSS tree document as first parameter, and the theme_config object as second parameter. A return value is not required, the tree can be edited in place.
string theme_config::$darrow = null |
Accessibility: Down arrow-like character.
If the theme does not set characters, appropriate defaults are set automatically.
string theme_config::$dir |
The folder where this themes files are stored.
This is set automatically. This can not be set in theme config.php
string theme_config::$doctype = 'html5' |
Determines served document types.
array theme_config::$editor_sheets = array() |
List of style sheets that are included in the text editor bodies.
Sheets from parent themes are used automatically and can not be excluded.
array theme_config::$javascripts = array() |
The names of all the javascript files this theme that you would like included from head, in order.
Give the names of the files without .js.
array theme_config::$javascripts_footer = array() |
The names of all the javascript files this theme that you would like included from footer, in order.
Give the names of the files without .js.
string theme_config::$larrow = null |
Accessibility: Left arrow-like character is used in the breadcrumb trail, course navigation menu (previous/next activity), calendar, and search forum block.
If the theme does not set characters, appropriate defaults are set automatically. Please DO NOT use < > » - these are confusing for blind users.
array theme_config::$layouts = array() |
Which file to use for each page layout.
This is an array of arrays. The keys of the outer array are the different layouts. Pages in Moodle are using several different layouts like 'normal', 'course', 'home', 'popup', 'form', .... The most reliable way to get a complete list is to look at the base theme config.php file
. That file also has a good example of how to set this setting.
For each layout, the value in the outer array is an array that describes how you want that type of page to look. For example
$THEME->layouts = array( // Most pages - if we encounter an unknown or a missing page type, this one is used. 'standard' => array( 'theme' = 'mytheme', 'file' => 'normal.php', 'regions' => array('side-pre', 'side-post'), 'defaultregion' => 'side-post' ), // The site home page. 'home' => array( 'theme' = 'mytheme', 'file' => 'home.php', 'regions' => array('side-pre', 'side-post'), 'defaultregion' => 'side-post' ), // ... );
'theme' name of the theme where is the layout located 'file' is the layout file to use for this type of page. layout files are stored in layout subfolder 'regions' This lists the regions on the page where blocks may appear. For each region you list here, your layout file must include a call to
echo $OUTPUT->blocks_for_region($regionname);
or equivalent so that the blocks are actually visible.
'defaultregion' If the list of regions is non-empty, then you must pick one of the one of them as 'default'. This has two meanings. First, this is where new blocks are added. Second, if there are any blocks associated with the page, but in non-existent regions, they appear here. (Imaging, for example, that someone added blocks using a different theme that used different region names, and then switched to this theme.)
string theme_config::$name |
The name of this theme.
Set automatically when this theme is loaded. This can not be set in theme config.php
array theme_config::$parents |
You can base your theme on other themes by linking to the other theme as parents.
This lets you use the CSS and layouts from the other themes (see theme_config::$layouts). That makes it easy to create a new theme that is similar to another one but with a few changes. In this themes CSS you only need to override those rules you want to change.
array theme_config::$parents_exclude_javascripts = null |
The names of all the javascript files from parents that should be excluded.
true value may be used to specify all parents or all themes from one parent. If no value specified value from parent theme used.
array theme_config::$parents_exclude_sheets = null |
The names of all the stylesheets from parents that should be excluded.
true value may be used to specify all parents or all themes from one parent. If no value specified value from parent theme used.
array theme_config::$plugins_exclude_sheets = null |
List of plugin sheets to be excluded.
If no value specified value from parent theme used.
string theme_config::$rarrow = null |
Accessibility: Right arrow-like character is used in the breadcrumb trail, course navigation menu (previous/next activity), calendar, and search forum block.
If the theme does not set characters, appropriate defaults are set automatically. Please DO NOT use < > » - these are confusing for blind users.
string theme_config::$rendererfactory = 'standard_renderer_factory' |
Name of the renderer factory class to use.
Must implement the renderer_factory interface.
This is an advanced feature. Moodle output is generated by 'renderers', you can customise the HTML that is output by writing custom renderers, and then you need to specify 'renderer factory' so that Moodle can find your renderers.
There are some renderer factories supplied with Moodle. Please follow these links to see what they do.
string theme_config::$requiredblocks = false |
requiredblocks If set to a string, will list the block types that cannot be deleted.
Defaults to navigation and settings.
|
protected |
Instance of the renderer_factory implementation we are using.
Implementation detail.
string Closure theme_config::$scss = false |
The SCSS file to compile (without .scss), located in the scss/ folder of the theme.
Or a Closure, which receives the theme_config as argument and must return the SCSS content.
stdClass theme_config::$settings = null |
Theme settings stored in config_plugins table.
This can not be set in theme config.php
array theme_config::$sheets = array() |
The names of all the stylesheets from this theme that you would like included, in order.
Give the names of the files without .css.
string theme_config::$uarrow = null |
Accessibility: Up arrow-like character is used in the book heirarchical navigation.
If the theme does not set characters, appropriate defaults are set automatically. Please DO NOT use ^ - this is confusing for blind users.
array theme_config::$yuicssmodules = array('cssreset', 'cssfonts', 'cssgrids', 'cssbase') |
list of YUI CSS modules to be included on each page.
This may be used to remove cssreset and use cssnormalise module instead.