diff --git a/ajax/post-config.php b/ajax/post-config.php index 1022d43..ad11eaf 100644 --- a/ajax/post-config.php +++ b/ajax/post-config.php @@ -3,7 +3,11 @@ $options = array(); $module =''; include '../class/AccueilModules.php'; foreach($_POST as $module => $valeur){ - AccueilModules::updateModule($module, array('visibility'=>$valeur)); + $moduleToUpdate = AccueilModules::getModule($module); + if($moduleToUpdate != null){ + $moduleToUpdate->updateConfig(array('visibility'=>$valeur)); + } + //AccueilModules::updateModule($module, array('visibility'=>$valeur)); } -echo "1"; +echo "1" ?> diff --git a/ajax/update.php b/ajax/update.php index 0c7a240..03607cb 100644 --- a/ajax/update.php +++ b/ajax/update.php @@ -8,9 +8,12 @@ $options = array(); $module =''; foreach($_GET as $indice=>$valeur){ if($indice == 'id') - $module .= $valeur; + $module = $valeur; else $options[$indice] = $valeur; } include '../class/AccueilModules.php'; -echo AccueilModules::updateModule($module, $options); +$moduleToUpdate = AccueilModules::getModule($module); +if($moduleToUpdate != null){ + echo $moduleToUpdate->updateConfig($options); +} diff --git a/class/AccueilModules.php b/class/AccueilModules.php index ccd31d2..3091817 100644 --- a/class/AccueilModules.php +++ b/class/AccueilModules.php @@ -1,14 +1,23 @@ modules["$item[id]"] = $item; } - $this->getModules(); - $this->buildConfigMenu(); }else{ echo 'Impossible de trouver le fichier de configuration.'; } @@ -34,11 +41,40 @@ class AccueilModules { foreach($moduleConf as $confParam){ $params[$confParam->getName()] = "$confParam"; } - require 'modules/'.$module.'/'.ucfirst($module).'.php'; - call_user_func(array($module, "start"), $params); + $module = new $module($params); + if(is_subclass_of($module,'Module')) + $module->build(); + // require 'modules/'.$module.'/'.ucfirst($module).'.php'; + // call_user_func(array($module, "start"), $module, $params); } } } + + /** + * + * @return le module donné avec ses paramètres actuellement présent en conf + */ + public static function getModule($module){ + if($config = simplexml_load_file('../'.self::CONFIG_FILE)){ + $config_xml = $config->item; + foreach($config_xml as $item){ + if($item["id"] == $module){ + $params = array(); + foreach($item as $confParam){ + $params[$confParam->getName()] = "$confParam"; + } + //require '../modules/'.$module.'/'.ucfirst($module).'.php'; + return new $module($params); + } + } + echo "object not found"; + return; + }else{ + echo "bad persistance"; + return; + } + + } /** * @@ -92,10 +128,12 @@ class AccueilModules { * @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 '../modules/'.$module.'/'.ucfirst($module).'.php'; + /*public static function updateModule($module, $things2change){ + //require 'Module.php'; + //require '../modules/'.$module.'/'.ucfirst($module).'.php'; + $module = new $module(); return call_user_func(array($module, "updateConfig"), $things2change); - } + }*/ /** * diff --git a/class/GoogleWeather.class.php b/class/GoogleWeather.class.php index 1e58f99..fa2e281 100644 --- a/class/GoogleWeather.class.php +++ b/class/GoogleWeather.class.php @@ -94,8 +94,9 @@ class GoogleWeatherAPI { } } else { - trigger_error('Google results parse problem : http error '.$getContentCode,E_USER_WARNING); - return null; + //trigger_error('Google results parse problem : http error '.$getContentCode,E_USER_WARNING); + $this->is_found = false; + //return null; } } diff --git a/class/Module.php b/class/Module.php index 05ec710..1c8c3ae 100644 --- a/class/Module.php +++ b/class/Module.php @@ -1,5 +1,5 @@ setNames($class, $this->moduleTitle); + $this->setParams($params); + } + + /** + * @param array correspondant aux paramètres du $paramsList + * Applique les paramètres du module depuis le conf + */ + public function setParams($params){ $this->params = $params; } - abstract static function start($params); + /** + * @return Array les paramètres du module + */ + public function getParams(){ + return $this->params; + } + + /** + * @param string le paramètre dont on veut la valeur + * @return string valeur du paramètre + */ + public function getParam($param){ + if(isset($this->params[$param])) + return $this->params[$param]; + else + return; + } + + /** + * @return string le nom de la classe (du module) + */ + private function getModuleName(){ + return $this->moduleName; + } + + /** + * Donne les noms et chemins du module + */ + private function setNames($module, $libelle){ + $this->moduleName = $module; + $this->pathToModule = 'modules/'.$this->moduleName.'/'; + $this->moduleTitle = $libelle; + } + + /** + * @param $class string nom du module + * @param $key string le nom du paramètre à changer + * @param $value string valeur du paramètre + * Enregistre le paramètre dans le conf + */ + public function setParam($class, $key, $value) { + echo 'setting :'.$key.' as '.$value.' in the '.$class.'\'s module'; + $xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE); - public static function updateConfig($updated){ + $path = $xmla->xpath("//item[@id='".$class."']"); + $path[0]->$key = $value; + + $xmla->asXML('../'.AccueilModules::CONFIG_FILE); + } + + public function updateConfig($updated){ foreach ($updated as $what=>$withWhat){ - if(in_array($what, self::$paramsList)){ - call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat); + if(array_key_exists($what, $this->getParams())){ + $this->setParam($this->moduleName, $what, $withWhat); + }else{ + echo $what.' isn\'t in '; } - } + } } } \ No newline at end of file diff --git a/db/config.xml b/db/config.xml index 5014e32..f71ae76 100644 --- a/db/config.xml +++ b/db/config.xml @@ -31,7 +31,7 @@ -2 - true + false 80 10 Times New Roman, serif @@ -46,6 +46,8 @@ false + 0 + 600 true diff --git a/index.php b/index.php index ea26623..ceee37f 100644 --- a/index.php +++ b/index.php @@ -12,8 +12,10 @@ getModules(); +$index->buildConfigMenu(); ?> diff --git a/js/main.js b/js/main.js index a7f1eb6..b8cbe90 100644 --- a/js/main.js +++ b/js/main.js @@ -67,7 +67,7 @@ $(document).ready(function(){ $('#menu-bar').prepend($('#config-menu')); $("#q").focus(); //focus sur la recherche - //$('.iconlist').sortable(); + $('#config-menu').fancybox({ 'zoomSpeedIn' : 600, 'zoomSpeedOut' : 500, diff --git a/modules/blogs/Blogs.php b/modules/blogs/Blogs.php index b028717..e4dcf33 100644 --- a/modules/blogs/Blogs.php +++ b/modules/blogs/Blogs.php @@ -1,21 +1,21 @@ moduleName = get_class(); - $this->pathToModule = 'modules/'.$this->moduleName.'/'; - $this->setParams($params); + parent::__construct(__CLASS__, $params); + } + + public function build(){ echo ' '; require($this->pathToModule.'includes/blogs_last_post.php'); - echo '
'; + echo '
'; echo ''; echo '
@@ -34,55 +34,4 @@ class blogs extends Module {
'; } - - private function setParams($params){ - $this->params = $params; - } - - public static function start($params){ - $blogs = new blogs($params); - } - - public function setX($x){ - $xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE); - - $path = $xmla->xpath("//item[@id='blogs']"); - $path[0]->x = $x; - - $xmla->asXML('../'.AccueilModules::CONFIG_FILE); - - echo "ok"; - } - - public function setY($y){ - $xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE); - - $path = $xmla->xpath("//item[@id='blogs']"); - $path[0]->y = $y; - - $xmla->asXML('../'.AccueilModules::CONFIG_FILE); - - echo "ok"; - } - - public function setVisibility($visibility){ - $xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE); - - $path = $xmla->xpath("//item[@id='blogs']"); - $path[0]->visibility = $visibility; - - $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); - } - } - } - - } \ No newline at end of file diff --git a/modules/clock/Clock.php b/modules/clock/Clock.php index 0e948f4..42d260c 100644 --- a/modules/clock/Clock.php +++ b/modules/clock/Clock.php @@ -1,48 +1,19 @@ moduleName = get_class(); - $this->pathToModule = 'modules/'.$this->moduleName.'/'; - $this->setParams($params); + parent::__construct(__CLASS__, $params); + } + + public function build(){ echo ' '; - echo '
'; - } - - private function setParams($params){ - $this->params = $params; - } - - public static function start($params){ - $clock = new clock($params); - } - - 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='clock']"); - $path[0]->visibility = $visibility; - - $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); - } - } + echo '
'; } } \ No newline at end of file diff --git a/modules/clockAdvanced/ClockAdvanced.php b/modules/clockAdvanced/ClockAdvanced.php index 560b6e8..225cbcc 100644 --- a/modules/clockAdvanced/ClockAdvanced.php +++ b/modules/clockAdvanced/ClockAdvanced.php @@ -1,5 +1,6 @@ moduleName = get_class(); - $this->pathToModule = 'modules/'.$this->moduleName.'/'; - $this->setParams($params); + parent::__construct(__CLASS__, $params); + } + + public function build(){ echo ' '; - echo '
'; + echo '
'; $options = ''; foreach (self::$paramsList as $paramName){ - if(isset($this->params[$paramName])) - $options .= $paramName.' : "'.$this->params[$paramName].'",'; + if($this->getParam($paramName) != null) + $options .= $paramName.' : "'.$this->getParam($paramName).'",'; } echo ''; } - - 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); - } - } - } } \ No newline at end of file diff --git a/modules/gmap/Gmap.php b/modules/gmap/Gmap.php index 53840d6..ab3c41f 100644 --- a/modules/gmap/Gmap.php +++ b/modules/gmap/Gmap.php @@ -1,49 +1,19 @@ moduleName = get_class(); - $this->pathToModule = 'modules/'.$this->moduleName.'/'; - $this->setParams($params); + parent::__construct(__CLASS__, $params); + } + + public function build(){ echo '
'; } - - private function setParams($params){ - $this->params = $params; - } - - public static function start($params){ - $gmap = new gmap($params); - } - - 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='gmap']"); - $path[0]->visibility = $visibility; - - $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); - } - } - } } \ No newline at end of file diff --git a/modules/links/Links.php b/modules/links/Links.php index b496dbc..b671f18 100644 --- a/modules/links/Links.php +++ b/modules/links/Links.php @@ -1,22 +1,17 @@ moduleName = get_class(); - $this->pathToModule = 'modules/'.$this->moduleName.'/'; - $this->setParams($params); + parent::__construct(__CLASS__, $params); + } + + public function build(){ echo '
@@ -38,32 +33,4 @@ class links extends Module{ echo ''; } - - private function setParams($params){ - $this->params = $params; - } - - public static function start($params){ - $links = new links($params); - } - - 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='links']"); - $path[0]->visibility = $visibility; - - $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); - } - } - } } \ No newline at end of file diff --git a/modules/mappy/Mappy.php b/modules/mappy/Mappy.php index 62a0392..6234eca 100644 --- a/modules/mappy/Mappy.php +++ b/modules/mappy/Mappy.php @@ -1,49 +1,19 @@ moduleName = get_class(); - $this->pathToModule = 'modules/'.$this->moduleName.'/'; - $this->setParams($params); + parent::__construct(__CLASS__, $params); + } + + public function build(){ echo ' '; echo '
'; } - - private function setParams($params){ - $this->params = $params; - } - - public static function start($params){ - - $mappy = new mappy($params); - } - - 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='mappy']"); - $path[0]->visibility = $visibility; - - $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); - } - } - } } \ No newline at end of file diff --git a/modules/news/News.php b/modules/news/News.php index 5d24fa3..3821877 100644 --- a/modules/news/News.php +++ b/modules/news/News.php @@ -1,16 +1,21 @@ setParams($params); + parent::__construct(__CLASS__, $params); + } + + public function build(){ + echo ' + '; echo ' -
+
'; } - - private function setParams($params){ - $this->params = $params; - } - - public static function start($params){ - $news = new news($params); - } - - 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='news']"); - $path[0]->visibility = $visibility; - - $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); - } - } - } } \ No newline at end of file diff --git a/modules/news/css/news.css b/modules/news/css/news.css new file mode 100644 index 0000000..df48162 --- /dev/null +++ b/modules/news/css/news.css @@ -0,0 +1,2 @@ +#news{position:absolute;} +#news div{display:inline !important;} \ No newline at end of file diff --git a/modules/news/js/news.js b/modules/news/js/news.js new file mode 100644 index 0000000..d3ab445 --- /dev/null +++ b/modules/news/js/news.js @@ -0,0 +1,4 @@ +$(document).ready(function(){ + +make_draggable($('#news')); +}); \ No newline at end of file diff --git a/modules/notes/Notes.php b/modules/notes/Notes.php index f7a0dab..8aa120a 100644 --- a/modules/notes/Notes.php +++ b/modules/notes/Notes.php @@ -1,51 +1,19 @@ moduleName = get_class(); - $this->pathToModule = 'modules/'.$this->moduleName.'/'; - $this->setParams($params); + parent::__construct(__CLASS__, $params); + } + + public function build(){ echo ' Add a note'; - include $this->pathToModule.'includes/notes_extract.php'; - } - - private function setParams($params){ - $this->params = $params; - } - - public static function start($params){ - $notes = new notes($params); - } - - 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='notes']"); - $path[0]->visibility = $visibility; - - $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); - } - } + include $this->pathToModule.'includes/notes_extract.php'; } } \ No newline at end of file diff --git a/modules/ouifm/Ouifm.php b/modules/ouifm/Ouifm.php index 202ba22..6c2648b 100644 --- a/modules/ouifm/Ouifm.php +++ b/modules/ouifm/Ouifm.php @@ -1,48 +1,19 @@ moduleName = get_class(); - $this->pathToModule = 'modules/'.$this->moduleName.'/'; - $this->setParams($params); + parent::__construct(__CLASS__, $params); + } + + public function build(){ echo ' '; - echo '
'; - } - - private function setParams($params){ - $this->params = $params; - } - - public static function start($params){ - $ouifm = new ouifm($params); - } - - 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='ouifm']"); - $path[0]->visibility = $visibility; - - $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); - } - } + echo '
'; } } \ No newline at end of file diff --git a/modules/rssblogs/Rssblogs.php b/modules/rssblogs/Rssblogs.php index a43239f..2046db3 100644 --- a/modules/rssblogs/Rssblogs.php +++ b/modules/rssblogs/Rssblogs.php @@ -1,6 +1,6 @@ moduleName = get_class(); - $this->pathToModule = 'modules/'.$this->moduleName.'/'; - $this->setParams($params); + parent::__construct(__CLASS__, $params); + } + + public function build(){ echo ' '; require('class/lastRSS.php'); @@ -22,6 +23,7 @@ class rssblogs extends Module { $rss->cache_time = 3600; // fréquence de mise à jour du cache (en secondes) $rss->date_format = 'd/m/y'; // format de la date (voir fonction date() pour syntaxe) $rss->CDATA = 'content'; // on retire les tags CDATA en conservant leur contenu + echo '
'; if($linksXML = simplexml_load_file($this->pathToModule.'db/rss.xml')){ foreach($linksXML->link as $individualLink){ if ($rs = $rss->get($individualLink->url)) @@ -32,56 +34,4 @@ class rssblogs extends Module { } echo '
'; } - - private function setParams($params){ - $this->params = $params; - } - - public static function start($params){ - $rssblogs = new rssblogs($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='rssblogs']"); - $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='rssblogs']"); - $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='rssblogs']"); - $path[0]->visibility = $visibility; - - $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); - } - } - } } \ No newline at end of file diff --git a/modules/rssblogs/js/rssblogs.js b/modules/rssblogs/js/rssblogs.js index e69de29..77376cb 100644 --- a/modules/rssblogs/js/rssblogs.js +++ b/modules/rssblogs/js/rssblogs.js @@ -0,0 +1 @@ +$(document).ready(function(){ make_draggable($('#rssblogs')); }); \ No newline at end of file diff --git a/modules/search/Search.php b/modules/search/Search.php index b4dd4a0..9fd4b53 100644 --- a/modules/search/Search.php +++ b/modules/search/Search.php @@ -1,19 +1,15 @@ moduleName = get_class(); - $this->pathToModule = 'modules/'.$this->moduleName.'/'; - $this->setParams($params); + parent::__construct(__CLASS__, $params); + } + + public function build(){ echo '
@@ -31,32 +27,4 @@ class search extends Module {
'; } - - private function setParams($params){ - $this->params = $params; - } - - public static function start($params){ - $search = new search($params); - } - - 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='search']"); - $path[0]->visibility = $visibility; - - $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); - } - } - } } \ No newline at end of file diff --git a/modules/todo/Todo.php b/modules/todo/Todo.php index 6ff2c2e..a9671f4 100644 --- a/modules/todo/Todo.php +++ b/modules/todo/Todo.php @@ -1,6 +1,7 @@ moduleName = get_class(); - $this->pathToModule = 'modules/'.$this->moduleName.'/'; - $this->setParams($params); + parent::__construct(__CLASS__, $params); + } + + public function build(){ echo ' '; if($xmla = simplexml_load_file($this->pathToModule.self::TODO_FILE)){ $this->setToken($xmla->token); $this->setProjectName($xmla->name); $this->setProjectId($xmla->id); - echo '
'; + echo '
'; if($this->token == null || $this->project_id == null) echo 'Impossible de trouver votre configuration. Cliquez ici pour la mettre en place.
'; else{ @@ -38,7 +40,7 @@ class todo extends Module { });'; }else{ echo 'baaaaad persistance...'; - } + } } private function setToken($token){ @@ -61,56 +63,4 @@ class todo extends Module { else $this->project_id = $id; } - - private function setParams($params){ - $this->params = $params; - } - - public static function start($params){ - $todo = new todo($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='todo']"); - $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='todo']"); - $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='todo']"); - $path[0]->visibility = $visibility; - - $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); - } - } - } } \ No newline at end of file diff --git a/modules/weather/Weather.php b/modules/weather/Weather.php index 4eb3f3e..2fbea70 100644 --- a/modules/weather/Weather.php +++ b/modules/weather/Weather.php @@ -1,10 +1,7 @@ moduleName = get_class(); - $this->pathToModule = 'modules/'.$this->moduleName.'/'; - $this->setParams($params); - $ville = $params['city']; + parent::__construct(__CLASS__, $params); + } + + public function build(){ + $ville = $this->getParam('city'); include $this->pathToModule.'includes/GoogleMeteo.php'; echo ' '; - echo '
+ echo '
getParam("y").';"> '.$city.'
'.$present_weather.'
'.$future_weather1.'
'.$future_weather2.' -
'; - } - - private function setParams($params){ - $this->params = $params; - } - - public static function start($params){ - $weather = new weather($params); - } - - /** - * - * 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"; - } - - 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='weather']"); - $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='weather']"); - $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='weather']"); - $path[0]->visibility = $visibility; - - $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); - } - } +
'; } } \ No newline at end of file diff --git a/modules/weather/includes/meteo.php b/modules/weather/includes/meteo.php deleted file mode 100644 index 4fe3085..0000000 --- a/modules/weather/includes/meteo.php +++ /dev/null @@ -1,26 +0,0 @@ -channel->item[0]->title; - $future_weather1 = $weather->channel->item[1]->title; - $future_weather2 = $weather->channel->item[2]->title; - if(strpos(strtolower($present_weather),"soleil") !== false) {?> - - - - - - - - - -