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:
@@ -1,21 +1,21 @@
|
||||
<?php
|
||||
class blogs extends Module {
|
||||
|
||||
protected $moduleTitle = 'Blogs BD';
|
||||
protected static $paramsList = array(
|
||||
'visibility',
|
||||
'x',
|
||||
'y'
|
||||
);
|
||||
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 '<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
|
||||
<link rel="stylesheet" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />';
|
||||
require($this->pathToModule.'includes/blogs_last_post.php');
|
||||
echo '<div id="blogs" style="top:'.$params['y'].'; left :'.$params['x'].';"></div>';
|
||||
echo '<div id="blogs" style="top:'.$this->getParam('y').'; left :'.$this->getParam('x').';"></div>';
|
||||
echo '<a href="#blogLinksManager" id="blog-links-manager"><img src="images/interface/blogs_edit.png" /></a>';
|
||||
echo '<div style="display:none;">
|
||||
<div id="blogLinksManager">
|
||||
@@ -34,55 +34,4 @@ class blogs extends Module {
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
private function setParams($params){
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
public static function start($params){
|
||||
$blogs = new blogs($params);
|
||||
}
|
||||
|
||||
public function setX($x){
|
||||
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
|
||||
|
||||
$path = $xmla->xpath("//item[@id='blogs']");
|
||||
$path[0]->x = $x;
|
||||
|
||||
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
|
||||
|
||||
echo "ok";
|
||||
}
|
||||
|
||||
public function setY($y){
|
||||
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
|
||||
|
||||
$path = $xmla->xpath("//item[@id='blogs']");
|
||||
$path[0]->y = $y;
|
||||
|
||||
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
|
||||
|
||||
echo "ok";
|
||||
}
|
||||
|
||||
public function setVisibility($visibility){
|
||||
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
|
||||
|
||||
$path = $xmla->xpath("//item[@id='blogs']");
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user