Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 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\reporters; 18 19 use tool_brickfield\local\htmlchecker\brickfield_accessibility_reporter; 20 21 /** 22 * Returns an ATOM feed of all the issues - useful to run this as a web service 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 report_xml extends brickfield_accessibility_reporter { 29 30 /** 31 * Generates an ATOM feed of accessibility problems 32 * @return string|null A nested array of tests and problems with Report Item objects 33 */ 34 public function get_report() { 35 $output = "<?xml version='1.0' encoding='utf-8'?> 36 <feed xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 37 xsi:htmlchecker='https://www.brickfield.ie/htmlcheckerxml/2020.xsd'>"; 38 $results = $this->guideline->getReport(); 39 if (!is_array($results)) { 40 return null; 41 } 42 foreach ($results as $testname => $test) { 43 $translation = $this->guideline->get_translation($testname); 44 $output .= "\n\t<htmlchecker:test htmlchecker:testname='$testname' htmlchecker:severity='". 45 $this->guideline->get_severity($testname) ."'> 46 <updated>". date('c') ."</updated>"; 47 $output .= "\n\t<htmlchecker:title>". $translation['title'] ."</htmlchecker:title>"; 48 $output .= "\n\t<htmlchecker:description><![CDATA[". $translation['description'] ."]]></htmlchecker:description>"; 49 $output .= "\n\t<htmlchecker:problems>"; 50 foreach ($test as $problem) { 51 if (is_object($problem)) { 52 $output .= "\n\t<htmlchecker:entities><![CDATA[" . htmlentities($problem->get_html()) . 53 "]]></htmlchecker:entities>"; 54 $output .= "\n\t<htmlchecker:line>". $problem->get_line() ."</htmlchecker:line>"; 55 if ($problem->message) { 56 $output .= "\n\t<htmlchecker:message>$problem->message</htmlchecker:message>"; 57 } 58 $output .= "\n\t<htmlchecker:pass>$problem->pass</htmlchecker:pass>"; 59 } 60 } 61 $output .= "\n\t</htmlchecker:problems>"; 62 $output .= "</htmlchecker:test>"; 63 } 64 $output .= "</feed>"; 65 return $output; 66 } 67 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body