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.

Differences Between: [Versions 311 and 403] [Versions 400 and 403] [Versions 401 and 403]

(no description)

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

Defines 1 class


Class: brickfield_accessibility_test  - X-Ref

This handles importing DOM objects, adding items to the report and provides a few DOM-traversing methods

__construct(&$dom, &$css, &$path, $languagedomain = 'en', $options = null)   X-Ref
The class constructor. We pass items by reference so we can alter the DOM if necessary

param: object $dom The DOMDocument object
param: object $css The brickfieldCSS object
param: array $path The path of this request
param: string $languagedomain The langauge domain to user
param: mixed $options Any additional options passed by htmlchecker.

get_report()   X-Ref
Helper method to collect the report from this test. Some
tests do additional cleanup by overriding this method

return: array An array of ReportItem objects

get_severity()   X-Ref
Returns the default severity of the test

return: int The severity level

add_report($element = null, $message = null, $pass = null, $state = null, $manual = null)   X-Ref
Adds a new ReportItem to this current tests collection of reports.
Most reports pertain to a particular element (like an IMG with no Alt attribute);
however, some are document-level and just either pass or don't pass

param: object $element The DOMElement object that pertains to this report
param: string $message An additional message to add to the report
param: bool $pass Whether or not this report passed
param: object $state Extra information about the error state
param: bool $manual Whether the report needs a manual check

get_path($file)   X-Ref
Retrieves the full path for a file.

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

translation()   X-Ref
Returns a translated variable. If the translation is unavailable, English is returned
Because tests only really have one string array, we can get all of this info locally

return: mixed The translation for the object

get_all_elements($tags = null, string $options = '', bool $value = true)   X-Ref
Helper method to find all the elements that fit a particular query
in the document (either by tag name, or by attributes from the htmlElements object)

param: mixed $tags Either a single tag name in a string, or an array of tag names
param: string $options The kind of option to select an element by (see htmlElements)
param: bool $value The value of the above option
return: array An array of elements that fit the description

element_has_child($element, string $childtag)   X-Ref
Returns true if an element has a child with a given tag name

param: object $element A DOMElement object
param: string $childtag The tag name of the child to find
return: bool TRUE if the element does have a child with

get_element_ancestor($element, string $ancestortag, string $limittag = 'body')   X-Ref
Returns the first ancestor reached of a tag, or false if it hits
the document root or a given tag.

param: object $element A DOMElement object
param: string $ancestortag The name of the tag we are looking for
param: string $limittag Where to stop searching
return: bool

get_elements_by_attribute(string $tag, string $attribute, bool $unique = false)   X-Ref
Finds all the elements with a given tag name that has
an attribute

param: string $tag The tag name to search for
param: string $attribute The attribute to search on
param: bool $unique Whether we only want one result per attribute
return: array An array of DOMElements with the attribute

get_next_element($element)   X-Ref
Returns the next element after the current one.

param: object $element A DOMElement object
return: mixed FALSE if there is no other element, or a DOMElement object

property_is_equal($object, string $property, $value, bool $trim = false, bool $lower = false)   X-Ref
To minimize notices, this compares an object's property to the valus
and returns true or false. False will also be returned if the object is
not really an object, or if the property doesn't exist at all

param: object $object The object too look at
param: string $property The name of the property
param: mixed $value The value to check against
param: bool $trim Whether the property value should be trimmed
param: bool $lower Whether the property value should be compared on lower case
return: bool

get_parent($element, string $tagname, string $limiter)   X-Ref
Returns the parent of an elment that has a given tag Name, but
stops the search if it hits the $limiter tag

param: object $element The DOMElement object to search on
param: string $tagname The name of the tag of the parent to find
param: string $limiter The tag name of the element to stop searching on
return: mixed FALSE if no parent is found, or the DOMElement object of the found parent

image_is_animated($filename)   X-Ref
Returns if a GIF files is animated or not http://us.php.net/manual/en/function.imagecreatefromgif.php#88005

param: string $filename
return: int

element_contains_readable_text($element)   X-Ref
Returns if there are any printable/readable characters within an element.
This finds both node values or images with alt text.

param: object $element The given element to look at
return: bool TRUE if contains readable text, FALSE if otherwise

get_all_newwindowphrases()   X-Ref
Returns an array of the newwindowphrases for all enabled language packs.

return: array of the newwindowphrases for all enabled language packs.

get_all_invalidlinkphrases()   X-Ref
Returns an array of the invalidlinkphrases for all enabled language packs.

return: array of the invalidlinkphrases for all enabled language packs.

get_all_phrases(string $stringname)   X-Ref
Returns an array of the relevant phrases for all enabled language packs.

param: string $stringname the language string identifier you want get the phrases for.
return: array of the invalidlinkphrases for all enabled language packs.

is_text_readable(string $text)   X-Ref
Assesses whether a string contains any readable text, which is text that
contains any characters other than whitespace characters.

param: string $text
return: bool