diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index c85e50031..339d3159b 100644 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -1067,26 +1067,6 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid Requirements::javascript(CMS_DIR . "/javascript/SitetreeAccess.js"); Requirements::javascript(SAPPHIRE_DIR . '/javascript/UpdateURL.js'); - // Backlink report - if($this->hasMethod('BackLinkTracking')) { - $links = $this->BackLinkTracking(); - - if($links->exists()) { - foreach($links as $link) { - $backlinks[] = "
" . _t('SiteTree.NOBACKLINKS', 'This page hasn\'t been linked to from any pages.') . "
"; - } - - // Status / message // Create a status message for multiple parents if($this->ID && is_numeric($this->ID)) { @@ -1130,6 +1110,32 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid $message .= "NOTE: " . implode("' . _t('NOBACKLINKEDPAGES', 'There are no pages linked to this page.') . '
'); + + // Create a table for showing pages linked to this one + if($this->BackLinkTracking() && $this->BackLinkTracking()->Count() > 0) { + $backLinksNote = new LiteralField('BackLinksNote', '' . _t('SiteTree.PAGESLINKING', 'The following pages link to this page:') . '
'); + $backLinksTable = new TableListField( + 'BackLinkTracking', + 'SiteTree', + array( + 'ID' => 'ID', + 'Title' => 'Title' + ), + 'ChildID = ' . $this->ID, + '', + 'LEFT JOIN SiteTree_LinkTracking ON SiteTree.ID = SiteTree_LinkTracking.SiteTreeID' + ); + $backLinksTable->setFieldFormatting(array( + 'Title' => '$Title' + )); + $backLinksTable->setPermissions(array( + 'show', + 'export' + )); + } + // Lay out the fields $fields = new FieldSet( new TabSet("Root", @@ -1197,8 +1203,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid new TextareaField("ToDo", "") ), $tabReports = new TabSet('Reports', - $tabBacklinks =new Tab('Backlinks', - new LiteralField("Backlinks", $backlinks) + $tabBacklinks = new Tab('Backlinks', + $backLinksNote, + $backLinksTable ) ), $tabAccess = new Tab('Access',