Qware_core/lib/object_printing/objectprint/objectprint.php

173 lines
4.9 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 ObjectPrint.php
*
* Ce fichier contient la classe ObjectPrint
*
* @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 ObjectPrint
*/
if ( !defined('SYSTEM_IN') )
{
die("Hacking attempt");
}
/**
* Classe ObjectPrint
*<p>cette classe permet la recuperation de l'ObjectPrint</p>
* @package object_printing
* @subpackage ObjectPrint
*/
class ObjectPrint extends Printing
{
//
// Constructor
//
/**
* Constructeur de la classe ObjectPrint
* @access public
*/
function ObjectPrint()
{
$this->__construct();
}
function __construct()
{
parent::__construct("1.0", "Olivier DEVAINE", "Affichage de l'Object");
}
/**
* Remplace dans la template principale
* @access public
*/
function __print()
{
$this->printForNode($GLOBALS["SYSTEM_USER_SESSION"]->navigationNodeId);
}
/**
* affichage d'un noeud et de tous ses sous noeuds
* @access public
*/
function printForNode($nodeId)
{
global $SERVER_NAME, $SCRIPT_NAME, $CONF_PERSISTANT_SECURE;
$tabObject =$this->getObjectSon($nodeId);
if (count($tabObject)<=1)
return "";
$MaTemplate = new ModeliXeQware($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."object_printing/objectprint/object.mxt");
$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 */
/* Récupération du nom du noeud courant */
$node=$GLOBALS["SYSTEM_MANAGER"]["NODE"]->createInstance(nid());
$lib=$node->getLibelle($currentCode);
if ($lib=="")
{
$lib=$node->getLibelle($defaultCode);
}
$lib = eregi_replace("^[[:space:]]*[a-z]+[.)".chr(176)."][[:space:]]+", "", $lib);
$MaTemplate->MxText("nodeName", $lib);
$MaTemplate->MxText("ObjectPrintName", getMessage("ObjectPrintName"));
/* Pour le Tri/Nom */
$tabName=array();
for ($i=0; $i<count($tabObject);$i++)
{
$lib=$tabObject[$i][1]->getName($currentCode);
if ($lib=="")
{
$lib=$tabObject[$i][1]->getName($defaultCode);
}
$tabName[$i]=$lib;
}
asort($tabName);
reset($tabName);
while (list($i, $lib) = each($tabName))
{
/* recuperation de l'image de la langue courante */
if (file_exists($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."media/picto/object/".($tabObject[$i][1]->getIcone())) && ($tabObject[$i][1]->getIcone()!=""))
{
$img=$GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."media/picto/object/".($tabObject[$i][1]->getIcone());
}else{
$img=$GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."media/picto/object/defaultobject.png";
}
$urlToGo = formatUrl($tabObject[$i][1]->getId(), $tabObject[$i][0]->getClassName(), $tabObject[$i][0]->getMethodName(),"","",$tabObject[$i][0]->getNodeId());
/* pour l'url */
$MaTemplate->MxAttribut("bloc1.objectUrl", $urlToGo);
$lib=$tabObject[$i][1]->getName($currentCode);
// var_dump($lib);
if ($lib=="")
{
$lib=$tabObject[$i][1]->getName($defaultCode);
}
/* objet en cours */
if ( ($tabObject[$i][1]->getId()==oid() ) && ( strtolower($tabObject[$i][0]->getClassName())==strtolower(className())) && (!(strpos(strtolower(methodName()), strtolower(str_replace("action","",$tabObject[$i][0]->getMethodName())))===false)) ){
$MaTemplate->MxAttribut("bloc1.style", "ObjectSelected");
if(isset($GLOBALS["SYSTEM_PRINTING"]["HelpPrint"])) $GLOBALS["SYSTEM_PRINTING"]["HelpPrint"]->activate();
}
else
$MaTemplate->MxAttribut("bloc1.style", "Object");
/* Fin des objets en cours */
/*Fonction permettant de supprimer les numeros, le point et l'espace à l'affichage*/
// if( !strstr("0.", "", $lib) )
$lib = eregi_replace("^[[:space:]]*[a-z]+[.)".chr(176)."][[:space:]]+", "", $lib);
// else
// $lib = "";
$MaTemplate->MxImage("bloc1.pictoObject", $img ,htmlentitiesconv($lib));
//$MaTemplate->MxText("bloc1.objectName", htmlentitiesconv($lib));
$MaTemplate->MxText("bloc1.objectName", htmlentitiesconv($lib));
//var_dump(HTML_ENTITIES);
$MaTemplate->MxBloc("bloc1", "loop");
}
$data=$MaTemplate->MxWrite();
$GLOBALS["SYSTEM_TEMPLATE"]->MxText("objectprint", $data);
}
/**
* recupere les fils d'un noeud depuis le noeud principal
* @access public
*/
function getObjectSon($nodeId)
{
$tab=$GLOBALS["SYSTEM_CONTROL"]->getListObjectForNavigation($nodeId);
return $tab;
}
}
?>