TYPO3 CMS  TYPO3_7-6
ExtdirectTreeDataProvider.php
Go to the documentation of this file.
1 <?php
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 = $GLOBALS['LANG']->sL($doktypeLabelMap[$doktype], true);
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/locallang_core.xlf:';
182  $indicators = $this->getIndicators();
183  $configuration = [
184  'LLL' => [
185  'copyHint' => $GLOBALS['LANG']->sL($file . 'tree.copyHint', true),
186  'fakeNodeHint' => $GLOBALS['LANG']->sL($file . 'mess.please_wait', true),
187  'activeFilterMode' => $GLOBALS['LANG']->sL($file . 'tree.activeFilterMode', true),
188  'dropToRemove' => $GLOBALS['LANG']->sL($file . 'tree.dropToRemove', true),
189  'buttonRefresh' => $GLOBALS['LANG']->sL($file . 'labels.refresh', true),
190  'buttonNewNode' => $GLOBALS['LANG']->sL($file . 'tree.buttonNewNode', true),
191  'buttonFilter' => $GLOBALS['LANG']->sL($file . 'tree.buttonFilter', true),
192  'dropZoneElementRemoved' => $GLOBALS['LANG']->sL($file . 'tree.dropZoneElementRemoved', true),
193  'dropZoneElementRestored' => $GLOBALS['LANG']->sL($file . 'tree.dropZoneElementRestored', true),
194  'searchTermInfo' => $GLOBALS['LANG']->sL($file . 'tree.searchTermInfo', true),
195  'temporaryMountPointIndicatorInfo' => $GLOBALS['LANG']->sl($file . 'labels.temporaryDBmount', true),
196  'deleteDialogTitle' => $GLOBALS['LANG']->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:deleteItem', true),
197  'deleteDialogMessage' => $GLOBALS['LANG']->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:deleteWarning', true),
198  'recursiveDeleteDialogMessage' => $GLOBALS['LANG']->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:recursiveDeleteWarning', true)
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']