diff --git a/ajax/post-config.php b/ajax/post-config.php index 0c6096d..3db381c 100644 --- a/ajax/post-config.php +++ b/ajax/post-config.php @@ -1,20 +1,22 @@ item; $config_xml[0]->visibility = $clock; -$config_xml[1]->visibility = $meteo; +$config_xml[1]->visibility = $weather; $config_xml[2]->visibility = $notes; $config_xml[3]->visibility = $search; $config_xml[4]->visibility = $links; $config_xml[5]->visibility = $blogs; +$config_xml[6]->visibility = $todo; $xmla->asXML('../db/config.xml'); echo "1"; diff --git a/ajax/update-city.php b/ajax/update-city.php new file mode 100644 index 0000000..99ce595 --- /dev/null +++ b/ajax/update-city.php @@ -0,0 +1,10 @@ +$city)); + +?> \ No newline at end of file diff --git a/class/AccueilModules.php b/class/AccueilModules.php index 10d14b0..dc1c23f 100644 --- a/class/AccueilModules.php +++ b/class/AccueilModules.php @@ -1,11 +1,16 @@ persistance)){ + if($config = simplexml_load_file(self::CONFIG_FILE)){ $config_xml = $config->item; foreach($config_xml as $item){ $this->modules["$item[id]"] = $item; @@ -17,6 +22,10 @@ class AccueilModules { } } + /** + * + * Initialise les modules activés uniquement + */ function getModules(){ foreach($this->modules as $module=>$moduleConf){ if(file_exists('class/'.ucfirst($module).'.php') && $moduleConf->visibility == "true"){ @@ -30,6 +39,10 @@ class AccueilModules { } } + /** + * + * Construit et insère le menu de changement de config + */ function buildConfigMenu(){ echo 'Configuration
@@ -48,4 +61,16 @@ class AccueilModules {
'; } + + /** + * + * @property Chaque module possède la fonction updateModule en static qui permet de changer un ou plusieurs de ses attributs + * @param $module String Nom du module à modifier + * @param $things2change Array du ou des attributs à modifier avec sa ou ses nouvelles valeurs + * @return "ok" String si c'est bon, ou le message d'erreur + */ + public static function updateModule($module, $things2change){ + require ucfirst($module).'.php'; + return call_user_func(array($module, "updateConfig"), $things2change); + } } \ No newline at end of file diff --git a/class/Weather.php b/class/Weather.php index 8e17aaa..22051e2 100644 --- a/class/Weather.php +++ b/class/Weather.php @@ -1,9 +1,15 @@ setParams($params); + //$this->setParams($params); $city = $params['city']; include 'GoogleMeteo.php'; echo ' @@ -15,12 +21,45 @@ class weather { '.$future_weather2.' '; } - - 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"; + } } \ No newline at end of file diff --git a/js/jquery.weather.js b/js/jquery.weather.js index 25b4ab0..879118d 100644 --- a/js/jquery.weather.js +++ b/js/jquery.weather.js @@ -1,4 +1,29 @@ $(document).ready(function(){ + $('body').append('Weather City Choice
'); + $('#city').append('

Quelle ville pour la météo ?


Enregistrer'); + $('#city-menu').fancybox({ + 'zoomSpeedIn' : 600, + 'zoomSpeedOut' : 500, + 'easingIn' : 'easeOutBack', + 'easingOut' : 'easeInBack', + 'hideOnContentClick': false, + 'padding' : 15 + }); + $('#city-submit').live('click', function(){ + var ville = $('#cityChoice').val(); + if(ville != '' || ville != null){ + $.get('ajax/update-city.php', {city: ville}, function(msg){ + if(msg=='ok'){ + location.reload(); + }else{ + $('#city').append('An error occured while changing city.'); + } + }); + }else{ + $('#city').append('City can\'t be empty.'); + } + }); + var tmp; /* A helper function for converting a set of elements to draggables: */