mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #1613 from open-sausages/pulls/4.0/file-links
Moved Backlink list/table to SS Template
This commit is contained in:
commit
685a72d470
@ -10,6 +10,7 @@ use SilverStripe\ORM\DataExtension;
|
|||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\ManyManyList;
|
use SilverStripe\ORM\ManyManyList;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\View\SSViewer;
|
||||||
use Subsite;
|
use Subsite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,6 +39,10 @@ class SiteTreeFileExtension extends DataExtension {
|
|||||||
'BackLinkTracking'
|
'BackLinkTracking'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private static $casting = array(
|
||||||
|
'BackLinkHTMLList' => 'HTMLFragment'
|
||||||
|
);
|
||||||
|
|
||||||
public function updateCMSFields(FieldList $fields) {
|
public function updateCMSFields(FieldList $fields) {
|
||||||
$fields->insertAfter(
|
$fields->insertAfter(
|
||||||
'LastEdited',
|
'LastEdited',
|
||||||
@ -57,25 +62,9 @@ class SiteTreeFileExtension extends DataExtension {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function BackLinkHTMLList() {
|
public function BackLinkHTMLList() {
|
||||||
$html = '<em>' . _t(
|
$viewer = new SSViewer(["type" => "Includes", __CLASS__ . "_description"]);
|
||||||
'SiteTreeFileExtension.BACKLINK_LIST_DESCRIPTION',
|
|
||||||
'This list shows all pages where the file has been added through a WYSIWYG editor.'
|
|
||||||
) . '</em>';
|
|
||||||
|
|
||||||
$html .= '<ul>';
|
return $viewer->process($this->owner);
|
||||||
foreach ($this->BackLinkTracking() as $backLink) {
|
|
||||||
// Add the page link and CMS link
|
|
||||||
$html .= sprintf(
|
|
||||||
'<li><a href="%s" target="_blank">%s</a> – <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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -421,6 +421,9 @@ en:
|
|||||||
many_many_ImageTracking: 'Image Tracking'
|
many_many_ImageTracking: 'Image Tracking'
|
||||||
many_many_LinkTracking: 'Link Tracking'
|
many_many_LinkTracking: 'Link Tracking'
|
||||||
SiteTreeFileExtension:
|
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.'
|
BACKLINK_LIST_DESCRIPTION: 'This list shows all pages where the file has been added through a WYSIWYG editor.'
|
||||||
EDIT: Edit
|
EDIT: Edit
|
||||||
SiteTreeURLSegmentField:
|
SiteTreeURLSegmentField:
|
||||||
|
@ -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 %>
|
Loading…
Reference in New Issue
Block a user