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,16 +1,21 @@
|
||||
<?php
|
||||
class news {
|
||||
|
||||
class news extends Module{
|
||||
protected $moduleTitle = 'Google News';
|
||||
protected static $paramsList = array(
|
||||
'visibility'
|
||||
'visibility',
|
||||
'x',
|
||||
'y'
|
||||
);
|
||||
|
||||
public $params = array();
|
||||
|
||||
public function __construct($params){
|
||||
$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" />';
|
||||
echo '<script type="text/javascript" src="http://www.google.com/jsapi"></script>
|
||||
<div id="news"></div>
|
||||
<div id="news" style="top:' . $this->getParam('y') . '; left: ' . $this->getParam('x') . ';"></div>
|
||||
<script type="text/javascript">
|
||||
google.load("elements", "1", {packages : ["newsshow"]});
|
||||
function onLoad() {
|
||||
@@ -29,32 +34,4 @@ class news {
|
||||
google.setOnLoadCallback(onLoad);
|
||||
</script>';
|
||||
}
|
||||
|
||||
private function setParams($params){
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
public static function start($params){
|
||||
$news = new news($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='news']");
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
2
modules/news/css/news.css
Normal file
2
modules/news/css/news.css
Normal file
@@ -0,0 +1,2 @@
|
||||
#news{position:absolute;}
|
||||
#news div{display:inline !important;}
|
4
modules/news/js/news.js
Normal file
4
modules/news/js/news.js
Normal file
@@ -0,0 +1,4 @@
|
||||
$(document).ready(function(){
|
||||
|
||||
make_draggable($('#news'));
|
||||
});
|
Reference in New Issue
Block a user