1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Extends the file list. |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace HDNET\Focuspoint\Hooks; |
8
|
|
|
|
9
|
|
|
use HDNET\Autoloader\Annotation\Hook; |
10
|
|
|
use HDNET\Focuspoint\Service\WizardService; |
11
|
|
|
use HDNET\Focuspoint\Utility\FileUtility; |
12
|
|
|
use HDNET\Focuspoint\Utility\ImageUtility; |
13
|
|
|
use TYPO3\CMS\Backend\Utility\BackendUtility; |
14
|
|
|
use TYPO3\CMS\Core\Resource\FileInterface; |
15
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
16
|
|
|
use TYPO3\CMS\Filelist\FileListEditIconHookInterface; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Extends the file list. |
20
|
|
|
* |
21
|
|
|
* @Hook("TYPO3_CONF_VARS|SC_OPTIONS|fileList|editIconsHook") |
22
|
|
|
*/ |
23
|
|
|
class FileList implements FileListEditIconHookInterface |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* Modifies edit icon array. |
27
|
|
|
* |
28
|
|
|
* @param array $cells Array of edit icons |
29
|
|
|
* @param \TYPO3\CMS\Filelist\FileList $parentObject Parent object |
30
|
|
|
*/ |
31
|
|
|
public function manipulateEditIcons(&$cells, &$parentObject) |
32
|
|
|
{ |
33
|
|
|
/** @var WizardService $wizardService */ |
34
|
|
|
$wizardService = GeneralUtility::makeInstance(WizardService::class); |
35
|
|
|
|
36
|
|
|
try { |
37
|
|
|
$metaUid = $this->getFileMetaUidByCells($cells); |
38
|
|
|
$file = FileUtility::getFileByMetaData($metaUid); |
39
|
|
|
} catch (\Exception $ex) { |
40
|
|
|
$cells['focuspoint'] = $wizardService->getWizardButton(); |
41
|
|
|
|
42
|
|
|
return; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
if (!ImageUtility::isValidFileExtension($file->getExtension())) { |
46
|
|
|
$cells['focuspoint'] = $wizardService->getWizardButton(); |
47
|
|
|
|
48
|
|
|
return; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
$wizardArguments = [ |
52
|
|
|
'P' => [ |
53
|
|
|
'metaUid' => $metaUid, |
54
|
|
|
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'), |
55
|
|
|
], |
56
|
|
|
]; |
57
|
|
|
$wizardUri = BackendUtility::getModuleUrl('focuspoint', $wizardArguments); |
|
|
|
|
58
|
|
|
$cells['focuspoint'] = $wizardService->getWizardButton($wizardUri); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Get the file object of the given cell information. |
63
|
|
|
* |
64
|
|
|
* @param array $cells |
65
|
|
|
* |
66
|
|
|
* @throws \Exception |
67
|
|
|
* |
68
|
|
|
* @return int |
69
|
|
|
*/ |
70
|
|
|
protected function getFileMetaUidByCells($cells) |
71
|
|
|
{ |
72
|
|
|
if ($cells['__fileOrFolderObject'] instanceof FileInterface) { |
73
|
|
|
$metaData = $cells['__fileOrFolderObject']->_getMetaData(); |
|
|
|
|
74
|
|
|
} |
75
|
|
|
if (!isset($metaData['uid'])) { |
76
|
|
|
throw new \Exception('No meta data found', 1475144024); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
return (int) $metaData['uid']; |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.