ClassName, ClassInfo::subclassesFor('RedirectorPage'));
$isVirtualPage = in_array($record->ClassName, ClassInfo::subclassesFor('VirtualPage'));
if ($isVirtualPage) {
if ($record->HasBrokenLink) {
$reason = _t('BrokenLinksReport.VirtualPageNonExistent', "virtual page pointing to non-existent page");
$reasonCodes = array("VPBROKENLINK");
}
} else if ($isRedirectorPage) {
if ($record->HasBrokenLink) {
$reason = _t('BrokenLinksReport.RedirectorNonExistent', "redirector page pointing to non-existent page");
$reasonCodes = array("RPBROKENLINK");
}
} else {
if ($record->HasBrokenLink && $record->HasBrokenFile) {
$reason = _t('BrokenLinksReport.HasBrokenLinkAndFile', "has broken link and file");
$reasonCodes = array("BROKENFILE", "BROKENLINK");
} else if ($record->HasBrokenLink && !$record->HasBrokenFile) {
$reason = _t('BrokenLinksReport.HasBrokenLink', "has broken link");
$reasonCodes = array("BROKENLINK");
} else if (!$record->HasBrokenLink && $record->HasBrokenFile) {
$reason = _t('BrokenLinksReport.HasBrokenFile', "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 = $returnSet->sort('BrokenReason', $direction);
return $returnSet;
}
function columns() {
if(isset($_REQUEST['CheckSite']) && $_REQUEST['CheckSite'] == 'Draft') {
$dateTitle = _t('BrokenLinksReport.ColumnDateLastModified', 'Date last modified');
} else {
$dateTitle = _t('BrokenLinksReport.ColumnDateLastPublished', 'Date last published');
}
$linkBase = singleton('CMSPageEditController')->Link('show') . '/';
$fields = array(
"Title" => array(
"title" => _t('BrokenLinksReport.PageName', 'Page name'),
'formatting' => sprintf(
'$value',
_t('BrokenLinksReport.HoverTitleEditPage', 'Edit page')
)
),
"LastEdited" => array(
"title" => $dateTitle,
'casting' => 'SS_Datetime->Full'
),
"BrokenReason" => array(
"title" => _t('BrokenLinksReport.ColumnProblemType', "Problem type")
),
'AbsoluteLink' => array(
'title' => _t('BrokenLinksReport.ColumnURL', 'URL'),
'formatting' => function($value, $item) {
$liveLink = $item->AbsoluteLiveLink;
$stageLink = $item->AbsoluteLink();
return sprintf('%s %s',
$stageLink,
$liveLink ? $liveLink : $stageLink . '?stage=Stage',
$liveLink ? '(live)' : '(draft)'
);
}
)
);
return $fields;
}
function parameterFields() {
return new FieldList(
new DropdownField('CheckSite', _t('BrokenLinksReport.CheckSite','Check site'), array(
'Published' => _t('BrokenLinksReport.CheckSiteDropdownPublished', 'Published Site'),
'Draft' => _t('BrokenLinksReport.CheckSiteDropdownDraft', 'Draft Site')
)),
new DropdownField(
'Reason',
_t('BrokenLinksReport.ReasonDropdown', 'Problem to check'),
array(
'' => _t('BrokenLinksReport.Any', 'Any'),
'BROKENFILE' => _t('BrokenLinksReport.ReasonDropdownBROKENFILE', 'Broken file'),
'BROKENLINK' => _t('BrokenLinksReport.ReasonDropdownBROKENLINK', 'Broken link'),
'VPBROKENLINK' => _t('BrokenLinksReport.ReasonDropdownVPBROKENLINK', 'Virtual page pointing to non-existent page'),
'RPBROKENLINK' => _t('BrokenLinksReport.ReasonDropdownRPBROKENLINK', 'Redirector page pointing to non-existent page'),
)
)
);
}
}