Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test Class Reference
Inheritance diagram for tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test:
tool_brickfield\local\htmlchecker\common\brickfield_accessibility_color_test tool_brickfield\local\htmlchecker\common\brickfield_accessibility_header_test tool_brickfield\local\htmlchecker\common\brickfield_accessibility_table_test tool_brickfield\local\htmlchecker\common\brickfield_accessibility_tag_test tool_brickfield\local\htmlchecker\common\checks\a_links_dont_open_new_window tool_brickfield\local\htmlchecker\common\checks\a_must_contain_text tool_brickfield\local\htmlchecker\common\checks\a_suspicious_link_text tool_brickfield\local\htmlchecker\common\checks\area_dont_open_new_window tool_brickfield\local\htmlchecker\common\checks\area_has_alt_value tool_brickfield\local\htmlchecker\common\checks\content_too_long tool_brickfield\local\htmlchecker\common\checks\embed_has_associated_no_embed tool_brickfield\local\htmlchecker\common\checks\headers_have_text tool_brickfield\local\htmlchecker\common\checks\img_alt_is_different tool_brickfield\local\htmlchecker\common\checks\img_alt_is_too_long tool_brickfield\local\htmlchecker\common\checks\img_alt_not_empty_in_anchor tool_brickfield\local\htmlchecker\common\checks\img_alt_not_place_holder tool_brickfield\local\htmlchecker\common\checks\img_has_alt tool_brickfield\local\htmlchecker\common\checks\img_with_map_has_use_map tool_brickfield\local\htmlchecker\common\checks\legend_text_not_empty tool_brickfield\local\htmlchecker\common\checks\no_headings tool_brickfield\local\htmlchecker\common\checks\object_must_have_embed tool_brickfield\local\htmlchecker\common\checks\object_must_have_title tool_brickfield\local\htmlchecker\common\checks\object_must_have_valid_title tool_brickfield\local\htmlchecker\common\checks\table_summary_does_not_duplicate_caption tool_brickfield\local\htmlchecker\common\checks\table_th_should_have_scope tool_brickfield\local\htmlchecker\common\input_has_label tool_brickfield\local\htmlchecker\common\input_tab_index

Public Member Functions

 __construct (&$dom, &$css, &$path, $languagedomain='en', $options=null)
 The class constructor.
 
 add_report ($element=null, $message=null, $pass=null, $state=null, $manual=null)
 Adds a new ReportItem to this current tests collection of reports.
 
 element_contains_readable_text ($element)
 Returns if there are any printable/readable characters within an element.
 
 element_has_child ($element, string $childtag)
 Returns true if an element has a child with a given tag name.
 
 get_all_elements ($tags=null, string $options='', bool $value=true)
 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)
 
 get_element_ancestor ($element, string $ancestortag, string $limittag='body')
 Returns the first ancestor reached of a tag, or false if it hits the document root or a given tag.
 
 get_elements_by_attribute (string $tag, string $attribute, bool $unique=false)
 Finds all the elements with a given tag name that has an attribute.
 
 get_next_element ($element)
 Returns the next element after the current one.
 
 get_parent ($element, string $tagname, string $limiter)
 Returns the parent of an elment that has a given tag Name, but stops the search if it hits the $limiter tag.
 
 get_path ($file)
 Retrieves the full path for a file.
 
 get_report ()
 Helper method to collect the report from this test.
 
 get_severity ()
 Returns the default severity of the test.
 
 image_is_animated ($filename)
 Returns if a GIF files is animated or not http://us.php.net/manual/en/function.imagecreatefromgif.php#88005.
 
 property_is_equal ($object, string $property, $value, bool $trim=false, bool $lower=false)
 To minimize notices, this compares an object's property to the valus and returns true or false.
 
 translation ()
 Returns a translated variable.
 

Static Public Member Functions

static get_all_invalidlinkphrases ()
 Returns an array of the invalidlinkphrases for all enabled language packs.
 
static get_all_newwindowphrases ()
 Returns an array of the newwindowphrases for all enabled language packs.
 
static is_text_readable (string $text)
 Assesses whether a string contains any readable text, which is text that contains any characters other than whitespace characters.
 

Public Attributes

string $basepath
 The base path for this request.
 
bool $cms = true
 Whether the test can be used in a CMS (content without HTML head)
 
object $css
 The brickfieldCSS object.
 
int $defaultseverity = tool_brickfield\local\htmlchecker\brickfield_accessibility::BA_TEST_SUGGESTION
 The fallback severity level for all tests.
 
object $dom
 The DOMDocument object.
 
array $imageextensions = array('gif', 'jpg', 'png', 'jpeg', 'tiff', 'svn')
 An array of all the extensions that are images.
 
string $lang = 'en'
 The language domain.
 
mixed $options
 Any additional options passed by htmlchecker.
 
array $path
 The path for the request.
 
array $report = array()
 An array of ReportItem objects.
 
array $strings = array('en' => '')
 An array of translatable strings.
 

Static Protected Member Functions

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

Constructor & Destructor Documentation

◆ __construct()

tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test::__construct ( & $dom,
& $css,
& $path,
$languagedomain = 'en',
$options = null )

The class constructor.

We pass items by reference so we can alter the DOM if necessary

Parameters
object$domThe DOMDocument object
object$cssThe brickfieldCSS object
array$pathThe path of this request
string$languagedomainThe langauge domain to user
mixed$optionsAny additional options passed by htmlchecker.

Member Function Documentation

◆ add_report()

tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test::add_report ( $element = null,
$message = null,
$pass = null,
$state = null,
$manual = null )

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

Parameters
object$elementThe DOMElement object that pertains to this report
string$messageAn additional message to add to the report
bool$passWhether or not this report passed
object$stateExtra information about the error state
bool$manualWhether the report needs a manual check

◆ element_contains_readable_text()

tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test::element_contains_readable_text ( $element)

Returns if there are any printable/readable characters within an element.

This finds both node values or images with alt text.

Parameters
object$elementThe given element to look at
Return values
boolTRUE if contains readable text, FALSE if otherwise

◆ element_has_child()

tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test::element_has_child ( $element,
string $childtag )

Returns true if an element has a child with a given tag name.

Parameters
object$elementA DOMElement object
string$childtagThe tag name of the child to find
Return values
boolTRUE if the element does have a child with the given tag name, otherwise FALSE

◆ get_all_elements()

tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test::get_all_elements ( $tags = null,
string $options = '',
bool $value = true )

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)

Parameters
mixed$tagsEither a single tag name in a string, or an array of tag names
string$optionsThe kind of option to select an element by (see htmlElements)
bool$valueThe value of the above option
Return values
arrayAn array of elements that fit the description

◆ get_all_invalidlinkphrases()

static tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test::get_all_invalidlinkphrases ( )
static

Returns an array of the invalidlinkphrases for all enabled language packs.

Return values
arrayof the invalidlinkphrases for all enabled language packs.

◆ get_all_newwindowphrases()

static tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test::get_all_newwindowphrases ( )
static

Returns an array of the newwindowphrases for all enabled language packs.

Return values
arrayof the newwindowphrases for all enabled language packs.

◆ get_all_phrases()

static tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test::get_all_phrases ( string $stringname)
staticprotected

Returns an array of the relevant phrases for all enabled language packs.

Parameters
string$stringnamethe language string identifier you want get the phrases for.
Return values
arrayof the invalidlinkphrases for all enabled language packs.

◆ get_element_ancestor()

tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test::get_element_ancestor ( $element,
string $ancestortag,
string $limittag = 'body' )

Returns the first ancestor reached of a tag, or false if it hits the document root or a given tag.

Parameters
object$elementA DOMElement object
string$ancestortagThe name of the tag we are looking for
string$limittagWhere to stop searching
Return values
bool

◆ get_elements_by_attribute()

tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test::get_elements_by_attribute ( string $tag,
string $attribute,
bool $unique = false )

Finds all the elements with a given tag name that has an attribute.

Parameters
string$tagThe tag name to search for
string$attributeThe attribute to search on
bool$uniqueWhether we only want one result per attribute
Return values
arrayAn array of DOMElements with the attribute value as the key.

◆ get_next_element()

tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test::get_next_element ( $element)

Returns the next element after the current one.

Parameters
object$elementA DOMElement object
Return values
mixedFALSE if there is no other element, or a DOMElement object

◆ get_parent()

tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test::get_parent ( $element,
string $tagname,
string $limiter )

Returns the parent of an elment that has a given tag Name, but stops the search if it hits the $limiter tag.

Parameters
object$elementThe DOMElement object to search on
string$tagnameThe name of the tag of the parent to find
string$limiterThe tag name of the element to stop searching on regardless of the results (like search for a parent "P" tag of this node but stop if you reach "body")
Return values
mixedFALSE if no parent is found, or the DOMElement object of the found parent

◆ get_path()

tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test::get_path ( $file)

Retrieves the full path for a file.

Parameters
string$fileThe path to a file
Return values
stringThe absolute path to the file.

◆ get_report()

tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test::get_report ( )

Helper method to collect the report from this test.

Some tests do additional cleanup by overriding this method

Return values
arrayAn array of ReportItem objects

◆ get_severity()

tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test::get_severity ( )

Returns the default severity of the test.

Return values
intThe severity level

◆ image_is_animated()

tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test::image_is_animated ( $filename)

Returns if a GIF files is animated or not http://us.php.net/manual/en/function.imagecreatefromgif.php#88005.

Parameters
string$filename
Return values
int

◆ is_text_readable()

static tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test::is_text_readable ( string $text)
static

Assesses whether a string contains any readable text, which is text that contains any characters other than whitespace characters.

Parameters
string$text
Return values
bool

◆ property_is_equal()

tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test::property_is_equal ( $object,
string $property,
$value,
bool $trim = false,
bool $lower = false )

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

Parameters
object$objectThe object too look at
string$propertyThe name of the property
mixed$valueThe value to check against
bool$trimWhether the property value should be trimmed
bool$lowerWhether the property value should be compared on lower case
Return values
bool

◆ translation()

tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test::translation ( )

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 values
mixedThe translation for the object

The documentation for this class was generated from the following file: