mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
File Form missing CMS Usage information
This commit is contained in:
parent
d677760b24
commit
8b19afe235
@ -7,6 +7,9 @@ SilverStripe\Admin\LeftAndMain:
|
||||
SilverStripe\Assets\File:
|
||||
extensions:
|
||||
- SilverStripe\CMS\Model\SiteTreeFileExtension
|
||||
SilverStripe\AssetAdmin\Forms\FileFormFactory:
|
||||
extensions:
|
||||
- SilverStripe\CMS\Model\SiteTreeFileFormFactoryExtension
|
||||
---
|
||||
Name: cmsmodals
|
||||
---
|
||||
|
@ -41,20 +41,6 @@ class SiteTreeFileExtension extends DataExtension
|
||||
'BackLinkHTMLList' => 'HTMLFragment'
|
||||
);
|
||||
|
||||
public function updateCMSFields(FieldList $fields)
|
||||
{
|
||||
$fields->insertAfter(
|
||||
'LastEdited',
|
||||
ReadonlyField::create(
|
||||
'BackLinkCount',
|
||||
_t(__CLASS__.'.BACKLINKCOUNT', 'Used on:'),
|
||||
$this->BackLinkTracking()->count() . ' ' . _t(__CLASS__.'.PAGES', 'page(s)')
|
||||
)
|
||||
->addExtraClass('cms-description-toggle')
|
||||
->setDescription($this->BackLinkHTMLList())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an HTML list which provides links to where a file is used.
|
||||
*
|
||||
|
38
code/Model/SiteTreeFileFormFactoryExtension.php
Normal file
38
code/Model/SiteTreeFileFormFactoryExtension.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Model;
|
||||
|
||||
use SilverStripe\Assets\File;
|
||||
use SilverStripe\Forms\ReadonlyField;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
|
||||
/**
|
||||
* Extension applied to {@see FileFormFactoryExtension} object to track links to {@see SiteTree} records.
|
||||
*
|
||||
* {@see SiteTreeLinkTracking} for the extension applied to {@see SiteTree}
|
||||
*
|
||||
* Note that since both SiteTree and File are versioned, LinkTracking and ImageTracking will
|
||||
* only be enabled for the Stage record.
|
||||
*
|
||||
* @property File $owner
|
||||
*/
|
||||
class SiteTreeFileFormFactoryExtension extends DataExtension
|
||||
{
|
||||
public function updateForm($form, $controller, $name, $context)
|
||||
{
|
||||
$record = $context['Record'];
|
||||
$fields = $form->Fields();
|
||||
|
||||
$fields->insertAfter(
|
||||
'LastEdited',
|
||||
ReadonlyField::create(
|
||||
'BackLinkCount',
|
||||
_t(__CLASS__.'.BACKLINKCOUNT', 'Used on:'),
|
||||
$record->BackLinkTrackingCount() . ' ' . _t(__CLASS__.'.PAGES', 'page(s)')
|
||||
)
|
||||
->addExtraClass('cms-description-toggle')
|
||||
->setDescription($record->BackLinkHTMLList())
|
||||
);
|
||||
}
|
||||
}
|
@ -10,14 +10,14 @@
|
||||
<tbody>
|
||||
<% loop $BackLinkTracking %>
|
||||
<tr>
|
||||
<th>$Pos</th>
|
||||
<td>$Pos</td>
|
||||
<td><a href="$CMSEditLink">$MenuTitle</a></td>
|
||||
<td>
|
||||
$i18n_singular_name
|
||||
<% if $isPublished %>
|
||||
<span class="label label-success">Published</span>
|
||||
<span class="badge badge-success">Published</span>
|
||||
<% else %>
|
||||
<span class="label label-info">Draft</span>
|
||||
<span class="badge status-addedtodraft">Draft</span>
|
||||
<% end_if %>
|
||||
</td>
|
||||
</tr>
|
||||
|
Loading…
Reference in New Issue
Block a user