See Release Notes
Long Term Support Release
Differences Between: [Versions 401 and 402] [Versions 401 and 403]
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; 18 19 use stdClass; 20 21 /** 22 * The base class for a reporter 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 brickfield_accessibility_reporter { 29 /** @var object The current document's DOMDocument */ 30 public $dom; 31 32 /** @var object The current brickfieldaccessibilitycss object */ 33 public $css; 34 35 /** @var array An array of test names and the translation for the problems with it */ 36 public $translation; 37 38 /** @var array A collection of ReportItem objects */ 39 public $report; 40 41 /** @var array The path to the current document */ 42 public $path; 43 44 /** @var object Additional options for this reporter */ 45 public $options; 46 47 /** @var array An array of attributes to search for to turn into absolute paths rather than relative paths */ 48 public $absoluteattributes = ['src', 'href']; 49 50 /** 51 * The class constructor 52 * @param object $dom The current DOMDocument object 53 * @param object $css The current brickfield CSS object 54 * @param object $guideline The current guideline object 55 * @param string $path The current path 56 */ 57 public function __construct(&$dom, &$css, &$guideline, $path = '') { 58 $this->dom = &$dom; 59 $this->css = &$css; 60 $this->path = $path; 61 $this->options = new stdClass; 62 $this->guideline = &$guideline; 63 } 64 65 /** 66 * Sets options for the reporter 67 * @param array $options an array of options 68 */ 69 public function set_options(array $options) { 70 foreach ($options as $key => $value) { 71 $this->options->$key = $value; 72 } 73 } 74 75 /** 76 * Sets the absolute path for an element 77 * @param object $element A DOMElement object to turn into an absolute path 78 */ 79 public function set_absolute_path(&$element) { 80 $attr = false; 81 foreach ($this->absoluteattributes as $attribute) { 82 if ($element->hasAttribute($attribute)) { 83 $attr = $attribute; 84 } 85 } 86 87 if ($attr) { 88 $item = $element->getAttribute($attr); 89 // We are ignoring items with absolute URLs. 90 if (strpos($item, '://') === false) { 91 $item = implode('/', $this->path) . ltrim($item, '/'); 92 $element->setAttribute($attr, $item); 93 } 94 } 95 } 96 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body