Correction du bug de l'ajout de module avec la nouvelle classe Module

This commit is contained in:
Chouchen 2010-10-06 08:24:08 +00:00
parent 759a5556cc
commit 3574fc102c
15 changed files with 29 additions and 35 deletions

View File

@ -121,19 +121,10 @@ class AccueilModules {
</script>'; </script>';
} }
/** public static function retrieveModuleParams($module){
* $temp = new $module;
* @property Chaque module possède la fonction updateModule en static qui permet de changer un ou plusieurs de ses attributs return $temp->getParamsList();
* @param $module String Nom du module à modifier }
* @param $things2change Array du ou des attributs à 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 'Module.php';
//require '../modules/'.$module.'/'.ucfirst($module).'.php';
$module = new $module();
return call_user_func(array($module, "updateConfig"), $things2change);
}*/
/** /**
* *
@ -161,7 +152,8 @@ class AccueilModules {
if($config = simplexml_load_file('../'.self::CONFIG_FILE)){ if($config = simplexml_load_file('../'.self::CONFIG_FILE)){
$newItem = $config->addChild('item'); $newItem = $config->addChild('item');
$newItem->addAttribute('id', $name); $newItem->addAttribute('id', $name);
$params = call_user_func(array($name, 'getParamList')); //$params = call_user_func(array($name, 'getParamList'));
$params = self::retrieveModuleParams($name);
foreach($params as $param){ foreach($params as $param){
if($param == 'visibility') if($param == 'visibility')
$newItem->AddChild($param, 'true'); $newItem->AddChild($param, 'true');

View File

@ -1,13 +1,7 @@
<?php <?php
class Module class Module
{ {
/**
* Liste des paramètres du module en concordance avec le "config.xml"
* Ses éléments ne peuvent être modifiés
* @var array
*/
protected static $paramsList = array();
// Nom du module (aka le nom de la classe en minuscule) // Nom du module (aka le nom de la classe en minuscule)
protected $moduleName; protected $moduleName;
@ -24,8 +18,9 @@ class Module
*/ */
private $params = array(); private $params = array();
public function __construct($class, $params){ public function __construct($class, $params = null){
$this->setNames($class, $this->moduleTitle); $this->setNames($class, $this->moduleTitle);
if($params != null && is_array($params))
$this->setParams($params); $this->setParams($params);
} }
@ -71,6 +66,13 @@ class Module
$this->moduleTitle = $libelle; $this->moduleTitle = $libelle;
} }
/**
* @return la liste des paramètres du module
*/
public function getParamsList(){
return $this->paramsList;
}
/** /**
* @param $class string nom du module * @param $class string nom du module
* @param $key string le nom du paramètre à changer * @param $key string le nom du paramètre à changer

View File

@ -1,7 +1,7 @@
<?php <?php
class blogs extends Module { class blogs extends Module {
protected $moduleTitle = 'Blogs BD'; protected $moduleTitle = 'Blogs BD';
protected static $paramsList = array( protected $paramsList = array(
'visibility', 'visibility',
'x', 'x',
'y' 'y'

View File

@ -1,7 +1,7 @@
<?php <?php
class clock extends Module { class clock extends Module {
protected $moduleTitle = 'Horloge Simple'; protected $moduleTitle = 'Horloge Simple';
protected static $paramsList = array( protected $paramsList = array(
'visibility', 'visibility',
'x', 'x',
'y' 'y'

View File

@ -1,7 +1,7 @@
<?php <?php
class clockAdvanced extends Module { class clockAdvanced extends Module {
protected $moduleTitle = 'Horloge Avancée'; protected $moduleTitle = 'Horloge Avancée';
protected static $paramsList = array( protected $paramsList = array(
'visibility', 'visibility',
'x', 'x',
'y', 'y',

View File

@ -1,7 +1,7 @@
<?php <?php
class gmap extends Module { class gmap extends Module {
protected $moduleTitle = 'Google Maps'; protected $moduleTitle = 'Google Maps';
protected static $paramsList = array( protected $paramsList = array(
'visibility' 'visibility'
); );

View File

@ -1,7 +1,7 @@
<?php <?php
class links extends Module{ class links extends Module{
protected $moduleTitle = 'Liens'; protected $moduleTitle = 'Liens';
protected static $paramsList = array( protected $paramsList = array(
'visibility' 'visibility'
); );

View File

@ -1,7 +1,7 @@
<?php <?php
class mappy extends Module { class mappy extends Module {
protected $moduleTitle = 'Mappy'; protected $moduleTitle = 'Mappy';
protected static $paramsList = array( protected $paramsList = array(
'visibility' 'visibility'
); );

View File

@ -1,7 +1,7 @@
<?php <?php
class news extends Module{ class news extends Module{
protected $moduleTitle = 'Google News'; protected $moduleTitle = 'Google News';
protected static $paramsList = array( protected $paramsList = array(
'visibility', 'visibility',
'x', 'x',
'y' 'y'

View File

@ -2,7 +2,7 @@
class notes extends Module { class notes extends Module {
protected $moduleTitle = 'Post-It'; protected $moduleTitle = 'Post-It';
protected static $paramsList = array( protected $paramsList = array(
'visibility' 'visibility'
); );

View File

@ -1,7 +1,7 @@
<?php <?php
class ouifm extends Module { class ouifm extends Module {
protected $moduleTitle = 'Oui FM Radio'; protected $moduleTitle = 'Oui FM Radio';
protected static $paramsList = array( protected $paramsList = array(
'visibility', 'visibility',
'x', 'x',
'y' 'y'

View File

@ -1,7 +1,7 @@
<?php <?php
class rssblogs extends Module { class rssblogs extends Module {
protected $moduleTitle = 'Lecteur de flux RSS'; protected $moduleTitle = 'Lecteur de flux RSS';
protected static $paramsList = array( protected $paramsList = array(
'visibility', 'visibility',
'x', 'x',
'y' 'y'

View File

@ -1,7 +1,7 @@
<?php <?php
class search extends Module { class search extends Module {
protected $moduleTitle = 'Recherche'; protected $moduleTitle = 'Recherche';
protected static $paramsList = array( protected $paramsList = array(
'visibility' 'visibility'
); );

View File

@ -3,7 +3,7 @@ class todo extends Module {
protected $moduleTitle = 'Todo List'; protected $moduleTitle = 'Todo List';
protected static $paramsList = array( protected $paramsList = array(
'visibility', 'visibility',
'x', 'x',
'y' 'y'

View File

@ -3,7 +3,7 @@ class weather extends Module {
protected $moduleTitle = 'Météo'; protected $moduleTitle = 'Météo';
protected static $paramsList = array( protected $paramsList = array(
'visibility', 'visibility',
'city', 'city',
'x', 'x',