From 10eca206d858f2b50482efeeee6725f0e3d78485 Mon Sep 17 00:00:00 2001 From: Claus Due Date: Thu, 7 Aug 2014 17:46:32 +0200 Subject: [PATCH] [BUGFIX] Analyse root line to find both main and sub template This change ensures that when resolving the page templates, the PageService will not stop until both a main and sub template seletion value is resolved. Close: #177 --- Classes/Service/PageService.php | 46 ++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/Classes/Service/PageService.php b/Classes/Service/PageService.php index 57752a69..d5149e74 100755 --- a/Classes/Service/PageService.php +++ b/Classes/Service/PageService.php @@ -105,26 +105,36 @@ public function injectWorkspaceAwareRecordService(WorkspacesAwareRecordService $ * @api */ public function getPageTemplateConfiguration($pageUid) { - $pageUid = intval($pageUid); + $pageUid = (integer) $pageUid; if (1 > $pageUid) { return NULL; } $page = $this->workspaceAwareRecordService->getSingle('pages', '*', $pageUid); - // if page has a controller action - if (strpos($page['tx_fed_page_controller_action'], '->')) { - return $page; - } - // if no controller action was found loop through rootline. Note: 't3ver_oid' is analysed in order - // to make versioned records inherit the original record's configuration as an emulated first parent page. + + // Note: 't3ver_oid' is analysed in order to make versioned records inherit the original record's + // configuration as an emulated first parent page. + $resolvedMainTemplateIdentity = NULL; + $resolvedSubTemplateIdentity = NULL; do { - $resolveParentPageUid = 0 > (integer) $page['pid'] ? $page['t3ver_oid'] : $page['pid']; - $page = $this->workspaceAwareRecordService->getSingle('pages', '*', (integer) $resolveParentPageUid); - } while (NULL !== $page && FALSE === strpos($page['tx_fed_page_controller_action_sub'], '->')); - $page['tx_fed_page_controller_action'] = $page['tx_fed_page_controller_action_sub']; - if (TRUE === empty($page['tx_fed_page_controller_action'])) { - $page = NULL; + if (NULL === $resolvedMainTemplateIdentity && FALSE !== strpos($page['tx_fed_page_controller_action'], '->')) { + $resolvedMainTemplateIdentity = $page['tx_fed_page_controller_action']; + } + if (NULL === $resolvedSubTemplateIdentity && FALSE !== strpos($page['tx_fed_page_controller_action_sub'], '->')) { + $resolvedSubTemplateIdentity = $page['tx_fed_page_controller_action_sub']; + } + $resolveParentPageUid = (integer) (0 > $page['pid'] ? $page['t3ver_oid'] : $page['pid']); + $page = $this->workspaceAwareRecordService->getSingle('pages', '*', $resolveParentPageUid); + } while (NULL !== $page && (NULL === $resolvedMainTemplateIdentity || NULL === $resolvedSubTemplateIdentity)); + if (NULL === $resolvedMainTemplateIdentity && NULL === $resolvedSubTemplateIdentity) { + return NULL; + } + if (NULL === $resolvedMainTemplateIdentity && NULL !== $resolvedSubTemplateIdentity) { + $resolvedMainTemplateIdentity = $resolvedSubTemplateIdentity; } - return $page; + return array( + 'tx_fed_page_controller_action' => $resolvedMainTemplateIdentity, + 'tx_fed_page_controller_action_sub' => $resolvedSubTemplateIdentity + ); } @@ -136,14 +146,14 @@ public function getPageTemplateConfiguration($pageUid) { * @api */ public function getPageFlexFormSource($pageUid) { - $pageUid = intval($pageUid); + $pageUid = (integer) $pageUid; if (1 > $pageUid) { return NULL; } $page = $this->workspaceAwareRecordService->getSingle('pages', '*', $pageUid); - while (NULL !== $page && 0 !== intval($page['uid']) && TRUE === empty($page['tx_fed_page_flexform'])) { - $resolveParentPageUid = 0 > (integer) $page['pid'] ? $page['t3ver_oid'] : $page['pid']; - $page = $this->workspaceAwareRecordService->getSingle('pages', '*', (integer) $resolveParentPageUid); + while (NULL !== $page && 0 !== (integer) $page['uid'] && TRUE === empty($page['tx_fed_page_flexform'])) { + $resolveParentPageUid = (integer) (0 > $page['pid'] ? $page['t3ver_oid'] : $page['pid']); + $page = $this->workspaceAwareRecordService->getSingle('pages', '*', $resolveParentPageUid); }; return $page['tx_fed_page_flexform']; }