1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 namespace tool_brickfield\local\htmlchecker\common; 18 19 /** 20 * Base class for test dealing with WAI ERT color contrast for the document 21 * 22 * Because a lot of the tests deal with text, vlink, alink, etc. 23 * 24 * @package tool_brickfield 25 * @copyright 2020 onward: Brickfield Education Labs, www.brickfield.ie 26 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 27 */ 28 class body_wai_ert_color_contrast extends brickfield_accessibility_color_test { 29 /** @var string The attribute to check for the background color of the <body> tag */ 30 public $background = 'bgcolor'; 31 32 /** @var string The attribute to check for the foreground color of the <body> tag */ 33 public $foreground = 'text'; 34 35 /** 36 * Compares the WAI ERT contrast on the given color attributes of the <body> tag 37 */ 38 public function check() { 39 $body = $this->get_all_elements('body'); 40 if (!$body) { 41 return false; 42 } 43 $body = $body[0]; 44 if ($body->hasAttribute($this->foreground) && $body->hasAttribute($this->background)) { 45 if ($this->get_wai_ert_contrast($body->getAttribute($this->foreground), $body->getAttribute($this->background)) < 500) { 46 $this->add_report(null, null, false); 47 } else if ($this->get_wai_ert_brightness($body->getAttribute($this->foreground), 48 $body->getAttribute($this->background)) < 125) { 49 $this->add_report(null, null, false); 50 } 51 } 52 } 53 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body