<?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');
// $existing_languages = $node->getAvailableTranslations();
$allLanguages = Catalyz::getAllTranslations();
unset($allLanguages[$default]);
// $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 class="content-add03">

<?php use_javascript('http://maps.google.com/maps?file=api&amp;v=2&amp;key=' . sfConfig::get('app_gmap') . '&sensor=true'); ?>

	<div id="map_canvas" style="width: 385px; height: 300px"></div>

	<p><a href="javascript://" onclick="javascript:window.open('<?php echo url_for('@katao_fournisseurs_popup') ?>', 'PartnersPopup', 'status=0,toolbar=0,height=720,width=750,scrollbars=yes')">Voir les partenaires en détail &raquo;</a></p>

<script type="text/javascript" language="JavaScript">
/* <![CDATA[ */

window.onload = function(){
 if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
		map.setCenter(new GLatLng(45, 3), 6);
        map.setUIToDefault();

		var myIcon = new GIcon(G_DEFAULT_ICON);
		myIcon.image = 'http://maps.google.com/mapfiles/marker_green.png';
		var markerOptions = { icon: myIcon};

<?php foreach (KataoSupplierPeer::retrieveByPKs(array_keys(KataoSupplierPeer::getAllVisible())) as $katao_supplier): ?>
	<?php $katao_user = $katao_supplier->getFirstKataoUser() ?>
	<?php if (!is_null($katao_user) && KataoUser::STATUS_ACTIVE == $katao_user->getStatus() && '' != $katao_supplier->getGmapLat() && '' != $katao_supplier->getGmapLng()): ?>
		var markerS<?php echo $katao_user->getId(); ?> = new GMarker(new GLatLng(<?php printf('%f,%f', $katao_supplier->getGmapLat(), $katao_supplier->getGmapLng()); ?>), markerOptions);
		GEvent.addListener(markerS<?php echo $katao_user->getId(); ?>, "click", function() {
			markerS<?php echo $katao_user->getId(); ?>.openInfoWindowHtml('<?php echo str_replace(array("\r\n", "\n", "\r"), array('\n', '\n', ''), get_partial('katao/gmap_supplier', array('supplier' => $katao_user, 'popup' => false))); ?>');
		});
		map.addOverlay(markerS<?php echo $katao_user->getId(); ?>);
	<?php endif ?>
<?php endforeach ?>
    }
}

window.onunload = GUnload;

/* ]]> */
</script>

</div>

<?php

$content = ob_get_contents();

ob_end_clean();
// $layout = LayoutManager::instance()->getCatalyzTemplate($ContentTreeNode->getCurrentLayoutNameForAction());
$properties['layout_family'] = 'katao';
$properties['layout_name'] = 'default';
$properties['content'] = $content;

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

?>