281 lines
8.5 KiB
PHP
Raw Normal View History

2020-12-03 16:35:44 +01:00
<?php
/**-----------------------------------------------
*
2020-12-10 18:33:53 +01:00
* Granilim (C) 2004-2006, Limousin expansion
* Limousin expansion contact@granilim.org
2020-12-03 16:35:44 +01:00
*
* 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 NavigationPrint.php
*
* Ce fichier contient la classe NavigationPrint
*<BR>
* @author Initiance <www.initiance.com|martial@initiance.com>
2020-12-10 18:33:53 +01:00
* @copyright Copyright &copy; 2004-2006, Limousin expansion
2020-12-03 16:35:44 +01:00
* @since 2004/06/07
2020-12-10 18:33:53 +01:00
* @version 0.1
* @link www.granilim.org
2020-12-03 16:35:44 +01:00
* @package object_printing
* @subpackage NavigationPrint
*/
if ( !defined('SYSTEM_IN') )
{
die("Hacking attempt");
}
/**
* Classe NavigationPrint
*<p>cette classe permet la recuperation de l'NavigationPrint</p>
* @package object_printing
* @subpackage NavigationPrint
*/
class NavigationPrint extends Printing
{
//
// Constructor
//
/**
* Constructeur de la classe NavigationPrint
* @access public
*/
function NavigationPrint()
{
$this->__construct();
}
function __construct()
{
2020-12-10 18:33:53 +01:00
parent::__construct("1.0", "Olivier DEVAINE", "Affichage de la NavigationNode");
2020-12-03 16:35:44 +01:00
}
/**
* Remplace dans la template principale
* @access public
*/
function __print()
{
/* gestion du lib en fonction de la langue courante */
$currentCode=$GLOBALS["SYSTEM_USER_SESSION"]->langue->getCode();
$defaultCode=$GLOBALS["SYSTEM_DEFAULT_LANGUAGE_CODE"];
/* fin récupération des codes par defaut */
$MaTemplate = new ModeliXeQware($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."object_printing/navigationprint/main.mxt");
2020-12-03 16:35:44 +01:00
$MaTemplate->SetModeliXe(true);
$MaTemplate->MxText("NavigationPrintName", getMessage("NavigationPrintName"));
$Node =$GLOBALS["SYSTEM_USER_SESSION"]->getNode($GLOBALS["SYSTEM_USER_SESSION"]->entryNodeId);
/* recuperation de l'image de la langue courante */
2020-12-10 18:33:53 +01:00
if (file_exists("data/image/icons/node/".strtolower($Node->getIcone())) && ($Node->getIcone()!=""))
2020-12-03 16:35:44 +01:00
{
2020-12-10 18:33:53 +01:00
$img="data/image/icons/node/".strtolower($Node->getIcone());
2020-12-03 16:35:44 +01:00
}else{
2020-12-10 18:33:53 +01:00
$img="data/image/icons/node/defaultnode.gif";
2020-12-03 16:35:44 +01:00
}
$urlToGo = formatUrlNode("navigationNode", $Node->getId());
/* pour l'url */
$MaTemplate->MxAttribut("nodeUrl", htmlentitiesconv($urlToGo));
2020-12-10 18:33:53 +01:00
$lib=$Node->getLibelle($currentCode);
2020-12-03 16:35:44 +01:00
if ($lib=="")
{
2020-12-10 18:33:53 +01:00
$lib=$Node->getLibelle($defaultCode);
2020-12-03 16:35:44 +01:00
}
2020-12-10 18:33:53 +01:00
$MaTemplate->MxImage("pictoNode", $img ,htmlentitiesconv($lib),"");
2020-12-03 16:35:44 +01:00
/* objet en cours */
2020-12-10 18:33:53 +01:00
if ($Node->getId()==nid())
$MaTemplate->MxAttribut("style", "NavigationSelected");
else
$MaTemplate->MxAttribut("style", "Navigation");
/* Fin des objets en cours */
2020-12-03 16:35:44 +01:00
$MaTemplate->MxText("nodeName", htmlentitiesconv($lib));
/* On affiche les noeuds suivants */
$forNode=$this->printForNode($GLOBALS["SYSTEM_USER_SESSION"]->entryNodeId);
$MaTemplate->MxText("Navigation", $forNode);
$data=$MaTemplate->MxWrite();
if ($forNode!="")
{
$GLOBALS["SYSTEM_TEMPLATE"]->MxText("navigationprint", $data);
}else{
$GLOBALS["SYSTEM_TEMPLATE"]->MxText("navigationprint", "");
}
}
/**
* affichage d'un noeud et de tous ses sous noeuds
* @access public
*/
function printForNode($nodeId, $modelixeMxt="navigationnode.mxt")
{
global $SERVER_NAME, $SCRIPT_NAME, $CONF_PERSISTANT_SECURE;
$MaTemplate = new ModeliXeQware($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."object_printing/navigationprint/".$modelixeMxt);
2020-12-03 16:35:44 +01:00
$MaTemplate->SetModeliXe(true);
/* gestion du lib en fonction de la langue courante */
$currentCode=$GLOBALS["SYSTEM_USER_SESSION"]->langue->getCode();
$defaultCode=$GLOBALS["SYSTEM_DEFAULT_LANGUAGE_CODE"];
/* fin récupération des codes par defaut */
/**
* recuperation des "tools"
* recuperation des "reps"
* + merge des 2 tableaux
*/
$tabObj=array_merge($this->getNodeSon($nodeId), $this->getObjectSon($nodeId));
/* Pour le Tri/Nom */
$tabName=array();
for ($i=0; $i<count($tabObj);$i++)
{
if(!is_object($tabObj[$i])) // c un obj!!!!
{
2020-12-10 18:33:53 +01:00
$lib=$tabObj[$i][1]->getName($currentCode);
if ($lib=="")
2020-12-03 16:35:44 +01:00
{
2020-12-10 18:33:53 +01:00
$lib=$tabObj[$i][1]->getName($defaultCode);
2020-12-03 16:35:44 +01:00
}
}else{
2020-12-10 18:33:53 +01:00
$lib=$tabObj[$i]->getLibelle($currentCode);
if ($lib=="")
2020-12-03 16:35:44 +01:00
{
2020-12-10 18:33:53 +01:00
$lib=$tabObj[$i]->getLibelle($defaultCode);
2020-12-03 16:35:44 +01:00
}
}
2020-12-10 18:33:53 +01:00
$tabName[$i]=$lib;
2020-12-03 16:35:44 +01:00
}
asort($tabName);
reset($tabName);
while (list($i, $lib) = each($tabName))
{
/* en fonction de l'obj */
if(is_object($tabObj[$i])) // c un dir!!!!
{
/* recuperation de l'image de la langue courante */
2020-12-10 18:33:53 +01:00
if (file_exists("data/image/icons/node/".strtolower($tabObj[$i]->getIcone())) && ($tabObj[$i]->getIcone()!=""))
2020-12-03 16:35:44 +01:00
{
2020-12-10 18:33:53 +01:00
$img="data/image/icons/node/".strtolower($tabObj[$i]->getIcone());
2020-12-03 16:35:44 +01:00
}else{
2020-12-10 18:33:53 +01:00
$img="data/image/icons/node/defaultnode.gif";
2020-12-03 16:35:44 +01:00
}
/* on prepare l'url */
$urlToGo = formatUrlNode("navigationNode", $tabObj[$i]->getId());
/* pour l'url */
2020-12-10 18:33:53 +01:00
$MaTemplate->MxAttribut("bloc1.nodeUrl", ($urlToGo));
2020-12-03 16:35:44 +01:00
$lib=$tabObj[$i]->getLibelle($currentCode);
if ($lib=="")
{
$lib=$tabObj[$i]->getLibelle($defaultCode);
}
/*Fonction permettant de supprimer les numeros, le point et l'espace à l'affichage*/
2020-12-10 18:33:53 +01:00
// $lib = eregi_replace("^[[:space:]]*[a-z]+[.)".chr(176)."][[:space:]]+", "", $lib);
$lib = ltrim(substr( $lib, strpos($lib, ". "), strlen($lib) ), ". ");
$MaTemplate->MxImage("bloc1.pictoNode", $img ,htmlentitiesconv($lib),"");
2020-12-03 16:35:44 +01:00
/* objet en cours */
$bool=false;
$tabSon=$GLOBALS["SYSTEM_USER_SESSION"]->listUserNode->getSonOfNodeAllowed(eid(),$tabObj[$i]->getId());
for($l=0;$l<count($tabSon);$l++)
{
if ($tabSon[$l]->getId()==nid())
{
$bool=true;
break;
}
}
2020-12-10 18:33:53 +01:00
if ($tabObj[$i]->getId()==nid() || $bool==true)
$MaTemplate->MxAttribut("bloc1.class", "active");
else
$MaTemplate->MxAttribut("bloc1.class", "none");
2020-12-03 16:35:44 +01:00
/* Fin des objets en cours */
2020-12-10 18:33:53 +01:00
$MaTemplate->MxText("bloc1.nodeName", htmlentitiesconv($lib)."1");
2020-12-03 16:35:44 +01:00
// on récupére les sous niveau...
$ssLevel=$this->printForNode($tabObj[$i]->getId(), ( (($modelixeMxt=="navigationsub.mxt") || ($modelixeMxt=="navigationdiv.mxt")) && (($modelixeMxt!="navigationnode.mxt"))?"navigationdiv.mxt":"navigationsub.mxt"));
2020-12-10 18:33:53 +01:00
$MaTemplate->MxText("bloc1.nodeDir", $ssLevel);
2020-12-03 16:35:44 +01:00
}else{
/* recuperation de l'image de la langue courante */
2020-12-10 18:33:53 +01:00
if (file_exists("data/image/icons/object/".strtolower($tabObj[$i][1]->getIcone())) && ($tabObj[$i][1]->getIcone()!=""))
2020-12-03 16:35:44 +01:00
{
2020-12-10 18:33:53 +01:00
$img="data/image/icons/object/".strtolower($tabObj[$i][1]->getIcone());
2020-12-03 16:35:44 +01:00
}else{
2020-12-10 18:33:53 +01:00
$img="data/image/icons/object/defaultobject.gif";
2020-12-03 16:35:44 +01:00
}
$urlToGo = formatUrl($tabObj[$i][1]->getId(), $tabObj[$i][0]->getClassName(), $tabObj[$i][0]->getMethodName(),"","",$tabObj[$i][0]->getNodeId());
/* pour l'url */
$MaTemplate->MxAttribut("bloc1.nodeUrl", $urlToGo);
$lib=$tabObj[$i][1]->getName($currentCode);
if ($lib=="")
{
$lib=$tabObj[$i][1]->getName($defaultCode);
}
2020-12-10 18:33:53 +01:00
//$page -> MxImage(string $path, string $imageFile, [string $title], [string $imageAttribut], [string $getSize]);
$MaTemplate->MxImage("bloc1.pictoNode", $img ,htmlentitiesconv($lib), "");
2020-12-03 16:35:44 +01:00
/* objet en cours */
2020-12-10 18:33:53 +01:00
if ( ($tabObj[$i][1]->getId()==oid() ) && ( strtolower($tabObj[$i][0]->getClassName())==strtolower(className())) && (!(strpos(strtolower(methodName()), strtolower(str_replace("action","",$tabObj[$i][0]->getMethodName())))===false)) )
$MaTemplate->MxAttribut("bloc1.class", "active");
else
$MaTemplate->MxAttribut("bloc1.class", "none");
2020-12-03 16:35:44 +01:00
/* Fin des objets en cours */
/*Fonction permettant de supprimer les numeros, le point et l'espace à l'affichage*/
// $lib = eregi_replace("^[[:space:]]*[a-z]+[.)".chr(176)."][[:space:]]+", "", $lib);
2020-12-10 18:33:53 +01:00
$lib = ltrim(substr( $lib, strpos($lib, ". "), strlen($lib) ), ". ");
$MaTemplate->MxText("bloc1.nodeName", htmlentitiesconv($lib)."2");
$MaTemplate->MxText("bloc1.nodeDir", "");
2020-12-03 16:35:44 +01:00
}
$MaTemplate->MxBloc("bloc1", "loop");
}
if (count($tabName)!=0)
$data=$MaTemplate->MxWrite();
else
$data="";
return $data;
}
/**
* recupere les repertoires d'un noeud
* @access public
*/
2020-12-10 18:33:53 +01:00
function getNodeSon($nodeId)
2020-12-03 16:35:44 +01:00
{
$tab=$GLOBALS["SYSTEM_USER_SESSION"]->getSonOfNodeAllowed($nodeId);
return $tab;
}
/**
* recupere les fils d'un noeud depuis le noeud principal
* @access public
*/
2020-12-10 18:33:53 +01:00
function getObjectSon($nodeId)
2020-12-03 16:35:44 +01:00
{
$tab=$GLOBALS["SYSTEM_CONTROL"]->getListObjectForNavigation($nodeId);
return $tab;
}
}
?>