<?php

$properties = array();
$properties['page'] = $page;
$properties['node'] = $node;
$properties['culture'] = $culture;
$properties['ContentTree'] = $ContentTree;
$properties['sf_request'] = $sf_request;
$properties['sf_context'] = $sf_context;

if ($page instanceof ICatalyzAdvancedContentProvider) {
    $needsLayout = $page->needsLayout($node, $sf_request);
    $layoutName = $page->getTemplateName($node, $sf_request);
} else {
    $needsLayout = true;
    $layoutName = 'view';
}

sfContext::getInstance()->getUser()->setCulture(Catalyz::getPageCulture());
setlocale(LC_TIME, Catalyz::getPageCulture(true));
if ($needsLayout) {
	$ContentTreeNode = $ContentTree->getCurrentNode();
    $layout = $ContentTreeNode->getCurrentLayoutNameForAction();
    $properties['layout_family'] = $layout[0];
    $properties['layout_name'] = $layout[1];

    $content = '';
    if (!empty($custom_content)) {
        $content .= get_partial($custom_content, $properties);
    } else {
        $content .= get_partial($node->getNodeClass() . '/' . $layoutName, $properties);
    }

    use_helper('Catalyz');
    embed_with_layout($content, $layout, $properties);
} else {
    include_partial($node->getNodeClass() . '/' . $layoutName, $properties);
    exit;
}

?>