diff --git a/_config.php b/_config.php
index 82bcd7d3..98bfb724 100644
--- a/_config.php
+++ b/_config.php
@@ -54,6 +54,8 @@ HtmlEditorConfig::get('cms')->addButtonsToLine(3, 'tablecontrols');
SSReport::register("SideReport", "SideReport_EmptyPages");
SSReport::register("SideReport", "SideReport_RecentlyEdited");
SSReport::register("SideReport", "SideReport_ToDo");
+if (class_exists('Subsite')) SSReport::register('ReportAdmin', 'SubsiteReportWrapper("BrokenLinksReport")',-20);
+else SSReport::register('ReportAdmin', 'BrokenLinksReport',-20);
-?>
\ No newline at end of file
+?>
diff --git a/code/reports/BrokenLinksReport.php b/code/reports/BrokenLinksReport.php
new file mode 100644
index 00000000..ce37e427
--- /dev/null
+++ b/code/reports/BrokenLinksReport.php
@@ -0,0 +1,88 @@
+ClassName, ClassInfo::subclassesFor('RedirectorPage'));
+ $isVirtualPage = in_array($record->ClassName, ClassInfo::subclassesFor('VirtualPage'));
+
+ if ($isVirtualPage) {
+ if ($record->HasBrokenLink) {
+ $reason = "redirector page pointing to non-existant page";
+ $reasonCodes = array("VPBROKENLINK");
+ }
+ } else if ($isRedirectorPage) {
+ if ($record->HasBrokenLink) {
+ $reason = "redirector page pointing to non-existant 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 ($params['Reason'] && !in_array($params['Reason'], $reasonCodes)) continue;
+ $record->BrokenReason = $reason;
+ $returnSet->push($record);
+ }
+ }
+
+ return $returnSet;
+ }
+ function columns() {
+ $fields = array(
+ "Title" => array(
+ "title" => "Title",
+ 'formatting' => '$value'
+ ),
+ "BrokenReason" => array(
+ "title" => "Reason"
+ ),
+ 'AbsoluteLink' => array(
+ 'title' => 'Links',
+ 'formatting' => '$value " . ($AbsoluteLiveLink ? "(live)" : "") . " (draft)'
+ )
+ );
+
+ return $fields;
+ }
+ function parameterFields() {
+ return new FieldSet(
+ new CheckboxField('OnLive', 'Check live 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',
+ ))
+ );
+ }
+}