From 7bdca7f5cc44032474e2ed7368a24461a07782b8 Mon Sep 17 00:00:00 2001 From: David Craig Date: Tue, 28 Apr 2015 12:03:07 +1200 Subject: [PATCH] Added a list of pages where a file is used --- code/model/SiteTreeFileExtension.php | 34 +++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/code/model/SiteTreeFileExtension.php b/code/model/SiteTreeFileExtension.php index 76cc9d9f..d723f965 100644 --- a/code/model/SiteTreeFileExtension.php +++ b/code/model/SiteTreeFileExtension.php @@ -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 = '' . _t('SiteTreeFileExtension.BACKLINK_LIST_DESCRIPTION', 'This list shows all pages where the file has been added through a WYSIWYG editor.') . ''; + $html .= ''; + } + /** * Extend through {@link updateBackLinkTracking()} in your own {@link Extension}. *