2017-11-29 23:28:19 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\CMS\Model;
|
|
|
|
|
|
|
|
use SilverStripe\Assets\File;
|
2018-02-09 15:33:32 +13:00
|
|
|
use SilverStripe\Dev\Deprecation;
|
2018-01-16 16:53:11 +13:00
|
|
|
use SilverStripe\Forms\FieldList;
|
|
|
|
use SilverStripe\Forms\Tab;
|
|
|
|
use SilverStripe\Forms\TabSet;
|
2017-11-29 23:28:19 +00:00
|
|
|
use SilverStripe\ORM\DataExtension;
|
2018-02-09 15:33:32 +13:00
|
|
|
use SilverStripe\Admin\Forms\UsedOnTable;
|
|
|
|
use SilverStripe\Versioned\RecursivePublishable;
|
2017-11-29 23:28:19 +00:00
|
|
|
|
|
|
|
/**
|
2022-10-18 15:23:59 +13:00
|
|
|
* @deprecated 4.12.0 Use UsedOnTable instead
|
2018-02-09 15:33:32 +13:00
|
|
|
*
|
2018-01-16 16:53:11 +13: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-29 23:28:19 +00:00
|
|
|
*
|
|
|
|
* @property File $owner
|
2022-11-16 15:39:13 +13:00
|
|
|
* @deprecated 4.12.0 Use UsedOnTable instead
|
2017-11-29 23:28:19 +00:00
|
|
|
*/
|
|
|
|
class SiteTreeFileFormFactoryExtension extends DataExtension
|
|
|
|
{
|
2022-10-18 15:23:59 +13: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 16:53:11 +13:00
|
|
|
public function updateFormFields(FieldList $fields, $controller, $formName, $context)
|
2017-11-29 23:28:19 +00:00
|
|
|
{
|
2022-10-18 15:23:59 +13:00
|
|
|
Deprecation::notice('4.12.0', 'Use UsedOnTable instead');
|
2018-01-16 16:53:11 +13:00
|
|
|
/** @var TabSet $tabset */
|
|
|
|
$tabset = $fields->fieldByName('Editor');
|
2018-02-09 15:33:32 +13:00
|
|
|
if (!$tabset) {
|
|
|
|
return;
|
2018-01-31 10:45:31 +13:00
|
|
|
}
|
2018-02-09 15:33:32 +13:00
|
|
|
|
2018-02-14 14:00:04 +13:00
|
|
|
$usedOnField = UsedOnTable::create('UsedOnTableReplacement');
|
2018-04-06 15:53:57 +12:00
|
|
|
$usedOnField->setRecord($context['Record']);
|
2018-02-09 15:33:32 +13:00
|
|
|
|
|
|
|
// Add field to new tab
|
|
|
|
/** @var Tab $tab */
|
|
|
|
$tab = Tab::create('Usage', _t(__CLASS__ . '.USAGE', 'Usage'), $usedOnField);
|
|
|
|
$tabset->push($tab);
|
2017-11-29 23:28:19 +00:00
|
|
|
}
|
|
|
|
}
|