Merge pull request #1195 from flashbackzoo/pulls/used-on-list

Improve UX of asset management
This commit is contained in:
Damian Mooyman 2015-04-28 13:28:36 +12:00
commit 81097dfef6

View File

@ -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> &ndash; ';
// 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}.
*