2017-11-30 00:28:19 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\CMS\Model;
|
|
|
|
|
|
|
|
use SilverStripe\Assets\File;
|
2018-02-09 03:33:32 +01:00
|
|
|
use SilverStripe\Dev\Deprecation;
|
2018-01-16 04:53:11 +01:00
|
|
|
use SilverStripe\Forms\FieldList;
|
|
|
|
use SilverStripe\Forms\Tab;
|
|
|
|
use SilverStripe\Forms\TabSet;
|
2017-11-30 00:28:19 +01:00
|
|
|
use SilverStripe\ORM\DataExtension;
|
2018-02-09 03:33:32 +01:00
|
|
|
use SilverStripe\Admin\Forms\UsedOnTable;
|
|
|
|
use SilverStripe\Versioned\RecursivePublishable;
|
2017-11-30 00:28:19 +01:00
|
|
|
|
|
|
|
/**
|
2022-10-18 04:23:59 +02:00
|
|
|
* @deprecated 4.12.0 Use UsedOnTable instead
|
2018-02-09 03:33:32 +01:00
|
|
|
*
|
2018-01-16 04:53:11 +01:00
|
|
|
* Extension applied to {@see FileFormFactory} to decorate with a "Used on:" information area.
|
|
|
|
* Uses tracking provided by {@see SiteTreeFileExtension} to generate this.
|
2017-11-30 00:28:19 +01:00
|
|
|
*
|
|
|
|
* @property File $owner
|
2022-11-16 03:39:13 +01:00
|
|
|
* @deprecated 4.12.0 Use UsedOnTable instead
|
2017-11-30 00:28:19 +01:00
|
|
|
*/
|
|
|
|
class SiteTreeFileFormFactoryExtension extends DataExtension
|
|
|
|
{
|
2022-10-18 04:23:59 +02:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
Deprecation::notice('4.12.0', 'Use UsedOnTable instead', Deprecation::SCOPE_CLASS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated 4.12.0 Use UsedOnTable instead
|
|
|
|
*/
|
2018-01-16 04:53:11 +01:00
|
|
|
public function updateFormFields(FieldList $fields, $controller, $formName, $context)
|
2017-11-30 00:28:19 +01:00
|
|
|
{
|
2022-10-18 04:23:59 +02:00
|
|
|
Deprecation::notice('4.12.0', 'Use UsedOnTable instead');
|
2018-01-16 04:53:11 +01:00
|
|
|
/** @var TabSet $tabset */
|
|
|
|
$tabset = $fields->fieldByName('Editor');
|
2018-02-09 03:33:32 +01:00
|
|
|
if (!$tabset) {
|
|
|
|
return;
|
2018-01-30 22:45:31 +01:00
|
|
|
}
|
2018-02-09 03:33:32 +01:00
|
|
|
|
2018-02-14 02:00:04 +01:00
|
|
|
$usedOnField = UsedOnTable::create('UsedOnTableReplacement');
|
2018-04-06 05:53:57 +02:00
|
|
|
$usedOnField->setRecord($context['Record']);
|
2018-02-09 03:33:32 +01:00
|
|
|
|
|
|
|
// Add field to new tab
|
|
|
|
/** @var Tab $tab */
|
|
|
|
$tab = Tab::create('Usage', _t(__CLASS__ . '.USAGE', 'Usage'), $usedOnField);
|
|
|
|
$tabset->push($tab);
|
2017-11-30 00:28:19 +01:00
|
|
|
}
|
|
|
|
}
|