Differences Between: [Versions 311 and 402] [Versions 400 and 402] [Versions 401 and 402]
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 /** @var int the line number of the report item */ 46 public $line; 47 48 /** 49 * Returns the line number of the report item. Unfortunately we can't use getLineNo 50 * if we are before PHP 5.3, so if not we try to get the line number through a more 51 * circuitous way. 52 */ 53 public function get_line() { 54 if (is_object($this->element) && method_exists($this->element, 'getLineNo')) { 55 return $this->element->getLineNo(); 56 } 57 return 0; 58 } 59 60 /** 61 * Returns the current element in plain HTML form 62 * @param array $extraattributes An array of extra attributes to add to the element 63 * @return string An HTML string version of the provided DOMElement object 64 */ 65 public function get_html(array $extraattributes = []): string { 66 if (!$this->element) { 67 return ''; 68 } 69 70 $resultdom = new DOMDocument(); 71 $resultdom->formatOutput = true; 72 $resultdom->preserveWhiteSpace = false; 73 74 try { 75 $resultelement = $resultdom->importNode($this->element, true); 76 } catch (Exception $e) { 77 return false; 78 } 79 80 foreach ($this->element->attributes as $attribute) { 81 if ($attribute->name != 'brickfield_accessibility_style_index') { 82 $resultelement->setAttribute($attribute->name, $attribute->value); 83 } 84 } 85 86 foreach ($extraattributes as $name => $value) { 87 $resultelement->setAttribute($name, $value); 88 } 89 90 @$resultdom->appendChild($resultelement); 91 return @$resultdom->saveHTML(); 92 } 93 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body