move BackLinkHTMLList to template

This commit is contained in:
Christopher Joe 2016-09-13 10:47:02 +12:00
parent fba54c8ae8
commit 4b3f4ba01c
3 changed files with 33 additions and 18 deletions

View File

@ -10,6 +10,7 @@ use SilverStripe\ORM\DataExtension;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\ManyManyList;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\View\SSViewer;
use Subsite;
/**
@ -57,25 +58,9 @@ class SiteTreeFileExtension extends DataExtension {
* @return string
*/
public function BackLinkHTMLList() {
$html = '<em>' . _t(
'SiteTreeFileExtension.BACKLINK_LIST_DESCRIPTION',
'This list shows all pages where the file has been added through a WYSIWYG editor.'
) . '</em>';
$viewer = new SSViewer(["type" => "Includes", __CLASS__ . "_description"]);
$html .= '<ul>';
foreach ($this->BackLinkTracking() as $backLink) {
// Add the page link and CMS link
$html .= sprintf(
'<li><a href="%s" target="_blank">%s</a> &ndash; <a href="%s">%s</a></li>',
Convert::raw2att($backLink->Link()),
Convert::raw2xml($backLink->MenuTitle),
Convert::raw2att($backLink->CMSEditLink()),
_t('SiteTreeFileExtension.EDIT', 'Edit')
);
}
$html .= '</ul>';
return $html;
return $viewer->process($this->owner)->forTemplate();
}
/**

View File

@ -421,6 +421,9 @@ en:
many_many_ImageTracking: 'Image Tracking'
many_many_LinkTracking: 'Link Tracking'
SiteTreeFileExtension:
TITLE_INDEX: '#'
TITLE_USED_ON: 'Used On'
TITLE_TYPE: 'Type'
BACKLINK_LIST_DESCRIPTION: 'This list shows all pages where the file has been added through a WYSIWYG editor.'
EDIT: Edit
SiteTreeURLSegmentField:

View File

@ -0,0 +1,27 @@
<% if $BackLinkTracking %>
<table class="table">
<thead>
<tr>
<th><% _t('SiteTreeFileExtension.TITLE_INDEX', '#') %></th>
<th><% _t('SiteTreeFileExtension.TITLE_USED_ON', 'Used on') %></th>
<th><% _t('SiteTreeFileExtension.TITLE_TYPE', 'Type') %></th>
</tr>
</thead>
<tbody>
<% loop $BackLinkTracking %>
<tr>
<th>$Pos</th>
<td><a href="$CMSEditLink">$MenuTitle</a></td>
<td>
$i18n_singular_name
<% if $isPublished %>
<span class="label label-success">Published</span>
<% else %>
<span class="label label-info">Draft</span>
<% end_if %>
</td>
</tr>
<% end_loop %>
</tbody>
</table>
<% end_if %>