Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 14... Línea 14...
14
// You should have received a copy of the GNU General Public License
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/>.
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea 16... Línea 16...
16
 
16
 
Línea -... Línea 17...
-
 
17
namespace tool_brickfield\local\htmlchecker\common\checks;
17
namespace tool_brickfield\local\htmlchecker\common\checks;
18
 
Línea 18... Línea 19...
18
 
19
use core_text;
19
use tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test;
20
use tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test;
20
 
21
 
Línea 27... Línea 28...
27
 * @package    tool_brickfield
28
 * @package    tool_brickfield
28
 * @copyright  2020 onward: Brickfield Education Labs, www.brickfield.ie
29
 * @copyright  2020 onward: Brickfield Education Labs, www.brickfield.ie
29
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30
 */
31
 */
31
class img_alt_is_too_long extends brickfield_accessibility_test {
32
class img_alt_is_too_long extends brickfield_accessibility_test {
32
 
-
 
33
    /** @var int The default severity code for this test. */
-
 
34
    public $defaultseverity = \tool_brickfield\local\htmlchecker\brickfield_accessibility::BA_TEST_SEVERE;
-
 
35
 
-
 
36
    /**
33
    /**
37
     * The main check function. This is called by the parent class to actually check content.
34
     * The main check function. This is called by the parent class to actually check content.
38
     */
35
     */
39
    public function check(): void {
36
    public function check(): void {
40
        global $alttextlengthlimit;
37
        global $alttextlengthlimit;
Línea 41... Línea 38...
41
 
38
 
42
        foreach ($this->get_all_elements('img') as $img) {
39
        foreach ($this->get_all_elements('img') as $img) {
43
            $alttextlengthlimit = 125;
40
            $alttextlengthlimit = 750;
44
            if ($img->hasAttribute('alt') && strlen($img->getAttribute('alt')) > $alttextlengthlimit) {
41
            if ($img->hasAttribute('alt') && core_text::strlen($img->getAttribute('alt')) > $alttextlengthlimit) {
45
                $this->add_report($img);
42
                $this->add_report($img);
46
            }
43
            }
47
        }
44
        }
48
    }
45
    }