Ville de la météo modifiable
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
<?php
|
||||
class weather {
|
||||
private $params = array();
|
||||
|
||||
//TODO rajouter les params en d<>tail
|
||||
public static $params = array(
|
||||
'visibility',
|
||||
'city',
|
||||
'x',
|
||||
'y'
|
||||
);
|
||||
|
||||
public function __construct($params){
|
||||
$this->setParams($params);
|
||||
//$this->setParams($params);
|
||||
$city = $params['city'];
|
||||
include 'GoogleMeteo.php';
|
||||
echo '<script type="text/javascript" src="js/jquery.weather.js"></script>
|
||||
@@ -15,12 +21,45 @@ class weather {
|
||||
'.$future_weather2.'
|
||||
</div>';
|
||||
}
|
||||
|
||||
private function setParams($params){
|
||||
|
||||
private static function setParams($params){
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
|
||||
public static function start($params){
|
||||
$weather = new weather($params);
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user