TYPO3 CMS  TYPO3_6-2
ExtdirectTreeDataProvider.php
Go to the documentation of this file.
1 <?php
3 
20 
27 
33  protected $dataProvider = NULL;
34 
40  protected function initDataProvider() {
42  $dataProvider = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\Pagetree\\DataProvider');
44  }
45 
51  public function getRoot() {
52  $this->initDataProvider();
53  $node = $this->dataProvider->getRoot();
54  return $node->toArray();
55  }
56 
64  public function getNextTreeLevel($nodeId, $nodeData) {
65  $this->initDataProvider();
67  $node = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\Pagetree\\PagetreeNode', (array) $nodeData);
68  if ($nodeId === 'root') {
69  $nodeCollection = $this->dataProvider->getTreeMounts();
70  } else {
71  $nodeCollection = $this->dataProvider->getNodes($node, $node->getMountPoint());
72  }
73  return $nodeCollection->toArray();
74  }
75 
84  public function getFilteredTree($nodeId, $nodeData, $searchFilter) {
85  if (strval($searchFilter) === '') {
86  return array();
87  }
89  $node = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\Pagetree\\PagetreeNode', (array) $nodeData);
90  $this->initDataProvider();
91  if ($nodeId === 'root') {
92  $nodeCollection = $this->dataProvider->getTreeMounts($searchFilter);
93  } else {
94  $nodeCollection = $this->dataProvider->getFilteredNodes($node, $searchFilter, $node->getMountPoint());
95  }
96  return $nodeCollection->toArray();
97  }
98 
107  public function getNodeTypes() {
108  $doktypeLabelMap = array();
109  foreach ($GLOBALS['TCA']['pages']['columns']['doktype']['config']['items'] as $doktypeItemConfig) {
110  if ($doktypeItemConfig[1] === '--div--') {
111  continue;
112  }
113  $doktypeLabelMap[$doktypeItemConfig[1]] = $doktypeItemConfig[0];
114  }
115  $doktypes = GeneralUtility::trimExplode(',', $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.doktypesToShowInNewPageDragArea'));
116  $output = array();
117  $allowedDoktypes = GeneralUtility::trimExplode(',', $GLOBALS['BE_USER']->groupData['pagetypes_select']);
118  $isAdmin = $GLOBALS['BE_USER']->isAdmin();
119  foreach ($doktypes as $doktype) {
120  if (!$isAdmin && !in_array($doktype, $allowedDoktypes)) {
121  continue;
122  }
123  $label = $GLOBALS['LANG']->sL($doktypeLabelMap[$doktype], TRUE);
124  $spriteIcon = IconUtility::getSpriteIconClasses($GLOBALS['TCA']['pages']['ctrl']['typeicon_classes'][$doktype]);
125  $output[] = array(
126  'nodeType' => $doktype,
127  'cls' => 'typo3-pagetree-topPanel-button',
128  'iconCls' => $spriteIcon,
129  'title' => $label,
130  'tooltip' => $label
131  );
132  }
133  return $output;
134  }
135 
141  public function getIndicators() {
143  $indicatorProvider = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\Pagetree\\Indicator');
144  $indicatorHtmlArr = $indicatorProvider->getAllIndicators();
145  $indicator = array(
146  'html' => implode(' ', $indicatorHtmlArr),
147  '_COUNT' => count($indicatorHtmlArr)
148  );
149  return $indicator;
150  }
151 
157  public function loadResources() {
158  $file = 'LLL:EXT:lang/locallang_core.xlf:';
159  $indicators = $this->getIndicators();
160  $configuration = array(
161  'LLL' => array(
162  'copyHint' => $GLOBALS['LANG']->sL($file . 'tree.copyHint', TRUE),
163  'fakeNodeHint' => $GLOBALS['LANG']->sL($file . 'mess.please_wait', TRUE),
164  'activeFilterMode' => $GLOBALS['LANG']->sL($file . 'tree.activeFilterMode', TRUE),
165  'dropToRemove' => $GLOBALS['LANG']->sL($file . 'tree.dropToRemove', TRUE),
166  'buttonRefresh' => $GLOBALS['LANG']->sL($file . 'labels.refresh', TRUE),
167  'buttonNewNode' => $GLOBALS['LANG']->sL($file . 'tree.buttonNewNode', TRUE),
168  'buttonFilter' => $GLOBALS['LANG']->sL($file . 'tree.buttonFilter', TRUE),
169  'dropZoneElementRemoved' => $GLOBALS['LANG']->sL($file . 'tree.dropZoneElementRemoved', TRUE),
170  'dropZoneElementRestored' => $GLOBALS['LANG']->sL($file . 'tree.dropZoneElementRestored', TRUE),
171  'searchTermInfo' => $GLOBALS['LANG']->sL($file . 'tree.searchTermInfo', TRUE),
172  'temporaryMountPointIndicatorInfo' => $GLOBALS['LANG']->sl($file . 'labels.temporaryDBmount', TRUE),
173  'deleteDialogTitle' => $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xlf:deleteItem', TRUE),
174  'deleteDialogMessage' => $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xlf:deleteWarning', TRUE),
175  'recursiveDeleteDialogMessage' => $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xlf:recursiveDeleteWarning', TRUE)
176  ),
177  'Configuration' => array(
178  'hideFilter' => $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.hideFilter'),
179  'displayDeleteConfirmation' => $GLOBALS['BE_USER']->jsConfirmation(4),
180  'canDeleteRecursivly' => $GLOBALS['BE_USER']->uc['recursiveDelete'] == TRUE,
181  'disableIconLinkToContextmenu' => $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu'),
182  'indicator' => $indicators['html'],
183  'temporaryMountPoint' => Commands::getMountPointPath()
184  ),
185  'Sprites' => array(
186  'Filter' => IconUtility::getSpriteIconClasses('actions-system-tree-search-open'),
187  'NewNode' => IconUtility::getSpriteIconClasses('actions-page-new'),
188  'Refresh' => IconUtility::getSpriteIconClasses('actions-system-refresh'),
189  'InputClear' => IconUtility::getSpriteIconClasses('actions-input-clear'),
190  'TrashCan' => IconUtility::getSpriteIconClasses('actions-edit-delete'),
191  'TrashCanRestore' => IconUtility::getSpriteIconClasses('actions-edit-restore'),
192  'Info' => IconUtility::getSpriteIconClasses('actions-document-info')
193  )
194  );
195  return $configuration;
196  }
197 
198 }
setDataProvider(\TYPO3\CMS\Backend\Tree\AbstractTreeDataProvider $dataProvider)
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]