Skip to content
Snippets Groups Projects
Commit 3bea1ab6 authored by Brett Bieber's avatar Brett Bieber
Browse files

Allow you to validate just the invalid pages.

parent 42010697
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,23 @@ class UNL_WDN_Assessment ...@@ -11,6 +11,23 @@ class UNL_WDN_Assessment
$this->db = $db; $this->db = $db;
} }
function checkInvalid()
{
$plogger = new UNL_WDN_Assessment_PageLogger($this);
$vlogger = new UNL_WDN_Assessment_ValidateInvalidLogger($this);
$downloader = new Spider_Downloader();
$parser = new Spider_Parser();
$spider = new Spider($downloader, $parser);
$spider->addLogger($plogger);
$spider->addLogger($vlogger);
$spider->addUriFilter('Spider_AnchorFilter');
$spider->addUriFilter('Spider_MailtoFilter');
$spider->addUriFilter('UNL_WDN_Assessment_FileExtensionFilter');
$spider->spider($this->baseUri);
}
function reValidate() function reValidate()
{ {
$this->removeEntries(); $this->removeEntries();
...@@ -45,13 +62,13 @@ class UNL_WDN_Assessment ...@@ -45,13 +62,13 @@ class UNL_WDN_Assessment
function setValidationResult($uri, $result) function setValidationResult($uri, $result)
{ {
$sth = $this->db->prepare('UPDATE assessment SET valid = ? WHERE baseurl = ? AND url = ?;'); $sth = $this->db->prepare('UPDATE assessment SET valid = ?, timestamp = ? WHERE baseurl = ? AND url = ?;');
if ($result) { if ($result) {
$result = 'true'; $result = 'true';
} else { } else {
$result = 'false'; $result = 'false';
} }
$sth->execute(array($result, $this->baseUri, $uri)); $sth->execute(array($result, date('Y-m-d H:i:s'), $this->baseUri, $uri));
} }
function getSubPages() function getSubPages()
...@@ -60,4 +77,15 @@ class UNL_WDN_Assessment ...@@ -60,4 +77,15 @@ class UNL_WDN_Assessment
$sth->execute(array($this->baseUri)); $sth->execute(array($this->baseUri));
return $sth->fetchAll(); return $sth->fetchAll();
} }
function pageWasValid($uri)
{
$sth = $this->db->prepare('SELECT valid FROM assessment WHERE baseurl = ? AND url = ?;');
$sth->execute(array($this->baseUri, $uri));
$result = $sth->fetch();
if ($result['valid'] == 'true') {
return true;
}
return false;
}
} }
\ No newline at end of file
<?php
class UNL_WDN_Assessment_ValidateInvalidLogger extends UNL_WDN_Assessment_ValidationLogger
{
function log($uri, DOMXPath $xpath)
{
if (!$this->assessment->pageWasValid($uri)) {
parent::log($uri, $xpath);
}
}
}
\ No newline at end of file
...@@ -9,14 +9,17 @@ if (isset($_GET['uri'])) { ...@@ -9,14 +9,17 @@ if (isset($_GET['uri'])) {
$assessment = new UNL_WDN_Assessment($uri, $db); $assessment = new UNL_WDN_Assessment($uri, $db);
if (isset($_GET['revalidate'])) { if (isset($_GET['revalidate'])) {
$assessment->reValidate(); $assessment->reValidate();
} elseif (isset($_GET['invalid'])) {
$assessment->checkInvalid();
} }
} }
?> ?>
<h1>Welcome to the batch validator</h1> <h1>Welcome to the new batch validator</h1>
<form method="GET" action=""> <form method="GET" action="">
<input type="text" name="uri" value="<?php echo $uri; ?>" /> <input type="text" name="uri" value="<?php echo $uri; ?>" />
Revalidate all? <input type="checkbox" name="revalidate" /> Revalidate all? <input type="checkbox" name="revalidate" />
Revalidate invalid? <input type="checkbox" name="invalid" />
<input type="submit" name="submit" /></form> <input type="submit" name="submit" /></form>
<?php <?php
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment