91 'backend_layout_next_level' 123 $this->pageUid = (int)
$uid;
125 if ($context === NULL) {
127 $this->pageContext =
$GLOBALS[
'TSFE']->sys_page;
132 $this->pageContext = $context;
144 $this->languageUid = (int)$this->pageContext->sys_language_uid;
145 $this->workspaceUid = (
int)$this->pageContext->versioningWorkspaceId;
146 $this->versionPreview = $this->pageContext->versioningPreview;
147 if ($this->mountPointParameter !==
'') {
148 if (!
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'enable_mount_pids']) {
149 throw new \RuntimeException(
'Mount-Point Pages are disabled for this installation. Cannot resolve a Rootline for a page with Mount-Points', 1343462896);
154 if (self::$cache === NULL) {
158 self::$rootlineFields = array_unique(self::$rootlineFields);
159 $this->databaseConnection =
$GLOBALS[
'TYPO3_DB'];
172 self::$localCache = array();
173 self::$pageRecordCache = array();
189 return implode(
'_', array(
190 $otherUid !== NULL ? (
int)$otherUid : $this->pageUid,
194 $this->versionPreview ? 1 : 0
203 public function get() {
204 if (!isset(static::$localCache[$this->cacheIdentifier])) {
205 $entry = static::$cache->get($this->cacheIdentifier);
207 $this->generateRootlineCache();
210 $depth = count($entry);
218 if (isset(static::$localCache[$parentCacheIdentifier])) {
223 $entry = array_slice($entry, 1, NULL, TRUE);
224 static::$localCache[$parentCacheIdentifier] = $entry;
240 if (!isset(self::$pageRecordCache[$currentCacheIdentifier])) {
241 $row = $this->databaseConnection->exec_SELECTgetSingleRow(implode(
',', self::$rootlineFields),
'pages',
'uid = ' . (
int)
$uid .
' AND pages.deleted = 0 AND pages.doktype <> ' . \
TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_RECYCLER);
243 throw new \RuntimeException(
'Could not fetch page data for uid ' .
$uid .
'.', 1343589451);
245 $this->pageContext->versionOL(
'pages', $row, FALSE, TRUE);
246 $this->pageContext->fixVersioningPid(
'pages', $row);
247 if (is_array($row)) {
248 if ($this->languageUid > 0) {
249 $row = $this->pageContext->getPageOverlay($row, $this->languageUid);
251 $row = $this->enrichWithRelationFields(isset($row[
'_PAGES_OVERLAY_UID']) ? $row[
'_PAGES_OVERLAY_UID'] :
$uid, $row);
252 self::$pageRecordCache[$currentCacheIdentifier] = $row;
255 if (!is_array(self::$pageRecordCache[$currentCacheIdentifier])) {
256 throw new \RuntimeException(
'Broken rootline. Could not resolve page with uid ' .
$uid .
'.', 1343464101);
258 return self::$pageRecordCache[$currentCacheIdentifier];
269 protected function enrichWithRelationFields(
$uid, array $pageRecord) {
271 foreach (
$GLOBALS[
'TCA'][
'pages'][
'columns'] as $column => $configuration) {
273 $configuration = $configuration[
'config'];
274 if ($configuration[
'MM']) {
278 $pageRecord[$column],
279 isset($configuration[
'allowed']) ? $configuration[
'allowed'] : $configuration[
'foreign_table'],
280 $configuration[
'MM'],
285 $relatedUids = isset($loadDBGroup->tableArray[$configuration[
'foreign_table']])
286 ? $loadDBGroup->tableArray[$configuration[
'foreign_table']]
289 $columnIsOverlaid = in_array($column, $pageOverlayFields, TRUE);
290 $table = $configuration[
'foreign_table'];
291 $field = $configuration[
'foreign_field'];
292 $whereClauseParts = array($field .
' = ' . (
int)($columnIsOverlaid ?
$uid : $pageRecord[
'uid']));
293 if (isset($configuration[
'foreign_match_fields']) && is_array($configuration[
'foreign_match_fields'])) {
294 foreach ($configuration[
'foreign_match_fields'] as $field => $value) {
295 $whereClauseParts[] = $field .
' = ' . $this->databaseConnection->fullQuoteStr($value, $table);
298 if (isset($configuration[
'foreign_table_field'])) {
299 if ((
int)$this->languageUid > 0 && $columnIsOverlaid) {
300 $whereClauseParts[] = trim($configuration[
'foreign_table_field']) .
' = \'pages_language_overlay\'';
302 $whereClauseParts[] = trim($configuration[
'foreign_table_field']) .
' = \'pages\'';
305 if (isset(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'][
'disabled'])) {
306 $whereClauseParts[] = $table .
'.' .
$GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'][
'disabled'] .
' = 0';
308 $whereClause = implode(
' AND ', $whereClauseParts);
309 $whereClause .= $this->pageContext->deleteClause($table);
310 $orderBy = isset($configuration[
'foreign_sortby']) ? $configuration[
'foreign_sortby'] :
'';
311 $rows = $this->databaseConnection->exec_SELECTgetRows(
'uid', $table, $whereClause,
'', $orderBy);
312 if (!is_array($rows)) {
313 throw new \RuntimeException(
'Could to resolve related records for page ' .
$uid .
' and foreign_table ' . htmlspecialchars($configuration[
'foreign_table']), 1343589452);
315 $relatedUids = array();
316 foreach ($rows as $row) {
317 $relatedUids[] = $row[
'uid'];
320 $pageRecord[$column] = implode(
',', $relatedUids);
334 $configuration = $configuration[
'config'];
335 if (!empty($configuration[
'MM']) && !empty($configuration[
'type']) && in_array($configuration[
'type'], array(
'select',
'inline',
'group'))) {
338 if (!empty($configuration[
'foreign_field']) && !empty($configuration[
'type']) && in_array($configuration[
'type'], array(
'select',
'inline'))) {
350 protected function generateRootlineCache() {
354 $mountPoint = $this->
getRecordArray($this->parsedMountPointParameters[$this->pageUid]);
356 $parentUid = $mountPoint[
'pid'];
358 unset($this->parsedMountPointParameters[$this->pageUid]);
360 $parentUid = $page[
'pid'];
362 $cacheTags = array(
'pageId_' . $page[
'uid']);
363 if ($parentUid > 0) {
365 $mountPointParameter = count($this->parsedMountPointParameters) > 0 ? $this->mountPointParameter :
'';
368 $rootline = $rootline->get();
370 foreach ($rootline as $entry) {
371 $cacheTags[] =
'pageId_' . $entry[
'uid'];
372 if ($entry[
'uid'] == $this->pageUid) {
373 throw new \RuntimeException(
'Circular connection in rootline for page with uid ' . $this->pageUid .
' found. Check your mountpoint configuration.', 1343464103);
379 array_push($rootline, $page);
381 static::$cache->set($this->cacheIdentifier, $rootline, $cacheTags);
392 return in_array($this->pageUid, array_keys($this->parsedMountPointParameters));
404 if ($mountPointPageData[
'mount_pid'] != $mountedPageData[
'uid']) {
405 throw new \RuntimeException(
'Broken rootline. Mountpoint parameter does not match the actual rootline. mount_pid (' . $mountPointPageData[
'mount_pid'] .
') does not match page uid (' . $mountedPageData[
'uid'] .
').', 1343464100);
408 if ($mountPointPageData[
'mount_pid_ol']) {
409 $mountedPageData[
'_MOUNT_OL'] = TRUE;
410 $mountedPageData[
'_MOUNT_PAGE'] = array(
411 'uid' => $mountPointPageData[
'uid'],
412 'pid' => $mountPointPageData[
'pid'],
413 'title' => $mountPointPageData[
'title']
417 $mountedPageData = $mountPointPageData;
420 $mountedPageData[
'_MP_PARAM'] = $this->pageUid .
'-' . $mountPointPageData[
'uid'];
421 return $mountedPageData;
433 foreach ($mountPoints as $mP) {
435 $this->parsedMountPointParameters[$mountedPageUid] = $mountPageUid;
getCacheIdentifier($otherUid=NULL)
__construct($uid, $mountPointParameter='', \TYPO3\CMS\Frontend\Page\PageRepository $context=NULL)
static intExplode($delimiter, $string, $removeEmptyValues=FALSE, $limit=0)
parseMountPointParameter()
static makeInstance($className)
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
$parsedMountPointParameters
processMountedPage(array $mountedPageData, array $mountPointPageData)
columnHasRelationToResolve(array $configuration)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]