Accueil/modules/clock/Clock.php

48 lines
1.3 KiB
PHP
Raw Normal View History

2010-09-21 18:07:23 +02:00
<?php
2010-09-27 12:48:53 +02:00
class clock extends Module {
2010-09-21 18:07:23 +02:00
protected static $paramsList = array(
'visibility',
'x',
'y'
);
public $params = array();
public function __construct($params){
2010-09-27 12:48:53 +02:00
$this->moduleName = get_class();
$this->pathToModule = 'modules/'.$this->moduleName.'/';
2010-09-21 18:07:23 +02:00
$this->setParams($params);
2010-09-27 12:48:53 +02:00
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 '<div class="jclock" id="clock" style="left:'.$params['x'].'; top:'.$params['y'].';"></div>';
2010-09-21 18:07:23 +02:00
}
private function setParams($params){
$this->params = $params;
}
public static function start($params){
2010-09-27 12:48:53 +02:00
$clock = new clock($params);
2010-09-21 18:07:23 +02:00
}
public function setVisibility($visibility){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
2010-09-27 12:48:53 +02:00
$path = $xmla->xpath("//item[@id='clock']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
2010-09-21 18:07:23 +02:00
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);
}
}
}
}