Skip to content

Commit

Permalink
NEW: Adding back in the Broken links model no model admin this time t…
Browse files Browse the repository at this point in the history
…hough
  • Loading branch information
kmayo-ss committed Jul 24, 2014
1 parent 72dc652 commit a3c6931
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
28 changes: 28 additions & 0 deletions code/model/BrokenExternalLinks.php
Original file line number Diff line number Diff line change
@@ -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;
}

}
6 changes: 6 additions & 0 deletions code/tasks/CheckExternalLinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ function run($request) {
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';
Expand Down

0 comments on commit a3c6931

Please sign in to comment.