133 lines
3.8 KiB
PHP
133 lines
3.8 KiB
PHP
<?php
|
|
class clockAdvanced extends Module {
|
|
protected static $paramsList = array(
|
|
'visibility',
|
|
'x',
|
|
'y',
|
|
'fontFamily',
|
|
'fontSize',
|
|
'format',
|
|
'color'
|
|
);
|
|
|
|
public $params = array();
|
|
|
|
public function __construct($params){
|
|
$this->moduleName = get_class();
|
|
$this->pathToModule = 'modules/'.$this->moduleName.'/';
|
|
$this->setParams($params);
|
|
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="jclockAdvanced" id="clockAdvanced" style="left:'.$params['x'].'; top:'.$params['y'].';"></div>';
|
|
$options = '';
|
|
foreach (self::$paramsList as $paramName){
|
|
if(isset($this->params[$paramName]))
|
|
$options .= $paramName.' : "'.$this->params[$paramName].'",';
|
|
}
|
|
echo '<script>$(document).ready(function(){
|
|
$(\'#fontFamily\').val("'.$params['fontFamily'].'");
|
|
$(\'#fontSize\').val("'.$params['fontSize'].'");
|
|
$(\'#format\').val("'.$params['format'].'");
|
|
$(\'#color\').val("'.$params['color'].'");
|
|
$(\'.jclockAdvanced\').jclock({'.substr($options,0,-1).'});
|
|
});
|
|
</script>';
|
|
}
|
|
|
|
private function setParams($params){
|
|
$this->params = $params;
|
|
}
|
|
|
|
public static function start($params){
|
|
$clockAdvanced = new clockAdvanced($params);
|
|
}
|
|
|
|
public function setX($x){
|
|
// Saving the position and z-index of the note:
|
|
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
|
|
|
|
|
|
$path = $xmla->xpath("//item[@id='clockAdvanced']");
|
|
$path[0]->x = $x;
|
|
|
|
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
|
|
|
|
echo "ok";
|
|
}
|
|
|
|
public function setY($y){
|
|
// Saving the position and z-index of the note:
|
|
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
|
|
|
|
$path = $xmla->xpath("//item[@id='clockAdvanced']");
|
|
$path[0]->y = $y;
|
|
|
|
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
|
|
|
|
echo "ok";
|
|
}
|
|
|
|
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='clockAdvanced']");
|
|
$path[0]->visibility = $visibility;
|
|
|
|
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
|
|
|
|
echo "ok";
|
|
}
|
|
public function setFontFamily($fontFamily){
|
|
// Saving the position and z-index of the note:
|
|
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
|
|
|
|
$path = $xmla->xpath("//item[@id='clockAdvanced']");
|
|
$path[0]->fontFamily = $fontFamily;
|
|
|
|
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
|
|
|
|
echo "ok";
|
|
}
|
|
public function setFontSize($fontSize){
|
|
// Saving the position and z-index of the note:
|
|
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
|
|
|
|
$path = $xmla->xpath("//item[@id='clockAdvanced']");
|
|
$path[0]->fontSize = $fontSize;
|
|
|
|
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
|
|
|
|
echo "ok";
|
|
}
|
|
public function setColor($color){
|
|
// Saving the position and z-index of the note:
|
|
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
|
|
|
|
$path = $xmla->xpath("//item[@id='clockAdvanced']");
|
|
$path[0]->color = $color;
|
|
|
|
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
|
|
|
|
echo "ok";
|
|
}
|
|
public function setFormat($format){
|
|
// Saving the position and z-index of the note:
|
|
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
|
|
|
|
$path = $xmla->xpath("//item[@id='clockAdvanced']");
|
|
$path[0]->format = $format;
|
|
|
|
$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);
|
|
}
|
|
}
|
|
}
|
|
} |