NEW: Adding back in the Broken links model no model admin this time though

This commit is contained in:
Kirk Mayo 2014-07-24 14:50:14 +12:00
parent 72dc652ecd
commit a3c693189b
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,28 @@
<?php
class BrokenExternalLinks extends DataObject {
private static $db = array(
'Link' => 'Varchar(2083)', // 2083 is the maximum length of a URL in Internet Explorer.
'HTTPCode' =>'Int'
);
private static $has_one = array(
'Page' => 'Page'
);
public static $summary_fields = array(
'Page.Title' => 'Page',
'HTTPCode' => 'HTTP Code',
'Created' => 'Created'
);
public static $searchable_fields = array(
'HTTPCode' => array('title' => 'HTTP Code')
);
function canEdit($member = false) {
return false;
}
}

View File

@ -60,6 +60,12 @@ class CheckExternalLinks extends BuildTask {
if (($httpCode < 200 || $httpCode > 302)
|| ($href == '' || $href[0] == '/'))
{
$brokenLink = new BrokenExternalLinks();
$brokenLink->PageID = $page->ID;
$brokenLink->Link = $href;
$brokenLink->HTTPCode = $httpCode;
$brokenLink->write();
// set the broken link class
$class = ($class && stripos($class, 'ss-broken')) ?
$class . ' ss-broken' : 'ss-broken';