Browse Source

Ajout de la fonctionnalité d'upload de module.

remotes/svn/tags/beta-1.0.0
Chouchen 8 years ago
parent
commit
5a8dbbb330

+ 0
- 10
ajax/update-city.php View File

@@ -1,10 +0,0 @@
1
-<?php
2
-// Error reporting
3
-error_reporting(E_ALL^E_NOTICE);
4
-
5
-// Escaping:
6
-$city = $_GET['city'];
7
-include '../class/AccueilModules.php';
8
-echo AccueilModules::updateModule('weather', array('city'=>$city));
9
-
10
-?>

+ 61
- 9
class/AccueilModules.php View File

@@ -1,4 +1,4 @@
1
-<?php 
1
+<?php 
2 2
 require 'Module.php';
3 3
 class AccueilModules {
4 4
 	const CONFIG_FILE = 'db/config.xml';
@@ -6,7 +6,7 @@ class AccueilModules {
6 6
 	
7 7
 	/**
8 8
 	 * Constructeur
9
-	 * Initialise le XML de conf générale
9
+	 * Initialise le XML de conf générale
10 10
 	 * Active les modules
11 11
 	 * Construit le menu
12 12
 	 */
@@ -25,7 +25,7 @@ class AccueilModules {
25 25
 	
26 26
 	/**
27 27
 	 * 
28
-	 * Initialise les modules activés uniquement
28
+	 * Initialise les modules activés uniquement
29 29
 	 */
30 30
 	function getModules(){
31 31
 		foreach($this->modules as $module=>$moduleConf){
@@ -42,7 +42,7 @@ class AccueilModules {
42 42
 
43 43
 	/**
44 44
 	 * 
45
-	 * Construit et insère le menu de changement de config
45
+	 * Construit et insère le menu de changement de config
46 46
 	 */
47 47
 	function buildConfigMenu(){
48 48
 		echo '<a href="#config" id="config-menu"><img src="images/interface/config.png" /></a>
@@ -53,11 +53,16 @@ class AccueilModules {
53 53
 		foreach($this->modules as $module=>$moduleConf){
54 54
 			echo $module.' module : <input type="radio" name="'.$module.'_group" value="true"';
55 55
 			if ($moduleConf->visibility == "true") echo " checked";
56
-			echo '/>true&nbsp;&nbsp;<input type="radio" name="'.$module.'_group" value="false"';
56
+			echo '/>activé&nbsp;&nbsp;<input type="radio" name="'.$module.'_group" value="false"';
57 57
 			if ($moduleConf->visibility == "false") echo " checked";
58
-			echo '/>false<br/><br/>';
58
+			echo '/>desactivé<br/><br/>';
59 59
 		}
60 60
 		echo '<span id="config-submit" class="green-button">Enregistrer</span>
61
+				</form><br/><br/>
62
+				<h3>Ajout d\'un module</h3>
63
+				<form action="includes/addModule.php" method="POST" enctype="multipart/form-data">
64
+				<input type="file" name="newModuleFile" id="newModuleFile"/>
65
+				<input type="submit" value="Envoyer"/>
61 66
 				</form>
62 67
 				</div>
63 68
 				</div>';
@@ -82,13 +87,60 @@ class AccueilModules {
82 87
 	
83 88
 	/**
84 89
 	 * 
85
-	 * @property Chaque module possède la fonction updateModule en static qui permet de changer un ou plusieurs de ses attributs
86
-	 * @param $module String Nom du module à modifier
87
-	 * @param $things2change Array du ou des attributs à modifier avec sa ou ses nouvelles valeurs
90
+	 * @property Chaque module possède la fonction updateModule en static qui permet de changer un ou plusieurs de ses attributs
91
+	 * @param $module String Nom du module à modifier
92
+	 * @param $things2change Array du ou des attributs à modifier avec sa ou ses nouvelles valeurs
88 93
 	 * @return "ok" String si c'est bon, ou le message d'erreur
89 94
 	 */
90 95
 	public static function updateModule($module, $things2change){
91 96
 		require '../modules/'.$module.'/'.ucfirst($module).'.php';
92 97
 		return call_user_func(array($module, "updateConfig"), $things2change);
93 98
 	}
99
+	
100
+	/**
101
+	*
102
+	* Fonction d'ajout de module dans le fichier de config
103
+	*/
104
+	public static function addModule($file, $name)
105
+	{
106
+		if($config = simplexml_load_file('../'.self::CONFIG_FILE)){
107
+			foreach($config->item as $item){
108
+				if($item['id'] == $name)
109
+					exit ('module déjà présent !');
110
+			}
111
+		}
112
+		if(class_exists('ZipArchive')){
113
+			$zip = new ZipArchive;
114
+			$res = $zip->open($file);
115
+			if ($res === TRUE) {
116
+				$zip->extractTo('../modules/');
117
+				$zip->close();
118
+				if(!file_exists('../modules/'.$name.'/'.ucfirst($name).'.php'))
119
+					exit ('L\'extraction n\'a pas fonctionné...');
120
+				else{
121
+					unlink ($file);
122
+					require '../modules/'.$name.'/'.ucfirst($name).'.php';
123
+					if($config = simplexml_load_file('../'.self::CONFIG_FILE)){
124
+						$newItem = $config->addChild('item');
125
+						$newItem->addAttribute('id', $name);
126
+						$params = call_user_func(array($name, 'getParamList')); 
127
+						foreach($params as $param){
128
+							if($param == 'visibility')
129
+								$newItem->AddChild($param, 'true');
130
+							else
131
+								$newItem->AddChild($param, '0');
132
+						}
133
+						$config->asXML('../'.self::CONFIG_FILE);
134
+						echo 'Module enregistré. Vous pouvez revenir à la page d\'accueil';
135
+					}else{
136
+						exit ('L\'enregistrement dans le menu a échoué...');
137
+					}
138
+				}
139
+			} else {
140
+				exit ('failed, code:' . $res);
141
+			}			
142
+		}else{
143
+			exit ('Votre serveur ne peut installer les modules automatiquement. Merci de passer par votre client FTP habituel ou d\'ajouter la classe ZipArchive à votre serveur PHP');
144
+		}
145
+	}
94 146
 }

+ 0
- 12
config.php View File

@@ -1,12 +0,0 @@
1
-<div id="config">
2
-	<form id="config_form" action="" method="post">
3
-		<h3>Modules configuration</h3><br/>
4
-		Clock module : <input type="radio" name="clock_group" value="true"<?if ($config_xml[0]->visibility == "true"){echo " checked";}?> />true&nbsp;&nbsp;<input type="radio" name="clock_group" value="false"<?if ($config_xml[0]->visibility == "false"){echo " checked";}?> />false<br/><br/>
5
-		Meteo module : <input type="radio" name="meteo_group" value="true"<?if ($config_xml[1]->visibility == "true"){echo " checked";}?> />true&nbsp;&nbsp;<input type="radio" name="meteo_group" value="false"<?if ($config_xml[1]->visibility == "false"){echo " checked";}?> />false<br/><br/>
6
-		Notes module : <input type="radio" name="notes_group" value="true"<?if ($config_xml[2]->visibility == "true"){echo " checked";}?> />true&nbsp;&nbsp;<input type="radio" name="notes_group" value="false"<?if ($config_xml[2]->visibility == "false"){echo " checked";}?> />false<br/><br/>
7
-		Search module : <input type="radio" name="search_group" value="true"<?if ($config_xml[3]->visibility == "true"){echo " checked";}?> />true&nbsp;&nbsp;<input type="radio" name="search_group" value="false"<?if ($config_xml[3]->visibility == "false"){echo " checked";}?> />false<br/><br/>
8
-		Links module : <input type="radio" name="links_group" value="true"<?if ($config_xml[4]->visibility == "true"){echo " checked";}?> />true&nbsp;&nbsp;<input type="radio" name="links_group" value="false"<?if ($config_xml[4]->visibility == "false"){echo " checked";}?> />false<br/><br/>
9
-		Blogs module : <input type="radio" name="blogs_group" value="true"<?if ($config_xml[5]->visibility == "true"){echo " checked";}?> />true&nbsp;&nbsp;<input type="radio" name="blogs_group" value="false"<?if ($config_xml[5]->visibility == "false"){echo " checked";}?> />false<br/><br/>
10
-		<a id="config-submit" href="" class="green-button">Enregistrer</a>
11
-	</form>
12
-	</div>

+ 1
- 0
includes/addModule.php
File diff suppressed because it is too large
View File


+ 0
- 12
modules/links/Links.php View File

@@ -47,18 +47,6 @@ class links extends Module{
47 47
 		$links = new links($params);
48 48
 	}
49 49
 	
50
-	public function setLink($link){
51
-		// Saving the position and z-index of the note:
52
-		$xmla = simplexml_load_file('../'.self::LINKS_FILE);
53
-
54
-		$path = $xmla->xpath("//item[@id='weather']"); 
55
-		$path[0]->x = $x;
56
-		
57
-		$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
58
-		
59
-		echo "ok";
60
-	}
61
-	
62 50
 	public function setVisibility($visibility){
63 51
 		// Saving the position and z-index of the note:
64 52
 		$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);

ajax/delete-notes.php → modules/notes/ajax/delete-notes.php View File


ajax/post-notes.php → modules/notes/ajax/post-notes.php View File


+ 2
- 2
modules/search/Search.php View File

@@ -14,8 +14,8 @@ class search extends Module {
14 14
 		$this->moduleName = get_class();
15 15
 		$this->pathToModule = 'modules/'.$this->moduleName.'/';
16 16
 		$this->setParams($params);
17
-		echo '<link rel="stylesheet" type="text/css" href="'.$this->pathToModule.'css/search.css">
18
-				<script type="text/javascript" src="'.$this->pathToModule.'js/jquery.search.js"></script>
17
+		echo '<link rel="stylesheet" type="text/css" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css">
18
+				<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
19 19
 				<form id="searchForm" method="post">
20 20
 				<fieldset>
21 21
 					<input id="s" type="text" />

+ 3
- 18
modules/todo/includes/getProjectsList.php View File

@@ -1,18 +1,3 @@
1
-<?

2
-$xmla = simplexml_load_file('../db/todoist.xml');

3
-if($xmla->token== '' || $xmla->token == null)

4
-	header('Location: install-todoist.php');

5
-if($xmla->name == '' || $xmla->name == null):?>

6
-<html>  

7
-	<head>
		
		<style>
			.selectableProject{text-decoration:underline; color:blue; cursor:pointer;}
		</style>
8
-		<title>Todoist : getProjects</title>   

9
-		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

10
-		<script type="text/javascript" src="../js/getProjectsList.php?token=<?=$xmla->token?>"></script>

11
-      </head>  

12
-      <body>  

13
-		

14
-      </body>  

15
-    </html> 

16
-	<? else:

17
-	header('Location: index.php');

18
-	endif;
1
+<?
$xmla = simplexml_load_file('../db/todoist.xml');
if($xmla->token== '' || $xmla->token == null)
	header('Location: install-todoist.php');
if($xmla->name == '' || $xmla->name == null):?>
<html>  
	<head>	
		<style>
			.selectableProject{text-decoration:underline; color:blue; cursor:pointer;}
		</style>
2
+		<title>Todoist : getProjects</title>   
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
		<script type="text/javascript" src="../js/getProjectsList.php?token=<?=$xmla->token?>"></script>
      </head>  
      <body>  

3
+      </body>  
    </html> 
	<? else:
	header('Location: ../../../');
	endif;

+ 1
- 1
modules/todo/includes/getUncompletedTasks.php View File

@@ -1,7 +1,7 @@
1 1
 <?

2 2
 $xmla = simplexml_load_file('../db/todoist.xml');

3 3
 if($xmla->token== '' || $xmla->token == null)

4
-	header('Location: ./');

4
+	header('Location: install-todoist.php');

5 5
 if($xmla->id != '' || $xmla->id != null): 

6 6
 $token 	= $xmla->token;

7 7
 $id		= $xmla->id;?>


+ 7
- 54
modules/todo/js/getUncompletedTasks.php
File diff suppressed because it is too large
View File


+ 3
- 20
modules/todo/js/index.js
File diff suppressed because it is too large
View File


Loading…
Cancel
Save