| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | declare(strict_types = 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * This file is part of the package lns/digital-asset-management. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * For the full copyright and license information, please read the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * LICENSE file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | namespace TYPO3\CMS\DigitalAssetManagement\ContextMenu\ItemProviders; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use TYPO3\CMS\Backend\ContextMenu\ItemProviders\AbstractProvider; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use TYPO3\CMS\Core\Resource\FolderInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use TYPO3\CMS\Core\Resource\ResourceFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use TYPO3\CMS\Core\Utility\GeneralUtility; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * Click menu on a folder in list view | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * 'table' argument must be 'damListFolder-drag' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * 'uid' argument must be a combinedIdentifier of a folder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | class ListFolderProvider extends AbstractProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     protected $itemsConfiguration = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         'newFile' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |             'label' => 'New File', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |             'iconIdentifier' => 'actions-page-new', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |             'callbackAction' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         'newFolder' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |             'label' => 'New Folder', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |             'iconIdentifier' => 'actions-folder', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |             'callbackAction' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         'upload' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |             'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.upload', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |             'iconIdentifier' => 'actions-edit-upload', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |             'callbackAction' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         'download' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |             'label' => 'Download', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |             'iconIdentifier' => 'actions-download', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |             'callbackAction' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         'moveTo' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |             'label' => 'Move to', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |             'iconIdentifier' => 'actions-move', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |             'callbackAction' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         'copyTo' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |             'label' => 'Copy to', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |             'iconIdentifier' => 'actions-document-paste-into', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |             'callbackAction' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         'delete' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |             'label' => 'Delete', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |             'iconIdentifier' => 'actions-delete', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |             'callbackAction' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         'rename' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |             'label' => 'Rename', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |             'iconIdentifier' => 'actions-rename', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |             'callbackAction' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         'info' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |             'label' => 'Details', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             'iconIdentifier' => 'actions-document-info', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |             'callbackAction' => '' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |      * @var FolderInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     protected $folder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     public function canHandle(): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         // -drag suffix used to shut down ext:impexp provider that would add import and export items | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         return $this->table === 'damListFolder-drag'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 89 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |     protected function initialize() | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |         parent::initialize(); | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |         $resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |         $this->folder = $resourceFactory->retrieveFileOrFolderObject($this->identifier); | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |         if (!$this->folder instanceof FolderInterface) { | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  |             throw new \InvalidArgumentException('uid must be either the combined identifier of a folder'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 99 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 100 |  |  |  |