137 lines
3.8 KiB
PHP
137 lines
3.8 KiB
PHP
|
<?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 LanguagePrint.php
|
||
|
*
|
||
|
* Ce fichier contient la classe LanguagePrint
|
||
|
*
|
||
|
* @author Initiance <www.initiance.com|martial@initiance.com>
|
||
|
* @copyright Copyright © 2009-2018, Rooty
|
||
|
* @since 2004/06/07
|
||
|
* @version 0.3
|
||
|
* @link www.rooty.me
|
||
|
* @package object_printing
|
||
|
* @subpackage LanguagePrint
|
||
|
*/
|
||
|
|
||
|
if ( !defined('SYSTEM_IN') )
|
||
|
{
|
||
|
die("Hacking attempt");
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Classe LanguagePrint
|
||
|
*<p>Cette classe permet la recuperation de Language</p>
|
||
|
* @package object_printing
|
||
|
* @subpackage LanguagePrint
|
||
|
*/
|
||
|
|
||
|
class LanguagePrint extends Printing
|
||
|
{
|
||
|
//
|
||
|
// Constructor
|
||
|
//
|
||
|
/**
|
||
|
* Constructeur de la classe Language
|
||
|
* @access public
|
||
|
*/
|
||
|
function LanguagePrint()
|
||
|
{
|
||
|
$this->__construct();
|
||
|
}
|
||
|
|
||
|
function __construct()
|
||
|
{
|
||
|
parent::__construct("1.0", "Olivier DEVAINE", "Affichage des Langues 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_MANAGER"]["LANGUAGE"]->createActiveLanguageList();
|
||
|
// var_dump($tab);
|
||
|
|
||
|
if (count($tab)>1)
|
||
|
{
|
||
|
$MaTemplate = new ModeliXe($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."object_printing/languageprint/language.mxt");
|
||
|
//$template->SetMxFileParameter($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['TEMPLATE_DIR'].$GLOBALS['TEMPLATE_CONF']);
|
||
|
$MaTemplate->SetModeliXe(true);
|
||
|
|
||
|
/* création de l'url de login */
|
||
|
$url =$_SERVER['SCRIPT_NAME'];
|
||
|
$url.="?system=language";
|
||
|
$url=addIdToUrl($url);
|
||
|
$MaTemplate->MxAttribut("urlAction", $url);
|
||
|
|
||
|
/* recuperation de l'image de la langue courante */
|
||
|
if (file_exists($GLOBALS['CONF_DATA_PATH']."data/image/language/".strtolower($GLOBALS["SYSTEM_USER_SESSION"]->langue->getCode()).".png"))
|
||
|
{
|
||
|
$img=$GLOBALS['CONF_DATA_PATH']."data/image/language/".strtolower($GLOBALS["SYSTEM_USER_SESSION"]->langue->getCode()).".png";
|
||
|
}else{
|
||
|
$img=$GLOBALS['CONF_DATA_PATH']."data/image/language/default.png";
|
||
|
}
|
||
|
|
||
|
/* gestion du lib en fonction de la langue courante */
|
||
|
$currentCode=$GLOBALS["SYSTEM_USER_SESSION"]->langue->getCode();
|
||
|
$currentId=$GLOBALS["SYSTEM_USER_SESSION"]->langue->getId();
|
||
|
$defaultCode=$GLOBALS["SYSTEM_DEFAULT_LANGUAGE_CODE"];
|
||
|
$lib=$GLOBALS["SYSTEM_USER_SESSION"]->langue->getLibelle($currentCode);
|
||
|
|
||
|
if ($lib=="")
|
||
|
{
|
||
|
$lib=$GLOBALS["SYSTEM_USER_SESSION"]->langue->getLibelle($defaultCode);
|
||
|
}
|
||
|
|
||
|
if ($MaTemplate->IsMxFlag("currentLanguage", "text"))
|
||
|
$MaTemplate->MxText("currentLanguage", htmlentitiesconv($lib));
|
||
|
|
||
|
if ($MaTemplate->IsMxFlag("pictoLanguage", "image"))
|
||
|
$MaTemplate->MxImage("pictoLanguage", $img);
|
||
|
|
||
|
// var_dump($currentId);
|
||
|
$MaTemplate->MxAttribut("currentlanguageid", $currentId);
|
||
|
$MaTemplate->MxAttribut("title", getMessage("tipLanguageSelect"));
|
||
|
$MaTemplate->MxText("currentlanguage", $lib);
|
||
|
|
||
|
for ($i=0; $i<count($tab);$i++)
|
||
|
{
|
||
|
if ($tab[$i]->getId() != $currentId) {
|
||
|
$MaTemplate->MxAttribut("bloc1.languageid", $tab[$i]->getId());
|
||
|
$lib=$tab[$i]->getLibelle($currentCode);
|
||
|
if ($lib=="")
|
||
|
{
|
||
|
$lib=$tab[$i]->getLibelle($defaultCode);
|
||
|
}
|
||
|
$MaTemplate->MxText("bloc1.language", htmlentitiesconv($lib) );
|
||
|
$MaTemplate->MxBloc("bloc1", "loop");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$data=$MaTemplate->MxWrite();
|
||
|
$GLOBALS["SYSTEM_TEMPLATE"]->MxText("languageprint", $data); // Et voila!!!!!
|
||
|
return true;
|
||
|
}else{
|
||
|
$GLOBALS["SYSTEM_TEMPLATE"]->MxText("languageprint", "");
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
?>
|