mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Change UploadField to TreeDropdownField for modal fields
Change UploadField to abstract placeholder FileHandleField for non-modal fields
This commit is contained in:
parent
6641560987
commit
98ecaf9bd0
@ -66,3 +66,9 @@ SilverStripe\Core\Injector\Injector:
|
||||
SilverStripe\Assets\Image_Backend:
|
||||
class: SilverStripe\Assets\GDBackend
|
||||
Image_Backend: '%$SilverStripe\Assets\Image_Backend'
|
||||
---
|
||||
Name: coreassetfield
|
||||
---
|
||||
SilverStripe\Core\Injector\Injector:
|
||||
SilverStripe\Forms\FileHandleField:
|
||||
class: SilverStripe\Forms\FileField
|
||||
|
4
admin/client/dist/js/bundle.js
vendored
4
admin/client/dist/js/bundle.js
vendored
@ -1,7 +1,7 @@
|
||||
webpackJsonp([4],[function(e,t,n){"use strict"
|
||||
n(2),n(3),n(6),n(16),n(18),n(24),n(26),n(28),n(29),n(31),n(34),n(104),n(112),n(116),n(126),n(127),n(128),n(129),n(130),n(131),n(133),n(136),n(138),n(140),n(143),n(146),n(148),n(150),n(152),n(154),n(156),
|
||||
n(157),n(166),n(167),n(169),n(170),n(171),n(172),n(173),n(174),n(175),n(176),n(177),n(178),n(179),n(180),n(181),n(184),n(186),n(187),n(188),n(189),n(193),n(194),n(195),n(196),n(197),n(194),n(189),n(200),
|
||||
n(202),n(204),n(205)},,function(e,t){"use strict"
|
||||
n(157),n(166),n(167),n(169),n(170),n(171),n(172),n(173),n(174),n(175),n(176),n(177),n(178),n(179),n(180),n(181),n(184),n(186),n(187),n(188),n(189),n(193),n(194),n(195),n(196),n(197),n(194),n(200),n(202),
|
||||
n(204),n(205)},,function(e,t){"use strict"
|
||||
function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0})
|
||||
var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n]
|
||||
i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),r=function(){function e(){
|
||||
|
@ -65,7 +65,6 @@ require('../legacy/ToggleCompositeField.js');
|
||||
require('../legacy/MemberDatetimeOptionsetField.js');
|
||||
require('../legacy/TreeDropdownField.js');
|
||||
require('../legacy/DateField.js');
|
||||
require('../legacy/UploadField.js');
|
||||
require('../legacy/HtmlEditorField.js');
|
||||
require('../legacy/TabSet.js');
|
||||
require('../legacy/GridField.js');
|
||||
|
@ -46,7 +46,7 @@ use SilverStripe\Core\Object;
|
||||
* }
|
||||
* </code>
|
||||
*/
|
||||
class FileField extends FormField
|
||||
class FileField extends FormField implements FileHandleField
|
||||
{
|
||||
use UploadReceiver;
|
||||
|
||||
|
18
src/Forms/FileHandleField.php
Normal file
18
src/Forms/FileHandleField.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
interface FileHandleField
|
||||
{
|
||||
public function getAttributes();
|
||||
|
||||
public function getFolderName();
|
||||
|
||||
public function setAllowedExtensions($rules);
|
||||
|
||||
public function getAllowedExtensions();
|
||||
|
||||
public function setAllowedFileCategories($category);
|
||||
|
||||
public function setFolderName($folderName);
|
||||
}
|
@ -10,10 +10,12 @@ use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\RequestHandler;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Forms\CheckboxField;
|
||||
use SilverStripe\Forms\CompositeField;
|
||||
use SilverStripe\Forms\EmailField;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\FileHandleField;
|
||||
use SilverStripe\Forms\Form;
|
||||
use SilverStripe\Forms\GridField\GridField;
|
||||
use SilverStripe\Forms\GridField\GridFieldConfig;
|
||||
@ -122,6 +124,7 @@ class HTMLEditorField_Toolbar extends RequestHandler
|
||||
|
||||
$numericLabelTmpl = '<span class="step-label"><span class="flyout">Step %d.</span>'
|
||||
. '<span class="title">%s</span></span>';
|
||||
|
||||
$form = new Form(
|
||||
$this->controller,
|
||||
"{$this->name}/LinkForm",
|
||||
@ -159,7 +162,10 @@ class HTMLEditorField_Toolbar extends RequestHandler
|
||||
$siteTree,
|
||||
TextField::create('external', _t('HTMLEditorField.URL', 'URL'), 'http://'),
|
||||
EmailField::create('email', _t('HTMLEditorField.EMAIL', 'Email address')),
|
||||
$fileField = UploadField::create('file', _t('HTMLEditorField.FILE', 'File')),
|
||||
$fileField = TreeDropdownField::create(
|
||||
'file',
|
||||
_t('HTMLEditorField.FILE', 'File'),
|
||||
File::class),
|
||||
TextField::create('Anchor', _t('HTMLEditorField.ANCHORVALUE', 'Anchor')),
|
||||
TextField::create('Subject', _t('HTMLEditorField.SUBJECT', 'Email subject')),
|
||||
TextField::create('Description', _t('HTMLEditorField.LINKDESCR', 'Link description')),
|
||||
@ -177,7 +183,6 @@ class HTMLEditorField_Toolbar extends RequestHandler
|
||||
$headerWrap->addExtraClass('CompositeField composite cms-content-header form-group--no-label ');
|
||||
$contentComposite->setName('ContentBody');
|
||||
$contentComposite->addExtraClass('ss-insert-link content');
|
||||
$fileField->setAllowedMaxFileNumber(1);
|
||||
|
||||
$form->unsetValidator();
|
||||
$form->loadDataFrom($this);
|
||||
|
@ -4,8 +4,9 @@ namespace SilverStripe\ORM\FieldType;
|
||||
|
||||
use SilverStripe\Assets\File;
|
||||
use SilverStripe\Assets\Image;
|
||||
use SilverStripe\Forms\UploadField;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Forms\DropdownField;
|
||||
use SilverStripe\Forms\FileHandleField;
|
||||
use SilverStripe\Forms\NumericField;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
@ -48,7 +49,7 @@ class DBForeignKey extends DBInt
|
||||
}
|
||||
$hasOneSingleton = singleton($hasOneClass);
|
||||
if ($hasOneSingleton instanceof File) {
|
||||
$field = new UploadField($relationName, $title);
|
||||
$field = Injector::inst()->create(FileHandleField::class, $relationName, $title);
|
||||
if ($hasOneSingleton instanceof Image) {
|
||||
$field->setAllowedFileCategories('image/supported');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user