mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Added a list of pages where a file is used
This commit is contained in:
parent
857ade7d1d
commit
7bdca7f5cc
@ -10,13 +10,41 @@ class SiteTreeFileExtension extends DataExtension {
|
||||
);
|
||||
|
||||
public function updateCMSFields(FieldList $fields) {
|
||||
$fields->insertAfter(new ReadonlyField('BackLinkCount',
|
||||
_t('AssetTableField.BACKLINKCOUNT', 'Used on:'),
|
||||
$this->BackLinkTracking()->Count() . ' ' . _t('AssetTableField.PAGES', 'page(s)')),
|
||||
$fields->insertAfter(
|
||||
ReadonlyField::create(
|
||||
'BackLinkCount',
|
||||
_t('AssetTableField.BACKLINKCOUNT', 'Used on:'),
|
||||
$this->BackLinkTracking()->Count() . ' ' . _t('AssetTableField.PAGES', 'page(s)'))
|
||||
->addExtraClass('cms-description-toggle')
|
||||
->setDescription($this->BackLinkHTMLList()),
|
||||
'LastEdited'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an HTML list which provides links to where a file is used.
|
||||
*
|
||||
* @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>';
|
||||
$html .= '<ul>';
|
||||
|
||||
foreach ($this->BackLinkTracking() as $backLink) {
|
||||
$listItem = '<li>';
|
||||
|
||||
// Add the page link
|
||||
$listItem .= '<a href="' . $backLink->Link() . '" target="_blank">' . Convert::raw2xml($backLink->MenuTitle) . '</a> – ';
|
||||
|
||||
// Add the CMS link
|
||||
$listItem .= '<a href="' . $backLink->CMSEditLink() . '">' . _t('SiteTreeFileExtension.EDIT', 'Edit') . '</a>';
|
||||
|
||||
$html .= $listItem . '</li>';
|
||||
}
|
||||
|
||||
return $html .= '</ul>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Extend through {@link updateBackLinkTracking()} in your own {@link Extension}.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user