2 namespace TYPO3\CMS\Backend\Tree\Pagetree;
72 $this->showRootlineAboveMounts =
$GLOBALS[
'BE_USER']->getTSConfigVal(
'options.pageTree.showPathAboveMounts');
75 $hookElements =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/tree/pagetree/class.t3lib_tree_pagetree_dataprovider.php'][
'postProcessCollections'];
76 if (is_array($hookElements)) {
77 foreach ($hookElements as $classRef) {
81 $this->processCollectionHookObjects[] = $hookObject;
97 $node->setExpanded(
true);
109 public function getNodes(\TYPO3\CMS\Backend\Tree\TreeNode $node, $mountPoint = 0, $level = 0)
114 return $nodeCollection;
116 $isVirtualRootNode =
false;
120 if ((
int)$node->getId() === 0) {
122 if (!(
int)
$GLOBALS[
'BE_USER']->uc[
'pageTree_temporaryMountPoint']) {
123 $mountPoints = array_map(
'intval',
$GLOBALS[
'BE_USER']->returnWebmounts());
124 $mountPoints = array_unique($mountPoints);
125 if (!in_array(0, $mountPoints)) {
128 $isVirtualRootNode =
true;
130 foreach ($mountPoints as $webMountPoint) {
132 'uid' => $webMountPoint,
133 'isMountPoint' =>
true
139 if (is_array($subpages) && !empty($subpages)) {
140 foreach ($subpages as $subpage) {
141 if (in_array($subpage[
'uid'], $this->hiddenRecords)) {
146 $isMountPoint = $subpage[
'isMountPoint'] ===
true;
147 if ($isVirtualRootNode) {
148 $mountPoint = (int)$subpage[
'uid'];
154 $subNode = Commands::getNewNode($subpage, $mountPoint);
155 $subNode->setIsMountPoint($isMountPoint);
156 if ($isMountPoint && $this->showRootlineAboveMounts) {
158 $subNode->setReadableRootline($rootline);
160 if ($this->nodeCounter < $this->nodeLimit) {
161 $childNodes = $this->
getNodes($subNode, $mountPoint, $level + 1);
162 $subNode->setChildNodes($childNodes);
163 $this->nodeCounter += $childNodes->count();
167 if (!
$GLOBALS[
'BE_USER']->isAdmin() && (int)$subpage[
'editlock'] === 1) {
168 $subNode->setLabelIsEditable(
false);
170 $nodeCollection->append($subNode);
173 foreach ($this->processCollectionHookObjects as $hookObject) {
175 $hookObject->postProcessGetNodes($node, $mountPoint, $level, $nodeCollection);
177 return $nodeCollection;
200 public function getFilteredNodes(\TYPO3\CMS\Backend\Tree\
TreeNode $node, $searchFilter, $mountPoint = 0)
205 if (!is_array($records) || empty($records)) {
206 return $nodeCollection;
207 }
elseif (count($records) > 500) {
208 return $nodeCollection;
211 $mountPoints = (int)
$GLOBALS[
'BE_USER']->uc[
'pageTree_temporaryMountPoint'];
213 $mountPoints = array_map(
'intval',
$GLOBALS[
'BE_USER']->returnWebmounts());
214 $mountPoints = array_unique($mountPoints);
216 $mountPoints = array($mountPoints);
218 $isNumericSearchFilter = is_numeric($searchFilter) && $searchFilter > 0;
219 $searchFilterQuoted = preg_quote($searchFilter,
'/');
220 $nodeId = (int)$node->getId();
221 $processedRecordIds = array();
222 foreach ($records as $record) {
223 if ((
int)$record[
't3ver_wsid'] !== (
int)
$GLOBALS[
'BE_USER']->workspace && (
int)$record[
't3ver_wsid'] !== 0) {
227 if ($liveVersion !== null) {
228 $record = $liveVersion;
232 if ((
int)$record[
'pid'] === -1
233 || in_array($record[
'uid'], $this->hiddenRecords)
234 || in_array($record[
'uid'], $processedRecordIds)
238 $processedRecordIds[] = $record[
'uid'];
241 $rootline = array_reverse($rootline);
242 if (!in_array(0, $mountPoints,
true)) {
243 $isInsideMountPoints =
false;
244 foreach ($rootline as $rootlineElement) {
245 if (in_array((
int)$rootlineElement[
'uid'], $mountPoints,
true)) {
246 $isInsideMountPoints =
true;
250 if (!$isInsideMountPoints) {
254 $reference = $nodeCollection;
255 $inFilteredRootline =
false;
256 $amountOfRootlineElements = count($rootline);
257 for ($i = 0; $i < $amountOfRootlineElements; ++$i) {
258 $rootlineElement = $rootline[$i];
259 $rootlineElement[
'uid'] = (int)$rootlineElement[
'uid'];
260 $isInWebMount = (int)
$GLOBALS[
'BE_USER']->isInWebMount($rootlineElement[
'uid']);
262 || ($rootlineElement[
'uid'] === (
int)$mountPoints[0]
263 && $rootlineElement[
'uid'] !== $isInWebMount)
267 if ((
int)$rootlineElement[
'pid'] === $nodeId
268 || $rootlineElement[
'uid'] === $nodeId
269 || ($rootlineElement[
'uid'] === $isInWebMount
270 && in_array($rootlineElement[
'uid'], $mountPoints,
true))
272 $inFilteredRootline =
true;
274 if (!$inFilteredRootline || $rootlineElement[
'uid'] === $mountPoint) {
278 $ident = (int)$rootlineElement[
'sorting'] . (
int)$rootlineElement[
'uid'];
279 if ($reference && $reference->offsetExists($ident)) {
281 $refNode = $reference->offsetGet($ident);
282 $refNode->setExpanded(
true);
283 $refNode->setLeaf(
false);
284 $reference = $refNode->getChildNodes();
285 if ($reference == null) {
287 $refNode->setChildNodes($reference);
290 $refNode = Commands::getNewNode($rootlineElement, $mountPoint);
291 $replacement =
'<span class="typo3-pagetree-filteringTree-highlight">$1</span>';
292 if ($isNumericSearchFilter && (
int)$rootlineElement[
'uid'] === (
int)$searchFilter) {
293 $text = str_replace(
'$1', $refNode->getText(), $replacement);
295 $text = preg_replace(
'/(' . $searchFilterQuoted .
')/i', $replacement, $refNode->getText());
297 $refNode->setText($text, $refNode->getTextSourceField(), $refNode->getPrefix(), $refNode->getSuffix());
300 if ($i + 1 >= $amountOfRootlineElements) {
301 $childNodes = $this->
getNodes($refNode, $mountPoint);
302 foreach ($childNodes as $childNode) {
304 $childRecord = $childNode->getRecord();
305 $childIdent = (int)$childRecord[
'sorting'] . (
int)$childRecord[
'uid'];
306 $childCollection->offsetSet($childIdent, $childNode);
308 $refNode->setChildNodes($childNodes);
310 $refNode->setChildNodes($childCollection);
311 $reference->offsetSet($ident, $refNode);
313 $reference = $childCollection;
317 foreach ($this->processCollectionHookObjects as $hookObject) {
319 $hookObject->postProcessFilteredNodes($node, $searchFilter, $mountPoint, $nodeCollection);
321 return $nodeCollection;
332 public function getTreeMounts($searchFilter =
'')
336 $isTemporaryMountPoint =
false;
337 $rootNodeIsVirtual =
false;
338 $mountPoints = (int)
$GLOBALS[
'BE_USER']->uc[
'pageTree_temporaryMountPoint'];
340 $mountPoints = array_map(
'intval',
$GLOBALS[
'BE_USER']->returnWebmounts());
341 $mountPoints = array_unique($mountPoints);
342 if (!in_array(0, $mountPoints)) {
343 $rootNodeIsVirtual =
true;
347 $mountPoints = array(0);
350 $isTemporaryMountPoint =
true;
351 $mountPoints = array($mountPoints);
353 if (empty($mountPoints)) {
354 return $nodeCollection;
357 foreach ($mountPoints as $mountPoint) {
358 if ($mountPoint === 0) {
360 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'sitename'] !==
'') {
361 $sitename =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'sitename'];
367 $subNode = Commands::getNewNode($record);
368 $subNode->setLabelIsEditable(
false);
369 if ($rootNodeIsVirtual) {
370 $subNode->setType(
'virtual_root');
371 $subNode->setIsDropTarget(
false);
373 $subNode->setType(
'pages_root');
374 $subNode->setIsDropTarget(
true);
377 if (in_array($mountPoint, $this->hiddenRecords)) {
384 $subNode = Commands::getNewNode($record, $mountPoint);
385 if ($this->showRootlineAboveMounts && !$isTemporaryMountPoint) {
387 $subNode->setReadableRootline($rootline);
390 if (count($mountPoints) <= 1) {
391 $subNode->setExpanded(
true);
392 $subNode->setCls(
'typo3-pagetree-node-notExpandable');
394 $subNode->setIsMountPoint(
true);
395 $subNode->setDraggable(
false);
396 if ($searchFilter ===
'') {
397 $childNodes = $this->
getNodes($subNode, $mountPoint);
399 $childNodes = $this->getFilteredNodes($subNode, $searchFilter, $mountPoint);
400 $subNode->setExpanded(
true);
402 $subNode->setChildNodes($childNodes);
403 $nodeCollection->append($subNode);
405 foreach ($this->processCollectionHookObjects as $hookObject) {
407 $hookObject->postProcessGetTreeMounts($searchFilter, $nodeCollection);
409 return $nodeCollection;
422 if (is_numeric($id) && $id >= 0) {
423 $where .=
' AND pid= ' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr((
int)$id,
'pages');
426 $excludedDoktypes =
$GLOBALS[
'BE_USER']->getTSConfigVal(
'options.pageTree.excludeDoktypes');
427 if (!empty($excludedDoktypes)) {
429 $where .=
' AND doktype NOT IN (' . implode(
',', $excludedDoktypes) .
')';
432 if ($searchFilter !==
'') {
433 if (is_numeric($searchFilter) && $searchFilter > 0) {
434 $searchWhere .=
'uid = ' . (int)$searchFilter .
' OR ';
436 $searchFilter =
$GLOBALS[
'TYPO3_DB']->fullQuoteStr(
'%' . $searchFilter .
'%',
'pages');
437 $useNavTitle =
$GLOBALS[
'BE_USER']->getTSConfigVal(
'options.pageTree.showNavTitle');
438 $useAlias =
$GLOBALS[
'BE_USER']->getTSConfigVal(
'options.pageTree.searchInAlias');
440 $searchWhereAlias =
'';
442 $searchWhereAlias =
' OR alias LIKE ' . $searchFilter;
446 $searchWhere .=
'(nav_title LIKE ' . $searchFilter .
447 ' OR (nav_title = "" AND title LIKE ' . $searchFilter .
')' . $searchWhereAlias .
')';
449 $searchWhere .=
'title LIKE ' . $searchFilter . $searchWhereAlias;
452 $where .=
' AND (' . $searchWhere .
')';
467 return $GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
'uid,t3ver_wsid',
'pages', $where,
'',
'sorting',
'',
'uid');
479 $subpage =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetSingleRow(
'uid',
'pages', $where,
'',
'sorting',
'',
'uid');
481 if (!$subpage[
'uid']) {
482 $returnValue =
false;