|
1
|
|
|
<?php |
|
2
|
|
|
namespace Fab\Media\ViewHelpers\Form\Select; |
|
3
|
|
|
|
|
4
|
|
|
/* |
|
5
|
|
|
* This file is part of the Fab/Media project under GPLv2 or later. |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please read the |
|
8
|
|
|
* LICENSE.md file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
use Fab\Media\Module\MediaModule; |
|
12
|
|
|
use Fab\Media\Module\VidiModule; |
|
13
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
14
|
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* View helper dealing with the storage menu |
|
18
|
|
|
* displayed in the top right corner of the Media module. |
|
19
|
|
|
*/ |
|
20
|
|
|
class StorageViewHelper extends AbstractViewHelper |
|
21
|
|
|
{ |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @return void |
|
25
|
|
|
*/ |
|
26
|
|
|
public function initializeArguments() |
|
27
|
|
|
{ |
|
28
|
|
|
$this->registerArgument('objects', 'array', '', false, []); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Render a file upload field |
|
33
|
|
|
* |
|
34
|
|
|
* @return string |
|
35
|
|
|
*/ |
|
36
|
|
|
public function render() |
|
37
|
|
|
{ |
|
38
|
|
|
$objects = $this->arguments['objects']; |
|
39
|
|
|
|
|
40
|
|
|
// Check if a storages is selected |
|
41
|
|
|
$currentStorage = $this->getMediaModule()->getCurrentStorage(); |
|
42
|
|
|
|
|
43
|
|
|
$template = '<select name="%s[target]">%s</select>'; |
|
44
|
|
|
$options = []; |
|
45
|
|
|
foreach ($objects as $storage) { |
|
46
|
|
|
|
|
47
|
|
|
/** @var \TYPO3\CMS\Core\Resource\ResourceStorage $storage */ |
|
48
|
|
|
$options[] = sprintf('<option value="%s" %s>%s %s</option>', |
|
49
|
|
|
$storage->getUid(), |
|
50
|
|
|
is_object($currentStorage) && $currentStorage->getUid() == $storage->getUid() ? 'selected="selected"' : '', |
|
51
|
|
|
$storage->getName(), |
|
52
|
|
|
!$storage->isOnline() ? '(offline)' : '' |
|
53
|
|
|
); |
|
54
|
|
|
} |
|
55
|
|
|
return sprintf($template, |
|
56
|
|
|
VidiModule::getParameterPrefix(), |
|
57
|
|
|
implode("\n", $options) |
|
58
|
|
|
); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @return MediaModule|object |
|
63
|
|
|
*/ |
|
64
|
|
|
protected function getMediaModule() |
|
65
|
|
|
{ |
|
66
|
|
|
return GeneralUtility::makeInstance(\Fab\Media\Module\MediaModule::class); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
} |
|
70
|
|
|
|