2023-01-08 10:06:36 +01:00

477 lines
19 KiB
PHP
Executable File

<?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 NavigationPrint.php
*
* Ce fichier contient la classe NavigationPrint
*<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 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()
{
parent::__construct("1.1", "Rooty <rooty@rooty.me>", "Affichage de la NavigationNode");
}
/**
* Remplace dans la template principale
* @access public
*/
function __print()
{
global $SERVER_NAME, $SCRIPT_NAME, $CONF_AUTH_SECURE;
/* 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");
$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 */
if (file_exists($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."media/picto/node/".strtolower($Node->getIcone())) && ($Node->getIcone()!=""))
{
$img=$GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."media/picto/node/".strtolower($Node->getIcone());
}else{
$img=$GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."media/picto/node/defaultnode.png";
}
/* recuperation de l'icone de la communauté */
if (file_exists($GLOBALS['CONF_DATA_PATH']."data/image/communities/".recupCommunity()."_logo.svg"))
{
$imgLogo=$GLOBALS['CONF_DATA_PATH']."data/image/communities/".recupCommunity()."_logo.svg";
}else{
$imgLogo=$GLOBALS['CONF_DATA_PATH']."data/image/communities/3_logo.svg";
}
/* Obtention des informations du bloc d'affichage des réseaux sociaux */
/* Cas où le noeud correspond à la racine de la plateforme Qware */
if(recupCommunity() === "3") $nodeCom = "2"; else $nodeCom = recupCommunity();
$NodeSettings=$GLOBALS["SYSTEM_MANAGER"]["NODESETTINGS"]->createInstance($nodeCom);
/* Link Email */
if( $NodeSettings->getEmail() && $NodeSettings->getEmail()!="" ) { $MaTemplate->MxAttribut("blocSLinks.linkEmail.email", "mailto:".$NodeSettings->getEmail()); } else $MaTemplate->MxBloc("blocSLinks.linkEmail", "DELETE");
/* Link Git */
if( $NodeSettings->getGit() && $NodeSettings->getGit()!="" ) { $MaTemplate->MxAttribut("blocSLinks.linkGit.git", $NodeSettings->getGit()); } else $MaTemplate->MxBloc("blocSLinks.linkGit", "DELETE");
/* Link Mastodon */
if( $NodeSettings->getMastodon() && $NodeSettings->getMastodon()!="" ) { $MaTemplate->MxAttribut("blocSLinks.linkMastodon.mastodon", $NodeSettings->getMastodon()); } else $MaTemplate->MxBloc("blocSLinks.linkMastodon", "DELETE");
/* Link Mobilizon */
if( $NodeSettings->getMobilizon() && $NodeSettings->getobilizon()!="" ) { $MaTemplate->MxAttribut("blocSLinks.linkMatrix.mobilizon", $NodeSettings->getMobilizon()); } else $MaTemplate->MxBloc("blocSLinks.linkMobilizon", "DELETE");
/* Link Matrix */
if( $NodeSettings->getMatrix() && $NodeSettings->getMatrix()!="" ) { $MaTemplate->MxAttribut("blocSLinks.linkMatrix.matrix", $NodeSettings->getMatrix()); } else $MaTemplate->MxBloc("blocSLinks.linkMatrix", "DELETE");
/* Link Peertube */
if( $NodeSettings->getPeertube() && $NodeSettings->getPeertube()!="" ) { $MaTemplate->MxAttribut("blocSLinks.linkPeertube.peertube", $NodeSettings->getPeertube()); } else $MaTemplate->MxBloc("blocSLinks.linkPeertube", "DELETE");
/* Link Nextcloud */
if( $NodeSettings->getNextcloud() && $NodeSettings->getNextcloud()!="" ) { $MaTemplate->MxAttribut("blocSLinks.linkNextcloud.nextcloud", $NodeSettings->getNextcloud()); } else $MaTemplate->MxBloc("blocSLinks.linkNextcloud", "DELETE");
/* Link Twitter */
if( $NodeSettings->getTwitter() && $NodeSettings->getTwitter()!="" ) { $MaTemplate->MxAttribut("blocSLinks.linkTwitter.twitter", $NodeSettings->getTwitter()); } else $MaTemplate->MxBloc("blocSLinks.linkTwitter", "DELETE");
/* Link Facebook */
if( $NodeSettings->getFacebook() && $NodeSettings->getFacebook()!="" ) { $MaTemplate->MxAttribut("blocSLinks.linkFacebook.facebook", $NodeSettings->getFacebook()); } else $MaTemplate->MxBloc("blocSLinks.linkFacebook", "DELETE");
// BLOC INFOS UTILISATEUR
if ($GLOBALS["SYSTEM_USER_SESSION"]->user->getId()==$GLOBALS["SYSTEM_DEFAULT_USER_GUEST"])
{
$nodeId = $GLOBALS["SYSTEM_USER_SESSION"]->navigationNodeId;
/* création de l'url de login */
$url =$_SERVER['SCRIPT_NAME'];
$url.="?system=authSession";
$url=addIdToUrl($url);
$tabObject =$GLOBALS["SYSTEM_CONTROL"]->getListObjectForNavigation($nodeId);
for ($i=0; $i<count($tabObject);$i++)
{
echo $tabObject[$i][0]->getClassName();
if ($tabObject[$i][0]->getClassName()=="Home")
{
$urlArray["id"]=$tabObject[$i][1]->getId();
}
}
/* Création de l'URL pour nouveau compte */
$urlNewAccount = $_SERVER['SCRIPT_NAME'];
$urlNewAccount.= "?system=authNewAccount";
$urlNewAccount = addIdToUrl($urlNewAccount);
$MaTemplate->MxAttribut("urlActionNewAccount", Navigation::formatUrl($urlArray["id"],"Home","formLecture","",recupCommunity()));
$MaTemplate->MxAttribut("urlActionNewSubscription", Navigation::formatUrl($urlArray["id"],"Home","formLectureAdh","",recupCommunity()));
/* Création de l'URL pour rappel du mot de passe */
$urlForgotPassword = $_SERVER['SCRIPT_NAME'];
$urlForgotPassword.= "?system=authForgotPassword";
$urlForgotPassword = addIdToUrl($urlForgotPassword);
$MaTemplate->MxText("blocGUEST".".auth", getMessage("UserPrintAuth"));
$MaTemplate->MxText("blocGUEST".".LOGIN", getMessage("UserPrintLogin"));
$MaTemplate->MxFormField("blocGUEST".".login", "text", "login", "", "title='".getMessage("tipUserPrintLogin")."'");
$MaTemplate->MxText("blocGUEST".".PASSWORD", getMessage("UserPrintPassword"));
$MaTemplate->MxFormField("blocGUEST".".password", "password", "password", "", "title='".getMessage("tipUserPrintPassword")."'");
$MaTemplate->MxAttribut("blocGUEST".".urlActionNewAccount", $urlNewAccount);
$MaTemplate->MxText("blocGUEST".".NEWACCOUNT", getMessage("UserPrintNewAccount"));
$MaTemplate->MxText("blocGUEST".".NEWSUBSCRIPTION", getMessage("UserPrintNewSubscription"));
$MaTemplate->MxAttribut("blocGUEST".".urlActionForgotPassword", $urlForgotPassword);
$MaTemplate->MxText("blocGUEST".".FORGOTPASSWORD", getMessage("UserPrintForgotPassword"));
$MaTemplate->MxAttribut("blocGUEST".".urlAction", $url);
$MaTemplate->MxAttribut("blocGUEST".".BtnEnter", getMessage("UserPrintEnter"));
$MaTemplate->MxAttribut("blocGUEST".".titleButton", getMessage("tipUserPrintEnter"));
$MaTemplate->MxBloc("blocAUTH", "delete");
} else {
/* création de l'url de déconnexion */
$urlDisco =$_SERVER['SCRIPT_NAME'];
$urlDisco.="?system=disconnectSession";
$urlDisco=addIdToUrl($urlDisco);
// On récupère la liste des objets pour l'EID courant (racine)
$tabObject =$this->getObjectSon(eid());
/* création de l'url de l'outil de gestion du compte utilisateur */
$nodeId = $GLOBALS["SYSTEM_USER_SESSION"]->navigationNodeId;
$tabObjectNode =$this->getObjectSon($nodeId);
for ($j=0; $j<count($tabObjectNode);$j++)
{
if ($tabObjectNode[$j][0]->getClassName()=="UserModif")
{
$objID=$tabObjectNode[$j][1]->getId();
$objCN=$tabObjectNode[$j][0]->getClassName();
$objMN=$tabObjectNode[$j][0]->getMethodName();
}
}
// var_dump($objID."\n".$objCN."\n".$objMN);
if( isset($objID) AND isset($objCN) AND isset($objMN) )
$MaTemplate->MxAttribut("blocAUTH".".urlAccount", Navigation::formatUrl($objID, $objCN, $objMN, "", ""));
$MaTemplate->MxAttribut("blocAUTH".".disconnectURL", $urlDisco);
$MaTemplate->MxText("blocAUTH".".firstName", $GLOBALS["SYSTEM_USER_SESSION"]->user->getFirstName());
$MaTemplate->MxText("blocAUTH".".lastName", $GLOBALS["SYSTEM_USER_SESSION"]->user->getLastName());
// $MaTemplate->MxText("id", $GLOBALS["SYSTEM_USER_SESSION"]->user->getId());
// $MaTemplate->MxText("mail", $GLOBALS["SYSTEM_USER_SESSION"]->user->getMail());
// $MaTemplate->MxText("organisation", $GLOBALS["SYSTEM_USER_SESSION"]->user->getOrganisation());
// $MaTemplate->MxText("title", $GLOBALS["SYSTEM_USER_SESSION"]->user->getTitle());
// $MaTemplate->MxText("postalAddress", $GLOBALS["SYSTEM_USER_SESSION"]->user->getPostalAddress());
// $MaTemplate->MxText("postalCode", $GLOBALS["SYSTEM_USER_SESSION"]->user->getPostalCode());
// $MaTemplate->MxText("state", $GLOBALS["SYSTEM_USER_SESSION"]->user->getState());
// $MaTemplate->MxText("country", $GLOBALS["SYSTEM_USER_SESSION"]->user->getCountry());
$MaTemplate->MxText("blocAUTH".".login", $GLOBALS["SYSTEM_USER_SESSION"]->user->getLogin());
// $MaTemplate->MxText("tel", $GLOBALS["SYSTEM_USER_SESSION"]->user->getTel());
$MaTemplate->MxText("blocAUTH".".decon", getMessage("UserPrintDecon"));
// $MaTemplate->MxAttribut("decon", getMessage("UserPrintDecon"));
// $MaTemplate->MxText("fax", $GLOBALS["SYSTEM_USER_SESSION"]->user->getFax());
// $MaTemplate->MxText("TxtWelcome", getMessage("TxtWelcome"));
$MaTemplate->MxBloc("blocGUEST", "delete");
}
$urlToGo = formatUrlNode("navigationNode", $Node->getId());
/* pour l'url */
$MaTemplate->MxAttribut("nodeUrl", htmlentitiesconv($urlToGo));
if ( $Node->getLibelle($currentCode) != "" )
{
if( !strstr("0.", $Node->getLibelle($currentCode)) )
{
$lib=$Node->getLibelle($currentCode);
}
} else {
$lib = "";
}
if ($lib=="")
{
if ( $Node->getLibelle($currentCode) != "" )
{
if( !strstr("0.", $Node->getLibelle($currentCode)) )
$lib=$Node->getLibelle($defaultCode);
}
}
$MaTemplate->MxImage("pictoNode", $img , htmlentitiesconv($lib),"");
$MaTemplate->MxImage("pictoCommunity", $imgLogo , "", "");
$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);
$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!!!!
{
if( strpos( $tabObj[$i][1]->getName($currentCode), "zz. ") === false )
{
if( $GLOBALS["SYSTEM_USER_SESSION"]->user->getId() != 1 )
{
if( !in_array($tabObj[$i][1]->getName($currentCode), $GLOBALS['EXCLUDETOOLSFROMUSERMENU']) )
{
$lib=$tabObj[$i][1]->getName($currentCode);
} else {
$lib = false;
}
} else {
if( !in_array($tabObj[$i][1]->getName($currentCode), $GLOBALS['EXCLUDETOOLSFROMGUESTMENU']) )
{
$lib=$tabObj[$i][1]->getName($currentCode);
} else {
$lib = false;
}
}
} else {
$lib = false;
}
}else{
if( strpos( $tabObj[$i]->getLibelle($currentCode), "zz. ") === false )
{
if( $GLOBALS["SYSTEM_USER_SESSION"]->user->getId() != 1 )
$lib=$tabObj[$i]->getLibelle($currentCode);
else
if( !in_array($tabObj[$i][1]->getName($currentCode), $GLOBALS['EXCLUDETOOLSFROMGUESTMENU']) )
$lib=$tabObj[$i][1]->getName($currentCode);
else
$lib = false;
} else {
$lib = false;
}
}
if( $lib && !empty($lib) )
$tabName[$i]=$lib;
}
asort($tabName);
reset($tabName);
// while (list($i, $lib) = each($tabName))
// PHP8.0
foreach ($tabName as $i => $lib)
{
/* en fonction de l'obj */
if(is_object($tabObj[$i])) // c un dir!!!!
{
/* recuperation de l'image de la langue courante */
if (file_exists("data/image/icons/node/".strtolower($tabObj[$i]->getIcone())) && ($tabObj[$i]->getIcone()!=""))
{
$img="data/image/icons/node/".strtolower($tabObj[$i]->getIcone());
}else{
$img="data/image/icons/node/defaultnode.png";
}
/* on prepare l'url */
$urlToGo = formatUrlNode("navigationNode", $tabObj[$i]->getId());
/* pour l'url */
$MaTemplate->MxAttribut("bloc1.nodeUrl", $urlToGo);
$MaTemplate->MxAttribut("bloc1.blocDropdown.nodeUrl", $urlToGo);
$MaTemplate->MxAttribut("bloc1.blocNoDropdown.nodeUrl", $urlToGo);
$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*/
$lib = ltrim(substr( $lib, strpos($lib, ". "), strlen($lib) ), ". ");
$MaTemplate->MxImage("bloc1.pictoNode", $img , htmlentitiesconv($lib), "");
$MaTemplate->MxImage("bloc1.blocDropdown.pictoNode", $img , htmlentitiesconv($lib), "");
$MaTemplate->MxImage("bloc1.blocNoDropdown.pictoNode", $img , htmlentitiesconv($lib), "");
/* 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;
}
}
if ($tabObj[$i]->getId()==nid() || $bool==true) {
$classBoostrapMenu = " active";
} else {
$classBoostrapMenu = "";
}
/* Fin des objets en cours */
$MaTemplate->MxText("bloc1.nodeName", htmlentitiesconv($lib));
$MaTemplate->MxText("bloc1.blocDropdown.nodeName", htmlentitiesconv($lib));
$MaTemplate->MxText("bloc1.blocNoDropdown.nodeName", htmlentitiesconv($lib));
// 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"));
$MaTemplate->MxText("bloc1.blocDropdown.nodeDir.nodeDir", $ssLevel);
if( $ssLevel ) {
$classBoostrapMenu = " dropdown".$classBoostrapMenu;
$MaTemplate->MxBloc("bloc1.blocNoDropdown", "delete");
} else {
$classBoostrapMenu = $classBoostrapMenu;
$MaTemplate->MxBloc("bloc1.blocDropdown", "delete");
}
$MaTemplate->MxAttribut("bloc1.class", $classBoostrapMenu);
}else{
/* recuperation de l'image de la langue courante */
if (file_exists("data/image/icons/object/".strtolower($tabObj[$i][1]->getIcone())) && ($tabObj[$i][1]->getIcone()!=""))
{
$img="data/image/icons/object/".strtolower($tabObj[$i][1]->getIcone());
}else{
$img="data/image/icons/object/defaultobject.png";
}
$urlToGo = Navigation::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);
$MaTemplate->MxAttribut("bloc1.blocDropdown.nodeUrl", $urlToGo);
$MaTemplate->MxAttribut("bloc1.blocNoDropdown.nodeUrl", $urlToGo);
$lib=$tabObj[$i][1]->getName($currentCode);
if ($lib=="")
{
$lib=$tabObj[$i][1]->getName($defaultCode);
}
$lib = ltrim(substr( $lib, strpos($lib, ". "), strlen($lib) ), ". ");
$MaTemplate->MxImage("bloc1.pictoNode", $img ,htmlentitiesconv($lib), "");
$MaTemplate->MxImage("bloc1.blocDropdown.pictoNode", $img ,htmlentitiesconv($lib), "");
$MaTemplate->MxImage("bloc1.blocNoDropdown.pictoNode", $img ,htmlentitiesconv($lib), "");
/* objet en cours */
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");
$MaTemplate->MxAttribut("bloc1.blocDropdown.class", "nav-item active");
$MaTemplate->MxAttribut("bloc1.blocNoDropdown.class", " nav-item active");
} else {
$MaTemplate->MxAttribut("bloc1.class", "");
$MaTemplate->MxAttribut("bloc1.blocDropdown.class", "nav-item");
$MaTemplate->MxAttribut("bloc1.blocNoDropdown.class", "nav-item");
}
/* Fin des objets en cours */
/*Fonction permettant de supprimer les numeros, le point et l'espace à l'affichage*/
$lib = preg_replace("/^[[:space:]]*[a-z]+[.)".chr(176)."][[:space:]]+/i", "", $lib);
$MaTemplate->MxText("bloc1.nodeName", htmlentitiesconv($lib));
$MaTemplate->MxText("bloc1.blocNoDropdown.nodeName", htmlentitiesconv($lib));
$MaTemplate->MxText("bloc1.blocDropdown.nodeName", htmlentitiesconv($lib));
$MaTemplate->MxBloc("bloc1.blocDropdown.nodeDir", "delete");
if ( $lib && ($GLOBALS["SYSTEM_USER_SESSION"]->user->getId() == 1) )
$MaTemplate->MxBloc("bloc1.blocDropdown", "delete");
}
$MaTemplate->MxBloc("bloc1", "loop");
}
if (count($tabName)!=0)
$data=$MaTemplate->MxWrite();
else
$data="";
return $data;
}
/**
* recupere les repertoires d'un noeud
* @access public
*/
private function getNodeSon($nodeId)
{
$tab=$GLOBALS["SYSTEM_USER_SESSION"]->getSonOfNodeAllowed($nodeId);
return $tab;
}
/**
* recupere les fils d'un noeud depuis le noeud principal
* @access public
*/
private function getObjectSon($nodeId)
{
$tab=$GLOBALS["SYSTEM_CONTROL"]->getListObjectForNavigation($nodeId);
return $tab;
}
}
?>