Skip to content

Commit

Permalink
[BUGFIX] Analyse root line to find both main and sub template
Browse files Browse the repository at this point in the history
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: FluidTYPO3#177
  • Loading branch information
NamelessCoder committed Aug 7, 2014
1 parent 1ffe8ec commit 10eca20
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions Classes/Service/PageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

}

Expand All @@ -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'];
}
Expand Down

0 comments on commit 10eca20

Please sign in to comment.