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 {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Columns in the report
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @config
|
|
|
|
*/
|
|
|
|
private static $columns = array(
|
|
|
|
'Created' => 'Checked',
|
|
|
|
'Link' => 'External Link',
|
|
|
|
'HTTPCode' => 'HTTP Error Code',
|
|
|
|
'PageLink' => array(
|
|
|
|
'title' => 'Page link is on',
|
|
|
|
'link' => true
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
public function init() {
|
|
|
|
parent::init();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the report title
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function title() {
|
|
|
|
return _t('ExternalBrokenLinksReport.EXTERNALBROKENLINKS',"External broken links report");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the column names of the report
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function columns() {
|
|
|
|
return self::$columns;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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() {
|
|
|
|
$returnSet = new ArrayList();
|
2014-07-28 02:39:19 +02:00
|
|
|
$links = BrokenExternalLink::get();
|
2014-07-28 01:23:33 +02:00
|
|
|
foreach ($links as $link) {
|
|
|
|
$link->PageLink = $link->Page()->Title;
|
|
|
|
$returnSet->push($link);
|
|
|
|
}
|
|
|
|
return $returnSet;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|