TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
ExtdirectTreeDataProvider.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend\Tree\Pagetree;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 
26 {
32  protected $dataProvider = null;
33 
37  protected $iconFactory;
38 
42  public function __construct()
43  {
44  $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
45  }
46 
52  protected function initDataProvider()
53  {
55  $dataProvider = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\Pagetree\DataProvider::class);
57  }
58 
64  public function getRoot()
65  {
66  $this->initDataProvider();
67  $node = $this->dataProvider->getRoot();
68  return $node->toArray();
69  }
70 
78  public function getNextTreeLevel($nodeId, $nodeData)
79  {
80  $this->initDataProvider();
82  $node = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNode::class, (array)$nodeData);
83  if ($nodeId === 'root') {
84  $nodeCollection = $this->dataProvider->getTreeMounts();
85  } else {
86  $nodeCollection = $this->dataProvider->getNodes($node, $node->getMountPoint());
87  }
88  return $nodeCollection->toArray();
89  }
90 
99  public function getFilteredTree($nodeId, $nodeData, $searchFilter)
100  {
101  if (strval($searchFilter) === '') {
102  return [];
103  }
105  $node = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNode::class, (array)$nodeData);
106  $this->initDataProvider();
107  if ($nodeId === 'root') {
108  $nodeCollection = $this->dataProvider->getTreeMounts($searchFilter);
109  } else {
110  $nodeCollection = $this->dataProvider->getFilteredNodes($node, $searchFilter, $node->getMountPoint());
111  }
112  return $nodeCollection->toArray();
113  }
114 
123  public function getNodeTypes()
124  {
125  $doktypeLabelMap = [];
126  foreach ($GLOBALS['TCA']['pages']['columns']['doktype']['config']['items'] as $doktypeItemConfig) {
127  if ($doktypeItemConfig[1] === '--div--') {
128  continue;
129  }
130  $doktypeLabelMap[$doktypeItemConfig[1]] = $doktypeItemConfig[0];
131  }
132  $doktypes = GeneralUtility::trimExplode(',', $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.doktypesToShowInNewPageDragArea'));
133  $output = [];
134  $allowedDoktypes = GeneralUtility::trimExplode(',', $GLOBALS['BE_USER']->groupData['pagetypes_select'], true);
135  $isAdmin = $GLOBALS['BE_USER']->isAdmin();
136  // Early return if backend user may not create any doktype
137  if (!$isAdmin && empty($allowedDoktypes)) {
138  return $output;
139  }
140  foreach ($doktypes as $doktype) {
141  if (!$isAdmin && !in_array($doktype, $allowedDoktypes)) {
142  continue;
143  }
144  $label = htmlspecialchars($GLOBALS['LANG']->sL($doktypeLabelMap[$doktype]));
145  $icon = $this->iconFactory->getIcon($GLOBALS['TCA']['pages']['ctrl']['typeicon_classes'][$doktype], Icon::SIZE_SMALL)->render();
146  $output[] = [
147  'nodeType' => $doktype,
148  'cls' => 'typo3-pagetree-topPanel-button',
149  'html' => $icon,
150  'title' => $label,
151  'tooltip' => $label
152  ];
153  }
154  return $output;
155  }
156 
162  public function getIndicators()
163  {
165  $indicatorProvider = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\Pagetree\Indicator::class);
166  $indicatorHtmlArr = $indicatorProvider->getAllIndicators();
167  $indicator = [
168  'html' => implode(' ', $indicatorHtmlArr),
169  '_COUNT' => count($indicatorHtmlArr)
170  ];
171  return $indicator;
172  }
173 
179  public function loadResources()
180  {
181  $file = 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:';
182  $indicators = $this->getIndicators();
183  $configuration = [
184  'LLL' => [
185  'copyHint' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'tree.copyHint')),
186  'fakeNodeHint' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'mess.please_wait')),
187  'activeFilterMode' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'tree.activeFilterMode')),
188  'dropToRemove' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'tree.dropToRemove')),
189  'buttonRefresh' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'labels.refresh')),
190  'buttonNewNode' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'tree.buttonNewNode')),
191  'buttonFilter' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'tree.buttonFilter')),
192  'dropZoneElementRemoved' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'tree.dropZoneElementRemoved')),
193  'dropZoneElementRestored' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'tree.dropZoneElementRestored')),
194  'searchTermInfo' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'tree.searchTermInfo')),
195  'temporaryMountPointIndicatorInfo' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'labels.temporaryDBmount')),
196  'deleteDialogTitle' => htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:deleteItem')),
197  'deleteDialogMessage' => htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:deleteWarning')),
198  'recursiveDeleteDialogMessage' => htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:recursiveDeleteWarning'))
199  ],
200  'Configuration' => [
201  'hideFilter' => $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.hideFilter'),
202  'displayDeleteConfirmation' => $GLOBALS['BE_USER']->jsConfirmation(JsConfirmation::DELETE),
203  'canDeleteRecursivly' => $GLOBALS['BE_USER']->uc['recursiveDelete'] == true,
204  'disableIconLinkToContextmenu' => $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu'),
205  'indicator' => $indicators['html'],
206  'temporaryMountPoint' => Commands::getMountPointPath()
207  ],
208  'Icons' => [
209  'InputClear' => $this->iconFactory->getIcon('actions-input-clear', Icon::SIZE_SMALL)->render(),
210  'Close' => $this->iconFactory->getIcon('actions-close', Icon::SIZE_SMALL)->render('inline'),
211  'TrashCan' => $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render('inline'),
212  'TrashCanRestore' => $this->iconFactory->getIcon('actions-edit-restore', Icon::SIZE_SMALL)->render('inline'),
213  'Info' => $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL)->render('inline'),
214  'NewNode' => $this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL)->render(),
215  'Filter' => $this->iconFactory->getIcon('actions-filter', Icon::SIZE_SMALL)->render(),
216  'Refresh' => $this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)->render()
217  ]
218  ];
219  return $configuration;
220  }
221 }
setDataProvider(\TYPO3\CMS\Backend\Tree\AbstractTreeDataProvider $dataProvider)
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static makeInstance($className,...$constructorArguments)