2014-07-28 01:23:33 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Content side-report listing pages with external broken links
|
|
|
|
* @package externallinks
|
|
|
|
* @subpackage content
|
|
|
|
*/
|
|
|
|
|
|
|
|
class BrokenExternalLinksReport extends SS_Report {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the report title
|
2014-08-07 03:56:15 +02:00
|
|
|
*
|
2014-07-28 01:23:33 +02:00
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function title() {
|
2014-08-07 03:56:15 +02:00
|
|
|
return _t('ExternalBrokenLinksReport.EXTERNALBROKENLINKS', "External broken links report");
|
2014-07-28 01:23:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function columns() {
|
2014-08-07 03:56:15 +02:00
|
|
|
return array(
|
|
|
|
"Created" => "Checked",
|
|
|
|
'Link' => array(
|
|
|
|
'title' => 'External Link',
|
|
|
|
'formatting' => function($value, $item) {
|
|
|
|
return sprintf(
|
|
|
|
'<a target="_blank" href="%s">%s</a>',
|
|
|
|
Convert::raw2att($item->Link),
|
|
|
|
Convert::raw2xml($item->Link)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
),
|
2014-08-13 00:20:39 +02:00
|
|
|
'HTTPCodeDescription' => 'HTTP Error Code',
|
2014-08-07 03:56:15 +02:00
|
|
|
"Title" => array(
|
|
|
|
"title" => 'Page link is on',
|
|
|
|
'formatting' => function($value, $item) {
|
|
|
|
$page = $item->Page();
|
2020-04-13 23:16:23 +02:00
|
|
|
|
|
|
|
if ($page) {
|
|
|
|
return sprintf(
|
|
|
|
'<a href="%s">%s</a>',
|
|
|
|
Convert::raw2att($page->CMSEditLink()),
|
|
|
|
Convert::raw2xml($page->Title)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return sprintf(
|
|
|
|
'%s',
|
|
|
|
$item->Track()->PageID
|
|
|
|
);
|
|
|
|
}
|
2014-08-07 03:56:15 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|
2014-07-28 01:23:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Alias of columns(), to support the export to csv action
|
|
|
|
* in {@link GridFieldExportButton} generateExportFileData method.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getColumns() {
|
|
|
|
return $this->columns();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function sourceRecords() {
|
2014-08-07 03:56:15 +02:00
|
|
|
$track = BrokenExternalPageTrackStatus::get_latest();
|
|
|
|
if ($track) return $track->BrokenLinks();
|
|
|
|
return new ArrayList();
|
2014-07-28 01:23:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getCMSFields() {
|
2014-07-30 02:34:39 +02:00
|
|
|
Requirements::javascript('externallinks/javascript/BrokenExternalLinksReport.js');
|
2014-07-28 01:23:33 +02:00
|
|
|
$fields = parent::getCMSFields();
|
2014-07-30 02:34:39 +02:00
|
|
|
|
2014-07-31 06:49:20 +02:00
|
|
|
$reportResultSpan = '</ br></ br><h3 id="ReportHolder"></h3>';
|
|
|
|
$reportResult = new LiteralField('ResultTitle', $reportResultSpan);
|
|
|
|
$fields->push($reportResult);
|
|
|
|
|
|
|
|
$button = '<button id="externalLinksReport" type="button">%s</button>';
|
|
|
|
$runReportButton = new LiteralField(
|
|
|
|
'runReport',
|
|
|
|
sprintf(
|
|
|
|
$button,
|
|
|
|
_t('ExternalBrokenLinksReport.RUNREPORT', 'Create new report')
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$fields->push($runReportButton);
|
|
|
|
|
2014-07-28 01:23:33 +02:00
|
|
|
return $fields;
|
|
|
|
}
|
|
|
|
}
|