Browse Source

Amélioration de l'organisation du code : la classe principale "Module" est maintenant prête et les modules l'ont bien étendue.

Chouchen 8 years ago
parent
commit
759a5556cc

+ 6
- 2
ajax/post-config.php View File

@@ -3,7 +3,11 @@ $options = array();
3 3
 $module	='';
4 4
 include '../class/AccueilModules.php';
5 5
 foreach($_POST as $module => $valeur){
6
-	AccueilModules::updateModule($module, array('visibility'=>$valeur));
6
+	$moduleToUpdate = AccueilModules::getModule($module);
7
+	if($moduleToUpdate != null){
8
+		$moduleToUpdate->updateConfig(array('visibility'=>$valeur));
9
+	}
10
+	//AccueilModules::updateModule($module, array('visibility'=>$valeur));
7 11
 }
8
-echo "1";
12
+echo "1"
9 13
 ?>

+ 5
- 2
ajax/update.php View File

@@ -8,9 +8,12 @@ $options = array();
8 8
 $module	='';
9 9
 foreach($_GET as $indice=>$valeur){
10 10
 	if($indice == 'id')
11
-		$module .= $valeur;
11
+		$module = $valeur;
12 12
 	else
13 13
 		$options[$indice] = $valeur;
14 14
 }
15 15
 include '../class/AccueilModules.php';
16
-echo AccueilModules::updateModule($module, $options);
16
+$moduleToUpdate = AccueilModules::getModule($module);
17
+if($moduleToUpdate != null){
18
+	echo $moduleToUpdate->updateConfig($options);
19
+}

+ 49
- 11
class/AccueilModules.php View File

@@ -1,14 +1,23 @@
1 1
 <?php 
2
-require 'Module.php';
2
+function __autoload($class)
3
+{
4
+	$BASE_DIR = '/homez.9/shikiryu/www/test/trunk3/';
5
+	set_include_path($BASE_DIR);
6
+	$path = 'modules/'.$class;
7
+	if(file_exists($path . DIRECTORY_SEPARATOR . ucfirst($class) . '.php') || file_exists($BASE_DIR . $path . DIRECTORY_SEPARATOR . ucfirst($class) . '.php')){
8
+		require_once($path . DIRECTORY_SEPARATOR . ucfirst($class) . '.php');
9
+	}else{
10
+		require_once('class/' . $class . '.php');
11
+	}
12
+}
3 13
 class AccueilModules {
14
+
4 15
 	const CONFIG_FILE = 'db/config.xml';
5 16
 	private $modules = array();
6
-	
17
+
7 18
 	/**
8 19
 	 * Constructeur
9 20
 	 * Initialise le XML de conf générale
10
-	 * Active les modules
11
-	 * Construit le menu
12 21
 	 */
13 22
 	function __construct(){
14 23
 		if($config = simplexml_load_file(self::CONFIG_FILE)){
@@ -16,8 +25,6 @@ class AccueilModules {
16 25
 			foreach($config_xml as $item){
17 26
 				$this->modules["$item[id]"] = $item;
18 27
 			}
19
-			$this->getModules();
20
-			$this->buildConfigMenu();
21 28
 		}else{
22 29
 			echo 'Impossible de trouver le fichier de configuration.';
23 30
 		}
@@ -34,11 +41,40 @@ class AccueilModules {
34 41
 				foreach($moduleConf as $confParam){
35 42
 					$params[$confParam->getName()] = "$confParam";
36 43
 				}
37
-				require 'modules/'.$module.'/'.ucfirst($module).'.php';
38
-				call_user_func(array($module, "start"), $params);
44
+				$module = new $module($params);
45
+				if(is_subclass_of($module,'Module'))
46
+				$module->build();
47
+				// require 'modules/'.$module.'/'.ucfirst($module).'.php';
48
+				// call_user_func(array($module, "start"), $module, $params);
39 49
 			}
40 50
 		}
41 51
 	}
52
+	
53
+	/**
54
+	 *
55
+	 * @return le module donné avec ses paramètres actuellement présent en conf
56
+	 */
57
+	public static function getModule($module){
58
+		if($config = simplexml_load_file('../'.self::CONFIG_FILE)){
59
+			$config_xml = $config->item;
60
+			foreach($config_xml as $item){
61
+				if($item["id"] == $module){
62
+					$params = array();
63
+					foreach($item as $confParam){
64
+						$params[$confParam->getName()] = "$confParam";
65
+					}
66
+					//require '../modules/'.$module.'/'.ucfirst($module).'.php';
67
+					return new $module($params);
68
+				}
69
+			}
70
+			echo "object not found";
71
+			return;
72
+		}else{
73
+			echo "bad persistance";
74
+			return;
75
+		}
76
+		
77
+	}
42 78
 
43 79
 	/**
44 80
 	 * 
@@ -92,10 +128,12 @@ class AccueilModules {
92 128
 	 * @param $things2change Array du ou des attributs à modifier avec sa ou ses nouvelles valeurs
93 129
 	 * @return "ok" String si c'est bon, ou le message d'erreur
94 130
 	 */
95
-	public static function updateModule($module, $things2change){
96
-		require '../modules/'.$module.'/'.ucfirst($module).'.php';
131
+	/*public static function updateModule($module, $things2change){
132
+		//require 'Module.php';
133
+		//require '../modules/'.$module.'/'.ucfirst($module).'.php';
134
+		$module = new $module();
97 135
 		return call_user_func(array($module, "updateConfig"), $things2change);
98
-	}
136
+	}*/
99 137
 	
100 138
 	/**
101 139
 	*

+ 3
- 2
class/GoogleWeather.class.php View File

@@ -94,8 +94,9 @@ class GoogleWeatherAPI {
94 94
 			}
95 95
 			
96 96
 		} else {
97
-			trigger_error('Google results parse problem : http error '.$getContentCode,E_USER_WARNING);
98
-			return null;
97
+			//trigger_error('Google results parse problem : http error '.$getContentCode,E_USER_WARNING);
98
+			$this->is_found = false;
99
+			//return null;
99 100
 		}
100 101
 	}
101 102
 	

+ 67
- 8
class/Module.php View File

@@ -1,5 +1,5 @@
1 1
 <?php 
2
-abstract class Module
2
+class Module
3 3
 {
4 4
 	/**
5 5
 	* Liste des paramètres du module en concordance avec le "config.xml"
@@ -22,20 +22,79 @@ abstract class Module
22 22
 	*
23 23
 	* @var array
24 24
 	*/
25
-	public $params = array();
25
+	private $params = array();
26 26
 	
27
-	private function setParams($params){
27
+	public function __construct($class, $params){
28
+		$this->setNames($class, $this->moduleTitle);
29
+		$this->setParams($params);
30
+	}
31
+	
32
+	/**
33
+	 * @param array correspondant aux paramètres du $paramsList
34
+	 * Applique les paramètres du module depuis le conf
35
+	 */
36
+	public function setParams($params){
28 37
 		$this->params = $params;
29 38
 	}
30 39
 	
31
-	abstract static function start($params);
40
+	/**
41
+	 * @return Array les paramètres du module
42
+	 */
43
+	public function getParams(){
44
+		return $this->params;
45
+	}
46
+	
47
+	/**
48
+	 * @param string le paramètre dont on veut la valeur
49
+	 * @return string valeur du paramètre
50
+	 */
51
+	public function getParam($param){
52
+		if(isset($this->params[$param]))
53
+			return $this->params[$param];
54
+		else
55
+			return;
56
+	}
57
+	
58
+	/**
59
+	 * @return string le nom de la classe (du module)
60
+	 */
61
+	private function getModuleName(){
62
+		return $this->moduleName;
63
+	}
64
+	
65
+	/**
66
+	 * Donne les noms et chemins du module
67
+	 */
68
+	private function setNames($module, $libelle){
69
+		$this->moduleName 	= $module;
70
+		$this->pathToModule = 'modules/'.$this->moduleName.'/';
71
+		$this->moduleTitle	= $libelle;
72
+	}
73
+	
74
+	/**
75
+	 * @param $class string nom du module
76
+	 * @param $key string le nom du paramètre à changer
77
+	 * @param $value string valeur du paramètre
78
+	 * Enregistre le paramètre dans le conf
79
+	 */
80
+	public function setParam($class, $key, $value) {
81
+		echo 'setting :'.$key.' as '.$value.' in the '.$class.'\'s module';
82
+        $xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
32 83
 
33
-	public static function updateConfig($updated){
84
+		$path = $xmla->xpath("//item[@id='".$class."']"); 
85
+		$path[0]->$key = $value;
86
+		
87
+		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
88
+     }
89
+	 
90
+	public function updateConfig($updated){
34 91
 		foreach ($updated as $what=>$withWhat){
35
-			if(in_array($what, self::$paramsList)){
36
-				call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
92
+			if(array_key_exists($what, $this->getParams())){
93
+				$this->setParam($this->moduleName, $what, $withWhat);
94
+			}else{
95
+				echo $what.' isn\'t in ';
37 96
 			}
38
-		}
97
+		}		
39 98
 	}
40 99
 	
41 100
 }

+ 3
- 1
db/config.xml View File

@@ -31,7 +31,7 @@
31 31
 		<y>-2</y>
32 32
 	</item>
33 33
 	<item id="clockAdvanced">
34
-		<visibility>true</visibility>
34
+		<visibility>false</visibility>
35 35
 		<x>80</x>
36 36
 		<y>10</y>
37 37
 		<fontFamily>Times New Roman, serif</fontFamily>
@@ -46,6 +46,8 @@
46 46
 	</item>
47 47
 	<item id="news">
48 48
 		<visibility>false</visibility>
49
+		<x>0</x>
50
+		<y>600</y>
49 51
 	</item>
50 52
 	<item id="ouifm">
51 53
 		<visibility>true</visibility>

+ 3
- 1
index.php View File

@@ -12,8 +12,10 @@
12 12
 </head> 
13 13
 <body> 
14 14
 <?
15
-require 'class/AccueilModules.php';
15
+include "class/AccueilModules.php";
16 16
 $index = new AccueilModules();
17
+$index->getModules();
18
+$index->buildConfigMenu();
17 19
 ?>
18 20
 </body> 
19 21
 </html> 

+ 1
- 1
js/main.js View File

@@ -67,7 +67,7 @@ $(document).ready(function(){
67 67
 	$('#menu-bar').prepend($('#config-menu'));
68 68
 	
69 69
 	$("#q").focus(); //focus sur la recherche
70
-	//$('.iconlist').sortable();
70
+
71 71
 	$('#config-menu').fancybox({
72 72
 		'zoomSpeedIn'		: 600,
73 73
 		'zoomSpeedOut'		: 500,

+ 6
- 57
modules/blogs/Blogs.php View File

@@ -1,21 +1,21 @@
1 1
 <?php
2 2
 class blogs extends Module {
3
-
3
+	protected $moduleTitle = 'Blogs BD';
4 4
 	protected static $paramsList = array(
5 5
 		'visibility',
6 6
 		'x',
7 7
 		'y'
8 8
 	);
9
-	public $params = array();
10 9
 	
11 10
 	public function __construct($params){
12
-		$this->moduleName = get_class();
13
-		$this->pathToModule = 'modules/'.$this->moduleName.'/';
14
-		$this->setParams($params);
11
+		parent::__construct(__CLASS__, $params);
12
+	}
13
+	
14
+	public function build(){
15 15
 		echo '<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
16 16
 				<link rel="stylesheet" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />';
17 17
 		require($this->pathToModule.'includes/blogs_last_post.php');
18
-		echo '<div id="blogs" style="top:'.$params['y'].'; left :'.$params['x'].';"></div>';
18
+		echo '<div id="blogs" style="top:'.$this->getParam('y').'; left :'.$this->getParam('x').';"></div>';
19 19
 		echo '<a href="#blogLinksManager" id="blog-links-manager"><img src="images/interface/blogs_edit.png" /></a>';
20 20
 		echo '<div style="display:none;">
21 21
 				<div id="blogLinksManager">
@@ -34,55 +34,4 @@ class blogs extends Module {
34 34
 				</div>
35 35
 				</div>';
36 36
 	}
37
-	
38
-	private function setParams($params){
39
-		$this->params = $params;
40
-	}
41
-	
42
-	public static function start($params){
43
-		$blogs = new blogs($params);
44
-	}
45
-	
46
-	public function setX($x){
47
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
48
-
49
-		$path = $xmla->xpath("//item[@id='blogs']"); 
50
-		$path[0]->x = $x;
51
-		
52
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
53
-		
54
-		echo "ok";
55
-	}
56
-	
57
-	public function setY($y){
58
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
59
-
60
-		$path = $xmla->xpath("//item[@id='blogs']"); 
61
-		$path[0]->y = $y;
62
-		
63
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
64
-		
65
-		echo "ok";
66
-	}
67
-	
68
-	public function setVisibility($visibility){
69
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
70
-
71
-		$path = $xmla->xpath("//item[@id='blogs']"); 
72
-		$path[0]->visibility = $visibility;
73
-		
74
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
75
-		
76
-		echo "ok";
77
-	}
78
-	
79
-	public static function updateConfig($updated){
80
-		foreach ($updated as $what=>$withWhat){
81
-			if(in_array($what, self::$paramsList)){
82
-				call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
83
-			}
84
-		}
85
-	}
86
-	
87
-
88 37
 }

+ 6
- 35
modules/clock/Clock.php View File

@@ -1,48 +1,19 @@
1 1
 <?php
2 2
 class clock extends Module {
3
-
3
+	protected $moduleTitle = 'Horloge Simple';
4 4
 	protected static $paramsList = array(
5 5
 		'visibility',
6 6
 		'x',
7 7
 		'y'
8 8
 	);
9 9
 	
10
-	public $params = array();
11
-	
12 10
 	public function __construct($params){
13
-		$this->moduleName = get_class();
14
-		$this->pathToModule = 'modules/'.$this->moduleName.'/';
15
-		$this->setParams($params);
16
-		echo '<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
17
-				<link rel="stylesheet" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />';
18
-		echo '<div class="jclock" id="clock" style="left:'.$params['x'].'; top:'.$params['y'].';"></div>';
11
+		parent::__construct(__CLASS__, $params);
19 12
 	}
20 13
 	
21
-	private function setParams($params){
22
-		$this->params = $params;
23
-	}
24
-	
25
-	public static function start($params){
26
-		$clock = new clock($params);
27
-	}
28
-	
29
-	public function setVisibility($visibility){
30
-		// Saving the position and z-index of the note:
31
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
32
-
33
-		$path = $xmla->xpath("//item[@id='clock']"); 
34
-		$path[0]->visibility = $visibility;
35
-		
36
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
37
-		
38
-		echo "ok";
39
-	}
40
-	
41
-	public static function updateConfig($updated){
42
-		foreach ($updated as $what=>$withWhat){
43
-			if(in_array($what, self::$paramsList)){
44
-				call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
45
-			}
46
-		}
14
+	public function build(){
15
+		echo '<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
16
+				<link rel="stylesheet" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />';
17
+		echo '<div class="jclock" id="clock" style="left:'.$this->getParam('x').'; top:'.$this->getParam('y').';"></div>';
47 18
 	}
48 19
 }

+ 12
- 109
modules/clockAdvanced/ClockAdvanced.php View File

@@ -1,5 +1,6 @@
1 1
 <?php
2 2
 class clockAdvanced extends Module {
3
+	protected $moduleTitle = 'Horloge Avancée';
3 4
 	protected static $paramsList = array(
4 5
 		'visibility',
5 6
 		'x',
@@ -10,124 +11,26 @@ class clockAdvanced extends Module {
10 11
 		'color'
11 12
 	);
12 13
 	
13
-	public $params = array();
14
-	
15 14
 	public function __construct($params){
16
-		$this->moduleName = get_class();
17
-		$this->pathToModule = 'modules/'.$this->moduleName.'/';
18
-		$this->setParams($params);
15
+		parent::__construct(__CLASS__, $params);
16
+	}
17
+	
18
+	public function build(){
19 19
 		echo '<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
20 20
 				<link rel="stylesheet" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />';
21
-		echo '<div class="jclockAdvanced" id="clockAdvanced" style="left:'.$params['x'].'; top:'.$params['y'].';"></div>';
21
+		echo '<div class="jclockAdvanced" id="clockAdvanced" style="left:'.$this->getParam('x').'; top:'.$this->getParam('y').';"></div>';
22 22
 		$options = '';
23 23
 		foreach (self::$paramsList as $paramName){
24
-			if(isset($this->params[$paramName]))
25
-				$options .= $paramName.' : "'.$this->params[$paramName].'",';
24
+			if($this->getParam($paramName) != null)
25
+				$options .= $paramName.' : "'.$this->getParam($paramName).'",';
26 26
 		}
27 27
 		echo '<script>$(document).ready(function(){
28
-					$(\'#fontFamily\').val("'.$params['fontFamily'].'");
29
-					$(\'#fontSize\').val("'.$params['fontSize'].'");
30
-					$(\'#format\').val("'.$params['format'].'");
31
-					$(\'#color\').val("'.$params['color'].'");
28
+					$(\'#fontFamily\').val("'.$this->getParam('fontFamily').'");
29
+					$(\'#fontSize\').val("'.$this->getParam('fontSize').'");
30
+					$(\'#format\').val("'.$this->getParam('format').'");
31
+					$(\'#color\').val("'.$this->getParam('color').'");
32 32
 					$(\'.jclockAdvanced\').jclock({'.substr($options,0,-1).'}); 
33 33
 				});
34 34
 				</script>';
35 35
 	}
36
-	
37
-	private function setParams($params){
38
-		$this->params = $params;
39
-	}
40
-	
41
-	public static function start($params){
42
-		$clockAdvanced = new clockAdvanced($params);
43
-	}
44
-	
45
-	public function setX($x){
46
-		// Saving the position and z-index of the note:
47
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
48
-
49
-		
50
-		$path = $xmla->xpath("//item[@id='clockAdvanced']"); 
51
-		$path[0]->x = $x;
52
-		
53
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
54
-		
55
-		echo "ok";
56
-	}
57
-	
58
-	public function setY($y){
59
-		// Saving the position and z-index of the note:
60
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
61
-
62
-		$path = $xmla->xpath("//item[@id='clockAdvanced']"); 
63
-		$path[0]->y = $y;
64
-		
65
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
66
-		
67
-		echo "ok";
68
-	}
69
-	
70
-	public function setVisibility($visibility){
71
-		// Saving the position and z-index of the note:
72
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
73
-
74
-		$path = $xmla->xpath("//item[@id='clockAdvanced']"); 
75
-		$path[0]->visibility = $visibility;
76
-		
77
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
78
-		
79
-		echo "ok";
80
-	}
81
-	public function setFontFamily($fontFamily){
82
-		// Saving the position and z-index of the note:
83
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
84
-
85
-		$path = $xmla->xpath("//item[@id='clockAdvanced']"); 
86
-		$path[0]->fontFamily = $fontFamily;
87
-		
88
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
89
-		
90
-		echo "ok";
91
-	}
92
-	public function setFontSize($fontSize){
93
-		// Saving the position and z-index of the note:
94
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
95
-
96
-		$path = $xmla->xpath("//item[@id='clockAdvanced']"); 
97
-		$path[0]->fontSize = $fontSize;
98
-		
99
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
100
-		
101
-		echo "ok";
102
-	}
103
-	public function setColor($color){
104
-		// Saving the position and z-index of the note:
105
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
106
-
107
-		$path = $xmla->xpath("//item[@id='clockAdvanced']"); 
108
-		$path[0]->color = $color;
109
-		
110
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
111
-		
112
-		echo "ok";
113
-	}
114
-	public function setFormat($format){
115
-		// Saving the position and z-index of the note:
116
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
117
-
118
-		$path = $xmla->xpath("//item[@id='clockAdvanced']"); 
119
-		$path[0]->format = $format;
120
-		
121
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
122
-		
123
-		echo "ok";
124
-	}
125
-	
126
-	public static function updateConfig($updated){
127
-		foreach ($updated as $what=>$withWhat){
128
-			if(in_array($what, self::$paramsList)){
129
-				call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
130
-			}
131
-		}
132
-	}
133 36
 }

+ 5
- 35
modules/gmap/Gmap.php View File

@@ -1,49 +1,19 @@
1 1
 <?php
2
-
3 2
 class gmap extends Module {
4
-	//TODO rajouter les params en détail
3
+	protected $moduleTitle = 'Google Maps';
5 4
 	protected static $paramsList = array(
6 5
 		'visibility'
7 6
 	);
8 7
 	
9
-	public $params = array();
10
-
11 8
 	public function __construct($params){
12
-		$this->moduleName = get_class();
13
-		$this->pathToModule = 'modules/'.$this->moduleName.'/';
14
-		$this->setParams($params);
9
+		parent::__construct(__CLASS__, $params);
10
+	}
11
+	
12
+	public function build(){
15 13
 		echo '<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=fr"></script>
16 14
 		<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
17 15
 				<link rel="stylesheet" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />
18 16
 				
19 17
 				<div id="myAdress"><label for="myAdressField"><img src="images/interface/map.png" /> Adresse pour Google Maps :</label><input type="text" name="myAdressField" id="myAdressField" /></div><a href="#map" id="gmapLink"></a><div id="map"><div id="mymap" style="width:400px;height:400px"></div></div>';
20 18
 	}
21
-
22
-	private function setParams($params){
23
-		$this->params = $params;
24
-	}
25
-
26
-	public static function start($params){
27
-		$gmap = new gmap($params);
28
-	}
29
-	
30
-	public function setVisibility($visibility){
31
-		// Saving the position and z-index of the note:
32
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
33
-
34
-		$path = $xmla->xpath("//item[@id='gmap']"); 
35
-		$path[0]->visibility = $visibility;
36
-		
37
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
38
-		
39
-		echo "ok";
40
-	}
41
-	
42
-	public static function updateConfig($updated){
43
-		foreach ($updated as $what=>$withWhat){
44
-			if(in_array($what, self::$paramsList)){
45
-				call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
46
-			}
47
-		}
48
-	}
49 19
 }

+ 5
- 38
modules/links/Links.php View File

@@ -1,22 +1,17 @@
1 1
 <?php
2 2
 class links extends Module{
3
-
4
-	protected $moduleName;
5
-	protected $moduleTitle;
6
-	protected $pathToModule;
7
-	
3
+	protected $moduleTitle = 'Liens';
8 4
 	protected static $paramsList = array(
9 5
 		'visibility'
10 6
 	);
11 7
 	
12 8
 	const LINKS_FILE = 'db/links.xml';
13 9
 	
14
-	public $params = array();
15
-	
16 10
 	public function __construct($params){
17
-		$this->moduleName = get_class();
18
-		$this->pathToModule = 'modules/'.$this->moduleName.'/';
19
-		$this->setParams($params);
11
+		parent::__construct(__CLASS__, $params);
12
+	}
13
+	
14
+	public function build(){
20 15
 		echo '<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
21 16
 				<link rel="stylesheet" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />
22 17
 				<div style="display:none;"><div id="links-add-fancy"></div></div>
@@ -38,32 +33,4 @@ class links extends Module{
38 33
 		echo '</div>';
39 34
 		
40 35
 	}
41
-	
42
-	private function setParams($params){
43
-		$this->params = $params;
44
-	}
45
-	
46
-	public static function start($params){
47
-		$links = new links($params);
48
-	}
49
-	
50
-	public function setVisibility($visibility){
51
-		// Saving the position and z-index of the note:
52
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
53
-
54
-		$path = $xmla->xpath("//item[@id='links']"); 
55
-		$path[0]->visibility = $visibility;
56
-		
57
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
58
-		
59
-		echo "ok";
60
-	}
61
-	
62
-	public static function updateConfig($updated){
63
-		foreach ($updated as $what=>$withWhat){
64
-			if(in_array($what, self::$paramsList)){
65
-				call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
66
-			}
67
-		}
68
-	}
69 36
 }

+ 5
- 35
modules/mappy/Mappy.php View File

@@ -1,49 +1,19 @@
1 1
 <?php
2 2
 class mappy extends Module {
3
-
3
+	protected $moduleTitle = 'Mappy';
4 4
 	protected static $paramsList = array(
5 5
 		'visibility'
6 6
 	);
7 7
 	
8
-	public $params = array();
9
-	
10 8
 	public function __construct($params){
11
-		$this->moduleName = get_class();
12
-		$this->pathToModule = 'modules/'.$this->moduleName.'/';
13
-		$this->setParams($params);
9
+		parent::__construct(__CLASS__, $params);
10
+	}
11
+	
12
+	public function build(){
14 13
 		echo '<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
15 14
 				<link rel="stylesheet" type="text/css" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css">';
16 15
 		echo '<script src="http://axe.mappy.com/1v1/init/get.aspx?version=2.01&solution=ajax&auth=HbTTpMfC4//GWuldL2IsF+HJA4xVuTBsIQi0wcC7xRz+e17hobrJ+1947aq34rdjYAPy6nBYBQF8o56Qzdun9w=="></script>
17 16
 				<div id="mymap"></div>
18 17
 				<div id="myAdress"><input type="text" name="myAdressField" id="myAdressField" /></div>';
19 18
 	}
20
-	
21
-	private function setParams($params){
22
-		$this->params = $params;
23
-	}
24
-	
25
-	public static function start($params){
26
-		
27
-		$mappy = new mappy($params);
28
-	}
29
-	
30
-	public function setVisibility($visibility){
31
-		// Saving the position and z-index of the note:
32
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
33
-
34
-		$path = $xmla->xpath("//item[@id='mappy']"); 
35
-		$path[0]->visibility = $visibility;
36
-		
37
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
38
-		
39
-		echo "ok";
40
-	}
41
-	
42
-	public static function updateConfig($updated){
43
-		foreach ($updated as $what=>$withWhat){
44
-			if(in_array($what, self::$paramsList)){
45
-				call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
46
-			}
47
-		}
48
-	}
49 19
 }

+ 12
- 35
modules/news/News.php View File

@@ -1,16 +1,21 @@
1 1
 <?php
2
-class news {
3
-
2
+class news extends Module{
3
+	protected $moduleTitle = 'Google News';
4 4
 	protected static $paramsList = array(
5
-		'visibility'
5
+		'visibility',
6
+		'x',
7
+		'y'
6 8
 	);
7 9
 	
8
-	public $params = array();
9
-	
10 10
 	public function __construct($params){
11
-		$this->setParams($params);
11
+		parent::__construct(__CLASS__, $params);
12
+	}
13
+	
14
+	public function build(){
15
+		echo '<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
16
+				<link rel="stylesheet" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />';
12 17
 		echo '<script type="text/javascript" src="http://www.google.com/jsapi"></script>
13
-				<div id="news"></div>
18
+				<div id="news" style="top:' . $this->getParam('y') . '; left: ' . $this->getParam('x') . ';"></div>
14 19
 					<script type="text/javascript">
15 20
 						google.load("elements", "1", {packages : ["newsshow"]});
16 21
 						function onLoad() {
@@ -29,32 +34,4 @@ class news {
29 34
 						google.setOnLoadCallback(onLoad);
30 35
 					</script>';
31 36
 	}
32
-	
33
-	private function setParams($params){
34
-		$this->params = $params;
35
-	}
36
-	
37
-	public static function start($params){
38
-		$news = new news($params);
39
-	}
40
-	
41
-	public function setVisibility($visibility){
42
-		// Saving the position and z-index of the note:
43
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
44
-
45
-		$path = $xmla->xpath("//item[@id='news']"); 
46
-		$path[0]->visibility = $visibility;
47
-		
48
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
49
-		
50
-		echo "ok";
51
-	}
52
-	
53
-	public static function updateConfig($updated){
54
-		foreach ($updated as $what=>$withWhat){
55
-			if(in_array($what, self::$paramsList)){
56
-				call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
57
-			}
58
-		}
59
-	}
60 37
 }

+ 2
- 0
modules/news/css/news.css View File

@@ -0,0 +1,2 @@
1
+#news{position:absolute;}
2
+#news div{display:inline !important;}

+ 4
- 0
modules/news/js/news.js View File

@@ -0,0 +1,4 @@
1
+$(document).ready(function(){
2
+
3
+make_draggable($('#news'));
4
+});

+ 7
- 39
modules/notes/Notes.php View File

@@ -1,51 +1,19 @@
1 1
 <?php
2 2
 class notes extends Module {
3
-
4
-	protected $moduleName;
5
-	protected $moduleTitle;
6
-	protected $pathToModule;
7
-
3
+	protected $moduleTitle = 'Post-It';
4
+	
8 5
 	protected static $paramsList = array(
9 6
 		'visibility'
10 7
 	);
11 8
 	
12
-	public $params = array();
13
-	
14 9
 	public function __construct($params){
15
-		$this->moduleName = get_class();
16
-		$this->pathToModule = 'modules/'.$this->moduleName.'/';
17
-		$this->setParams($params);
10
+		parent::__construct(__CLASS__, $params);
11
+	}
12
+	
13
+	public function build(){
18 14
 		echo '<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
19 15
 				<link rel="stylesheet" type="text/css" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css">
20 16
 				<a id="addButton" class="green-button" href="'.$this->pathToModule.'includes/add_note.html">Add a note</a>';
21
-		include $this->pathToModule.'includes/notes_extract.php';
22
-	}
23
-	
24
-	private function setParams($params){
25
-		$this->params = $params;
26
-	}
27
-	
28
-	public static function start($params){
29
-		$notes = new notes($params);
30
-	}
31
-	
32
-	public function setVisibility($visibility){
33
-		// Saving the position and z-index of the note:
34
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
35
-
36
-		$path = $xmla->xpath("//item[@id='notes']"); 
37
-		$path[0]->visibility = $visibility;
38
-		
39
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
40
-		
41
-		echo "ok";
42
-	}
43
-	
44
-	public static function updateConfig($updated){
45
-		foreach ($updated as $what=>$withWhat){
46
-			if(in_array($what, self::$paramsList)){
47
-				call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
48
-			}
49
-		}
17
+		include $this->pathToModule.'includes/notes_extract.php';	
50 18
 	}
51 19
 }

+ 6
- 35
modules/ouifm/Ouifm.php View File

@@ -1,48 +1,19 @@
1 1
 <?php
2 2
 class ouifm extends Module {
3
-
3
+	protected $moduleTitle = 'Oui FM Radio';
4 4
 	protected static $paramsList = array(
5 5
 		'visibility',
6 6
 		'x',
7 7
 		'y'
8 8
 	);
9 9
 	
10
-	public $params = array();
11
-	
12 10
 	public function __construct($params){
13
-		$this->moduleName = get_class();
14
-		$this->pathToModule = 'modules/'.$this->moduleName.'/';
15
-		$this->setParams($params);
16
-		echo '<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
17
-				<link rel="stylesheet" type="text/css" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css">';
18
-		echo '<div id="ouifm" style="left:'.$params['x'].'; top:'.$params['y'].';"></div>';
11
+		parent::__construct(__CLASS__, $params);
19 12
 	}
20 13
 	
21
-	private function setParams($params){
22
-		$this->params = $params;
23
-	}
24
-	
25
-	public static function start($params){
26
-		$ouifm = new ouifm($params);
27
-	}
28
-	
29
-	public function setVisibility($visibility){
30
-		// Saving the position and z-index of the note:
31
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
32
-
33
-		$path = $xmla->xpath("//item[@id='ouifm']"); 
34
-		$path[0]->visibility = $visibility;
35
-		
36
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
37
-		
38
-		echo "ok";
39
-	}
40
-	
41
-	public static function updateConfig($updated){
42
-		foreach ($updated as $what=>$withWhat){
43
-			if(in_array($what, self::$paramsList)){
44
-				call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
45
-			}
46
-		}
14
+	public function build(){
15
+		echo '<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
16
+				<link rel="stylesheet" type="text/css" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css">';
17
+		echo '<div id="ouifm" style="left:'.$this->getParam('x').'; top:'.$this->getParam('y').';"></div>';
47 18
 	}
48 19
 }

+ 6
- 56
modules/rssblogs/Rssblogs.php View File

@@ -1,6 +1,6 @@
1 1
 <?php
2 2
 class rssblogs extends Module {
3
-	//TODO rajouter les params en détail
3
+	protected $moduleTitle = 'Lecteur de flux RSS';
4 4
 	protected static $paramsList = array(
5 5
 		'visibility',
6 6
 		'x',
@@ -10,9 +10,10 @@ class rssblogs extends Module {
10 10
 	public $params = array();
11 11
 
12 12
 	public function __construct($params){
13
-		$this->moduleName = get_class();
14
-		$this->pathToModule = 'modules/'.$this->moduleName.'/';
15
-		$this->setParams($params);
13
+		parent::__construct(__CLASS__, $params);
14
+	}
15
+	
16
+	public function build(){
16 17
 		echo '<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
17 18
 				<link rel="stylesheet" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />';
18 19
 		require('class/lastRSS.php');
@@ -22,6 +23,7 @@ class rssblogs extends Module {
22 23
 		$rss->cache_time  = 3600;      // fréquence de mise à jour du cache (en secondes)
23 24
 		$rss->date_format = 'd/m/y';     // format de la date (voir fonction date() pour syntaxe)
24 25
 		$rss->CDATA       = 'content'; // on retire les tags CDATA en conservant leur contenu
26
+		echo '<div id="rssblogs" style="top:' . $this->getParam('y') . '; left: ' . $this->getParam('x') . ';">';
25 27
 		if($linksXML = simplexml_load_file($this->pathToModule.'db/rss.xml')){
26 28
 			foreach($linksXML->link as $individualLink){
27 29
 				if ($rs = $rss->get($individualLink->url)) 
@@ -32,56 +34,4 @@ class rssblogs extends Module {
32 34
 		}
33 35
 		echo '</div>';
34 36
 	}
35
-
36
-	private function setParams($params){
37
-		$this->params = $params;
38
-	}
39
-
40
-	public static function start($params){
41
-		$rssblogs = new rssblogs($params);
42
-	}
43
-	
44
-	public function setX($x){
45
-		// Saving the position and z-index of the note:
46
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
47
-
48
-		$path = $xmla->xpath("//item[@id='rssblogs']"); 
49
-		$path[0]->x = $x;
50
-		
51
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
52
-		
53
-		echo "ok";
54
-	}
55
-	
56
-	public function setY($y){
57
-		// Saving the position and z-index of the note:
58
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
59
-
60
-		$path = $xmla->xpath("//item[@id='rssblogs']"); 
61
-		$path[0]->y = $y;
62
-		
63
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
64
-		
65
-		echo "ok";
66
-	}
67
-	
68
-	public function setVisibility($visibility){
69
-		// Saving the position and z-index of the note:
70
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
71
-
72
-		$path = $xmla->xpath("//item[@id='rssblogs']"); 
73
-		$path[0]->visibility = $visibility;
74
-		
75
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
76
-		
77
-		echo "ok";
78
-	}
79
-	
80
-	public static function updateConfig($updated){
81
-		foreach ($updated as $what=>$withWhat){
82
-			if(in_array($what, self::$paramsList)){
83
-				call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
84
-			}
85
-		}
86
-	}
87 37
 }

+ 1
- 0
modules/rssblogs/js/rssblogs.js View File

@@ -0,0 +1 @@
1
+$(document).ready(function(){
	make_draggable($('#rssblogs'));
});

+ 5
- 37
modules/search/Search.php View File

@@ -1,19 +1,15 @@
1 1
 <?php
2 2
 class search extends Module {
3
-	
4
-	protected $moduleName;
5
-	protected $moduleTitle;
6
-	protected $pathToModule;
7
-
3
+	protected $moduleTitle = 'Recherche';
8 4
 	protected static $paramsList = array(
9 5
 		'visibility'
10 6
 	);
11
-	public $params = array();
12 7
 	
13 8
 	public function __construct($params){
14
-		$this->moduleName = get_class();
15
-		$this->pathToModule = 'modules/'.$this->moduleName.'/';
16
-		$this->setParams($params);
9
+		parent::__construct(__CLASS__, $params);
10
+	}
11
+	
12
+	public function build(){
17 13
 		echo '<link rel="stylesheet" type="text/css" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css">
18 14
 				<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
19 15
 				<form id="searchForm" method="post">
@@ -31,32 +27,4 @@ class search extends Module {
31 27
 				</fieldset>
32 28
 			</form>';
33 29
 	}
34
-	
35
-	private function setParams($params){
36
-		$this->params = $params;
37
-	}
38
-	
39
-	public static function start($params){
40
-		$search = new search($params);
41
-	}
42
-	
43
-	public function setVisibility($visibility){
44
-		// Saving the position and z-index of the note:
45
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
46
-
47
-		$path = $xmla->xpath("//item[@id='search']"); 
48
-		$path[0]->visibility = $visibility;
49
-		
50
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
51
-		
52
-		echo "ok";
53
-	}
54
-	
55
-	public static function updateConfig($updated){
56
-		foreach ($updated as $what=>$withWhat){
57
-			if(in_array($what, self::$paramsList)){
58
-				call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
59
-			}
60
-		}
61
-	}
62 30
 }

+ 9
- 59
modules/todo/Todo.php View File

@@ -1,6 +1,7 @@
1 1
 <?php
2 2
 class todo extends Module {
3 3
 
4
+	protected $moduleTitle = 'Todo List';
4 5
 	
5 6
 	protected static $paramsList = array(
6 7
 		'visibility',
@@ -8,23 +9,24 @@ class todo extends Module {
8 9
 		'y'
9 10
 	);
10 11
 
11
-	public $params = array();
12 12
 	const TODO_FILE = 'db/todoist.xml';
13
+	
13 14
 	private $token;
14 15
 	private $project_name;
15 16
 	private $project_id;
16
-	
17
+
17 18
 	public function __construct($params){
18
-		$this->moduleName = get_class();
19
-		$this->pathToModule = 'modules/'.$this->moduleName.'/';
20
-		$this->setParams($params);
19
+		parent::__construct(__CLASS__, $params);
20
+	}
21
+	
22
+	public function build(){
21 23
 		echo '<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
22 24
 				<link rel="stylesheet" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />';
23 25
 		if($xmla = simplexml_load_file($this->pathToModule.self::TODO_FILE)){
24 26
 			$this->setToken($xmla->token);
25 27
 			$this->setProjectName($xmla->name);
26 28
 			$this->setProjectId($xmla->id);
27
-			echo '<div id="todo" style="top:'.$params['y'].'; left :'.$params['x'].';">';
29
+			echo '<div id="todo" style="top:'.$this->getParam('y').'; left :'.$this->getParam('x').';">';
28 30
 			if($this->token == null || $this->project_id == null)
29 31
 				echo 'Impossible de trouver votre configuration. <a href="'.$this->pathToModule.'includes/install-todoist.php">Cliquez ici</a> pour la mettre en place.</div>';
30 32
 			else{
@@ -38,7 +40,7 @@ class todo extends Module {
38 40
 					});</script>';
39 41
 		}else{
40 42
 			echo 'baaaaad persistance...';
41
-		}
43
+		}	
42 44
 	}
43 45
 	
44 46
 	private function setToken($token){
@@ -61,56 +63,4 @@ class todo extends Module {
61 63
 		else
62 64
 			$this->project_id = $id;
63 65
 	}
64
-	
65
-	private function setParams($params){
66
-		$this->params = $params;
67
-	}
68
-	
69
-	public static function start($params){
70
-		$todo = new todo($params);
71
-	}
72
-	
73
-	public function setX($x){
74
-		// Saving the position and z-index of the note:
75
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
76
-
77
-		$path = $xmla->xpath("//item[@id='todo']"); 
78
-		$path[0]->x = $x;
79
-		
80
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
81
-		
82
-		echo "ok";
83
-	}
84
-	
85
-	public function setY($y){
86
-		// Saving the position and z-index of the note:
87
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
88
-
89
-		$path = $xmla->xpath("//item[@id='todo']"); 
90
-		$path[0]->y = $y;
91
-		
92
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
93
-		
94
-		echo "ok";
95
-	}
96
-	
97
-	public function setVisibility($visibility){
98
-		// Saving the position and z-index of the note:
99
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
100
-
101
-		$path = $xmla->xpath("//item[@id='todo']"); 
102
-		$path[0]->visibility = $visibility;
103
-		
104
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
105
-		
106
-		echo "ok";
107
-	}
108
-	
109
-	public static function updateConfig($updated){
110
-		foreach ($updated as $what=>$withWhat){
111
-			if(in_array($what, self::$paramsList)){
112
-				call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
113
-			}
114
-		}
115
-	}
116 66
 }

+ 8
- 82
modules/weather/Weather.php View File

@@ -1,10 +1,7 @@
1 1
 <?php
2
-
3 2
 class weather extends Module {
4 3
 
5
-	protected $moduleName;
6
-	protected $moduleTitle;
7
-	protected $pathToModule;
4
+	protected $moduleTitle = 'Météo';
8 5
 	
9 6
 	protected static $paramsList = array(
10 7
 		'visibility',
@@ -13,92 +10,21 @@ class weather extends Module {
13 10
 		'y'
14 11
 	);
15 12
 	
16
-	public $params = array();
17
-
18 13
 	public function __construct($params){
19
-		$this->moduleName = get_class();
20
-		$this->pathToModule = 'modules/'.$this->moduleName.'/';
21
-		$this->setParams($params);
22
-		$ville = $params['city'];
14
+		parent::__construct(__CLASS__, $params);
15
+	}
16
+	
17
+	public function build(){
18
+		$ville = $this->getParam('city');
23 19
 		include $this->pathToModule.'includes/GoogleMeteo.php';
24 20
 		echo '<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
25 21
 				<link rel="stylesheet" type="text/css" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css">';
26
-		echo '<div id="weather" style="left:'.$params['x'].'; top:'.$params['y'].';">
22
+		echo '<div id="weather" style="left:'.$this->getParam("x").'; top:'.$this->getParam("y").';">
27 23
 				'.$city.'<br/>
28 24
 				<div class="weatherpic"></div>
29 25
 				<strong>'.$present_weather.'</strong><br/>
30 26
 				'.$future_weather1.'<br/>
31 27
 				'.$future_weather2.'
32
-			</div>';
33
-	}
34
-
35
-	private function setParams($params){
36
-		$this->params = $params;
37
-	}
38
-
39
-	public static function start($params){
40
-		$weather = new weather($params);
41
-	}
42
-	
43
-	/**
44
-	 * 
45
-	 * Modifie la ville
46
-	 * @param String $city la ville.
47
-	 * @return String "ok" ou message d'erreur (effectue aussi l'enregistrement en XML)
48
-	 */
49
-	public function setCity($city){
50
-		// Saving the position and z-index of the note:
51
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
52
-
53
-		$path = $xmla->xpath("//item[@id='weather']"); 
54
-		$path[0]->city = $city;
55
-		
56
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
57
-		
58
-		echo "ok";
59
-	}
60
-	
61
-	public function setX($x){
62
-		// Saving the position and z-index of the note:
63
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
64
-
65
-		$path = $xmla->xpath("//item[@id='weather']"); 
66
-		$path[0]->x = $x;
67
-		
68
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
69
-		
70
-		echo "ok";
71
-	}
72
-	
73
-	public function setY($y){
74
-		// Saving the position and z-index of the note:
75
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
76
-
77
-		$path = $xmla->xpath("//item[@id='weather']"); 
78
-		$path[0]->y = $y;
79
-		
80
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
81
-		
82
-		echo "ok";
83
-	}
84
-	
85
-	public function setVisibility($visibility){
86
-		// Saving the position and z-index of the note:
87
-		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
88
-
89
-		$path = $xmla->xpath("//item[@id='weather']"); 
90
-		$path[0]->visibility = $visibility;
91
-		
92
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
93
-		
94
-		echo "ok";
95
-	}
96
-	
97
-	public static function updateConfig($updated){
98
-		foreach ($updated as $what=>$withWhat){
99
-			if(in_array($what, self::$paramsList)){
100
-				call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
101
-			}
102
-		}
28
+			</div>';	
103 29
 	}
104 30
 }

+ 0
- 26
modules/weather/includes/meteo.php View File

@@ -1,26 +0,0 @@
1
-<?php
2
-if ($weather = simplexml_load_file('http://www.my-meteo.fr/meteo+rss+paris.html')){
3
-			$present_weather = $weather->channel->item[0]->title;
4
-			$future_weather1 = $weather->channel->item[1]->title;
5
-			$future_weather2 = $weather->channel->item[2]->title;
6
-			if(strpos(strtolower($present_weather),"soleil") !== false) {?>
7
-				<link rel="stylesheet" type="text/css" href="css/soleil.css">
8
-			<?}
9
-			if(strpos(strtolower($present_weather),"nuage") !== false) {?>
10
-				<link rel="stylesheet" type="text/css" href="css/nuage.css">
11
-			<?}
12
-			if(strpos(strtolower($present_weather),"peu nuageux") !== false) {?>
13
-				<link rel="stylesheet" type="text/css" href="css/peunuage.css">
14
-			<?}
15
-			if((strpos(strtolower($present_weather),"pluie") !== false) || (strpos(strtolower($present_weather),"averse") !== false)) {?>
16
-				<link rel="stylesheet" type="text/css" href="css/pluie.css">
17
-			<?}
18
-			if(strpos(strtolower($present_weather),"neige") !== false) {?>
19
-				<link rel="stylesheet" type="text/css" href="css/neige.css">
20
-			<?}
21
-		}
22
-		else 
23
-		{
24
-			die ('Flux RSS non trouvé');
25
-		}
26
-		?>

Loading…
Cancel
Save