2010-09-15 16:55:54 +02:00
|
|
|
|
<?php
|
|
|
|
|
class weather {
|
2010-09-15 23:36:14 +02:00
|
|
|
|
//TODO rajouter les params en d<>tail
|
|
|
|
|
public static $params = array(
|
|
|
|
|
'visibility',
|
|
|
|
|
'city',
|
|
|
|
|
'x',
|
|
|
|
|
'y'
|
|
|
|
|
);
|
|
|
|
|
|
2010-09-15 16:55:54 +02:00
|
|
|
|
public function __construct($params){
|
2010-09-15 23:36:14 +02:00
|
|
|
|
//$this->setParams($params);
|
2010-09-15 16:55:54 +02:00
|
|
|
|
$city = $params['city'];
|
|
|
|
|
include 'GoogleMeteo.php';
|
|
|
|
|
echo '<script type="text/javascript" src="js/jquery.weather.js"></script>
|
|
|
|
|
<link rel="stylesheet" type="text/css" href="css/weather.css">';
|
|
|
|
|
echo '<div id="weather" style="left:'.$params['x'].'; top:'.$params['y'].';">
|
|
|
|
|
<div class="weatherpic"></div>
|
|
|
|
|
<strong>'.$present_weather.'</strong><br/>
|
|
|
|
|
'.$future_weather1.'<br/>
|
|
|
|
|
'.$future_weather2.'
|
|
|
|
|
</div>';
|
|
|
|
|
}
|
2010-09-15 23:36:14 +02:00
|
|
|
|
|
|
|
|
|
private static function setParams($params){
|
2010-09-15 16:55:54 +02:00
|
|
|
|
$this->params = $params;
|
|
|
|
|
}
|
2010-09-15 23:36:14 +02:00
|
|
|
|
|
2010-09-15 16:55:54 +02:00
|
|
|
|
public static function start($params){
|
|
|
|
|
$weather = new weather($params);
|
|
|
|
|
}
|
2010-09-15 23:36:14 +02:00
|
|
|
|
|
|
|
|
|
public static function updateConfig($updated){
|
|
|
|
|
foreach ($updated as $what=>$withWhat){
|
|
|
|
|
if(in_array($what, self::$params)){
|
|
|
|
|
switch($what){
|
|
|
|
|
case 'city':
|
|
|
|
|
self::setCity($withWhat);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* Modifie la ville
|
|
|
|
|
* @param String $city la ville.
|
|
|
|
|
* @return String "ok" ou message d'erreur (effectue aussi l'enregistrement en XML)
|
|
|
|
|
*/
|
|
|
|
|
public function setCity($city){
|
|
|
|
|
// Saving the position and z-index of the note:
|
|
|
|
|
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
|
|
|
|
|
|
|
|
|
|
$path = $xmla->xpath("//item[@id='weather']");
|
|
|
|
|
$path[0]->city = $city;
|
|
|
|
|
|
|
|
|
|
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
|
|
|
|
|
|
|
|
|
|
echo "ok";
|
|
|
|
|
}
|
2010-09-15 16:55:54 +02:00
|
|
|
|
}
|