ClassName, ClassInfo::subclassesFor('RedirectorPage'));
$isVirtualPage = in_array($record->ClassName, ClassInfo::subclassesFor('VirtualPage'));
if ($isVirtualPage) {
if ($record->HasBrokenLink) {
$reason = "virtual page pointing to non-existent page";
$reasonCodes = array("VPBROKENLINK");
}
} else if ($isRedirectorPage) {
if ($record->HasBrokenLink) {
$reason = "redirector page pointing to non-existent page";
$reasonCodes = array("RPBROKENLINK");
}
} else {
if ($record->HasBrokenLink && $record->HasBrokenFile) {
$reason = "has broken link and file";
$reasonCodes = array("BROKENFILE", "BROKENLINK");
} else if ($record->HasBrokenLink && !$record->HasBrokenFile) {
$reason = "has broken link";
$reasonCodes = array("BROKENLINK");
} else if (!$record->HasBrokenLink && $record->HasBrokenFile) {
$reason = "has broken file";
$reasonCodes = array("BROKENFILE");
}
}
if ($reason) {
if (isset($params['Reason']) && $params['Reason'] && !in_array($params['Reason'], $reasonCodes)) continue;
$record->BrokenReason = $reason;
$returnSet->push($record);
}
}
if($sortBrokenReason) $returnSet->sort('BrokenReason', $direction);
return $returnSet;
}
function columns() {
$fields = array(
"Title" => array(
"title" => "Page name",
'formatting' => '$value'
),
"LastEdited" => array(
"title" => "Date ".(isset($_REQUEST['CheckSite']) && ($_REQUEST['CheckSite'] == 'Draft')?'last modified':'published'),
'casting' => 'SSDatetime->Full'
),
"BrokenReason" => array(
"title" => "Problem type"
),
'AbsoluteLink' => array(
'title' => 'URL',
'formatting' => '$value " . ($AbsoluteLiveLink ? "(live)" : "") . " (draft)'
)
);
return $fields;
}
function parameterFields() {
return new FieldSet(
new DropdownField('CheckSite', 'Check site', array(
'Published' => 'Published Site',
'Draft' => 'Draft Site'
)),
new DropdownField('Reason', 'Problem to check', array(
'' => 'Any',
'BROKENFILE' => 'Broken file',
'BROKENLINK' => 'Broken link',
'VPBROKENLINK' => 'Virtual page pointing to invalid source',
'RPBROKENLINK' => 'Redirector page pointing to invalid destination',
))
);
}
}