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) {
|
public function updateCMSFields(FieldList $fields) {
|
||||||
$fields->insertAfter(new ReadonlyField('BackLinkCount',
|
$fields->insertAfter(
|
||||||
_t('AssetTableField.BACKLINKCOUNT', 'Used on:'),
|
ReadonlyField::create(
|
||||||
$this->BackLinkTracking()->Count() . ' ' . _t('AssetTableField.PAGES', 'page(s)')),
|
'BackLinkCount',
|
||||||
|
_t('AssetTableField.BACKLINKCOUNT', 'Used on:'),
|
||||||
|
$this->BackLinkTracking()->Count() . ' ' . _t('AssetTableField.PAGES', 'page(s)'))
|
||||||
|
->addExtraClass('cms-description-toggle')
|
||||||
|
->setDescription($this->BackLinkHTMLList()),
|
||||||
'LastEdited'
|
'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}.
|
* Extend through {@link updateBackLinkTracking()} in your own {@link Extension}.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user