<?php

define('RENDER_MODE', 'catalyz');

$node = $page->getNode();

use_helper('Form');

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

ob_start();
use_helper('I18N');

$allLanguages = sfConfig::get('app_translations_available_languages');
$default = sfConfig::get('app_translations_default_language');

$ContentTreeNode = $ContentTree->getCurrentNode();
// $existing_languages = $node->getAvailableTranslations();
$allLanguages = Catalyz::getAllTranslations();
// $perms = array();
// $available_languages = array();
// foreach($allLanguages as $iso => $name) {
// if (!isset($existing_languages[$iso])) {
// $available_languages[$iso] = ucfirst($name);
// }
// $perms[$iso]['edit'] = true;
// $perms[$iso]['delete'] = ($iso != $default);
// }
include_partial('catalyz/header');

?>

<div id="catalyz-content">
<div id="catalyz-content-internal">
<h1><?php echo __('Administration', array(), 'catalyz'); ?></h1>
<?php include_partial('catalyz/flash'); ?>

<ul>
<?php foreach (CatalyzToolbar::instance()->getAdminActions($page) as $action): ?>
	<li>
	<?php
		$options = '';
        if (isset($action['target'])) {
            $options .= sprintf(' target="%s"', $action['target']);
        }
		$icon = sprintf('/images/catalyz/%s.png', $action['key']);
		if (!empty($action['icon']) && is_file(sfConfig::get('sf_web_dir') . $action['icon'])) {
			$icon = $action['icon'];
		}
        printf('&nbsp;<a href="%s"%s><img src="%s" border="0" align="top" alt="%s" title="%s" /></a>', $action['url'], $options, $icon, $action['caption'], $action['caption']);
        printf('&nbsp;<a href="%s"%s>%s</a>', $action['url'], $options, $action['caption']);
		if (!empty($action['description'])) {
			printf('<p><i>%s</i></p>', $action['description']);
		}
     ?>
	 </li>
<?php endforeach ?>
</ul>

</div>
</div>
<?php

$content = ob_get_contents();

ob_end_clean();

$layout = LayoutManager::instance()->getCatalyzTemplate($ContentTreeNode->getCurrentLayoutNameForAction());
$properties['layout_family'] = $layout[0];
$properties['layout_name'] = $layout[1];
$properties['content'] = $content;

include_component($properties['layout_family'], $properties['layout_name'], $properties);

?>