mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 12:05:56 +00:00
ENHANCEMENT: displaying the references count in the getCMSFields
This commit is contained in:
parent
a59646bb41
commit
b05cb59646
@ -479,7 +479,11 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
|
|||||||
|
|
||||||
$fields = new FieldList(); //don't use the automatic scaffolding, it is slow and unnecessary here
|
$fields = new FieldList(); //don't use the automatic scaffolding, it is slow and unnecessary here
|
||||||
|
|
||||||
$fieldsTop = $this->getFieldsForFile();
|
//get list of shortcode page relations
|
||||||
|
$relationFinder = new ShortCodeRelationFinder();
|
||||||
|
$relationList = $relationFinder->getList($this->ID);
|
||||||
|
|
||||||
|
$fieldsTop = $this->getFieldsForFile($relationList->count());
|
||||||
$fields->add($fieldsTop);
|
$fields->add($fieldsTop);
|
||||||
|
|
||||||
$fields->add(new TextField('Title','Title'));
|
$fields->add(new TextField('Title','Title'));
|
||||||
@ -519,11 +523,11 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
|
|||||||
$gridFieldConfig
|
$gridFieldConfig
|
||||||
);
|
);
|
||||||
|
|
||||||
$relationFinder = new ShortCodeRelationFinder();
|
|
||||||
$referencesGrid = GridField::create(
|
$referencesGrid = GridField::create(
|
||||||
'References',
|
'References',
|
||||||
_t('DMSDocument.RelatedReferences', 'Related References'),
|
_t('DMSDocument.RelatedReferences', 'Related References'),
|
||||||
$relationFinder->getList($this->ID),
|
$relationList,
|
||||||
$gridFieldConfig
|
$gridFieldConfig
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -640,7 +644,7 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
|
|||||||
/**
|
/**
|
||||||
* @return FieldList
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
protected function getFieldsForFile() {
|
protected function getFieldsForFile($relationListCount) {
|
||||||
$extension = $this->getFileExt();
|
$extension = $this->getFileExt();
|
||||||
|
|
||||||
$previewField = new LiteralField("ImageFull",
|
$previewField = new LiteralField("ImageFull",
|
||||||
@ -652,6 +656,9 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
|
|||||||
$publishedOnValue = "$publishedOnCount pages";
|
$publishedOnValue = "$publishedOnCount pages";
|
||||||
if ($publishedOnCount == 1) $publishedOnValue = "$publishedOnCount page";
|
if ($publishedOnCount == 1) $publishedOnValue = "$publishedOnCount page";
|
||||||
|
|
||||||
|
$relationListCountValue = "$relationListCount pages";
|
||||||
|
if ($relationListCount == 1) $relationListCountValue = "$relationListCount page";
|
||||||
|
|
||||||
$fields = new FieldGroup(
|
$fields = new FieldGroup(
|
||||||
$filePreview = CompositeField::create(
|
$filePreview = CompositeField::create(
|
||||||
CompositeField::create(
|
CompositeField::create(
|
||||||
@ -669,7 +676,8 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
|
|||||||
new DateField_Disabled("Created", _t('AssetTableField.CREATED','First uploaded') . ':', $this->Created),
|
new DateField_Disabled("Created", _t('AssetTableField.CREATED','First uploaded') . ':', $this->Created),
|
||||||
new DateField_Disabled("LastEdited", _t('AssetTableField.LASTEDIT','Last changed') . ':', $this->LastEdited),
|
new DateField_Disabled("LastEdited", _t('AssetTableField.LASTEDIT','Last changed') . ':', $this->LastEdited),
|
||||||
new DateField_Disabled("LastChanged", _t('AssetTableField.LASTCHANGED','Last replaced') . ':', $this->LastChanged),
|
new DateField_Disabled("LastChanged", _t('AssetTableField.LASTCHANGED','Last replaced') . ':', $this->LastChanged),
|
||||||
new ReadonlyField("PublishedOn", "Published on". ':', $publishedOnValue)
|
new ReadonlyField("PublishedOn", "Published on". ':', $publishedOnValue),
|
||||||
|
new ReadonlyField("ReferencedOn", "Referenced on". ':', $relationListCountValue)
|
||||||
)
|
)
|
||||||
)->setName("FilePreviewData")->addExtraClass('cms-file-info-data')
|
)->setName("FilePreviewData")->addExtraClass('cms-file-info-data')
|
||||||
)->setName("FilePreview")->addExtraClass('cms-file-info')
|
)->setName("FilePreview")->addExtraClass('cms-file-info')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user