‪TYPO3CMS  9.5
ItemProvider.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
25 {
29  protected ‪$itemsConfiguration = [
30  'exportT3d' => [
31  'type' => 'item',
32  'label' => 'LLL:EXT:impexp/Resources/Private/Language/locallang.xlf:export',
33  'iconIdentifier' => 'actions-document-export-t3d',
34  'callbackAction' => 'exportT3d'
35  ],
36  'importT3d' => [
37  'type' => 'item',
38  'label' => 'LLL:EXT:impexp/Resources/Private/Language/locallang.xlf:import',
39  'iconIdentifier' => 'actions-document-import-t3d',
40  'callbackAction' => 'importT3d',
41  ]
42  ];
43 
49  public function ‪canHandle(): bool
50  {
51  return !in_array($this->table, ['sys_file', 'sys_filemounts', 'sys_file_storage'], true)
52  && strpos($this->table, '-drag') === false;
53  }
54 
60  public function ‪getPriority(): int
61  {
62  return 50;
63  }
64 
71  public function ‪addItems(array $items): array
72  {
73  $this->‪initDisabledItems();
74  $localItems = $this->‪prepareItems($this->itemsConfiguration);
75  if (isset($items['more']['childItems'])) {
76  $items['more']['childItems'] = $items['more']['childItems'] + $localItems;
77  } else {
78  $items += $localItems;
79  }
80  return $items;
81  }
82 
88  protected function ‪canRender(string $itemName, string $type): bool
89  {
90  if (in_array($itemName, $this->disabledItems, true)) {
91  return false;
92  }
93  $canRender = false;
94  switch ($itemName) {
95  case 'exportT3d':
96  $canRender = true;
97  break;
98  case 'importT3d':
99  $canRender = $this->table === 'pages' && $this->‪isImportEnabled();
100  break;
101  }
102  return $canRender;
103  }
104 
111  protected function ‪getAdditionalAttributes(string $itemName): array
112  {
113  return ['data-callback-module' => 'TYPO3/CMS/Impexp/ContextMenuActions'];
114  }
115 
119  protected function ‪isImportEnabled(): bool
120  {
121  return $this->backendUser->isAdmin()
122  || !$this->backendUser->isAdmin() && (bool)($this->backendUser->getTSConfig()['options.']['impexp.']['enableImportForNonAdminUser'] ?? false);
123  }
124 }
‪TYPO3\CMS\Impexp\ContextMenu\ItemProvider\getAdditionalAttributes
‪array getAdditionalAttributes(string $itemName)
Definition: ItemProvider.php:110
‪TYPO3\CMS\Backend\ContextMenu\ItemProviders\AbstractProvider\prepareItems
‪array prepareItems(array $itemsConfiguration)
Definition: AbstractProvider.php:165
‪TYPO3\CMS\Backend\ContextMenu\ItemProviders\AbstractProvider
Definition: AbstractProvider.php:29
‪TYPO3\CMS\Impexp\ContextMenu\ItemProvider\isImportEnabled
‪isImportEnabled()
Definition: ItemProvider.php:118
‪TYPO3\CMS\Impexp\ContextMenu\ItemProvider\canRender
‪bool canRender(string $itemName, string $type)
Definition: ItemProvider.php:87
‪TYPO3\CMS\Impexp\ContextMenu
Definition: ItemProvider.php:3
‪TYPO3\CMS\Impexp\ContextMenu\ItemProvider
Definition: ItemProvider.php:25
‪TYPO3\CMS\Impexp\ContextMenu\ItemProvider\canHandle
‪bool canHandle()
Definition: ItemProvider.php:48
‪TYPO3\CMS\Impexp\ContextMenu\ItemProvider\addItems
‪array addItems(array $items)
Definition: ItemProvider.php:70
‪TYPO3\CMS\Impexp\ContextMenu\ItemProvider\getPriority
‪int getPriority()
Definition: ItemProvider.php:59
‪TYPO3\CMS\Backend\ContextMenu\ItemProviders\AbstractProvider\initDisabledItems
‪initDisabledItems()
Definition: AbstractProvider.php:136
‪TYPO3\CMS\Impexp\ContextMenu\ItemProvider\$itemsConfiguration
‪array $itemsConfiguration
Definition: ItemProvider.php:28