function validate($html) { $v = new Services_W3C_HTMLValidator(); $r = $v->validateFragment($html); if (!$r) { return false; } return array('errors' => $r->errors, 'warnings' => $r->warnings); }
<?php require_once 'Services/W3C/HTMLValidator.php'; $domain = "http://wikidata-dev-repo.wikimedia.de/wiki/"; $urls = array("Special:ItemByTitle/enwiki/Helium:", "Special:CreateItem", "Special:ItemDisambiguation&language=en&label=Helium", "Property:P2", "Special:NewProperty", "Special:EntitiesWithoutLabel", "Special:SetLabel"); $whiteList = array("Bad value ResourceLoaderDynamicStyles for attribute name on element meta: Keyword resourceloaderdynamicstyles is not registered."); $v = new Services_W3C_HTMLValidator(); function checkArrayValues($text) { global $whiteList; foreach ($whiteList as $key => $value) { if (strpos($value, $text) === 0) { return true; } } return false; } $validation_page_header = '<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Wikidata HTML Validation</title> </head> <body> <a href="http://meta.wikimedia.org/wiki/Wikidata"><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/6/66/Wikidata-logo-en.svg/160px-Wikidata-logo-en.svg.png" /></a> <h2>Wikidata HTML Validation</h2> <p> This page lists all HTML validation errors in Wikidata found by the <a href="http://validator.w3.org">W3C Markup Validation Service</a>.</p> '; $validation_page_content = ''; $validation_page_footer = ' </body>
/** * @group w3c * @group admin * @group settings_page * @group meta_box * @covers Fergcorp_Countdown_Timer::example_display_meta_box */ public function test_example_display_meta_box() { ob_start(); $this->plugin->example_display_meta_box(); $buffer = ob_get_clean(); require_once 'Services/W3C/HTMLValidator.php'; $v = new Services_W3C_HTMLValidator(); $v->setOptions(array("doctype" => $docType)); $r = $v->validateFragment($this->htmlStart . $buffer . $this->htmlEnd); //print $this->htmlStart.$buffer.$this->htmlEnd; //var_dump($r); $this->assertTrue($r->isValid(), $this->htmlStart . $buffer . $this->htmlEnd); sleep(1); }
private function initW3c() { if (!$this->w3cCalled) { $this->w3cCalled = true; $v = new Services_W3C_HTMLValidator(); $r = $v->validate($this->url); if ($r !== false) { $this->lastW3Cerrors = $r->errors; $this->lastW3Cwarnings = $r->warnings; $this->w3cValid = $r->isValid(); } else { throw new Exception("Request to W3C failed."); } } }