2010-09-15 16:55:54 +02:00
|
|
|
|
<?php
|
|
|
|
|
class AccueilModules {
|
2010-09-15 23:36:14 +02:00
|
|
|
|
const CONFIG_FILE = 'db/config.xml';
|
2010-09-15 16:55:54 +02:00
|
|
|
|
private $modules = array();
|
|
|
|
|
|
2010-09-15 23:36:14 +02:00
|
|
|
|
/**
|
|
|
|
|
* Constructeur
|
|
|
|
|
* Initialise le XML de conf g<EFBFBD>n<EFBFBD>rale
|
|
|
|
|
* Active les modules
|
|
|
|
|
* Construit le menu
|
|
|
|
|
*/
|
2010-09-15 16:55:54 +02:00
|
|
|
|
function __construct(){
|
2010-09-15 23:36:14 +02:00
|
|
|
|
if($config = simplexml_load_file(self::CONFIG_FILE)){
|
2010-09-15 16:55:54 +02:00
|
|
|
|
$config_xml = $config->item;
|
|
|
|
|
foreach($config_xml as $item){
|
|
|
|
|
$this->modules["$item[id]"] = $item;
|
|
|
|
|
}
|
|
|
|
|
$this->getModules();
|
|
|
|
|
$this->buildConfigMenu();
|
|
|
|
|
}else{
|
|
|
|
|
echo 'baaaaad persistance...';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-15 23:36:14 +02:00
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* Initialise les modules activ<EFBFBD>s uniquement
|
|
|
|
|
*/
|
2010-09-15 16:55:54 +02:00
|
|
|
|
function getModules(){
|
|
|
|
|
foreach($this->modules as $module=>$moduleConf){
|
|
|
|
|
if(file_exists('class/'.ucfirst($module).'.php') && $moduleConf->visibility == "true"){
|
|
|
|
|
$params = array();
|
|
|
|
|
foreach($moduleConf as $confParam){
|
|
|
|
|
$params[$confParam->getName()] = "$confParam";
|
|
|
|
|
}
|
|
|
|
|
require ucfirst($module).'.php';
|
|
|
|
|
call_user_func(array($module, "start"), $params);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-15 23:36:14 +02:00
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* Construit et ins<EFBFBD>re le menu de changement de config
|
|
|
|
|
*/
|
2010-09-15 16:55:54 +02:00
|
|
|
|
function buildConfigMenu(){
|
|
|
|
|
echo '<a href="#config" id="config-menu">Configuration</a>
|
|
|
|
|
<div style="display:none;">
|
|
|
|
|
<div id="config">
|
|
|
|
|
<form id="config_form" action="" method="post">
|
|
|
|
|
<h3>Modules configuration</h3><br/>';
|
|
|
|
|
foreach($this->modules as $module=>$moduleConf){
|
|
|
|
|
echo $module.' module : <input type="radio" name="'.$module.'_group" value="true"';
|
|
|
|
|
if ($moduleConf->visibility == "true") echo " checked";
|
|
|
|
|
echo '/>true <input type="radio" name="'.$module.'_group" value="false"';
|
|
|
|
|
if ($moduleConf->visibility == "false") echo " checked";
|
|
|
|
|
echo '/>false<br/><br/>';
|
|
|
|
|
}
|
|
|
|
|
echo '<a id="config-submit" href="" class="green-button">Enregistrer</a>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
</div>';
|
|
|
|
|
}
|
2010-09-15 23:36:14 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @property Chaque module poss<EFBFBD>de la fonction updateModule en static qui permet de changer un ou plusieurs de ses attributs
|
|
|
|
|
* @param $module String Nom du module <EFBFBD> modifier
|
|
|
|
|
* @param $things2change Array du ou des attributs <EFBFBD> modifier avec sa ou ses nouvelles valeurs
|
|
|
|
|
* @return "ok" String si c'est bon, ou le message d'erreur
|
|
|
|
|
*/
|
|
|
|
|
public static function updateModule($module, $things2change){
|
|
|
|
|
require ucfirst($module).'.php';
|
|
|
|
|
return call_user_func(array($module, "updateConfig"), $things2change);
|
|
|
|
|
}
|
2010-09-15 16:55:54 +02:00
|
|
|
|
}
|