<?php

/**-----------------------------------------------
*
* Rooty, 2018 <rooty@rooty.me>
*
*
* This software is protected by copyright, please
* read the file COPYRIGHT.
* This program is distributed in the hope that it
* will be useful, but without any warranty; without
* even the implied warranty of merchantability or
* fitness for a particular purpose. Please
* read the file LICENCE.
*
* Fichier EntryNodePrint.php
*
* Ce fichier contient la classe EntryNodePrint
*<BR>
* @author Initiance <www.initiance.com|martial@initiance.com>
* @copyright Copyright &copy; 2009-2018, Rooty 
* @since 2004/06/07
* @version 0.3
* @link www.rooty.me
* @package object_printing
* @subpackage EntryNodePrint 
*/
if ( !defined('SYSTEM_IN') )
{
 die("Hacking attempt");
}

/**
* Classe EntryNodePrint
*<p>Cette classe permet la recuperation d'EntryNode</p>
* @package object_printing
* @subpackage EntryNodePrint 
*/
class EntryNodePrint extends Printing
{

	//
	// Constructor
	//
/**
* Constructeur de la classe EntryNode
* @access public
*/
	function EntryNodePrint()
	{
		$this->__construct();
	}

	function __construct()
	{
		parent::__construct("1.0", "Olivier DEVAINE", "Affichage des \"Communautés accéssibles\" et possibilités d\'en Changer");
	}

/**
* Remplace dans la template principale
* @access public
*/
	function __print()
	{
		global $SERVER_NAME, $SCRIPT_NAME, $CONF_PERSISTANT_SECURE;

		/* Récupération de toutes les langues actives */
		$tab=$GLOBALS["SYSTEM_USER_SESSION"]->getValidEntryNode();
		$tabEntryNode=array();

		if (count($tab)<=1)
		return "";

		$MaTemplate = new ModeliXeQware($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."object_printing/entrynodeprint/entrynode.mxt");
		$MaTemplate->SetModeliXe(true);

		/* création de l'url de login */
		$url =$_SERVER['SCRIPT_NAME'];
		$url.="?system=entryNode";
		$url=addIdToUrl($url);

		$MaTemplate->MxAttribut("urlAction", $url);
		$MaTemplate->MxText("LblEntryNodeId", getMessage("LblEntryNodeId"));
		$MaTemplate->MxText("communaute", getMessage("communaute"));
		$MaTemplate->MxImage("picto", $GLOBALS['CONF_DATA_PATH']."data/template/".$GLOBALS['SYSTEM_TEMPLATE_DIR']."media/picto/groups.png");

		/* gestion du lib en fonction de la langue courante */
		$currentCode=$GLOBALS["SYSTEM_USER_SESSION"]->langue->getCode();
		$defaultCode=$GLOBALS["SYSTEM_DEFAULT_LANGUAGE_CODE"];

		$lib=eregi_replace("^[[:space:]]*[a-z]+[.)".chr(176)."][[:space:]]+", "", $GLOBALS["SYSTEM_USER_SESSION"]->listUserNode->getLibelleNodeId($GLOBALS["SYSTEM_USER_SESSION"]->entryNodeId, $currentCode));

		if ($lib=="")
		{
			$lib=$GLOBALS["SYSTEM_USER_SESSION"]->listUserNode->getLibelleNodeId($GLOBALS["SYSTEM_USER_SESSION"]->entryNodeId, $defaultCode);
		}
		$MaTemplate->MxText("currentEntryNode", htmlentitiesconv($lib));
		$MaTemplate->MxText("entryNode", getMessage("entryNode"));

		for ($i=0; $i<count($tab);$i++)
		{
			$lib=$GLOBALS["SYSTEM_USER_SESSION"]->listUserNode->getLibelleNodeId($tab[$i], $currentCode);
			if ($lib=="")
			{
				$lib=$GLOBALS["SYSTEM_USER_SESSION"]->listUserNode->getLibelleNodeId($tab[$i], $defaultCode);
			}
			/* Fonction permettant de supprimer les numeros, le point et l'espace à l'affichage */
			$lib = eregi_replace("^[[:space:]]*[a-z]+[.)".chr(176)."][[:space:]]+", "", $lib);

			$MaTemplate->MxText("bloc1.entrynode", htmlentitiesconv($lib));
// 			var_dump(htmlentitiesconv($lib));
			$MaTemplate->MxAttribut("bloc1.entrynodeid", $tab[$i]);
			if($tab[$i]==eid( ))
				$MaTemplate->MxAttribut("bloc1.class", "selected");
			else
				$MaTemplate->MxAttribut("bloc1.class", "none");
			$MaTemplate->MxAttribut("bloc1.url", $url."&entryNodeId=".$tab[$i]);
			$MaTemplate->MxBloc("bloc1", "loop");
		}
		$MaTemplate->MxSelect("entryNodeId", "entryNodeId", eid(), $tabEntryNode, '','', '');
		$data=$MaTemplate->MxWrite();
		$GLOBALS["SYSTEM_TEMPLATE"]->MxText("entrynodeprint", $data);	// Et voila!!!!!
		return true;
	}
}
?>