mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #1195 from flashbackzoo/pulls/used-on-list
Improve UX of asset management
This commit is contained in:
commit
81097dfef6
@ -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