Amélioration de l'organisation du code : la classe principale "Module" est maintenant prête et les modules l'ont bien étendue.

This commit is contained in:
Chouchen
2010-10-05 15:30:04 +00:00
parent ac017b84e9
commit 759a5556cc
25 changed files with 236 additions and 706 deletions

View File

@@ -1,19 +1,15 @@
<?php
class search extends Module {
protected $moduleName;
protected $moduleTitle;
protected $pathToModule;
protected $moduleTitle = 'Recherche';
protected static $paramsList = array(
'visibility'
);
public $params = array();
public function __construct($params){
$this->moduleName = get_class();
$this->pathToModule = 'modules/'.$this->moduleName.'/';
$this->setParams($params);
parent::__construct(__CLASS__, $params);
}
public function build(){
echo '<link rel="stylesheet" type="text/css" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css">
<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
<form id="searchForm" method="post">
@@ -31,32 +27,4 @@ class search extends Module {
</fieldset>
</form>';
}
private function setParams($params){
$this->params = $params;
}
public static function start($params){
$search = new search($params);
}
public function setVisibility($visibility){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='search']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
}
}
}
}