Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
tool_brickfield\local\htmlchecker\brickfield_accessibility Class Reference

Public Member Functions

 __construct (string $value='', string $guideline='wcag2aaa', string $type='string', string $reporter='static', string $domain='en')
 The class constructor.
 
 add_css (string $css)
 Helper method to add an additional CSS file.
 
 cleanup ()
 A general cleanup function which just does some memory cleanup by unsetting the particularly large local vars.
 
 get_absolute_path (string $absolute, string $relative)
 Returns an absolute path from a relative one.
 
 get_base_from_file (string $file)
 Retrieves the absolute path to a file.
 
 get_css_object ()
 Loads the brickfield_accessibility_css object.
 
 get_error (string $error)
 Retrives a single error from the current reporter.
 
 get_report (array $options=[])
 Returns a formatted report from the current reporter.
 
 get_test (string $test)
 Runs one test on the current DOMDocument.
 
 get_test_severity (string $test)
 Retrieves the default severity of a test.
 
 is_valid ()
 Checks that the DOM object is valid or not.
 
 load_reporter (array $options=[])
 A local method to load the required file for a reporter and set it for the current object.
 
 prepare_base_url (string $value, string $type)
 Formats the base URL for either a file or uri request.
 
 prepare_dom ()
 Prepares the DOMDocument object for brickfield_accessibility.
 
 prepare_value ()
 If the CMS mode options are set, then we remove some items front the HTML value before sending it back.
 
 run_check ($options=null)
 Starts running automated checks.
 
 set_option ($variable, $value=null)
 Set global predefined options for brickfield_accessibility.
 
 set_uri (string $uri)
 Sets the URI if this is for a string or to change where Will look for resources like CSS files.
 

Static Public Member Functions

static match_urls (string $text, string $href)
 Determines if the link text is the same as the link URL, without necessarily being an exact match.
 

Public Attributes

string $baseurl
 The base URL for any request of type URI.
 
object $css
 The brickfieldCSS object.
 
array $cssfiles = []
 An array of additional CSS files to load (useful for CMS content)
 
object $dom
 The central DOMDocument object.
 
string $domain
 The translation domain of the current library.
 
object $guideline
 The central guideline object.
 
string $guidelinename = 'wcag'
 The name of the guideline.
 
bool $isvalid = true
 An indicator if the DOMDocument loaded.
 
array $options
 An array of additional options.
 
array $path = []
 An array of the current file or URI path.
 
object $reporter
 A reporting object.
 
string $reportername = 'static'
 The name of the reporter to use.
 
string $type
 The type of request this is (either 'string', 'file', or 'uri'.
 
string $uri = ''
 The base URI of the current request (used to rebuild page if necessary)
 
string $value
 The value of the request.
 
string const BA_ERROR_TAG = 'bferror'
 Tag identifier to enclose all error HTML fragments in.
 
int const BA_TEST_MODERATE = 2
 Failure level moderate.
 
int const BA_TEST_SEVERE = 1
 Failure level severe.
 
int const BA_TEST_SUGGESTION = 3
 Failure level seggestion.
 

Constructor & Destructor Documentation

◆ __construct()

tool_brickfield\local\htmlchecker\brickfield_accessibility::__construct ( string $value = '',
string $guideline = 'wcag2aaa',
string $type = 'string',
string $reporter = 'static',
string $domain = 'en' )

The class constructor.

Parameters
string$valueEither the HTML string to check or the file/uri of the request
string$guidelineThe name of the guideline
string$typeThe type of the request (either file, uri, or string)
string$reporterThe name of the reporter to use
string$domainThe domain of the translation language to use

Member Function Documentation

◆ add_css()

tool_brickfield\local\htmlchecker\brickfield_accessibility::add_css ( string $css)

Helper method to add an additional CSS file.

Parameters
string$cssThe URI or file path to a CSS file

◆ get_absolute_path()

tool_brickfield\local\htmlchecker\brickfield_accessibility::get_absolute_path ( string $absolute,
string $relative )

Returns an absolute path from a relative one.

Parameters
string$absoluteThe absolute URL
string$relativeThe relative path
Return values
stringA new path

◆ get_base_from_file()

tool_brickfield\local\htmlchecker\brickfield_accessibility::get_base_from_file ( string $file)

Retrieves the absolute path to a file.

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

◆ get_error()

tool_brickfield\local\htmlchecker\brickfield_accessibility::get_error ( string $error)

Retrives a single error from the current reporter.

Parameters
string$errorThe error key
Return values
objectA ReportItem object

◆ get_report()

tool_brickfield\local\htmlchecker\brickfield_accessibility::get_report ( array $options = [])

Returns a formatted report from the current reporter.

Parameters
array$optionsAn array of all the options
Return values
mixedSee the documentation on your reporter's getReport method.

◆ get_test()

tool_brickfield\local\htmlchecker\brickfield_accessibility::get_test ( string $test)

Runs one test on the current DOMDocument.

Parameters
string$testThe name of the test to run
Return values
bool|arrayThe ReportItem returned from the test

◆ get_test_severity()

tool_brickfield\local\htmlchecker\brickfield_accessibility::get_test_severity ( string $test)

Retrieves the default severity of a test.

Parameters
string$testThe name of the test to run
Return values
objectThe severity level of the test

◆ is_valid()

tool_brickfield\local\htmlchecker\brickfield_accessibility::is_valid ( )

Checks that the DOM object is valid or not.

Return values
boolWhether the DOMDocument is valid

◆ load_reporter()

tool_brickfield\local\htmlchecker\brickfield_accessibility::load_reporter ( array $options = [])

A local method to load the required file for a reporter and set it for the current object.

Parameters
array$optionsAn array of options for the reporter

◆ match_urls()

static tool_brickfield\local\htmlchecker\brickfield_accessibility::match_urls ( string $text,
string $href )
static

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'.

Parameters
string$text
string$href
Return values
bool

◆ prepare_base_url()

tool_brickfield\local\htmlchecker\brickfield_accessibility::prepare_base_url ( string $value,
string $type )

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.

Parameters
string$valueThe path value
string$typeThe type of request

◆ prepare_dom()

tool_brickfield\local\htmlchecker\brickfield_accessibility::prepare_dom ( )

Prepares the DOMDocument object for brickfield_accessibility.

It loads based on the file type declaration and first scrubs the value using prepareValue().

◆ run_check()

tool_brickfield\local\htmlchecker\brickfield_accessibility::run_check ( $options = null)

Starts running automated checks.

Loads the CSS file parser and the guideline object.

Parameters
null$options
Return values
bool

◆ set_option()

tool_brickfield\local\htmlchecker\brickfield_accessibility::set_option ( $variable,
$value = null )

Set global predefined options for brickfield_accessibility.

First we check that the array key has been defined.

Parameters
mixed$variableEither an array of values, or a variable name of the option
mixed$valueIf this is a single option, the value of the option

◆ set_uri()

tool_brickfield\local\htmlchecker\brickfield_accessibility::set_uri ( string $uri)

Sets the URI if this is for a string or to change where Will look for resources like CSS files.

Parameters
string$uriThe URI to set

Member Data Documentation

◆ $isvalid

bool tool_brickfield\local\htmlchecker\brickfield_accessibility::$isvalid = true

An indicator if the DOMDocument loaded.

If not, this means that the HTML given to it was so munged it wouldn't even load.

◆ $options

array tool_brickfield\local\htmlchecker\brickfield_accessibility::$options
Initial value:
= [
'cms_mode' => false,
'start_element' => 0,
'end_element' => 0,
'cms_template' => []
]

An array of additional options.

◆ $value

string tool_brickfield\local\htmlchecker\brickfield_accessibility::$value

The value of the request.

Either HTML, a URI, or the path to a file


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