contao/import — Issue #3597: Allow custom uploaders in DC_Folder::move()
Author: Toflar
Created: 2011-11-29 21:52:10+00:00
State: open
Labels: backend, Feature

Hi Leo

Currently the implementation in DC_Folder::move() is very stiff. You either have the default uploader or fancyupload.
I'd love to have this extendable by developers.
Way to go in my opinion is the following:

config.php:

```
$GLOBALS['TL_UPLOADER'] = array_merge
(
array
(
'default' = 'UploaderDefault',
'fancyupload' =>'UploaderFancyUpload'
),
is_array($GLOBALS['TL_UPLOADER']) ? $GLOBALS['TL_UPLOADER'] : array()
);
```

dca/tl_user.php:

```
$GLOBALS['TL_DCA']['tl_user']['fields']['uploader'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_user']['uploader'],
'exclude' => true,
'inputType' => 'select',
'default' => 'default',
'options' => array_keys($GLOBALS['TL_UPLOADER']),
'reference' => &$GLOBALS['TL_LANG']['tl_user']
);
```

DC_Folder::move():

```
public function move()
{
$this->import('BackendUser', 'User');
$strClassKey = $this->User->uploader;
$objUploader = new $GLOBALS['TL_UPLOADER'][$strClassKey]();

// different methods to call, some examples
$objUploader->generate();
$objUploader->generateAjax();
}
```

And another design idea is to provide an UploaderInterface class that makes the methods mandatory (abstract) and provides some useful helper methods like "checkFileSize($file)" so the devs can only call this in their scripts.

Looking forward to reading your reply =)

--- _Originally created on November 3rd, 2011, at 02:59pm (ID 3597)_