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 DOMDocument; 20 21 /** 22 * A report item. There is one per issue with the report 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_report_item { 29 30 /** @var object The DOMElement that the report item refers to (if any) */ 31 public $element; 32 33 /** @var string The error message */ 34 public $message; 35 36 /** @var bool Whether the check needs to be manually verified */ 37 public $manual; 38 39 /** @var bool For document-level tests, this says whether the test passed or not */ 40 public $pass; 41 42 /** @var object For issues with more than two possible states, this contains information about the state */ 43 public $state; 44 45 /** 46 * Returns the line number of the report item. Unfortunately we can't use getLineNo 47 * if we are before PHP 5.3, so if not we try to get the line number through a more 48 * circuitous way. 49 */ 50 public function get_line() { 51 if (is_object($this->element) && method_exists($this->element, 'getLineNo')) { 52 return $this->element->getLineNo(); 53 } 54 return 0; 55 } 56 57 /** 58 * Returns the current element in plain HTML form 59 * @param array $extraattributes An array of extra attributes to add to the element 60 * @return string An HTML string version of the provided DOMElement object 61 */ 62 public function get_html(array $extraattributes = []): string { 63 if (!$this->element) { 64 return ''; 65 } 66 67 $resultdom = new DOMDocument(); 68 $resultdom->formatOutput = true; 69 $resultdom->preserveWhiteSpace = false; 70 71 try { 72 $resultelement = $resultdom->importNode($this->element, true); 73 } catch (Exception $e) { 74 return false; 75 } 76 77 foreach ($this->element->attributes as $attribute) { 78 if ($attribute->name != 'brickfield_accessibility_style_index') { 79 $resultelement->setAttribute($attribute->name, $attribute->value); 80 } 81 } 82 83 foreach ($extraattributes as $name => $value) { 84 $resultelement->setAttribute($name, $value); 85 } 86 87 @$resultdom->appendChild($resultelement); 88 return @$resultdom->saveHTML(); 89 } 90 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body