2 namespace TYPO3\CMS\Backend\Tree\Pagetree;
62 $data[
'pages'][$node->getWorkspaceId()][
'hidden'] = 0;
63 self::processTceCmdAndDataMap(array(), $data);
74 $data[
'pages'][$node->getWorkspaceId()][
'hidden'] = 1;
75 self::processTceCmdAndDataMap(array(), $data);
86 $cmd[
'pages'][$node->getId()][
'delete'] = 1;
87 self::processTceCmdAndDataMap($cmd);
99 $cmd[
'pages'][$node->getId()][
'undelete'] = 1;
100 self::processTceCmdAndDataMap($cmd);
101 if ($node->getId() !== $targetId) {
102 self::moveNode($node, $targetId);
115 if (
$GLOBALS[
'BE_USER']->checkLanguageAccess(0)) {
116 $data[
'pages'][$node->getWorkspaceId()][$node->getTextSourceField()] = $updatedLabel;
117 self::processTceCmdAndDataMap(array(), $data);
119 throw new \RuntimeException(implode(LF, array(
'Editing title of page id \'' . $node->getWorkspaceId() .
'\' failed. Editing
default language is not allowed.
')), 1365513336);
132 public static function copyNode(\TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNode $sourceNode, $targetId)
134 $cmd['pages
'][$sourceNode->getId()]['copy
'] = $targetId;
135 $returnValue = self::processTceCmdAndDataMap($cmd);
136 return $returnValue['pages
'][$sourceNode->getId()];
148 public static function moveNode(\TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNode $sourceNode, $targetId)
150 $cmd['pages
'][$sourceNode->getId()]['move
'] = $targetId;
151 self::processTceCmdAndDataMap($cmd);
162 public static function createNode(\TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNode $parentNode, $targetId, $pageType)
164 $placeholder = 'NEW12345
';
165 $pid = (int)$parentNode->getWorkspaceId();
166 $targetId = (int)$targetId;
168 // Use page TsConfig as default page initialization
169 $pageTs = BackendUtility::getPagesTSconfig($pid);
170 if (array_key_exists('TCAdefaults.
', $pageTs) && array_key_exists('pages.
', $pageTs['TCAdefaults.
'])) {
171 $data['pages
'][$placeholder] = $pageTs['TCAdefaults.
']['pages.
'];
173 $data['pages
'][$placeholder] = array();
176 $data['pages
'][$placeholder]['pid
'] = $pid;
177 $data['pages
'][$placeholder]['doktype
'] = $pageType;
178 $data['pages
'][$placeholder]['title
'] = $GLOBALS['LANG
']->sL('LLL:EXT:lang/locallang_core.xlf:tree.defaultPageTitle
', true);
179 $newPageId = self::processTceCmdAndDataMap(array(), $data);
180 $node = self::getNode($newPageId[$placeholder]);
181 if ($pid !== $targetId) {
182 self::moveNode($node, $targetId);
185 return $newPageId[$placeholder];
204 protected static function processTceCmdAndDataMap(array $cmd, array $data = array())
207 $tce = GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class);
208 $tce->stripslashes_values = 0;
209 $tce->start($data, $cmd);
210 $tce->copyTree = MathUtility::forceIntegerInRange($GLOBALS['BE_USER
']->uc['copyLevels
'], 0, 100);
212 $tce->process_cmdmap();
213 $returnValues = $tce->copyMappingArray_merged;
214 } elseif (!empty($data)) {
215 $tce->process_datamap();
216 $returnValues = $tce->substNEWwithIDs;
218 $returnValues = array();
221 if (!empty($tce->errorLog)) {
222 throw new \RuntimeException(implode(LF, $tce->errorLog), 1333754629);
224 return $returnValues;
234 public static function getNode($nodeId, $unsetMovePointers = true)
236 $record = self::getNodeRecord($nodeId, $unsetMovePointers);
237 return self::getNewNode($record);
246 public static function getMountPointPath($uid = -1)
249 $uid = (int)$GLOBALS['BE_USER
']->uc['pageTree_temporaryMountPoint
'];
254 if (self::$useNavTitle === null) {
255 self::$useNavTitle = $GLOBALS['BE_USER
']->getTSConfigVal('options.pageTree.showNavTitle
');
257 $rootline = array_reverse(BackendUtility::BEgetRootLine($uid));
258 array_shift($rootline);
260 foreach ($rootline as $rootlineElement) {
261 $record = self::getNodeRecord($rootlineElement['uid
']);
262 $text = $record['title
'];
263 if (self::$useNavTitle && trim($record['nav_title
']) !== '') {
264 $text = $record['nav_title
'];
266 $path[] = htmlspecialchars($text);
268 return '/
' . implode('/
', $path);
278 public static function getNodeRecord($nodeId, $unsetMovePointers = true)
280 $record = BackendUtility::getRecordWSOL('pages
', $nodeId, '*
', '', true, $unsetMovePointers);
290 public static function getDomainName($uid)
292 $whereClause = 'pid=
' . (int)$uid . BackendUtility::deleteClause('sys_domain
') . BackendUtility::BEenableFields('sys_domain
');
293 $domain = $GLOBALS['TYPO3_DB
']->exec_SELECTgetSingleRow('domainName
', 'sys_domain
', $whereClause, '', 'sorting
');
294 return is_array($domain) ? htmlspecialchars($domain['domainName
']) : '';
304 public static function getNewNode($record, $mountPoint = 0)
306 $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
307 if (self::$titleLength === null) {
308 self::$useNavTitle = $GLOBALS['BE_USER
']->getTSConfigVal('options.pageTree.showNavTitle
');
309 self::$addIdAsPrefix = $GLOBALS['BE_USER
']->getTSConfigVal('options.pageTree.showPageIdWithTitle
');
310 self::$addDomainName = $GLOBALS['BE_USER
']->getTSConfigVal('options.pageTree.showDomainNameWithTitle
');
311 self::$backgroundColors = $GLOBALS['BE_USER
']->getTSConfigProp('options.pageTree.backgroundColor
');
312 self::$titleLength = (int)$GLOBALS['BE_USER
']->uc['titleLen
'];
315 $subNode = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNode::class);
316 $subNode->setRecord($record);
317 $subNode->setCls($record['_CSSCLASS
']);
318 $subNode->setType('pages
');
319 $subNode->setId($record['uid
']);
320 $subNode->setMountPoint($mountPoint);
321 $subNode->setWorkspaceId($record['_ORIG_uid
'] ?: $record['uid
']);
322 $subNode->setBackgroundColor(self::$backgroundColors[$record['uid
']]);
324 $text = $record['title
'];
325 if (self::$useNavTitle && trim($record['nav_title
']) !== '') {
326 $field = 'nav_title
';
327 $text = $record['nav_title
'];
329 if (trim($text) === '') {
330 $visibleText = '[
' . $GLOBALS['LANG
']->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title
', true) . ']
';
332 $visibleText = $text;
334 $visibleText = GeneralUtility::fixed_lgd_cs($visibleText, self::$titleLength);
336 if (self::$addDomainName) {
337 $domain = self::getDomainName($record['uid
']);
338 $suffix = $domain !== '' ? ' [
' . $domain . ']
' : '';
340 $qtip = str_replace(' -
', '<br />
', htmlspecialchars(BackendUtility::titleAttribForPages($record, '', false)));
342 $lockInfo = BackendUtility::isRecordLocked('pages
', $record['uid
']);
343 if (is_array($lockInfo)) {
344 $qtip .= '<br />
' . htmlspecialchars($lockInfo['msg
']);
345 $prefix .= '<span
class=
"typo3-pagetree-status">
' . $iconFactory->getIcon('status-warning-in-use
', Icon::SIZE_SMALL)->render() . '</span>
';
347 // Call stats information hook
349 if (is_array($GLOBALS['TYPO3_CONF_VARS
']['SC_OPTIONS
']['GLOBAL
']['recStatInfoHooks
'])) {
350 $_params = array('pages
', $record['uid
']);
352 foreach ($GLOBALS['TYPO3_CONF_VARS
']['SC_OPTIONS
']['GLOBAL
']['recStatInfoHooks
'] as $_funcRef) {
353 $stat .= GeneralUtility::callUserFunction($_funcRef, $_params, $fakeThis);
356 $prefix .= htmlspecialchars(self::$addIdAsPrefix ? '[
' . $record['uid
'] . ']
' : '');
357 $subNode->setEditableText($text);
358 $subNode->setText(htmlspecialchars($visibleText), $field, $prefix, htmlspecialchars($suffix) . $stat);
359 $subNode->setQTip($qtip);
360 if ((int)$record['uid
'] !== 0) {
361 $spriteIconCode = $iconFactory->getIconForRecord('pages
', $record, Icon::SIZE_SMALL)->render();
363 $spriteIconCode = $iconFactory->getIcon('apps-pagetree-root
', Icon::SIZE_SMALL)->render();
365 $subNode->setSpriteIconCode($spriteIconCode);
367 !$subNode->canCreateNewPages()
368 || VersionState::cast($record['t3ver_state
'])->equals(VersionState::DELETE_PLACEHOLDER)
370 $subNode->setIsDropTarget(false);
373 !$subNode->canBeEdited()
374 || !$subNode->canBeRemoved()
375 || VersionState::cast($record['t3ver_state
'])->equals(VersionState::DELETE_PLACEHOLDER)
377 $subNode->setDraggable(false);