Browse Source

Ajout de la fonctionnalité d'upload de module.

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

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

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

+ 61
- 9
class/AccueilModules.php View File

@@ -1,4 +1,4 @@
<?php
<?php
require 'Module.php';
class AccueilModules {
const CONFIG_FILE = 'db/config.xml';
@@ -6,7 +6,7 @@ class AccueilModules {
/**
* Constructeur
* Initialise le XML de conf générale
* Initialise le XML de conf générale
* Active les modules
* Construit le menu
*/
@@ -25,7 +25,7 @@ class AccueilModules {
/**
*
* Initialise les modules activés uniquement
* Initialise les modules activés uniquement
*/
function getModules(){
foreach($this->modules as $module=>$moduleConf){
@@ -42,7 +42,7 @@ class AccueilModules {
/**
*
* Construit et insère le menu de changement de config
* Construit et insère le menu de changement de config
*/
function buildConfigMenu(){
echo '<a href="#config" id="config-menu"><img src="images/interface/config.png" /></a>
@@ -53,11 +53,16 @@ class AccueilModules {
foreach($this->modules as $module=>$moduleConf){
echo $module.' module : <input type="radio" name="'.$module.'_group" value="true"';
if ($moduleConf->visibility == "true") echo " checked";
echo '/>true&nbsp;&nbsp;<input type="radio" name="'.$module.'_group" value="false"';
echo '/>activé&nbsp;&nbsp;<input type="radio" name="'.$module.'_group" value="false"';
if ($moduleConf->visibility == "false") echo " checked";
echo '/>false<br/><br/>';
echo '/>desactivé<br/><br/>';
}
echo '<span id="config-submit" class="green-button">Enregistrer</span>
</form><br/><br/>
<h3>Ajout d\'un module</h3>
<form action="includes/addModule.php" method="POST" enctype="multipart/form-data">
<input type="file" name="newModuleFile" id="newModuleFile"/>
<input type="submit" value="Envoyer"/>
</form>
</div>
</div>';
@@ -82,13 +87,60 @@ 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
* @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 '../modules/'.$module.'/'.ucfirst($module).'.php';
return call_user_func(array($module, "updateConfig"), $things2change);
}
/**
*
* Fonction d'ajout de module dans le fichier de config
*/
public static function addModule($file, $name)
{
if($config = simplexml_load_file('../'.self::CONFIG_FILE)){
foreach($config->item as $item){
if($item['id'] == $name)
exit ('module déjà présent !');
}
}
if(class_exists('ZipArchive')){
$zip = new ZipArchive;
$res = $zip->open($file);
if ($res === TRUE) {
$zip->extractTo('../modules/');
$zip->close();
if(!file_exists('../modules/'.$name.'/'.ucfirst($name).'.php'))
exit ('L\'extraction n\'a pas fonctionné...');
else{
unlink ($file);
require '../modules/'.$name.'/'.ucfirst($name).'.php';
if($config = simplexml_load_file('../'.self::CONFIG_FILE)){
$newItem = $config->addChild('item');
$newItem->addAttribute('id', $name);
$params = call_user_func(array($name, 'getParamList'));
foreach($params as $param){
if($param == 'visibility')
$newItem->AddChild($param, 'true');
else
$newItem->AddChild($param, '0');
}
$config->asXML('../'.self::CONFIG_FILE);
echo 'Module enregistré. Vous pouvez revenir à la page d\'accueil';
}else{
exit ('L\'enregistrement dans le menu a échoué...');
}
}
} else {
exit ('failed, code:' . $res);
}
}else{
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');
}
}
}

+ 0
- 12
config.php View File

@@ -1,12 +0,0 @@
<div id="config">
<form id="config_form" action="" method="post">
<h3>Modules configuration</h3><br/>
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/>
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/>
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/>
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/>
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/>
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/>
<a id="config-submit" href="" class="green-button">Enregistrer</a>
</form>
</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{
$links = new links($params);
}
public function setLink($link){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.self::LINKS_FILE);
$path = $xmla->xpath("//item[@id='weather']");
$path[0]->x = $x;
$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);

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 {
$this->moduleName = get_class();
$this->pathToModule = 'modules/'.$this->moduleName.'/';
$this->setParams($params);
echo '<link rel="stylesheet" type="text/css" href="'.$this->pathToModule.'css/search.css">
<script type="text/javascript" src="'.$this->pathToModule.'js/jquery.search.js"></script>
echo '<link rel="stylesheet" type="text/css" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css">
<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
<form id="searchForm" method="post">
<fieldset>
<input id="s" type="text" />

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

@@ -1,18 +1,3 @@
<?
$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>
<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>
</body>
</html>
<? else:
header('Location: index.php');
endif;
<? $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>
<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>
</body> </html> <? else: header('Location: ../../../'); endif;

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

@@ -1,7 +1,7 @@
<?
$xmla = simplexml_load_file('../db/todoist.xml');
if($xmla->token== '' || $xmla->token == null)
header('Location: ./');
header('Location: install-todoist.php');
if($xmla->id != '' || $xmla->id != null):
$token = $xmla->token;
$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