Search moodle.org's
Developer Documentation

See Release Notes

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

(no description)

File Size: 436 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

brickfield_accessibility:: (19 methods):
  __construct()
  prepare_dom()
  prepare_value()
  set_option()
  get_absolute_path()
  set_uri()
  prepare_base_url()
  get_base_from_file()
  add_css()
  get_error()
  load_reporter()
  is_valid()
  run_check()
  get_css_object()
  get_report()
  get_test()
  get_test_severity()
  cleanup()
  match_urls()


Class: brickfield_accessibility  - X-Ref

Brickfield accessibility HTML checker library.

The main interface class for brickfield_accessibility.

__construct(string $value = '', string $guideline = 'wcag2aaa', string $type = 'string',string $reporter = 'static', string $domain = 'en')   X-Ref
The class constructor

param: string $value Either the HTML string to check or the file/uri of the request
param: string $guideline The name of the guideline
param: string $type The type of the request (either file, uri, or string)
param: string $reporter The name of the reporter to use
param: string $domain The domain of the translation language to use

prepare_dom()   X-Ref
Prepares the DOMDocument object for brickfield_accessibility. It loads based on the file type
declaration and first scrubs the value using prepareValue().


prepare_value()   X-Ref
If the CMS mode options are set, then we remove some items front the
HTML value before sending it back.


set_option($variable, $value = null)   X-Ref
Set global predefined options for brickfield_accessibility. First we check that the
array key has been defined.

param: mixed $variable Either an array of values, or a variable name of the option
param: mixed $value If this is a single option, the value of the option

get_absolute_path(string $absolute, string $relative)   X-Ref
Returns an absolute path from a relative one.

param: string $absolute The absolute URL
param: string $relative The relative path
return: string A new path

set_uri(string $uri)   X-Ref
Sets the URI if this is for a string or to change where
Will look for resources like CSS files

param: string $uri The URI to set

prepare_base_url(string $value, string $type)   X-Ref
Formats the base URL for either a file or uri request. We are essentially
formatting a base url for future reporters to use to find CSS files or
for tests that use external resources (images, objects, etc) to run tests on them.

param: string $value The path value
param: string $type The type of request

get_base_from_file(string $file)   X-Ref
Retrieves the absolute path to a file

param: string $file The path to a file
return: string The absolute path to a file

add_css(string $css)   X-Ref
Helper method to add an additional CSS file

param: string $css The URI or file path to a CSS file

get_error(string $error)   X-Ref
Retrives a single error from the current reporter

param: string $error The error key
return: object A ReportItem object

load_reporter(array $options = [])   X-Ref
A local method to load the required file for a reporter and set it for the current object

param: array $options An array of options for the reporter

is_valid()   X-Ref
Checks that the DOM object is valid or not

return: bool Whether the DOMDocument is valid

run_check($options = null)   X-Ref
Starts running automated checks. Loads the CSS file parser
and the guideline object.

param: null $options
return: bool

get_css_object()   X-Ref
Loads the brickfield_accessibility_css object


get_report(array $options = [])   X-Ref
Returns a formatted report from the current reporter.

param: array $options An array of all the options
return: mixed See the documentation on your reporter's getReport method.

get_test(string $test)   X-Ref
Runs one test on the current DOMDocument

param: string $test The name of the test to run
return: bool|array The ReportItem returned from the test

get_test_severity(string $test)   X-Ref
Retrieves the default severity of a test

param: string $test The name of the test to run
return: object The severity level of the test

cleanup()   X-Ref
A general cleanup function which just does some memory
cleanup by unsetting the particularly large local vars.


match_urls(string $text, string $href)   X-Ref
Determines if the link text is the same as the link URL, without necessarily being an exact match.
For example, 'www.google.com' matches 'https://www.google.com'.

param: string $text
param: string $href
return: bool