Compare commits
170 Commits
Author | SHA1 | Date |
---|---|---|
xdrm-brackets | 49a3056dcd | |
xdrm-brackets | c37c749087 | |
xdrm-brackets | 142cbff763 | |
xdrm-brackets | 24ba120631 | |
xdrm-brackets | 8b30dbb4d2 | |
xdrm-brackets | 255af4d6b0 | |
xdrm-brackets | 38e479c73c | |
xdrm-brackets | 4573343a94 | |
xdrm-brackets | c2f65a0227 | |
xdrm-brackets | 4175fef281 | |
xdrm-brackets | 0810d0be8e | |
xdrm-brackets | 90d79cf103 | |
xdrm-brackets | 44519c6484 | |
xdrm-brackets | be7fb63f9c | |
xdrm-brackets | bef99c46f8 | |
xdrm-brackets | 4dcc20e470 | |
xdrm-brackets | b5def6ffe8 | |
xdrm-brackets | f980ddd41d | |
xdrm-brackets | 29cacfa11e | |
xdrm-brackets | 0fd0aabd59 | |
xdrm-brackets | e888b04d50 | |
xdrm-brackets | 6be5358247 | |
xdrm-brackets | 6af402fa80 | |
xdrm-brackets | 2b40b7f9cf | |
xdrm-brackets | 0ded7f6bdf | |
xdrm-brackets | aebde78785 | |
xdrm-brackets | 164f3cd4ef | |
xdrm-brackets | 601c7f4ab6 | |
xdrm-brackets | f1d1fe00da | |
xdrm-brackets | 96e5111d5f | |
xdrm-brackets | 91e847789d | |
xdrm-brackets | 3a5d1c54d2 | |
xdrm-brackets | cda98e2fd8 | |
xdrm-brackets | fe9ade8717 | |
xdrm-brackets | 92db51d7aa | |
xdrm-brackets | 89d804a127 | |
xdrm-brackets | a5cbdcb429 | |
xdrm-brackets | ac2d70835b | |
xdrm-brackets | 009b463319 | |
xdrm-brackets | 623b75e67f | |
xdrm-brackets | 361858e604 | |
xdrm-brackets | 4272d15f29 | |
xdrm-brackets | 41a9480e49 | |
xdrm-brackets | 93de3e8c2c | |
xdrm-brackets | 7526e780ad | |
Adrien Marques | 4f56e9e009 | |
xdrm-brackets | 7b253bcff5 | |
xdrm-brackets | 3633d9f344 | |
xdrm-brackets | 8c6fbd9a74 | |
xdrm-brackets | 05aacfdad3 | |
xdrm-brackets | f2da5085f7 | |
xdrm-brackets | 336e8e84a8 | |
xdrm-brackets | 84faf9484e | |
xdrm-brackets | addd51a627 | |
xdrm-brackets | 52740e1ae4 | |
xdrm-brackets | 93112cdd44 | |
xdrm-brackets | fd724ece9d | |
xdrm-brackets | e67b59d110 | |
xdrm-brackets | f875c9dc53 | |
xdrm-brackets | b446ecd09e | |
xdrm-brackets | 4eaf463928 | |
xdrm-brackets | 07e000d8e3 | |
xdrm-brackets | 3c66937ec7 | |
xdrm-brackets | 3d2a4b02ae | |
xdrm-brackets | aa25bf3693 | |
xdrm-brackets | 7626adf3d5 | |
xdrm-brackets | 26f974ef1e | |
xdrm-brackets | a56bd2cc61 | |
xdrm-brackets | fe569b5b31 | |
xdrm-brackets | e77e326a1f | |
xdrm-brackets | 65a1883a53 | |
xdrm-brackets | 64e3ce58ac | |
xdrm-brackets | 50d7babcda | |
xdrm-brackets | dc30fbfcca | |
xdrm-brackets | 442ed330ae | |
xdrm-brackets | 4675fbb719 | |
xdrm-brackets | 83e7e18600 | |
xdrm-brackets | 05efdedd02 | |
xdrm-brackets | b41f50e23e | |
xdrm-brackets | f7457f3f38 | |
xdrm-brackets | a7db32ec6f | |
xdrm-brackets | 0e961f69b9 | |
xdrm-brackets | 0d38d1c684 | |
xdrm-brackets | 8e40423228 | |
xdrm-brackets | 42d19e7a87 | |
xdrm-brackets | 45240bfd17 | |
xdrm-brackets | 0b6702222f | |
xdrm-brackets | c63d025971 | |
xdrm-brackets | 247fb83b3e | |
xdrm-brackets | f8c0ef141f | |
xdrm-brackets | 4f09c888bf | |
xdrm-brackets | addf4c11f9 | |
xdrm-brackets | 8ab7bde4b8 | |
xdrm-brackets | d253a7fb3c | |
xdrm-brackets | af08363c17 | |
xdrm-brackets | ca35d0e5af | |
xdrm-brackets | 2276e63a55 | |
xdrm-brackets | 9ddd6cfe28 | |
xdrm-brackets | d5da2387c2 | |
xdrm-brackets | 08502b65fb | |
xdrm-brackets | 9eb7c9dfaf | |
xdrm-brackets | 7c2fdcaa48 | |
xdrm-brackets | 4e77bb69fe | |
xdrm-brackets | d5d1bead3f | |
xdrm-brackets | edf94ab9ac | |
xdrm-brackets | d1aed90146 | |
xdrm-brackets | 74afa03eed | |
xdrm-brackets | ed2a102e6d | |
xdrm-brackets | 85738e1626 | |
xdrm-brackets | 9e1e2fd2a6 | |
xdrm-brackets | b8e03b0ea5 | |
xdrm-brackets | 5c51989e43 | |
xdrm-brackets | fb93be99ea | |
xdrm-brackets | f1d96e0627 | |
xdrm-brackets | b2fc40bf71 | |
xdrm-brackets | aa66642712 | |
xdrm-brackets | 7dce7fbc58 | |
xdrm-brackets | 1dfac530ad | |
xdrm-brackets | 366355ae26 | |
xdrm-brackets | f2181ee048 | |
xdrm-brackets | 0adc2b1f9d | |
xdrm-brackets | bb07c5c582 | |
xdrm-brackets | 3bea51e7b8 | |
xdrm-brackets | 27330bf829 | |
xdrm-brackets | ba024a650a | |
xdrm-brackets | b412e5b6fb | |
xdrm-brackets | a6c1c8c8cf | |
xdrm-brackets | bdf1aa9ab1 | |
xdrm-brackets | 250d45197c | |
xdrm-brackets | 0e25d6d033 | |
xdrm-brackets | 934bff5828 | |
xdrm-brackets | f1c32cabdb | |
xdrm-brackets | 6b325f7198 | |
xdrm-brackets | c8bc92461a | |
xdrm-brackets | 8479d5a2b6 | |
xdrm-brackets | e09d2f3651 | |
xdrm-brackets | f4f749ffcc | |
xdrm-brackets | ca3c151867 | |
xdrm-brackets | 410e3f2359 | |
xdrm-brackets | 7e26e80604 | |
xdrm-brackets | 66ad11700d | |
xdrm-brackets | 2f8d0fc9ea | |
xdrm-brackets | ab97198abc | |
xdrm-brackets | bb75d62412 | |
xdrm-brackets | 3d5b5acda6 | |
xdrm-brackets | 0867417929 | |
xdrm-brackets | 1f0155e109 | |
xdrm-brackets | 1ce1788801 | |
xdrm-brackets | 2763a32e91 | |
xdrm-brackets | dff156a88b | |
xdrm-brackets | 6fb77480ca | |
xdrm-brackets | ca63da8d61 | |
xdrm-brackets | 8d91b62bc6 | |
xdrm-brackets | d997066e36 | |
xdrm-brackets | 504ee83d33 | |
xdrm-brackets | 3d346f5efe | |
xdrm-brackets | 01649b00bd | |
xdrm-brackets | c38862385e | |
xdrm-brackets | 21f9e10fe6 | |
xdrm-brackets | 5f0a670d5f | |
xdrm-brackets | b285d75fba | |
xdrm-brackets | 3326f44b15 | |
xdrm-brackets | 6ab5dec529 | |
xdrm-brackets | f8e28de6f6 | |
xdrm-brackets | 0959e171d5 | |
xdrm-brackets | db0c6a7933 | |
xdrm-brackets | acc2d9767e | |
xdrm-brackets | bc7bc68c7d | |
xdrm-brackets | 31f2545486 | |
xdrm-brackets | 02e2e6cd4b |
|
@ -1,3 +1,11 @@
|
|||
.ftpconfig
|
||||
sftp-config.json
|
||||
phpunit/coverage/
|
||||
/public_html/tmp/*
|
||||
<<<<<<< HEAD
|
||||
/build/lightdb/storage/*
|
||||
/config/server.json
|
||||
=======
|
||||
/build/lightdb/storage/*/data
|
||||
**.swp
|
||||
>>>>>>> 255af4d6b03408ab9f840db1fea74a35b7bc28c4
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
RewriteEngine on
|
||||
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
|
||||
RewriteRule ^(.*)$ public_html/$1 [QSA,L]
|
||||
|
|
226
api/client.php
226
api/client.php
|
@ -1,226 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace api;
|
||||
use \manager\ManagerError;
|
||||
|
||||
/* CLASSE PERMETANT L'UTILISATION DU manifest.json POUR UTILISER DES APIS DIVERSES
|
||||
*
|
||||
* @return nomRetour<typeRetour> Description du retour
|
||||
*
|
||||
*/
|
||||
class client{
|
||||
|
||||
// Fichier de configuration par defaut
|
||||
private $config_path = __ROOT__.'/api/manifest.json';
|
||||
public $error;
|
||||
|
||||
// liste des methodes
|
||||
public static $METHODS = array(
|
||||
'POST' => array( CURLOPT_POST, true ),
|
||||
'GET' => array( CURLOPT_HTTPGET, true ),
|
||||
'PUT' => array( CURLOPT_CUSTOMREQUEST, 'PUT' ),
|
||||
'DELETE' => array( CURLOPT_CUSTOMREQUEST, 'DELETE' )
|
||||
);
|
||||
|
||||
/*************/
|
||||
/* ATTRIBUTS */
|
||||
/*************/
|
||||
private $manifest = null; // Contiendra le tableau correspondant au JSON
|
||||
private $requests = array(); // Contiendra la liste des requetes de l'api et leurs parametres
|
||||
|
||||
private $name;
|
||||
private $description;
|
||||
private $version;
|
||||
|
||||
|
||||
/* CONSTRUCTEUR DU CLIENT DE L'API
|
||||
*
|
||||
* @config<String> Chemin du fichier de configuration de l'api
|
||||
*
|
||||
*/
|
||||
public function __construct($config=null){
|
||||
/* [0] Gestion du fichier de config si donne en param
|
||||
=========================================================*/
|
||||
if( $config !== null ) $this->config_path = $config;
|
||||
|
||||
/* [1] On recupere le contenu du fichier de config
|
||||
=========================================================*/
|
||||
$manifest = json_decode( file_get_contents($this->config_path), true );
|
||||
|
||||
// Si erreur de parsage ou de fichier, on retourne une erreur
|
||||
if( $manifest === null ){
|
||||
$this->error = ManagerError::ParsingFailed;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* [2] On repartie et classe les donnees
|
||||
=========================================================*/
|
||||
/* (1) Informations generales */
|
||||
$name = $manifest['name'];
|
||||
$description = $manifest['description'];
|
||||
$version = $manifest['version'];
|
||||
|
||||
/* (2) Liste des requetes */
|
||||
$this->requests = $manifest['requests'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* ENVOI ET CONSTRUCTION D'UNE REQUETE
|
||||
*
|
||||
* @request_name<String> Nom de la requete en question
|
||||
* @parameters<Array> Liste des parametres de la requete
|
||||
*
|
||||
* @return response<Array> Reponse HTTP au format norme ou FAUX si une erreur occure
|
||||
*
|
||||
*/
|
||||
public function send($request_name, $parameters=array()){
|
||||
/* [1] On construit la requete avec les parametres
|
||||
=========================================================*/
|
||||
$build = $this->build($request_name, $parameters);
|
||||
|
||||
// Si la construction a echoue, on retourne une erreur
|
||||
if( $build === false ) return false;
|
||||
|
||||
|
||||
/* [2] Header et pre-data de la requete
|
||||
=========================================================*/
|
||||
/* (1) On definit l'URL */
|
||||
$curl = curl_init($build['url']);
|
||||
|
||||
// permet de recupere le resultat au lieu de l'afficher
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
|
||||
/* (2) On definit la methode */
|
||||
$method_arguments = self::$METHODS[ $build['method'] ];
|
||||
|
||||
curl_setopt($curl, $method_arguments[0], $method_arguments[1]);
|
||||
|
||||
|
||||
/* (3) On definit les headers */
|
||||
$headers = array();
|
||||
|
||||
// On construit le header au bon format : 'name: value'
|
||||
foreach($build['headers'] as $name=>$value)
|
||||
array_push($headers, $name.': '.$value);
|
||||
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||
|
||||
|
||||
/* (4) On definit les donnees POST si on est pas en get */
|
||||
if( $build['method'] != 'GET' ){
|
||||
$postdata = '';
|
||||
|
||||
// On formatte les donnees au format 'key=value&key=value'
|
||||
foreach($build['postdata'] as $key=>$value)
|
||||
$postdata .= $key.'='.$value.'&';
|
||||
rtrim($postdata); // on supprime le '&' a la fin s'il y a
|
||||
|
||||
// On envoie les donnees
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
|
||||
}
|
||||
|
||||
|
||||
/* [4] Execution de la requete et recup de la response
|
||||
=========================================================*/
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
|
||||
|
||||
/* [5] On retourne la reponse
|
||||
=========================================================*/
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* CONSTRUCTION D'UNE REQUETE
|
||||
*
|
||||
* @request_name<String> Nom de la requete
|
||||
* @parameters<Array> Liste des parametres de la requete
|
||||
*
|
||||
* @return filledRequest<Array> Renvoie la requete avec les bons parametres
|
||||
*
|
||||
*/
|
||||
private function build($request_name, $parameters=array()){
|
||||
/* [0] Gestion des INPUTS
|
||||
=========================================================*/
|
||||
// On retourne une erreur si la requete n'existe pas
|
||||
if( !isset($this->requests[$request_name]) ) return false;
|
||||
|
||||
// On enregistre une copie de la requete
|
||||
$request = $this->requests[$request_name];
|
||||
|
||||
|
||||
/* [1] Gestion de la methode
|
||||
=========================================================*/
|
||||
// Si la methode n'est pas prise en compte, on retourne une erreur
|
||||
if( !isset( self::$METHODS[$request['method']] ) ) return false;
|
||||
|
||||
|
||||
|
||||
|
||||
/* [2] Remplacement des parametres (valeurs globales)
|
||||
=========================================================*/
|
||||
/* (1) Remplacement dans l'URL */
|
||||
$request['url'] = $this->fillParameters($request['url'], $parameters);
|
||||
|
||||
/* (2) Remplacement dans les headers */
|
||||
foreach($request['headers'] as $name=>$value)
|
||||
$request['headers'][$name] = $this->fillParameters($value, $parameters);
|
||||
|
||||
/* (2) Remplacement dans les postdata */
|
||||
foreach($request['postdata'] as $name=>$value)
|
||||
$request['postdata'][$name] = $this->fillParameters($value, $parameters);
|
||||
|
||||
|
||||
/* [3] Retour de la requete construite
|
||||
=========================================================*/
|
||||
return $request;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* REMPLACE LES PARAMETRES DANS UNE CHAINE
|
||||
*
|
||||
* @before<String> Chaine a etudier et dans laquelle remplacer les parametres
|
||||
* @parameters<Array> Liste des parametres a remplacer (prefixes d'un '@')
|
||||
*
|
||||
* @return after<String> Chaine contenant les parametres de la liste @parameters
|
||||
*
|
||||
*/
|
||||
private function fillParameters($before, $parameters){
|
||||
// On initialise la valeur de retour
|
||||
$after = $before;
|
||||
|
||||
/* [1] On remplace les parametres prefixes par '@'
|
||||
=========================================================*/
|
||||
foreach($parameters as $name=>$value){
|
||||
$position = strpos($after, $name);
|
||||
|
||||
// Si on a trouve, on remplace le nom de variable par la valeur
|
||||
if( $position !== false )
|
||||
$after = substr($after, 0, $position) . $value . substr($after, $position+strlen($name) );
|
||||
|
||||
}
|
||||
|
||||
/* [2] On retourne la nouvelle chaine
|
||||
=========================================================*/
|
||||
return $after;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -1,39 +0,0 @@
|
|||
{
|
||||
"name": "@api_name",
|
||||
"version": "@api_version_number",
|
||||
"description": "@api_description",
|
||||
|
||||
"requests": {
|
||||
|
||||
"@request_name":{
|
||||
"url": "@request_request_url",
|
||||
"headers": {
|
||||
"@header_name_1": "@header_value_1",
|
||||
"@header_name_2": "@header_value_2",
|
||||
},
|
||||
"method": "@request_http_method",
|
||||
"description": "@request_description",
|
||||
|
||||
"input": {
|
||||
"@input_variable1_name" : "@input_default1_value",
|
||||
"@input_variable2_name" : "@input_default2_value",
|
||||
"@input_variable..._name": "@input_default..._value",
|
||||
|
||||
"@input_variableA_name" : "<@input_variableA_type>",
|
||||
"@input_variableB_name" : "<@input_variableB_type>",
|
||||
"@input_variable..._name": "<@input_variable..._type>",
|
||||
},
|
||||
|
||||
"output": {
|
||||
"@output_variable1_name" : "<@output_variable1_type>",
|
||||
"@output_variable2_name" : "<@output_variable2_type>",
|
||||
"@output_variable..._name": "<@output_variable..._type>",
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
{
|
||||
"name": "socioview_api",
|
||||
"version": "0.1",
|
||||
"description": "API de la plateforme d'acquisition et de visualisation de donnees dans le cadre d'etudes relationnelles en sociologie",
|
||||
|
||||
"requests": {
|
||||
|
||||
"parse-call-log": {
|
||||
"url": "socioview/api/",
|
||||
"method": "POST",
|
||||
"headers": { "Authorization": "Digest @token" },
|
||||
"postdata": {
|
||||
"path": "call_log/unserialize",
|
||||
"data": "[@xmlstring]"
|
||||
},
|
||||
"description": "Renvoie a partir du contenu d'un fichier de journal d'appel XML un objet classant les relations SMS/MMS par nombre de messages recus et emis, et de meme pour les appels classes par nombre d'appels."
|
||||
},
|
||||
|
||||
|
||||
|
||||
"generate-network-chart-data": {
|
||||
"url": "socioview/api/",
|
||||
"method": "POST",
|
||||
"headers": { "Authorization": "Digest @token" },
|
||||
"postdata": {
|
||||
"path": "charts/network_data"
|
||||
},
|
||||
"description": "Renvoie un jeu de donnees pour un graphique de type network"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,36 +1,12 @@
|
|||
<?php
|
||||
|
||||
/* [0] On definit la racine __ROOT__ si c'est pas deja fait
|
||||
/* [1] On definit les chemins absolus si c'est pas deja fait
|
||||
=========================================================*/
|
||||
if( !defined('__ROOT__') ) define('__ROOT__', dirname(dirname(__FILE__)) );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* [1] On définit __SERVER_HOST__ et __SERVER_ROOT__ si c'est pas déja fait
|
||||
=========================================================*/
|
||||
if( !defined('__SERVER_HOST__') || !defined('__SERVER_ROOT') ){
|
||||
/* (1) On charge le fichier de configuration */
|
||||
$json = json_decode( file_get_contents(__ROOT__.'/config/server.json'), true );
|
||||
|
||||
// Si pas d'erreur, on définit
|
||||
if( !is_null($json) ){
|
||||
|
||||
/* (2) Gestion de la config si server local ou remote */
|
||||
if( !isset($_SERVER['SERVER_NAME']) || !checkdnsrr($_SERVER['SERVER_NAME'], 'NS') )
|
||||
$config = $json['local'];
|
||||
else
|
||||
$config = $json['remote'];
|
||||
|
||||
/* (3) Création des constantes */
|
||||
define('__SERVER_HOST__', $config['host']);
|
||||
define('__SERVER_ROOT__', $config['root']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if( !defined('__ROOT__') ) define('__ROOT__', dirname(__FILE__) );
|
||||
if( !defined('__CONFIG__') ) define('__CONFIG__', __ROOT__.'/config' );
|
||||
if( !defined('__BUILD__') ) define('__BUILD__', __ROOT__.'/build' );
|
||||
if( !defined('__PUBLIC__') ) define('__PUBLIC__', __ROOT__.'/public_html' );
|
||||
if( !defined('__TMP__') ) define('__TMP__', __ROOT__.'/public_html/tmp' );
|
||||
|
||||
|
||||
/* ACTIVE LE DEBUGGAGE (WARNING + EXCEPTION)
|
||||
|
@ -43,6 +19,8 @@
|
|||
}
|
||||
|
||||
|
||||
// Loads the build facade
|
||||
// require_once __BUILD__.'/Builder.php';
|
||||
|
||||
|
||||
/* AUTOLOADER
|
||||
|
@ -57,7 +35,7 @@
|
|||
===============================================*/
|
||||
// On remplace les '\' par des '/'
|
||||
$path = str_replace('\\', '/', $className) . '.php';
|
||||
$path = __ROOT__.'/'.$path;
|
||||
$path = __BUILD__.'/'.$path;
|
||||
|
||||
// Si le fichier existe
|
||||
if( file_exists($path) )
|
||||
|
@ -69,20 +47,18 @@
|
|||
spl_autoload_register('autoloader', false, true);
|
||||
|
||||
|
||||
|
||||
|
||||
/* On demarre la session securisee PHP
|
||||
=========================================================*/
|
||||
\manager\sessionManager::session_start();
|
||||
|
||||
|
||||
|
||||
/* [3] Gestion des droits des utilisateurs
|
||||
=========================================================*/
|
||||
/* (1) Retourne si l'utilisateur est connecte ou non */
|
||||
function connected(){ return isset($_SESSION['permission']) && count($_SESSION['permission']) > 0; }
|
||||
function connected(){ return isset($_SESSION['permission']) && is_array($_SESSION['permission']) && count($_SESSION['permission']) > 0; }
|
||||
|
||||
/* (2) Retourne si l'utilisateur a le status en question */
|
||||
function permission($type){ return connected() && in_array($type, $_SESSION['permission']); }
|
||||
|
||||
|
||||
?>
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
/**************************
|
||||
* Builder *
|
||||
* 05-11-16 *
|
||||
***************************
|
||||
* Designed & Developed by *
|
||||
* xdrm-brackets *
|
||||
***************************
|
||||
* https://xdrm.io/ *
|
||||
**************************/
|
||||
|
||||
|
||||
|
||||
class Builder{
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
<?php
|
||||
|
||||
namespace api\core;
|
||||
|
||||
|
||||
class Checker{
|
||||
|
||||
|
||||
/* VERIFICATIONS DES TYPES UTILES GENERIQUES
|
||||
*
|
||||
* @type<String> Type que l'on veut verifier
|
||||
* @value<mixed*> Valeur a verifier
|
||||
*
|
||||
* @return match<Boolean> Retourne si oui ou non la valeur @value est du bon type @type
|
||||
*
|
||||
*/
|
||||
public static function run($type, $value){
|
||||
$checker = true;
|
||||
|
||||
/* [0] On verifie que $value n'est pas nul
|
||||
=========================================================*/
|
||||
if( is_null($value) ) return false;
|
||||
|
||||
|
||||
|
||||
/* [1] Si de type VARCHAR(min, max, flags)
|
||||
=========================================================*/
|
||||
if( preg_match('/^varchar\((\d+), ?(\d+)((?:, ?\w+)+)?\)$/', $type, $match) ){
|
||||
// On recupere la taille min
|
||||
$min = (int) $match[1];
|
||||
// On recupere la taille max
|
||||
$max = (int) $match[2];
|
||||
|
||||
// On recupere le sous-type si défini
|
||||
$flags = isset($match[3]) ? explode(',', substr($match[3], 1)) : null;
|
||||
|
||||
// On effectue la verification de taille
|
||||
$lenCheck = $checker && is_string($value) && strlen($value) <= $max && strlen($value) >= $min;
|
||||
|
||||
// On vérifie les FLAGS s'il est donné
|
||||
if( is_array($flags) )
|
||||
foreach( $flags as $flag )
|
||||
$lenCheck = $lenCheck && self::run($flag, $value);
|
||||
|
||||
return $lenCheck;
|
||||
}
|
||||
|
||||
|
||||
/* [2] Si de type ARRAY(type_elements)
|
||||
=========================================================*/
|
||||
if( preg_match('/^array<(.+)>$/', $type, $match) ){
|
||||
|
||||
// Si c'est pas un tableau on retourne une erreur
|
||||
if( !is_array($value) )
|
||||
return false;
|
||||
|
||||
|
||||
$elements_type = $match[1];
|
||||
|
||||
// On verifie le type pour chaque element
|
||||
foreach($value as $element)
|
||||
// Si erreur dans au moins 1 element, on retourne que c'est incorrect
|
||||
if( !self::run($elements_type, ($element) ) )
|
||||
return false;
|
||||
|
||||
// Si aucune erreur, on retourne que tout est bon
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* [n] Sinon, tous les autres types definis
|
||||
=========================================================*/
|
||||
switch($type){
|
||||
// Quoi que ce soit
|
||||
case 'mixed':
|
||||
return $checker && !is_null($value);
|
||||
break;
|
||||
|
||||
// Entier positif (id dans BDD)
|
||||
case 'id':
|
||||
return $checker && is_numeric($value) && $value <= 2147483647 && $value >= 0;
|
||||
break;
|
||||
|
||||
// Code RFID
|
||||
case 'rfid':
|
||||
return $checker && is_string($value) && preg_match('/^[\dA-F]{2}(\-[\dA-F]{2}){3,5}$/i', $value);
|
||||
break;
|
||||
|
||||
// String quelconque (peut etre vide)
|
||||
case 'text':
|
||||
return $checker && is_string($value);
|
||||
|
||||
// Adresse mail (255 caracteres max)
|
||||
case 'mail':
|
||||
return $checker && is_string($value) && strlen($value) <= 50 && preg_match('/^[\w\.-]+@[\w\.-]+\.[a-z]{2,4}$/i', $value);
|
||||
break;
|
||||
|
||||
// Hash sha1/md5
|
||||
case 'hash':
|
||||
return $checker && is_string($value) && preg_match('/^[\da-f]+$/i', $value) && (strlen($value) == 40 || strlen($value) == 64);
|
||||
break;
|
||||
|
||||
case 'alphanumeric':
|
||||
return $checker && is_string($value) && preg_match('/^[\w\.-]+$/ui', $value);
|
||||
break;
|
||||
|
||||
case 'letters':
|
||||
return $checker && is_string($value) && preg_match('/^[a-z -]+$/i', $value);
|
||||
break;
|
||||
|
||||
case 'status':
|
||||
return $checker && is_numeric($value) && floor($value) == $value && $value >= 0 && $value <= 100;
|
||||
break;
|
||||
|
||||
// Tableau non vide
|
||||
case 'array':
|
||||
return $checker && is_array($value) && count($value) > 0;
|
||||
break;
|
||||
|
||||
// Boolean
|
||||
case 'boolean':
|
||||
return $checker && is_bool($value);
|
||||
break;
|
||||
|
||||
// Objet non vide
|
||||
case 'object':
|
||||
return $checker && is_object($value) && count((array) $value) > 0;
|
||||
break;
|
||||
|
||||
// Chaine JSON (on vérifie via le parser)
|
||||
case 'json':
|
||||
return $checker && is_string($value) && json_decode($value, true) !== NULL;
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
return $checker;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
|
@ -1,16 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace manager;
|
||||
use \manager\Database;
|
||||
namespace api\core;
|
||||
use \database\core\DatabaseDriver;
|
||||
use \manager\ManagerError;
|
||||
use \api\core\Checker;
|
||||
use \database\core\Repo;
|
||||
|
||||
|
||||
class ModuleRequest{
|
||||
|
||||
// Constantes
|
||||
public static $config_path = __ROOT__.'/config/modules.json';
|
||||
public static $default_options = array(
|
||||
public static function config_path(){ return __CONFIG__.'/modules.json'; }
|
||||
public static $default_options = [
|
||||
'download' => false
|
||||
);
|
||||
];
|
||||
|
||||
// Attributs prives utiles (initialisation)
|
||||
private $path;
|
||||
|
@ -47,7 +50,7 @@
|
|||
/* [0] On met a jour la configuration
|
||||
=========================================================*/
|
||||
// Modules specifies
|
||||
$this->modules = json_decode( file_get_contents(self::$config_path), true );
|
||||
$this->modules = json_decode( file_get_contents(self::config_path()), true );
|
||||
|
||||
// Gestion de l'erreur de parsage
|
||||
if( $this->modules == null ){
|
||||
|
@ -66,7 +69,7 @@
|
|||
}
|
||||
|
||||
// Type de @data (optionnel)
|
||||
$params = (is_array($params)) ? $params : array();
|
||||
$params = (is_array($params)) ? $params : [];
|
||||
|
||||
|
||||
/* [2] Verification du chemin (existence module+methode)
|
||||
|
@ -104,7 +107,6 @@
|
|||
}
|
||||
|
||||
|
||||
|
||||
/* EXECUTE LE TRAITEMENT ASSOCIE ET REMPLIE LA REPONSE
|
||||
*
|
||||
* @return answer<ModuleResponse> Retourne une reponse de type <ModuleResponse> si tout s'est bien passe
|
||||
|
@ -144,13 +146,6 @@
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* EXECUTE LE TRAITEMENT ASSOCIE ET RENVOIE UN FICHIER AVEC LE HEADER ET LE BODY SPECIFIE
|
||||
*
|
||||
*/
|
||||
|
@ -190,7 +185,7 @@
|
|||
|
||||
/* (3) Si @headers n'est pas défini on met par défaut */
|
||||
if( !isset($returned['headers']) || !is_array($returned['headers']) )
|
||||
$returned['headers'] = array();
|
||||
$returned['headers'] = [];
|
||||
|
||||
|
||||
$fromAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
|
||||
|
@ -199,12 +194,12 @@
|
|||
=========================================================*/
|
||||
if( $fromAjax ){
|
||||
|
||||
|
||||
$tmpfname = '/tmp/download_'.uniqid().'.php';
|
||||
$bodyfname = __ROOT__.'/tmp/content_'.uniqid().'.php';
|
||||
$tmpfname = 'download_'.uniqid().'.php';
|
||||
$link = '/tmp/'.$tmpfname;
|
||||
$bodyfname = __TMP__.'/content_'.uniqid().'.php';
|
||||
|
||||
/* (1) On crée le fichier temporaire */
|
||||
$tmpfnameroot = __ROOT__.$tmpfname;
|
||||
$tmpfnameroot = __TMP__.'/'.$tmpfname;
|
||||
$tmpfile = fopen($tmpfnameroot, 'w');
|
||||
|
||||
fwrite($tmpfile, '<?php'.PHP_EOL);
|
||||
|
@ -233,7 +228,7 @@
|
|||
chmod($tmpfnameroot, 0775);
|
||||
|
||||
$response = new ModuleResponse(ManagerError::Success);
|
||||
$response->append('link', $tmpfname);
|
||||
$response->append('link', $link);
|
||||
|
||||
return $response;
|
||||
|
||||
|
@ -282,7 +277,6 @@
|
|||
return new ModuleRequest();
|
||||
|
||||
|
||||
|
||||
/* [2] On verifie que @data est renseigne
|
||||
=========================================================*/
|
||||
// Si variable n'existe pas, on cree un tableau vide
|
||||
|
@ -308,9 +302,6 @@
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* VERIFICATION DU FORMAT ET DE LA COHERENCE DU CHEMIN SPECIFIE
|
||||
*
|
||||
* @path<String> String correspondant au chemin de delegation ("module/methode")
|
||||
|
@ -349,19 +340,15 @@
|
|||
|
||||
/* [4] Enregistrement du chemin et renvoi de SUCCESS
|
||||
=========================================================*/
|
||||
$this->path = array(
|
||||
$this->path = [
|
||||
'module' => $module,
|
||||
'method' => $method
|
||||
);
|
||||
];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* RETOURNE SI ON A LA PERMISSION D'EXECUTER CETTE METHODE
|
||||
*
|
||||
* @token<String> Token d'acces a l'API (OPTIONNEL)
|
||||
|
@ -380,11 +367,11 @@
|
|||
|
||||
/* [2] Gestion si un @token est defini
|
||||
=========================================================*/
|
||||
if( Database::check('sha1', $token) ){
|
||||
if( Checker::run('hash', $token) ){
|
||||
|
||||
|
||||
/* (1) On verifie que le token est valide */
|
||||
$checkToken = new Repo('token/check', array($token) );
|
||||
$checkToken = new Repo('token/check', [$token] );
|
||||
$token_permissions = $checkToken->answer();
|
||||
|
||||
// Si le token est invalide, on retourne une erreur -> FAUX
|
||||
|
@ -400,35 +387,35 @@
|
|||
=========================================================*/
|
||||
}else if( isset($_SESSION['permission']) )
|
||||
$local_permissions = $_SESSION['permission'];
|
||||
|
||||
// Si ni token, ni SESSION, erreur
|
||||
else{
|
||||
$this->error = ManagerError::PermissionError;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* [4] Verification des droits parmi les permissions donnees
|
||||
=========================================================*/
|
||||
/* (1) On recupere la liste des permissions possibles */
|
||||
$permissions = $method['permissions'];
|
||||
|
||||
/* (2) Si aucune permission n'est definie, on laisse l'acces */
|
||||
if( count($permissions) == 0 ) return true;
|
||||
if( !$permissions == 0 ) return true;
|
||||
|
||||
/* (3) On verifie qu'il y a au moins une permission ok */
|
||||
/* (3) On verifie qu'il y a aucune permission manquante */
|
||||
foreach($permissions as $permission)
|
||||
if( in_array($permission, $local_permissions) ) return true;
|
||||
if( !in_array($permission, $local_permissions) ){
|
||||
$this->error = ManagerError::PermissionError;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* [5] On retourne FAUX si aucun droit n'a ete trouve
|
||||
=========================================================*/
|
||||
$this->error = ManagerError::PermissionError;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* VERIFICATION DU TYPE DES PARAMETRES ENVOYES
|
||||
*
|
||||
* @params<Array> Tableau associatif contenant les parametres
|
||||
|
@ -478,7 +465,7 @@
|
|||
/* (6) Si le paramètre est renseigné */
|
||||
}else
|
||||
// Si la verification est fausse, on retourne faux
|
||||
if( !Database::check($paramsdata['type'], $params[$name]) )
|
||||
if( !Checker::run($paramsdata['type'], $params[$name]) )
|
||||
return false;
|
||||
|
||||
}
|
||||
|
@ -489,9 +476,6 @@
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* AJOUT DES OPTIONS A PARTIR DE LA CONFIGURATION
|
||||
*
|
||||
*/
|
||||
|
@ -532,16 +516,13 @@
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* RENVOI LE CHEMIN D'AMORCAGE DE LA METHODE
|
||||
*
|
||||
* @return path<Array> Retourne le chemin d'amorcage de la requete
|
||||
*
|
||||
*/
|
||||
private function getFunctionCaller(){
|
||||
return array( '\\manager\\module\\'.$this->path['module'], $this->path['method'] );
|
||||
return [ '\\api\\module\\'.$this->path['module'], $this->path['method'] ];
|
||||
}
|
||||
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace manager;
|
||||
namespace api\core;
|
||||
use \manager\ManagerError;
|
||||
|
||||
|
||||
// FORMAT:
|
||||
|
@ -31,7 +32,7 @@
|
|||
*
|
||||
*/
|
||||
public function __construct($error=ManagerError::Success){
|
||||
$this->data = array();
|
||||
$this->data = [];
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
|
@ -140,14 +141,14 @@
|
|||
ManagerError::setHttpCode($this->error);
|
||||
|
||||
// Type de contenu
|
||||
// header('Content-Type: application/json');
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
// On rajoute l'erreur au message
|
||||
$returnData = array_merge(
|
||||
array(
|
||||
[
|
||||
'ModuleError' => $this->error,
|
||||
'ErrorDescription' => ManagerError::explicit($this->error)
|
||||
),
|
||||
],
|
||||
$this->data
|
||||
);
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace manager\module;
|
||||
namespace api\module;
|
||||
use \manager\sessionManager;
|
||||
use \manager\ManagerError;
|
||||
use \manager\lightdb;
|
||||
use \lightdb\core\lightdb;
|
||||
|
||||
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
|||
*
|
||||
*/
|
||||
private static function loadDictionary(){
|
||||
$dict = file_get_contents(__ROOT__.'/src/dynamic/dictionary.json');
|
||||
$dict = file_get_contents(__BUILD__.'/src/dynamic/dictionary.json');
|
||||
|
||||
$dict = json_decode( $dict, true );
|
||||
|
||||
|
@ -39,18 +39,18 @@
|
|||
|
||||
/* [1] On récupère les données de ce sujet
|
||||
=========================================================*/
|
||||
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
||||
$db = new lightdb('phone_db');
|
||||
$data = $db->fetch($subject);
|
||||
$db->close();
|
||||
|
||||
// Si erreur
|
||||
if( $data === false )
|
||||
return array( 'ModuleError' => ManagerError::ModuleError );
|
||||
return [ 'ModuleError' => ManagerError::ModuleError ];
|
||||
|
||||
|
||||
/* [2] On initialise les compteurs
|
||||
=========================================================*/
|
||||
$labels = array('ENTRANT', 'SORTANT', 'MANQUÉ');
|
||||
$labels = ['ENTRANT', 'SORTANT', 'MANQUÉ'];
|
||||
|
||||
$MISSED = 0;
|
||||
$OUTGOING = 0;
|
||||
|
@ -80,20 +80,20 @@
|
|||
=========================================================*/
|
||||
|
||||
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'type' => 'pie',
|
||||
'title' => 'Répartition des appels',
|
||||
'pointFormat' => '{series.name}: <b>{point.percentage:.1f}%</b>',
|
||||
'series' => array(array(
|
||||
'series' => [[
|
||||
'colorByPoint' => true,
|
||||
'data' => array(
|
||||
array( 'name' => 'Entrant', 'y' => $INCOMING ),
|
||||
array( 'name' => 'Sortant', 'y' => $OUTGOING ),
|
||||
array( 'name' => 'Manqué', 'y' => $MISSED ),
|
||||
)
|
||||
))
|
||||
);
|
||||
'data' => [
|
||||
[ 'name' => 'Entrant', 'y' => $INCOMING ],
|
||||
[ 'name' => 'Sortant', 'y' => $OUTGOING ],
|
||||
[ 'name' => 'Manqué', 'y' => $MISSED ],
|
||||
]
|
||||
]]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,13 +111,13 @@
|
|||
|
||||
/* [1] On récupère les données de ce sujet
|
||||
=========================================================*/
|
||||
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
||||
$db = new lightdb('phone_db');
|
||||
$data = $db->fetch($subject);
|
||||
$db->close();
|
||||
|
||||
// Si erreur
|
||||
if( $data === false )
|
||||
return array( 'ModuleError' => ManagerError::ModuleError );
|
||||
return [ 'ModuleError' => ManagerError::ModuleError ];
|
||||
|
||||
|
||||
/* [2] On initialise les compteurs
|
||||
|
@ -142,19 +142,19 @@
|
|||
}
|
||||
|
||||
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'type' => 'pie',
|
||||
'title' => 'Répartition des types de communication',
|
||||
'pointFormat' => '{series.name}: <b>{point.percentage:.1f}%</b>',
|
||||
'series' => array(array(
|
||||
'series' => [[
|
||||
'colorByPoint' => true,
|
||||
'data' => array(
|
||||
array( 'name' => 'Appels', 'y' => $PHONE ),
|
||||
array( 'name' => 'SMS', 'y' => $SMS )
|
||||
)
|
||||
))
|
||||
);
|
||||
'data' => [
|
||||
[ 'name' => 'Appels', 'y' => $PHONE ],
|
||||
[ 'name' => 'SMS', 'y' => $SMS ]
|
||||
]
|
||||
]]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -171,13 +171,13 @@
|
|||
|
||||
/* [1] On récupère les données de ce sujet
|
||||
=========================================================*/
|
||||
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
||||
$db = new lightdb('phone_db');
|
||||
$data = $db->fetch($subject);
|
||||
$db->close();
|
||||
|
||||
// Si erreur
|
||||
if( $data === false )
|
||||
return array( 'ModuleError' => ManagerError::ModuleError );
|
||||
return [ 'ModuleError' => ManagerError::ModuleError ];
|
||||
|
||||
/* [2] On initialise les compteurs
|
||||
=========================================================*/
|
||||
|
@ -212,20 +212,20 @@
|
|||
}
|
||||
|
||||
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'type' => 'pie',
|
||||
'title' => 'Répartition des genres',
|
||||
'pointFormat' => '{series.name}: <b>{point.percentage:.1f}%</b>',
|
||||
'series' => array(array(
|
||||
'series' => [[
|
||||
'colorByPoint' => true,
|
||||
'data' => array(
|
||||
array( 'name' => 'Homme', 'y' => $H ),
|
||||
array( 'name' => 'Femme', 'y' => $F ),
|
||||
array( 'name' => 'Indéterminé', 'y' => $I )
|
||||
)
|
||||
))
|
||||
);
|
||||
'data' => [
|
||||
[ 'name' => 'Homme', 'y' => $H ],
|
||||
[ 'name' => 'Femme', 'y' => $F ],
|
||||
[ 'name' => 'Indéterminé', 'y' => $I ]
|
||||
]
|
||||
]]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -243,13 +243,13 @@
|
|||
|
||||
/* [1] On récupère les données de ce sujet
|
||||
=========================================================*/
|
||||
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
||||
$db = new lightdb('phone_db');
|
||||
$data = $db->fetch($subject);
|
||||
$db->close();
|
||||
|
||||
// Si erreur
|
||||
if( $data === false )
|
||||
return array( 'ModuleError' => ManagerError::ModuleError );
|
||||
return [ 'ModuleError' => ManagerError::ModuleError ];
|
||||
|
||||
|
||||
/* [2] On initialise les valeurs
|
||||
|
@ -257,12 +257,12 @@
|
|||
/* (1) On charge le dictionnaire */
|
||||
$dict = self::loadDictionary();
|
||||
if( $dict === false )
|
||||
return array( 'ModuleError' => ManagerError::ParsingFailed );
|
||||
return [ 'ModuleError' => ManagerError::ParsingFailed ];
|
||||
|
||||
/* (2) On initialise les compteurs et les labels */
|
||||
$age_classes = array();
|
||||
$age_classesByContact = array();
|
||||
$labels = array();
|
||||
$age_classes = [];
|
||||
$age_classesByContact = [];
|
||||
$labels = [];
|
||||
foreach($dict['contacts']['age'] as $i=>$label){
|
||||
array_push($labels, $label);
|
||||
$age_classes[$i] = 0;
|
||||
|
@ -322,7 +322,7 @@
|
|||
|
||||
|
||||
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'type' => 'column',
|
||||
'xlabels' => $labels,
|
||||
|
@ -330,17 +330,17 @@
|
|||
'zoom' => 'x',
|
||||
'pointFormat' => '{series.name}: <b>{point.y:.1f}%</b>',
|
||||
'ytitle' => "apparitition (%)",
|
||||
'series' => array(
|
||||
array(
|
||||
'series' => [
|
||||
[
|
||||
'name' => 'communications',
|
||||
'data' => array_values($age_classes)
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'contacts',
|
||||
'data' => array_values($age_classesByContact)
|
||||
)
|
||||
)
|
||||
);
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -359,13 +359,13 @@
|
|||
|
||||
/* [1] On récupère les données de ce sujet
|
||||
=========================================================*/
|
||||
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
||||
$db = new lightdb('phone_db');
|
||||
$data = $db->fetch($subject);
|
||||
$db->close();
|
||||
|
||||
// Si erreur
|
||||
if( $data === false )
|
||||
return array( 'ModuleError' => ManagerError::ModuleError );
|
||||
return [ 'ModuleError' => ManagerError::ModuleError ];
|
||||
|
||||
|
||||
/* [2] On initialise les valeurs
|
||||
|
@ -373,12 +373,12 @@
|
|||
/* (1) On charge le dictionnaire */
|
||||
$dict = self::loadDictionary();
|
||||
if( $dict === false )
|
||||
return array( 'ModuleError' => ManagerError::ParsingFailed );
|
||||
return [ 'ModuleError' => ManagerError::ParsingFailed ];
|
||||
|
||||
/* (2) On initialise les compteurs et labels */
|
||||
$relations = array(); // relations en fonction du log
|
||||
$relationsByContact = array(); // relations en fonction de la répartition des contacts
|
||||
$labels = array();
|
||||
$relations = []; // relations en fonction du log
|
||||
$relationsByContact = []; // relations en fonction de la répartition des contacts
|
||||
$labels = [];
|
||||
|
||||
foreach($dict['contacts']['reltype'] as $i=>$label){
|
||||
array_push($labels, $label);
|
||||
|
@ -437,24 +437,24 @@
|
|||
$relationsByContact[$r] = 100 * $relationsByContact[$r] / $tot;
|
||||
|
||||
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'type' => 'bar',
|
||||
'title' => 'Répartition des relations',
|
||||
'xlabels' => $labels,
|
||||
'ytitle' => "apparitition (%)",
|
||||
'pointFormat' => '{series.name}: <b>{point.y:.1f}%</b>',
|
||||
'series' => array(
|
||||
array( // En fonction du log
|
||||
'series' => [
|
||||
[ // En fonction du log
|
||||
'name' => 'communications',
|
||||
'data' => $relations
|
||||
),
|
||||
array( // contacts
|
||||
],
|
||||
[ // contacts
|
||||
'name' => 'contacts',
|
||||
'data' => $relationsByContact
|
||||
)
|
||||
)
|
||||
);
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -473,13 +473,13 @@
|
|||
|
||||
/* [1] On récupère les données de ce sujet
|
||||
=========================================================*/
|
||||
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
||||
$db = new lightdb('phone_db');
|
||||
$data = $db->fetch($subject);
|
||||
$db->close();
|
||||
|
||||
// Si erreur
|
||||
if( $data === false )
|
||||
return array( 'ModuleError' => ManagerError::ModuleError );
|
||||
return [ 'ModuleError' => ManagerError::ModuleError ];
|
||||
|
||||
|
||||
/* [2] On initialise les valeurs
|
||||
|
@ -487,14 +487,14 @@
|
|||
/* (1) On charge le dictionnaire */
|
||||
$dict = self::loadDictionary();
|
||||
if( $dict === false )
|
||||
return array( 'ModuleError' => ManagerError::ParsingFailed );
|
||||
return [ 'ModuleError' => ManagerError::ParsingFailed ];
|
||||
|
||||
/* (2) On initialise les compteurs et labels */
|
||||
$weekdays = array( // jours de la semaine en fonction du log
|
||||
'phone' => array(), // pour les appels
|
||||
'sms' => array() // pour les sms
|
||||
);
|
||||
$labels = array('Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche');
|
||||
$weekdays = [ // jours de la semaine en fonction du log
|
||||
'phone' => [], // pour les appels
|
||||
'sms' => [] // pour les sms
|
||||
];
|
||||
$labels = ['Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche'];
|
||||
|
||||
for( $i = 0 ; $i < 7 ; $i++ ){
|
||||
$weekdays['phone'][$i] = 0;
|
||||
|
@ -521,24 +521,24 @@
|
|||
|
||||
}
|
||||
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'type' => 'column',
|
||||
'title' => 'Répartition dans la semaine',
|
||||
'xlabels' => $labels,
|
||||
'ytitle' => "apparititions",
|
||||
'pointFormat' => '{series.name}: {point.y}<br/>Total: {point.stackTotal}',
|
||||
'series' => array(
|
||||
array( // En fonction des appels
|
||||
'series' => [
|
||||
[ // En fonction des appels
|
||||
'name' => 'appels',
|
||||
'data' => $weekdays['phone']
|
||||
),
|
||||
array( // En fonction des sms
|
||||
],
|
||||
[ // En fonction des sms
|
||||
'name' => 'sms',
|
||||
'data' => $weekdays['sms']
|
||||
)
|
||||
)
|
||||
);
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -555,13 +555,13 @@
|
|||
|
||||
/* [1] On récupère les données de ce sujet
|
||||
=========================================================*/
|
||||
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
||||
$db = new lightdb('phone_db');
|
||||
$data = $db->fetch($subject);
|
||||
$db->close();
|
||||
|
||||
// Si erreur
|
||||
if( $data === false )
|
||||
return array( 'ModuleError' => ManagerError::ModuleError );
|
||||
return [ 'ModuleError' => ManagerError::ModuleError ];
|
||||
|
||||
|
||||
/* [2] On initialise les valeurs
|
||||
|
@ -569,11 +569,11 @@
|
|||
/* (1) On charge le dictionnaire */
|
||||
$dict = self::loadDictionary();
|
||||
if( $dict === false )
|
||||
return array( 'ModuleError' => ManagerError::ParsingFailed );
|
||||
return [ 'ModuleError' => ManagerError::ParsingFailed ];
|
||||
|
||||
/* (2) On initialise les compteurs et labels et compteurs*/
|
||||
$labels = array(); // labels des heures
|
||||
$times = array(); // heure en fonction du log
|
||||
$labels = []; // labels des heures
|
||||
$times = []; // heure en fonction du log
|
||||
|
||||
for( $h = 0 ; $h < 24 ; $h++ ){
|
||||
array_push($labels, $h.'h00');
|
||||
|
@ -611,19 +611,19 @@
|
|||
|
||||
|
||||
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'type' => 'column',
|
||||
'title' => 'Répartition dans la journée',
|
||||
'xlabels' => $labels,
|
||||
'zoom' => 'x',
|
||||
'series' => array(
|
||||
array( // En fonction des appels
|
||||
'series' => [
|
||||
[ // En fonction des appels
|
||||
'name' => 'communications',
|
||||
'data' => array_values($times)
|
||||
)
|
||||
)
|
||||
);
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -642,13 +642,13 @@
|
|||
|
||||
/* [1] On récupère les données de ce sujet
|
||||
=========================================================*/
|
||||
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
||||
$db = new lightdb('phone_db');
|
||||
$data = $db->fetch($subject);
|
||||
$db->close();
|
||||
|
||||
// Si erreur
|
||||
if( $data === false )
|
||||
return array( 'ModuleError' => ManagerError::ModuleError );
|
||||
return [ 'ModuleError' => ManagerError::ModuleError ];
|
||||
|
||||
|
||||
/* [2] On initialise les valeurs
|
||||
|
@ -656,10 +656,10 @@
|
|||
/* (1) On charge le dictionnaire */
|
||||
$dict = self::loadDictionary();
|
||||
if( $dict === false )
|
||||
return array( 'ModuleError' => ManagerError::ParsingFailed );
|
||||
return [ 'ModuleError' => ManagerError::ParsingFailed ];
|
||||
|
||||
/* (2) On initialise les compteurs et labels et compteurs*/
|
||||
$times = array(); // heure en fonction du log
|
||||
$times = []; // heure en fonction du log
|
||||
|
||||
/* [3] S'il a un journal d'appel, on renvoie les données
|
||||
=========================================================*/
|
||||
|
@ -689,14 +689,12 @@
|
|||
|
||||
/* [4] On formatte les données
|
||||
=========================================================*/
|
||||
$formattedData = array();
|
||||
$sortedData = array();
|
||||
$formattedData = [];
|
||||
$sortedData = [];
|
||||
|
||||
// 1. Mise au bon format
|
||||
foreach($times as $duration=>$count){
|
||||
array_push($formattedData, array(
|
||||
$duration, $count
|
||||
));
|
||||
array_push($formattedData, [ $duration, $count ]);
|
||||
}
|
||||
|
||||
// 2. tri des données
|
||||
|
@ -718,20 +716,20 @@
|
|||
|
||||
|
||||
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'type' => 'spline',
|
||||
'title' => 'Durée des appels',
|
||||
'xaxis' => array( 'type' => 'datetime', 'labels' => array('format' => '{value:%X}') ),
|
||||
'xaxis' => [ 'type' => 'datetime', 'labels' => ['format' => '{value:%X}'] ],
|
||||
'ytitle' => 'appels',
|
||||
'zoom' => 'x',
|
||||
'series' => array(
|
||||
array( // En fonction des appels
|
||||
'series' => [
|
||||
[ // En fonction des appels
|
||||
'name' => 'communications',
|
||||
'data' => $sortedData
|
||||
)
|
||||
)
|
||||
);
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -751,80 +749,80 @@
|
|||
/* [1] On récupère les données de ce sujet
|
||||
=========================================================*/
|
||||
/* (1) On récupère les données téléphoniques */
|
||||
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
||||
$db = new lightdb('phone_db');
|
||||
$phone = $db->fetch($subject);
|
||||
$db->close();
|
||||
|
||||
// Si erreur
|
||||
if( $phone === false )
|
||||
$phone = array();
|
||||
$phone = [];
|
||||
|
||||
/* (2) On récupère les données facebook */
|
||||
$db = new lightdb('facebook_db', __ROOT__.'/src/dynamic/');
|
||||
$db = new lightdb('facebook_db');
|
||||
$facebook = $db->fetch($subject);
|
||||
$db->close();
|
||||
|
||||
// Si erreur
|
||||
if( $facebook === false )
|
||||
$facebook = array();
|
||||
$facebook = [];
|
||||
|
||||
/* (3) Si aucune donnée, erreur */
|
||||
if( count($phone) + count($facebook) == 0 )
|
||||
return array( 'ModuleError' => ManagerError::ModuleError );
|
||||
return [ 'ModuleError' => ManagerError::ModuleError ];
|
||||
|
||||
|
||||
/* [2] On récupère les top20 de chaque jeu (les contacts intéressants)
|
||||
=========================================================*/
|
||||
$nodes = array();
|
||||
$nodes = [];
|
||||
|
||||
/* (1) Contacts parmi les données téléphoniques */
|
||||
if( isset($phone['contacts']) )
|
||||
foreach($phone['contacts'] as $contact)
|
||||
if( isset($contact['studies2']) )
|
||||
array_push( $nodes, array(
|
||||
array_push( $nodes, [
|
||||
'id' => $contact['id'],
|
||||
'label' => $contact['name'],
|
||||
'type' => 'phone'
|
||||
) );
|
||||
] );
|
||||
|
||||
|
||||
/* (2) Contacts parmi les données facebook */
|
||||
if( isset($facebook['contacts']) )
|
||||
foreach($facebook['contacts'] as $contact)
|
||||
if( isset($contact['studies2']) )
|
||||
array_push( $nodes, array(
|
||||
array_push( $nodes, [
|
||||
'id' => $contact['id'],
|
||||
'label' => $contact['name'],
|
||||
'type' => 'facebook'
|
||||
) );
|
||||
] );
|
||||
|
||||
|
||||
|
||||
/* [3] On récupère toutes les relations
|
||||
=========================================================*/
|
||||
$edges = array();
|
||||
$edges = [];
|
||||
|
||||
/* (1) Parmi les relations des données téléphoniques */
|
||||
if( isset($phone['relations']) )
|
||||
foreach($phone['relations'] as $relation)
|
||||
array_push($edges, array($relation['idA'], $relation['idB']) );
|
||||
array_push($edges, [$relation['idA'], $relation['idB']] );
|
||||
|
||||
|
||||
/* (2) Parmi les relations des données facebook */
|
||||
if( isset($facebook['relations']) )
|
||||
foreach($facebook['relations'] as $relation)
|
||||
array_push($edges, array($relation['idA'], $relation['idB']) );
|
||||
array_push($edges, [$relation['idA'], $relation['idB']] );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'nodes' => $nodes,
|
||||
'edges' => $edges
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,506 @@
|
|||
<?php
|
||||
|
||||
namespace api\module;
|
||||
use \database\core\DatabaseDriver;
|
||||
use \manager\sessionManager;
|
||||
use \api\core\ModuleRequest;
|
||||
use \manager\ManagerError;
|
||||
use \database\core\Repo;
|
||||
use \lightdb\core\lightdb;
|
||||
|
||||
class download{
|
||||
|
||||
/* CONSTRUIT UN CONTENU CSV A PARTIR DES DONNEES @DATA ET DU DICTIONNAIRE @DICT
|
||||
*
|
||||
* @data<Array> Tableau contenant les valeurs
|
||||
* @dict<Array> Tableau contenant le dictionnaire des valeurs
|
||||
* @displayColumns<Boolean> VRAI s'il faut afficher les colonnes
|
||||
*
|
||||
* @return csvContent<String> Retourne le contenu CSV associé
|
||||
*
|
||||
*/
|
||||
private static function parseCSV($data, $dict, $displayColumns=true){
|
||||
$output = ''; // Contiendra le résultat
|
||||
$dictKeys = array_keys($dict); // Contient les clés de @dict
|
||||
|
||||
|
||||
/* [0] On récupère toutes les colonnes
|
||||
=========================================================*/
|
||||
$columns = []; // Contiendra les colonnes
|
||||
|
||||
/* (1) Pour chaque set de @data */
|
||||
foreach($data as $dataset){
|
||||
$keys = [];
|
||||
|
||||
/* (2) Pour chaque champ de chaque set de @data, on ajoute les clés */
|
||||
foreach($dataset as $key=>$value){
|
||||
|
||||
// {1} Si c'est un tableau -> on ajoute les sous-clés //
|
||||
if( is_array($value) )
|
||||
foreach($value as $subIndex=>$subValue)
|
||||
array_push( $keys, "${key}_$subIndex" );
|
||||
|
||||
// {2} Si c'est une valeur simple -> on ajoute la clé //
|
||||
else
|
||||
array_push( $keys, $key );
|
||||
|
||||
}
|
||||
|
||||
/* (3) On ajoute à chaque fois les clés du set à la liste des colonnes */
|
||||
$columns = array_unique( array_merge( $columns, $keys ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* [1] On ajoute les colonnes à la sortie
|
||||
=========================================================*/
|
||||
if( $displayColumns )
|
||||
foreach($columns as $i=>$column)
|
||||
$output .= ($i < count($columns)-1) ? "\"$column\";" : "\"$column\"\r\n";
|
||||
|
||||
|
||||
|
||||
/* [2] On récupère les valeurs et on les ajoute à la sortie
|
||||
=========================================================*/
|
||||
|
||||
/* (1) Pour chaque set de @data */
|
||||
foreach($data as $dataset){
|
||||
|
||||
/* (2) Pour chaque colonne */
|
||||
foreach($columns as $c=>$column){
|
||||
|
||||
/* (3) On décompose la colonne (ne change que si elle l'est) */
|
||||
$col = explode('_', $column);
|
||||
$composed = true;
|
||||
|
||||
// Si il n'existe pas une 2me partie numérique, on annule la décomposition
|
||||
if( !isset($col[1]) || !is_numeric($col[1]) ){
|
||||
$col = [ $column ];
|
||||
$composed = false;
|
||||
}
|
||||
|
||||
|
||||
/* (4) Si la colonne existe dans le set actuel */
|
||||
if( isset($dataset[$col[0]]) ){
|
||||
|
||||
/* (5) Si c'est une valeur composée, on récupère la valeur */
|
||||
if( $composed && isset($dataset[$col[0]][$col[1]]) )
|
||||
|
||||
// {1} Si valeur dans le dictionnaire, on fait modulo le nombre de choix possibles //
|
||||
if( isset($dict[$col[0]]) )
|
||||
$output .= "\"".( $dataset[$col[0]][$col[1]] % count($dict[$col[0]]) )."\"";
|
||||
// {2} Si pas dans le dictionnaire, on laisse la valeur //
|
||||
else
|
||||
$output .= "\"".$dataset[$col[0]][$col[1]]."\"";
|
||||
|
||||
/* (6) Si la valeur n'est pas composée, on récupère la valeur */
|
||||
elseif( !$composed && !is_array($dataset[$col[0]]) )
|
||||
$output .= "\"".$dataset[$col[0]]."\"";
|
||||
}
|
||||
|
||||
// On ajoute une virgule sauf à la dernière valeur
|
||||
$output .= ($c < count($columns)-1) ? ";" : "";
|
||||
|
||||
}
|
||||
|
||||
|
||||
$output .= "\r\n";
|
||||
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* DOWNLOAD D'UN FICHIER CONTENANT LES DONNEES SELECTIONNEES
|
||||
*
|
||||
* @subjects<Array> Liste des identifiants des sujets à prendre en compte
|
||||
* @all<Boolean> Si TRUE, prend en compte tous les sujets (annule @subjects)
|
||||
*
|
||||
* @return data<File> Retourne une archive .zip contenant toutes les données sélectionnées
|
||||
*
|
||||
*/
|
||||
public static function multiple($params){
|
||||
extract($params);
|
||||
|
||||
/* (0) Gestion du formattage des paramètres */
|
||||
$subjects = !is_array($subjects) ? [] : $subjects;
|
||||
$all = !is_bool($all) ? false : $all;
|
||||
|
||||
/* [0] On récupère le dictionnaire
|
||||
=========================================================*/
|
||||
$dict = file_get_contents(__BUILD__.'/lightdb/storage/dictionary.json');
|
||||
|
||||
/* (2) Si une erreur pour le fichier de conf */
|
||||
if( $dict === false )
|
||||
return [ 'ModuleError' => ManagerError::UnreachableResource ];
|
||||
|
||||
/* (3) On récupère la config sous forme de tableau */
|
||||
$dict = json_decode( $dict, true );
|
||||
|
||||
/* (4) Si erreur de PARSAGE */
|
||||
if( !is_array($dict) )
|
||||
return [ 'ModuleError' => ManagerError::ParsingFailed ];
|
||||
|
||||
|
||||
/* [1] Initialisation
|
||||
=========================================================*/
|
||||
/* (1) Fichiers de sortie */
|
||||
$output = [
|
||||
'contacts.fiche' => '', // contiendra les contacts et leurs données fiches
|
||||
'contacts.mini' => '', // contiendra les contacts et leurs données mini
|
||||
'relations' => '', // contiendra les relations
|
||||
'dict' => '' // contiendra le dictionnaire de valeurs
|
||||
];
|
||||
|
||||
/* (2) Base de données */
|
||||
$subjectdb = new lightdb('subject');
|
||||
$contactdb = new lightdb('contact');
|
||||
|
||||
|
||||
/* [2] On construit la liste des sujets
|
||||
=========================================================*/
|
||||
$subjectindexes = array_keys($subjectdb->index());
|
||||
$subjectids = [];
|
||||
|
||||
/* (1) On récupère tous les sujets si c'est spécifié */
|
||||
if( $all )
|
||||
|
||||
$subjectids = $subjectindexes;
|
||||
|
||||
/* (2) Sinon on retire les ids incorrects */
|
||||
else
|
||||
|
||||
foreach($subjects as $i=>$id)
|
||||
if( in_array($id, $subjectindexes) )
|
||||
$subjectids[] = intval($id);
|
||||
|
||||
|
||||
|
||||
/* (3) Si aucun sujet restant -> error */
|
||||
if( count($subjectids) === 0 )
|
||||
return ['ModuleError' => ManagerError::ParamError];
|
||||
|
||||
|
||||
/* [3] Export contacts/relations des sujets selectionnés
|
||||
=========================================================*/
|
||||
foreach($subjectids as $subid){
|
||||
|
||||
/* (1) On récupère les données du sujet */
|
||||
$subject = $subjectdb->fetch($subid);
|
||||
|
||||
// si pas trouvé -> suivant
|
||||
if( $subject === false )
|
||||
continue;
|
||||
|
||||
/* (2) Si aucun contact -> suivant */
|
||||
if( !isset($subject['contacts']) || !is_array($subject['contacts']) )
|
||||
continue;
|
||||
|
||||
/* (3) Pour chaque contact */
|
||||
foreach($subject['contacts'] as $c=>$contactid){
|
||||
|
||||
// {3.1} On récupère le contact //
|
||||
$contact = $contactdb->fetch($contactid);
|
||||
|
||||
// si pas trouvé -> suivant
|
||||
if( $contact === false )
|
||||
continue;
|
||||
|
||||
// {3.2} On ajoute le contact au fichier des FICHES //
|
||||
if( array_key_exists('studies2', $contact) )
|
||||
// On affiche les colonnes pour le premier contact uniquement
|
||||
$output['contacts.fiche'] .= self::parseCSV([$contact], $dict['contacts'], strlen($output['contacts.fiche']) == 0 );
|
||||
|
||||
// {3.3} On ajoute le contact au fichier des MINI //
|
||||
if( array_key_exists('studies1', $contact) )
|
||||
// On affiche les colonnes pour le premier contact uniquement
|
||||
$output['contacts.mini'] .= self::parseCSV([$contact], $dict['contacts'], strlen($output['contacts.mini']) == 0 );
|
||||
|
||||
}
|
||||
|
||||
// On ajoute le sujet à la liste des contacts
|
||||
$output['contacts.mini'] .= self::parseCSV([[
|
||||
'id' => $subid,
|
||||
'name' => $subject['subject']['name']
|
||||
]], [], strlen($output['contacts.mini']) == 0);
|
||||
|
||||
/* (4) Si aucune relation -> suivant */
|
||||
if( !isset($subject['relations']) || !is_array($subject['relations']) )
|
||||
continue;
|
||||
|
||||
/* (5) On ajoute les relations */
|
||||
$output['relations'] .= self::parseCSV($subject['relations'], [], strlen($output['relations']) == 0 );
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* [5] On ajoute le dictionnaire
|
||||
=========================================================*/
|
||||
$output['dict'] .= "\"sheet\";\"field\";\"key\";\"value\"\r\n";
|
||||
foreach($dict as $ds=>$dataset)
|
||||
foreach($dataset as $f=>$field)
|
||||
foreach($field as $key=>$value)
|
||||
$output['dict'] .= "\"$ds\";\"$f\";\"$key\";\"$value\"\r\n";
|
||||
|
||||
|
||||
/* [6] Création de l'archive
|
||||
=========================================================*/
|
||||
$zip = new \ZipArchive();
|
||||
$fname = __TMP__.'/'.time().'.zip';
|
||||
$zip->open($fname, \ZipArchive::CREATE);
|
||||
|
||||
|
||||
foreach($output as $file=>$content)
|
||||
if( strlen($content) > 0 )
|
||||
$zip->addFromString($file.'.csv', $content);
|
||||
|
||||
$zip->close();
|
||||
|
||||
|
||||
/* [5] On lance le téléchargement
|
||||
=========================================================*/
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/zip; charset=utf-8',
|
||||
'Content-Disposition' => 'attachment; filename=export'.date('_d_m_Y', time()).'.zip',
|
||||
'Pragma' => 'no-cache',
|
||||
'Expires' => '0'
|
||||
],
|
||||
'body' => file_get_contents($fname)
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* EXPORT POUR GEPHI OU AUTRE LOGICIEL SUR LE PRINCIPE NODES+EDGES
|
||||
*
|
||||
* @subjects<Array> Liste des identifiants des sujets à prendre en compte
|
||||
* @all<Boolean> Si TRUE, prend en compte tous les sujets (annule @subjects)
|
||||
*
|
||||
* @return data<File> Retourne une archive .zip contenant toutes les données sélectionnées
|
||||
*/
|
||||
public static function chart($params){
|
||||
extract($params);
|
||||
|
||||
/* (0) Gestion du formattage des paramètres */
|
||||
$subjects = !is_array($subjects) ? [] : $subjects;
|
||||
$all = !is_bool($all) ? false : $all;
|
||||
|
||||
/* [0] On récupère le dictionnaire
|
||||
=========================================================*/
|
||||
$dict = file_get_contents(__BUILD__.'/lightdb/storage/dictionary.json');
|
||||
|
||||
/* (2) Si une erreur pour le fichier de conf */
|
||||
if( $dict === false )
|
||||
return [ 'ModuleError' => ManagerError::UnreachableResource ];
|
||||
|
||||
/* (3) On récupère la config sous forme de tableau */
|
||||
$dict = json_decode( $dict, true );
|
||||
|
||||
/* (4) Si erreur de PARSAGE */
|
||||
if( !is_array($dict) )
|
||||
return [ 'ModuleError' => ManagerError::ParsingFailed ];
|
||||
|
||||
|
||||
/* [1] Initialisation
|
||||
=========================================================*/
|
||||
/* (1) Fichiers de sortie */
|
||||
$output = [
|
||||
'gephi.nodes' => '', // contiendra les contacts et leurs données
|
||||
'gephi.edges' => '', // contiendra les relations
|
||||
'dict' => '' // contiendra le dictionnaire de valeurs
|
||||
];
|
||||
|
||||
/* (2) Base de données */
|
||||
$subjectdb = new lightdb('subject');
|
||||
$contactdb = new lightdb('contact');
|
||||
|
||||
|
||||
/* [2] On construit la liste des sujets
|
||||
=========================================================*/
|
||||
$subjectindexes = array_keys($subjectdb->index());
|
||||
$subjectids = [];
|
||||
|
||||
/* (1) On récupère tous les sujets si c'est spécifié */
|
||||
if( $all )
|
||||
|
||||
$subjectids = $subjectindexes;
|
||||
|
||||
/* (2) Sinon on retire les ids incorrects */
|
||||
else
|
||||
|
||||
foreach($subjects as $i=>$id)
|
||||
if( in_array($id, $subjectindexes) )
|
||||
$subjectids[] = intval($id);
|
||||
|
||||
|
||||
|
||||
/* (3) Si aucun sujet restant -> error */
|
||||
if( count($subjectids) === 0 )
|
||||
return ['ModuleError' => ManagerError::ParamError];
|
||||
|
||||
|
||||
/* [3] Export contacts/relations des sujets selectionnés
|
||||
=========================================================*/
|
||||
foreach($subjectids as $subid){
|
||||
|
||||
/* (1) On récupère les données du sujet */
|
||||
$subject = $subjectdb->fetch($subid);
|
||||
|
||||
// si pas trouvé -> suivant
|
||||
if( $subject === false )
|
||||
continue;
|
||||
|
||||
/* (2) Si aucun contact -> suivant */
|
||||
if( !isset($subject['contacts']) || !is_array($subject['contacts']) )
|
||||
continue;
|
||||
|
||||
/* (3) Pour chaque contact */
|
||||
foreach($subject['contacts'] as $c=>$contactid){
|
||||
|
||||
// {3.1} On récupère le contact //
|
||||
$contact = $contactdb->fetch($contactid);
|
||||
|
||||
// si pas trouvé -> suivant
|
||||
if( $contact === false )
|
||||
continue;
|
||||
|
||||
// {3.2} On ajoute le contact au fichier des FICHES //
|
||||
if( array_key_exists('studies2', $contact) ){
|
||||
// On affiche les colonnes pour le premier contact uniquement
|
||||
$contact['type'] = 'fiche';
|
||||
$output['gephi.nodes'] .= self::parseCSV([$contact], $dict['contacts'], strlen($output['gephi.nodes']) == 0 );
|
||||
|
||||
// {3.3} On ajoute le contact au fichier des MINI //
|
||||
}elseif( array_key_exists('studies1', $contact) ){
|
||||
// On affiche les colonnes pour le premier contact uniquement
|
||||
$contact['type'] = 'mini';
|
||||
$output['gephi.nodes'] .= self::parseCSV([$contact], $dict['contacts'], strlen($output['gephi.nodes']) == 0 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// On ajoute le sujet à la liste des contacts
|
||||
$output['gephi.nodes'] .= self::parseCSV([[
|
||||
'id' => $subid,
|
||||
'name' => $subject['subject']['name']
|
||||
]], [], strlen($output['gephi.nodes']) == 0);
|
||||
|
||||
/* (4) Si aucune relation -> suivant */
|
||||
if( !isset($subject['relations']) || !is_array($subject['relations']) )
|
||||
continue;
|
||||
|
||||
/* (5) On ajoute les relations */
|
||||
foreach($subject['relations'] as $r=>$rel)
|
||||
|
||||
$output['gephi.edges'] .= self::parseCSV(
|
||||
[[
|
||||
'source' => $rel['idA'],
|
||||
'target' => $rel['idB'],
|
||||
'weight' => ($rel['idA']==$subid) ? .5 : 1,
|
||||
'type' => 'Undirected'
|
||||
]],
|
||||
[],
|
||||
strlen($output['gephi.edges']) == 0
|
||||
);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* [5] On ajoute le dictionnaire
|
||||
=========================================================*/
|
||||
$output['dict'] .= "\"sheet\";\"field\";\"key\";\"value\"\r\n";
|
||||
foreach($dict as $ds=>$dataset)
|
||||
foreach($dataset as $f=>$field)
|
||||
foreach($field as $key=>$value)
|
||||
$output['dict'] .= "\"$ds\";\"$f\";\"$key\";\"$value\"\r\n";
|
||||
|
||||
|
||||
/* [6] Création de l'archive
|
||||
=========================================================*/
|
||||
$zip = new \ZipArchive();
|
||||
$fname = __TMP__.'/'.time().'.zip';
|
||||
$zip->open($fname, \ZipArchive::CREATE);
|
||||
|
||||
|
||||
foreach($output as $file=>$content)
|
||||
if( strlen($content) > 0 )
|
||||
$zip->addFromString($file.'.csv', $content);
|
||||
|
||||
$zip->close();
|
||||
|
||||
|
||||
/* [5] On lance le téléchargement
|
||||
=========================================================*/
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/zip; charset=utf-8',
|
||||
'Content-Disposition' => 'attachment; filename=graphics'.date('_d_m_Y', time()).'.zip',
|
||||
'Pragma' => 'no-cache',
|
||||
'Expires' => '0'
|
||||
],
|
||||
'body' => file_get_contents($fname)
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* RENVOIE LE CONTENU DU MENU
|
||||
*
|
||||
*/
|
||||
public static function menu($params){
|
||||
extract($params);
|
||||
|
||||
$menu_json = json_decode( file_get_contents(__CONFIG__.'/menu.json'), true );
|
||||
|
||||
// si erreur
|
||||
if( $menu_json == null )
|
||||
return ['ModuleError' => ManagerError::ParsingFailed];
|
||||
|
||||
// si tout bon
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'menu' => $menu_json
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace manager\module;
|
||||
namespace api\module;
|
||||
use \manager\ManagerError;
|
||||
|
||||
class module{
|
||||
|
@ -10,10 +10,10 @@
|
|||
*/
|
||||
public static function method(){
|
||||
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'ReceivedArguments' => func_get_args()
|
||||
);
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
|
@ -24,11 +24,11 @@
|
|||
public static function phpunitParams($params){
|
||||
extract($params);
|
||||
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'p1' => $p1,
|
||||
'p2' => $p2
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/* RENVOIE UNE DESCRIPTION EN MARKDOWN DES MODULES DE L'API
|
||||
|
@ -40,11 +40,11 @@
|
|||
/* [1] Récupération de la configuration
|
||||
=========================================================*/
|
||||
// On récupère le fichier et on le parse
|
||||
$modules = json_decode( file_get_contents(__ROOT__.'/config/modules.json'), true );
|
||||
$modules = json_decode( file_get_contents(__CONFIG__.'/modules.json'), true );
|
||||
|
||||
// Gestion de l'erreur de parsage
|
||||
if( $modules == null )
|
||||
return array( 'ModuleError' => ManagerError::ParsingFailed );
|
||||
return [ 'ModuleError' => ManagerError::ParsingFailed ];
|
||||
|
||||
/* [2] Mise en forme de la liste des modules
|
||||
=========================================================*/
|
||||
|
@ -73,17 +73,17 @@
|
|||
|
||||
/* [n] Gestion du retour
|
||||
=========================================================*/
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'headers' => array(
|
||||
'headers' => [
|
||||
'Content-Type' => 'text/markdown; charset=utf-8',
|
||||
'Content-Transfer-Encoding' => 'binary',
|
||||
'Content-Disposition' => 'attachment; filename=NxTIC.apib',
|
||||
'Pragma' => 'no-cache',
|
||||
'Expires' => '0'
|
||||
),
|
||||
],
|
||||
'body' => $markdown
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -96,11 +96,11 @@
|
|||
/* [0] Récupération de la configuration
|
||||
=========================================================*/
|
||||
// On récupère le fichier et on le parse
|
||||
$modules = json_decode( file_get_contents(__ROOT__.'/config/modules.json'), true );
|
||||
$modules = json_decode( file_get_contents(__CONFIG__.'/modules.json'), true );
|
||||
|
||||
// Gestion de l'erreur de parsage
|
||||
if( $modules == null )
|
||||
return array( 'ModuleError' => ManagerError::ParsingFailed );
|
||||
return [ 'ModuleError' => ManagerError::ParsingFailed ];
|
||||
|
||||
|
||||
/* [1] Début du fichier custom
|
||||
|
@ -271,17 +271,17 @@
|
|||
}
|
||||
|
||||
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'headers' => array(
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/octet-stream; charset=utf-8',
|
||||
'Content-Transfer-Encoding' => 'binary',
|
||||
'Content-Disposition' => 'attachment; filename=NxTIC.apib',
|
||||
'Pragma' => 'no-cache',
|
||||
'Expires' => '0'
|
||||
),
|
||||
],
|
||||
'body' => $content
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace manager\module;
|
||||
namespace api\module;
|
||||
use \manager\sessionManager;
|
||||
use \manager\Database;
|
||||
use \database\core\DatabaseDriver;
|
||||
use \manager\ManagerError;
|
||||
use \manager\Repo;
|
||||
use \manager\lightdb;
|
||||
use \database\core\Repo;
|
||||
use \lightdb\core\lightdb;
|
||||
|
||||
class subject{
|
||||
|
||||
|
||||
/* FETCHES NEW SUBJECTS FROM Lab-Surveys Database
|
||||
*
|
||||
* @note: will store new subjects to localStorage
|
||||
*
|
||||
*/
|
||||
private static function fetchNewSubjects(){
|
||||
/* [1] Fetch subjects which have answer this survey
|
||||
=========================================================*/
|
||||
/* (1) Section Title */
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* RETOURNE LA LISTE DE TOUS LES SUJETS
|
||||
|
@ -21,12 +33,12 @@
|
|||
|
||||
|
||||
// Contiendra les sujets
|
||||
$subjects = array();
|
||||
$subjects = [];
|
||||
|
||||
/* [1] On récupére la liste des sujets
|
||||
=========================================================*/
|
||||
/* (1) On initialise et ouvre la bd */
|
||||
$db = new lightdb('survey_db', __ROOT__.'/src/dynamic/');
|
||||
$db = new lightdb('subject');
|
||||
$ids = array_keys( $db->index() );
|
||||
|
||||
/* (2) On récupère tous les sujets */
|
||||
|
@ -35,44 +47,25 @@
|
|||
|
||||
$sub['creation'] = date('d/m/Y H:i:s', $sub['creation']);
|
||||
$subjects[$id] = $sub;
|
||||
|
||||
/* (3) Si enquête PHONE passée */
|
||||
if( isset($sub['surveys']) && is_array($sub['surveys']) && in_array('phone', $sub['surveys']) )
|
||||
$subjects[$id]['phone'] = true;
|
||||
|
||||
/* (4) Si enquête FACEBOOK passée */
|
||||
if( isset($sub['surveys']) && is_array($sub['surveys']) && in_array('facebook', $sub['surveys']) )
|
||||
$subjects[$id]['facebook'] = true;
|
||||
|
||||
}
|
||||
$db->close();
|
||||
|
||||
|
||||
/* [2] On récupére la liste des sujets pour PHONE
|
||||
=========================================================*/
|
||||
/* (1) On initialise et ouvre la bd */
|
||||
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
||||
$ids = array_keys( $db->index() );
|
||||
$db->close();
|
||||
|
||||
/* (2) Si un des sujets de 'survey' est dans PHONE, on ajoute la mention */
|
||||
foreach($subjects as $id=>$data)
|
||||
if( in_array($id, $ids) ) // Si dans phone
|
||||
$subjects[$id]['phone'] = true;
|
||||
|
||||
|
||||
|
||||
|
||||
/* [3] On récupére la liste des sujets pour FACEBOOK
|
||||
=========================================================*/
|
||||
/* (1) On initialise et ouvre la bd */
|
||||
$db = new lightdb('facebook_db', __ROOT__.'/src/dynamic/');
|
||||
$ids = array_keys( $db->index() );
|
||||
$db->close();
|
||||
|
||||
/* (2) Si un des sujets de 'survey' est dans FACBEOOK, on ajoute la mention */
|
||||
foreach($subjects as $id=>$data)
|
||||
if( in_array($id, $ids) ) // Si dans facebook
|
||||
$subjects[$id]['facebook'] = true;
|
||||
|
||||
|
||||
/* [4] Gestion du retour
|
||||
=========================================================*/
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'subjects' => $subjects
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -90,59 +83,49 @@
|
|||
|
||||
|
||||
// Contiendra les sujets
|
||||
$subjects = array();
|
||||
$contacts = [];
|
||||
|
||||
/* [1] On récupére la liste des sujets
|
||||
=========================================================*/
|
||||
/* (1) On initialise et ouvre la bd */
|
||||
$db = new lightdb('survey_db', __ROOT__.'/src/dynamic/');
|
||||
$db = new lightdb('subject');
|
||||
$fetch = $db->fetch($subject_id);
|
||||
$db->close();
|
||||
|
||||
/* (2) Si on trouve personne, on renvoie une erreur */
|
||||
if( $fetch === false )
|
||||
return array( 'ModuleError' => ManagerError::ModuleError );
|
||||
return [ 'ModuleError' => ManagerError::ModuleError ];
|
||||
|
||||
/* (3) On enregistre ses contacts s'il en a */
|
||||
if( isset($fetch['contacts']) )
|
||||
foreach($fetch['contacts'] as $contact)
|
||||
$subjects[$contact['id']] = $contact;
|
||||
$db = new lightdb('contact');
|
||||
|
||||
if( isset($fetch['contacts']) ){
|
||||
|
||||
/* [2] On récupére la liste des contacts saisis dans PHONE
|
||||
=========================================================*/
|
||||
/* (1) On initialise et ouvre la bd */
|
||||
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
||||
$fetch = $db->fetch($subject_id);
|
||||
foreach($fetch['contacts'] as $contactId){
|
||||
|
||||
$contact = $db->fetch($contactId);
|
||||
// si le contact n'est pas trouvé -> passe au suivant
|
||||
if( $contact === false )
|
||||
continue;
|
||||
|
||||
$contacts[$contactId] = $contact;
|
||||
|
||||
}
|
||||
}
|
||||
$db->close();
|
||||
|
||||
/* (2) Si on trouve des contacts, on les ajoute */
|
||||
if( $fetch !== false && isset($fetch['contacts']) )
|
||||
foreach($fetch['contacts'] as $contact)
|
||||
$subjects[$contact['id']] = $contact;
|
||||
|
||||
|
||||
|
||||
|
||||
/* [3] On récupére la liste des sujets pour FACEBOOK
|
||||
/* [2] Gestion des relations
|
||||
=========================================================*/
|
||||
/* (1) On initialise et ouvre la bd */
|
||||
$db = new lightdb('facebook_db', __ROOT__.'/src/dynamic/');
|
||||
$fetch = $db->fetch($subject_id);
|
||||
$db->close();
|
||||
|
||||
/* (2) Si on trouve des contacts, on les ajoute */
|
||||
if( $fetch !== false && isset($fetch['contacts']) )
|
||||
foreach($fetch['contacts'] as $contact)
|
||||
$subjects[$contact['id']] = $contact;
|
||||
/* (1) On récupère toutes les relations */
|
||||
//blabla
|
||||
|
||||
|
||||
/* [4] Gestion du retour
|
||||
=========================================================*/
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'subjects' => $subjects
|
||||
);
|
||||
'subjects' => $contacts
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -162,7 +145,7 @@
|
|||
|
||||
/* [1] On récupère l'id unique actuel
|
||||
=========================================================*/
|
||||
$funiq = fopen( __ROOT__.'/src/dynamic/uniqid', 'r+' );
|
||||
$funiq = fopen( __BUILD__.'/lightdb/storage/uniqid', 'r+' );
|
||||
flock($funiq, LOCK_EX); // On verrouille le fichier
|
||||
$uniqid = trim( fgets( $funiq ) );
|
||||
|
||||
|
@ -174,16 +157,20 @@
|
|||
$newId = intval($uniqid) + 1;
|
||||
|
||||
// On crée notre sujet
|
||||
$data = array( 'subject' => array(
|
||||
'id' => $newId,
|
||||
'name' => $name,
|
||||
'creation' => time()
|
||||
));
|
||||
$data = [
|
||||
'subject' => [
|
||||
'id' => $newId,
|
||||
'name' => $name,
|
||||
'creation' => time(),
|
||||
'surveys' => [],
|
||||
'coords' => ''
|
||||
]
|
||||
];
|
||||
|
||||
/* [2] On crée le sujet dans SURVEYS
|
||||
=========================================================*/
|
||||
/* (1) On initialise et ouvre la bd */
|
||||
$db = new lightdb('survey_db', __ROOT__.'/src/dynamic/');
|
||||
$db = new lightdb('subject');
|
||||
$db->insert( $newId, $data );
|
||||
$db->close();
|
||||
|
||||
|
@ -199,10 +186,10 @@
|
|||
|
||||
/* [2] Gestion du retour
|
||||
=========================================================*/
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'id_subject' => $newId
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -218,13 +205,18 @@
|
|||
public static function search($params){
|
||||
extract($params);
|
||||
|
||||
|
||||
// Contiendra les sujets
|
||||
$subjects = array();
|
||||
$subjects = [];
|
||||
|
||||
|
||||
/* [0] Notre fonction de recherche (comparaison)
|
||||
=========================================================*/
|
||||
function compareSearch($A, $B){
|
||||
// Returns all if no search keyword
|
||||
if( $A == '' )
|
||||
return true;
|
||||
|
||||
// {1} On supprime les espaces et tout en minuscule //
|
||||
$A = str_replace(' ', '', strtolower($A));
|
||||
$B = str_replace(' ', '', strtolower($B));
|
||||
|
@ -239,7 +231,7 @@
|
|||
/* [1] On récupére la liste des sujets
|
||||
=========================================================*/
|
||||
/* (1) On initialise et ouvre la bd */
|
||||
$db = new lightdb('survey_db', __ROOT__.'/src/dynamic/');
|
||||
$db = new lightdb('subject');
|
||||
$ids = array_keys( $db->index() );
|
||||
|
||||
/* (2) On récupère tous les sujets */
|
||||
|
@ -249,47 +241,24 @@
|
|||
|
||||
$sub['creation'] = date('d/m/Y H:i:s', $sub['creation']);
|
||||
$subjects[$id] = $sub;
|
||||
|
||||
/* (3) Si enquête PHONE passée */
|
||||
if( isset($sub['surveys']) && is_array($sub['surveys']) && in_array('phone', $sub['surveys']) )
|
||||
$subjects[$id]['phone'] = true;
|
||||
|
||||
/* (4) Si enquête FACEBOOK passée */
|
||||
if( isset($sub['surveys']) && is_array($sub['surveys']) && in_array('facebook', $sub['surveys']) )
|
||||
$subjects[$id]['facebook'] = true;
|
||||
}
|
||||
}
|
||||
$db->close();
|
||||
|
||||
|
||||
/* [2] On récupére la liste des sujets pour PHONE
|
||||
=========================================================*/
|
||||
/* (1) On initialise et ouvre la bd */
|
||||
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
||||
$ids = array_keys( $db->index() );
|
||||
$db->close();
|
||||
|
||||
/* (2) Si un des sujets de 'survey' est dans PHONE, on ajoute la mention */
|
||||
foreach($subjects as $id=>$data)
|
||||
if( in_array($id, $ids) ) // Si dans phone
|
||||
$subjects[$id]['phone'] = true;
|
||||
|
||||
|
||||
|
||||
|
||||
/* [3] On récupére la liste des sujets pour FACEBOOK
|
||||
=========================================================*/
|
||||
/* (1) On initialise et ouvre la bd */
|
||||
$db = new lightdb('facebook_db', __ROOT__.'/src/dynamic/');
|
||||
$ids = array_keys( $db->index() );
|
||||
$db->close();
|
||||
|
||||
/* (2) Si un des sujets de 'survey' est dans FACBEOOK, on ajoute la mention */
|
||||
foreach($subjects as $id=>$data)
|
||||
if( in_array($id, $ids) ) // Si dans facebook
|
||||
$subjects[$id]['facebook'] = true;
|
||||
|
||||
|
||||
|
||||
|
||||
/* [4] Retour des données
|
||||
=========================================================*/
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'results' => $subjects
|
||||
);
|
||||
];
|
||||
|
||||
}
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace manager\module;
|
||||
use \manager\Database;
|
||||
namespace api\module;
|
||||
use \database\core\DatabaseDriver;
|
||||
use \api\core\Checker;
|
||||
use \manager\sessionManager;
|
||||
use \manager\ManagerError;
|
||||
use \manager\Repo;
|
||||
use \database\core\Repo;
|
||||
|
||||
|
||||
|
||||
|
@ -22,15 +23,15 @@
|
|||
|
||||
/* [1] Suppression du token
|
||||
=========================================================*/
|
||||
$remove = new Repo('token/remove', array($token_id));
|
||||
$remove = new Repo('token/remove', [$token_id]);
|
||||
|
||||
// On renvoie une erreur si une erreur intervient pendant la suppression
|
||||
if( $remove->answer() === false ) return array('ModuleError' => ManagerError::ModuleError);
|
||||
if( $remove->answer() === false ) return ['ModuleError' => ManagerError::ModuleError];
|
||||
|
||||
|
||||
/* [n] Gestion du retour quand tout est normal
|
||||
=========================================================*/
|
||||
return array( 'ModuleError' => ManagerError::Success );
|
||||
return [ 'ModuleError' => ManagerError::Success ];
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,38 +53,31 @@
|
|||
|
||||
/* [0] Verification des INPUT
|
||||
=========================================================*/
|
||||
if( !Database::check('varchar(3,50)', $name) || !Database::check('id', $duration) )
|
||||
return array('ModuleError' => ManagerError::ParamError); // erreur de parametre
|
||||
if( !Checker::run('varchar(3,50)', $name) || !Checker::run('id', $duration) )
|
||||
return ['ModuleError' => ManagerError::ParamError]; // erreur de parametre
|
||||
|
||||
|
||||
/* [1] On cree le token et recupere son id ou FAUX
|
||||
=========================================================*/
|
||||
$create = new Repo('token/generate', array($name, $duration));
|
||||
$create = new Repo('token/generate', [$name, $duration]);
|
||||
$created = $create->answer();
|
||||
|
||||
|
||||
// Si erreur de creation
|
||||
if( $created === false ) return array('ModuleError' => ManagerError::ModuleError );
|
||||
if( $created === false ) return ['ModuleError' => ManagerError::ModuleError ];
|
||||
|
||||
|
||||
/* [2] Gestion du retour
|
||||
=========================================================*/
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'id_token' => $created
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace manager\module;
|
||||
use \manager\Database;
|
||||
namespace api\module;
|
||||
use \database\core\DatabaseDriver;
|
||||
use \manager\sessionManager;
|
||||
use \manager\ModuleRequest;
|
||||
use \api\core\ModuleRequest;
|
||||
use \manager\ManagerError;
|
||||
use \manager\Repo;
|
||||
use \database\core\Repo;
|
||||
|
||||
class upload{
|
||||
|
||||
|
@ -20,35 +20,35 @@
|
|||
*/
|
||||
private static function getPath($prefix, $extension){
|
||||
// Si on est pas connecté, on retourne une erreur -> impossible via token
|
||||
if( !connected() ) return array( 'error' => ManagerError::PermissionError );
|
||||
if( !connected() ) return [ 'error' => ManagerError::PermissionError ];
|
||||
|
||||
/* [1] Chargement du fichier de config
|
||||
=========================================================*/
|
||||
/* (1) On récupère le fichier */
|
||||
$uploadAuth = file_get_contents(__ROOT__.'/config/upload-auth.json');
|
||||
$uploadAuth = file_get_contents(__CONFIG__.'/upload-auth.json');
|
||||
|
||||
/* (2) Si une erreur pour le fichier de conf */
|
||||
if( $uploadAuth === false )
|
||||
return array( 'error' => ManagerError::UnreachableResource );
|
||||
return [ 'error' => ManagerError::UnreachableResource ];
|
||||
|
||||
/* (3) On récupère la config sous forme de tableau */
|
||||
$uploadAuth = json_decode( $uploadAuth, true );
|
||||
|
||||
/* (4) Si erreur de PARSAGE */
|
||||
if( !is_array($uploadAuth) )
|
||||
return array( 'error' => ManagerError::ParsingFailed );
|
||||
return [ 'error' => ManagerError::ParsingFailed ];
|
||||
|
||||
|
||||
/* [2] Vérification du préfixe
|
||||
=========================================================*/
|
||||
// Si le préfixe n'est pas dans la config -> erreur
|
||||
if( !in_array($prefix, $uploadAuth['directories']) )
|
||||
return array( 'error' => ManagerError::UploadError );
|
||||
return [ 'error' => ManagerError::UploadError ];
|
||||
|
||||
/* [3] Construction du chemin
|
||||
=========================================================*/
|
||||
/* (1) On construit le chemin */
|
||||
$path = __ROOT__.$uploadAuth['root'].'/'.$prefix.'/';
|
||||
$path = __PUBLIC__.$uploadAuth['root'].'/'.$prefix.'/';
|
||||
|
||||
/* (2) On crée le dossier s'il n'existe pas */
|
||||
if ( !file_exists($path) ) mkdir($path, 0775, true);
|
||||
|
@ -62,16 +62,14 @@
|
|||
|
||||
/* [4] Gestion du retour
|
||||
=========================================================*/
|
||||
return array(
|
||||
return [
|
||||
'error' => ManagerError::Success,
|
||||
'path' => $path.$fileName
|
||||
);
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* EFFECTUE UN UPLOAD D'UN fichier
|
||||
*
|
||||
* @prefix<String> Préfixe (dossier parent) du fichier
|
||||
|
@ -84,8 +82,8 @@
|
|||
*/
|
||||
private static function simpleFile($prefix, $extension, $file, $tester){
|
||||
// Si on est pas connecté, on retourne une erreur -> impossible via token
|
||||
if( !connected() ) return array( 'error' => ManagerError::PermissionError );
|
||||
if( !file_exists($file['tmp_name']) ) return array( 'error' => ManagerError::UnreachableResource );
|
||||
if( !connected() ) return ManagerError::PermissionError;
|
||||
if( !file_exists($file['tmp_name']) ) return ManagerError::UnreachableResource;
|
||||
|
||||
|
||||
/* [1] On récupère le chemin du fichier à créer et vérifie le dossier
|
||||
|
@ -125,97 +123,6 @@
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* IMPORT D'UN JOURNAL D'APPEL
|
||||
*
|
||||
* @file<FILE> Pointeur vers $_FILES['']
|
||||
*
|
||||
*/
|
||||
public static function call_log($params){
|
||||
extract($params);
|
||||
|
||||
/* [1] Gestion de l'upload du fichier et de la vérification du format
|
||||
=========================================================*/
|
||||
$uploadError = self::simpleFile(
|
||||
'call_log', // nom du dossier d'upload
|
||||
'xml', // format du fichier
|
||||
$file, // Fichier lui-même
|
||||
function($content){ // Vérification du format du fichier
|
||||
/* (1) Vérification du format XML */
|
||||
$xml = simplexml_load_string($content);
|
||||
if( $xml === false ) return false; // Si erreur de parsage, on retourne une erreur
|
||||
|
||||
/* (2) Vérification du contenu (balises) */
|
||||
// Doit avoir des Item(s)
|
||||
if( !isset($xml->Item) )
|
||||
return false;
|
||||
|
||||
// Vérification de tous les champs
|
||||
foreach($xml->Item as $log){
|
||||
$checkAttributes = isset($log['Number']);
|
||||
$checkAttributes = $checkAttributes && isset($log['Name']);
|
||||
$checkAttributes = $checkAttributes && isset($log['Date']);
|
||||
$checkAttributes = $checkAttributes && isset($log['Duration']);
|
||||
$checkAttributes = $checkAttributes && isset($log['Direction']);
|
||||
$checkAttributes = $checkAttributes && isset($log['Type']);
|
||||
|
||||
// Si on a pas tout les champs, on retourne une erreur
|
||||
if( !$checkAttributes )
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (3) Si tout s'est bien passé, le format est bon */
|
||||
return true;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
/* [2] Gestion du retour (unserialize)
|
||||
=========================================================*/
|
||||
/* (1) Si erreur d'upload, on la renvoie */
|
||||
if( $uploadError != ManagerError::Success )
|
||||
return array( 'ModuleError' => $uploadError );
|
||||
|
||||
/* (2) Gestion du parsage (unserialize) du journal d'appel */
|
||||
$request = new ModuleRequest('call_log/unserialize', array() );
|
||||
$response = $request->dispatch();
|
||||
|
||||
/* (3) Restitution du retour de `unserialize` */
|
||||
return array_merge(
|
||||
array( 'ModuleError' => $response->error ),
|
||||
$response->getAll()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* IMPORT D'UNE SAUVEGARDE DE FORMULAIRE LOCAL
|
||||
*
|
||||
* @file<FILE> Pointeur vers $_FILES['']
|
||||
|
@ -250,8 +157,8 @@
|
|||
|
||||
|
||||
/* (3) Vérification du sujet */
|
||||
$checkSubject = isset($json['subject']['tmp_id']) && ( is_string($json['subject']['tmp_id']) || is_null($json['subject']['tmp_id']) );
|
||||
$checkSubject = $checkSubject && isset($json['subject']['subject_id']) && is_numeric($json['subject']['subject_id']);
|
||||
$checkSubject = isset($json['subject']['subject_id']) && is_numeric($json['subject']['subject_id']);
|
||||
$checkSubject = $checkSubject && isset($json['subject']['coords']) && is_string($json['subject']['coords']);
|
||||
|
||||
// Erreur des attributs du sujet incorrects ou manquants
|
||||
if( !$checkSubject )
|
||||
|
@ -261,11 +168,15 @@
|
|||
/* (4) Vérification des contacts */
|
||||
foreach($json['contacts'] as $contact){
|
||||
$checkContact = isset($contact['uid']) && is_numeric($contact['uid']);
|
||||
$checkContact = $checkContact && isset($contact['username']) && is_string($contact['username']);
|
||||
$checkContact = $checkContact && isset($contact['sms']) && is_numeric($contact['sms']);
|
||||
$checkContact = $checkContact && isset($contact['call']) && is_numeric($contact['call']);
|
||||
$checkContact = $checkContact && isset($contact['countsms']) && is_numeric($contact['countsms']);
|
||||
$checkContact = $checkContact && isset($contact['countcall']) && is_numeric($contact['countcall']);
|
||||
$checkContact = $checkContact && (
|
||||
( isset($contact['username']) && is_string($contact['username']) )
|
||||
||
|
||||
( isset($contact['existing']) && is_numeric($contact['existing']) )
|
||||
);
|
||||
// $checkContact = $checkContact && isset($contact['sms']) && is_numeric($contact['sms']);
|
||||
// $checkContact = $checkContact && isset($contact['call']) && is_numeric($contact['call']);
|
||||
// $checkContact = $checkContact && isset($contact['countsms']) && is_numeric($contact['countsms']);
|
||||
// $checkContact = $checkContact && isset($contact['countcall']) && is_numeric($contact['countcall']);
|
||||
|
||||
// Si erreur des attributs du contact incorrects ou manquants
|
||||
if( !$checkContact )
|
||||
|
@ -275,12 +186,13 @@
|
|||
|
||||
/* (5) Vérification des mini-fiches */
|
||||
foreach($json['mini'] as $mini){
|
||||
$checkMini = isset($mini['uid']) && is_numeric($mini['uid']);
|
||||
$checkMini = $checkMini && isset($mini['sexe']) && is_numeric($mini['sexe']);
|
||||
$checkMini = $checkMini && isset($mini['age']) && is_string($mini['age']);
|
||||
$checkMini = $checkMini && isset($mini['studies']) && is_string($mini['studies']);
|
||||
$checkMini = $checkMini && isset($mini['loc']) && is_string($mini['loc']);
|
||||
$checkMini = $checkMini && isset($mini['unknown']) && is_bool($mini['unknown']);
|
||||
$checkMini = isset($mini['uid']) && is_numeric($mini['uid']);
|
||||
$checkMini = $checkMini && isset($mini['contact']) && is_numeric($mini['contact']);
|
||||
$checkMini = $checkMini && isset($mini['sexe']) && is_numeric($mini['sexe']);
|
||||
$checkMini = $checkMini && isset($mini['age']) && is_string($mini['age']);
|
||||
$checkMini = $checkMini && isset($mini['studies']) && is_string($mini['studies']);
|
||||
$checkMini = $checkMini && isset($mini['loc']) && is_string($mini['loc']);
|
||||
$checkMini = $checkMini && isset($mini['unknown']) && is_bool($mini['unknown']);
|
||||
|
||||
// Si erreur des attributs des mini-fiches incorrects ou manquants
|
||||
if( !$checkMini )
|
||||
|
@ -288,18 +200,21 @@
|
|||
}
|
||||
|
||||
|
||||
|
||||
/* (6) Vérification des fiches */
|
||||
foreach($json['fiches'] as $fiches){
|
||||
$checkFiche = isset($fiches['uid']) && is_numeric($fiches['uid']);
|
||||
$checkFiche = $checkFiche && isset($fiches['contact']) && is_numeric($fiches['contact']);
|
||||
$checkFiche = $checkFiche && isset($fiches['sexe']) && is_numeric($fiches['sexe']);
|
||||
$checkFiche = $checkFiche && isset($fiches['age']) && is_string($fiches['age']);
|
||||
$checkFiche = $checkFiche && isset($fiches['interest']) && is_numeric($fiches['interest']);
|
||||
$checkFiche = $checkFiche && isset($fiches['relmark']) && is_numeric($fiches['relmark']);
|
||||
$checkFiche = $checkFiche && isset($fiches['job']) && is_string($fiches['job']);
|
||||
$checkFiche = $checkFiche && isset($fiches['loc']) && (is_numeric($fiches['loc']) || $fiches['loc']=='.');
|
||||
$checkFiche = $checkFiche && isset($fiches['studies']) && is_string($fiches['studies']);
|
||||
$checkFiche = $checkFiche && isset($fiches['famsit']) && is_numeric($fiches['famsit']);
|
||||
$checkFiche = $checkFiche && isset($fiches['reltype']) && is_numeric($fiches['reltype']);
|
||||
$checkFiche = $checkFiche && isset($fiches['medsoc']) && is_numeric($fiches['medsoc']);
|
||||
$checkFiche = $checkFiche && isset($fiches['medrel']) && is_numeric($fiches['medrel']);
|
||||
$checkFiche = $checkFiche && isset($fiches['reltypeSpecial']) && is_string($fiches['reltypeSpecial']);
|
||||
$checkFiche = $checkFiche && isset($fiches['city']) && is_string($fiches['city']);
|
||||
$checkFiche = $checkFiche && isset($fiches['cp']) && is_string($fiches['cp']);
|
||||
|
@ -307,6 +222,7 @@
|
|||
$checkFiche = $checkFiche && isset($fiches['context']) && is_numeric($fiches['context']);
|
||||
$checkFiche = $checkFiche && isset($fiches['contextSpecial']) && is_array($fiches['contextSpecial']);
|
||||
$checkFiche = $checkFiche && isset($fiches['freq']) && is_array($fiches['freq']);
|
||||
$checkFiche = $checkFiche && isset($fiches['irlfreq']) && is_array($fiches['irlfreq']);
|
||||
$checkFiche = $checkFiche && isset($fiches['connect']) && is_array($fiches['connect']);
|
||||
$checkFiche = $checkFiche && isset($fiches['connectSpecial']) && is_array($fiches['connectSpecial']);
|
||||
|
||||
|
@ -341,13 +257,13 @@
|
|||
=========================================================*/
|
||||
/* (1) Si erreur d'upload, on la renvoie */
|
||||
if( $uploadError != ManagerError::Success )
|
||||
return array( 'ModuleError' => $uploadError );
|
||||
return [ 'ModuleError' => $uploadError ];
|
||||
|
||||
/* (2) On récupère le fichier */
|
||||
$responsePath = self::getPath('local_data', 'json');
|
||||
// Si erreur, on la renvoie
|
||||
if( $responsePath['error'] != ManagerError::Success )
|
||||
return array( 'ModuleError' => $responsePath['error'] );
|
||||
return [ 'ModuleError' => $responsePath['error'] ];
|
||||
|
||||
// On lit le fichier
|
||||
$json = json_decode( file_get_contents($responsePath['path']), true );
|
||||
|
@ -357,131 +273,10 @@
|
|||
return ManagerError::ParsingFailed;
|
||||
|
||||
/* (3) On renvoie le contenu du fichier */
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'local_data' => $json
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* CONVERTISSEUR .txt de iExplorer vers .xml de Call Log
|
||||
*
|
||||
* @file<FILE> Pointeur vers $_FILES['']
|
||||
*
|
||||
*/
|
||||
public static function iexplorer_convert($params){
|
||||
extract($params);
|
||||
|
||||
/* [1] Gestion de l'upload du fichier et de la vérification du format
|
||||
=========================================================*/
|
||||
$uploadError = self::simpleFile(
|
||||
'convert_iexplorer',// nom du dossier d'upload
|
||||
'txt', // format du fichier
|
||||
$file, // Fichier lui-même
|
||||
function($content){
|
||||
$lines = explode("\n", $content);
|
||||
|
||||
foreach($lines as $l=>$line)
|
||||
if( strlen($line) > 0 && !preg_match('/^([\w\(\):\.@-]+(?: {1,3}[\w\(\):\.@-]+)*) +([\w\(\):\.@-]+(?: {1,3}[\w\(\):\.@-]+)*) +([\w\(\):\.@-]+(?: {1,3}[\w\(\):\.@-]+)*) +([\w\(\):\.@-]+(?: {1,3}[\w\(\):\.@-]+)*) *$/u', $line) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
);
|
||||
|
||||
/* (1) Si erreur d'upload, on la renvoie */
|
||||
if( $uploadError != ManagerError::Success )
|
||||
return array( 'ModuleError' => $uploadError );
|
||||
|
||||
|
||||
|
||||
/* [2] On récupère les colonnes avec la premiére ligne
|
||||
=========================================================*/
|
||||
/* (1) On met un handler sur le fichier pour le lire */
|
||||
$path = __ROOT__."/src/upload/convert_iexplorer/".$_SESSION['username'].".txt";
|
||||
|
||||
$handler = new \SplFileObject($path, 'r');
|
||||
|
||||
/* (2) On récupère pour chaque colonne, la position dans le chaine, et la valeur */
|
||||
$data = array();
|
||||
$lineCount = 0;
|
||||
while( !$handler->eof() ){
|
||||
$line = $handler->fgets();
|
||||
|
||||
/* (1) Si première ligne, c'est les intitulés */
|
||||
if( $lineCount == 0 ){
|
||||
// Si erreur dans les intitulés, on retourne une erreur
|
||||
if( !preg_match('/^([\w\(\):\.@-]+(?: [\w\(\):\.@-]+)*) +([\w\(\):\.@-]+(?: [\w\(\):\.@-]+)*) +([\w\(\):\.@-]+(?: [\w\(\):\.@-]+)*) +([\w\(\):\.@-]+(?: [\w\(\):\.@-]+)*) *$/u', $line, $matches) )
|
||||
return array( 'ModuleError' => ManagerError::FormatError );
|
||||
|
||||
// On récupère les colonnes
|
||||
$columns = array_slice($matches, 1);
|
||||
|
||||
// On récupére les positions des colonnes
|
||||
$colpos = array();
|
||||
foreach($columns as $column)
|
||||
array_push($colpos, strpos($line, $column));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (2) S'il reconnait pas la ligne, on passe à la suivante */
|
||||
if( !preg_match('/^([\w\(\):\.@-]+(?: {1,3}[\w\(\):\.@-]+)*) +([\w\(\):\.@-]+(?: {1,3}[\w\(\):\.@-]+)*) +([\w\(\):\.@-]+(?: {1,3}[\w\(\):\.@-]+)*) +([\w\(\):\.@-]+(?: {1,3}[\w\(\):\.@-]+)*) *$/u', $line, $matches) )
|
||||
continue;
|
||||
|
||||
/* (3) On enregistre les données sinon */
|
||||
$cur = array();
|
||||
foreach($columns as $c=>$column)
|
||||
$cur[$column] = $matches[$c+1];
|
||||
|
||||
array_push($data, $cur);
|
||||
|
||||
|
||||
$lineCount++;
|
||||
}
|
||||
|
||||
|
||||
$handler = null;
|
||||
|
||||
/* (3) Restitution du retour de `unserialize` */
|
||||
return array(
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'data' => $data
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace manager\module;
|
||||
namespace api\module;
|
||||
use \manager\sessionManager;
|
||||
use \manager\Database;
|
||||
use \database\core\DatabaseDriver;
|
||||
use \manager\ManagerError;
|
||||
use \manager\Repo;
|
||||
use \database\core\Repo;
|
||||
|
||||
class user{
|
||||
|
||||
|
@ -22,26 +22,25 @@
|
|||
|
||||
/* [1] On verifie les logins
|
||||
=========================================================*/
|
||||
$check = new Repo('user/login', array($login, $password));
|
||||
$check = new Repo('user/login', [$login, $password]);
|
||||
$user = $check->answer();
|
||||
|
||||
// Si le login/password est incorrect, on retourne une erreur
|
||||
if( $user === false ) return array('ModuleError' => ManagerError::ModuleError);
|
||||
if( $user === false ) return ['ModuleError' => ManagerError::ModuleError];
|
||||
|
||||
|
||||
/* [2] Gestion du login
|
||||
=========================================================*/
|
||||
$_SESSION['userid'] = $user['id_user'];
|
||||
$_SESSION['username'] = $user['login'];
|
||||
$_SESSION['permission'] = explode( ',', str_replace(' ', '', $user['permission']) );
|
||||
$_SESSION['permission'] = ['admin'];
|
||||
|
||||
/* [4] Retour de l'id user
|
||||
=========================================================*/
|
||||
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'id_user' => $user['id_user']
|
||||
);
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
|
@ -53,7 +52,9 @@
|
|||
public static function logout(){
|
||||
$_SESSION['userid'] = null;
|
||||
$_SESSION['username'] = null;
|
||||
$_SESSION['permission'] = array();
|
||||
$_SESSION['permission'] = [];
|
||||
|
||||
return ['ModuleError' => ManagerError::Success];
|
||||
}
|
||||
|
||||
|
||||
|
@ -71,23 +72,18 @@
|
|||
|
||||
/* [1] On recupere les donnees de l'utilisateur
|
||||
=========================================================*/
|
||||
$getUser = new Repo('user/getById', array($id_user));
|
||||
$getUser = new Repo('user/getById', [$id_user]);
|
||||
$user_data = $getUser->answer();
|
||||
|
||||
// Si aucun utilisateur n'est trouve
|
||||
if( count($user_data) == 0 ) return array('ModuleError' => ManagerError::ModuleError);
|
||||
|
||||
|
||||
/* [2] On met les permissions au bon format (string -> array)
|
||||
=========================================================*/
|
||||
$user_data[0]['permission'] = explode( ',', str_replace(' ', '', $user_data[0]['permission']) );
|
||||
if( count($user_data) == 0 ) return ['ModuleError' => ManagerError::ModuleError];
|
||||
|
||||
/* [3] Gestion du retour
|
||||
=========================================================*/
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'user' => $user_data[0]
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,19 +101,14 @@
|
|||
$users_data = $getUsers->answer();
|
||||
|
||||
// Si aucun utilisateur n'est trouve
|
||||
if( $users_data === false ) return array('ModuleError' => ManagerError::ModuleError);
|
||||
|
||||
/* [2] On met les permissions au bon format (string -> array)
|
||||
=========================================================*/
|
||||
foreach($users_data as $i=>$user)
|
||||
$users_data[$i]['permission'] = explode( ',', str_replace(' ', '', $user['permission']) );
|
||||
if( $users_data === false ) return ['ModuleError' => ManagerError::ModuleError];
|
||||
|
||||
/* [3] Gestion du retour
|
||||
=========================================================*/
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'users' => $users_data
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -129,8 +120,6 @@
|
|||
* @login<String> Login (identifiant) de l'utilisateur
|
||||
* @password<String> Password de l'utilisateur
|
||||
* @mail<String> Adresse mail de l'utilisateur
|
||||
* @reference<int> Reference vers une Personne (sinon NULL)
|
||||
* @permissions<String> Liste des permissions de l'utilisateur
|
||||
*
|
||||
* @return id_user<int> Renvoie l'id de l'utilisateur cree
|
||||
*
|
||||
|
@ -141,24 +130,22 @@
|
|||
/* [0] Verification et formattage des INPUT
|
||||
=========================================================*/
|
||||
$password = sessionManager::sha1($password);
|
||||
$reference = (is_numeric($reference)) ? (int) $reference : null;
|
||||
$permission = ($permission=='admin') ? 'admin' : 'subject';
|
||||
|
||||
|
||||
/* [1] Creation de l'utilisateur
|
||||
=========================================================*/
|
||||
$create = new Repo('user/create', array($login, $password, $mail, $reference, $permission));
|
||||
$create = new Repo('user/create', [$login, $password, $mail]);
|
||||
$created_id = $create->answer();
|
||||
|
||||
// Si erreur de creation, on retourne une erreur
|
||||
if( $created_id === false ) return array( 'ModuleError' => ManagerError::ModuleError );
|
||||
if( $created_id === false ) return [ 'ModuleError' => ManagerError::ModuleError ];
|
||||
|
||||
/* [2] Gestion du retour
|
||||
=========================================================*/
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'id_user' => $created_id
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -175,30 +162,30 @@
|
|||
|
||||
/* [1] On verifie que l'utilisateur existe
|
||||
=========================================================*/
|
||||
$exists = new Repo('user/getById', array($id_user));
|
||||
$exists = new Repo('user/getById', [$id_user]);
|
||||
$exists_status = $exists->answer();
|
||||
|
||||
// Si l'utilisateur n'existe pas, on retourne une erreur
|
||||
if( count($exists_status) == 0 ) return array( 'ModuleError' => ManagerError::ModuleError );
|
||||
if( count($exists_status) == 0 ) return [ 'ModuleError' => ManagerError::ModuleError ];
|
||||
|
||||
/* [2] Suppression de l'utilisateur
|
||||
=========================================================*/
|
||||
$remove = new Repo('user/remove', array($id_user));
|
||||
$remove = new Repo('user/remove', [$id_user]);
|
||||
$remove_status = $remove->answer();
|
||||
|
||||
|
||||
/* [3] On verifie que l'utilisateur est bien supprime
|
||||
=========================================================*/
|
||||
$removed = new Repo('user/getById', array($id_user));
|
||||
$removed = new Repo('user/getById', [$id_user]);
|
||||
$removed_status = $removed->answer();
|
||||
|
||||
// Si l'utilisateur n'existe pas, on retourne une erreur
|
||||
if( count($removed_status) > 0 ) return array( 'ModuleError' => ManagerError::ModuleError );
|
||||
if( count($removed_status) > 0 ) return [ 'ModuleError' => ManagerError::ModuleError ];
|
||||
|
||||
|
||||
/* [4] Gestion du retour
|
||||
=========================================================*/
|
||||
return array( 'ModuleError' => ManagerError::Success );
|
||||
return [ 'ModuleError' => ManagerError::Success ];
|
||||
}
|
||||
|
||||
// [x] "login",
|
|
@ -1,86 +1,172 @@
|
|||
<?php
|
||||
|
||||
namespace manager;
|
||||
namespace database\core;
|
||||
use \manager\ManagerError;
|
||||
|
||||
|
||||
class DataBase{
|
||||
class DataBaseDriver{
|
||||
|
||||
/* ATTRIBUTS STATIQUES */
|
||||
public static $config_path = array(
|
||||
'local' => __ROOT__.'/config/database-local.json',
|
||||
'remote' => __ROOT__.'/config/database.json'
|
||||
);
|
||||
/* STATIC ATTRIBUTES */
|
||||
private static function conf(){
|
||||
// YOUR CONFIGURATION BEHIND
|
||||
$path = __CONFIG__.'/database-driver.json';
|
||||
|
||||
private static $pdo;
|
||||
private static $instance;
|
||||
/* (1) Checks the file */
|
||||
if( !is_file($path) )
|
||||
return [];
|
||||
|
||||
/* (2) Checks json */
|
||||
$parsed = json_decode( file_get_contents($path), true );
|
||||
|
||||
if( !is_array($parsed) )
|
||||
return [];
|
||||
|
||||
/* (3) Returns configuration */
|
||||
return $parsed;
|
||||
}
|
||||
|
||||
|
||||
/* ATTRIBUTS */
|
||||
private static $path; // Databases configurations files
|
||||
private static $config; // PDO configurations
|
||||
private static $instance = []; // Database driver instance list
|
||||
|
||||
public $error;
|
||||
|
||||
/* ATTRIBUTES */
|
||||
private $host;
|
||||
private $dbname;
|
||||
private $username;
|
||||
private $password;
|
||||
|
||||
public static $error;
|
||||
private $pdo;
|
||||
|
||||
|
||||
public function __construct($host, $dbname, $username, $password){
|
||||
|
||||
/* CONSTRUCTOR OF A DATABASE DRIVER
|
||||
*
|
||||
* @host<String> Database Server's host
|
||||
* @dbname<String> Database name
|
||||
* @username<String> Database username
|
||||
* @password<String> Database password
|
||||
*
|
||||
*/
|
||||
private function __construct($host, $dbname, $username, $password){
|
||||
/* (2) Stores configuration */
|
||||
$this->host = $host;
|
||||
$this->dbname = $dbname;
|
||||
$this->username = $username;
|
||||
$this->password = $password;
|
||||
|
||||
try{
|
||||
self::$pdo = new \PDO('mysql:host='.$this->host.';dbname='.$this->dbname, $this->username, $this->password);
|
||||
|
||||
$this->pdo = new \PDO('mysql:host='.$this->host.';dbname='.$this->dbname, $this->username, $this->password);
|
||||
|
||||
// On signale que tout s'est bien passe
|
||||
self::$error = ManagerError::Success;
|
||||
$this->error = ManagerError::Success;
|
||||
|
||||
}catch(Exception $e){
|
||||
// On signale qu'il y a une erreur
|
||||
self::$error = ManagerError::PDOConnection;
|
||||
$this->error = ManagerError::PDOConnection;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* retourne une instance de la classe */
|
||||
public static function getInstance(){
|
||||
if( self::$instance == null || self::$error != ManagerError::Success ){ // Si aucune instance existante OU erreur de connection
|
||||
|
||||
// chargement de la configuration du server SQL
|
||||
/************************************************
|
||||
**** Multiton Management (static) ****
|
||||
************************************************/
|
||||
|
||||
/* ADDS A NEW CONNECTION
|
||||
*
|
||||
* @label<String> [optional] Database Label
|
||||
*
|
||||
* @return status<Boolean> If added successfully
|
||||
*
|
||||
*/
|
||||
private static function add($label=null){
|
||||
$conf = self::conf();
|
||||
|
||||
/* [1] Default values
|
||||
=========================================================*/
|
||||
/* (1) If label isn't given */
|
||||
is_null($label) && ($label = 'default');
|
||||
|
||||
/* (2) If label and no path */
|
||||
if( $label !== 'default' && !isset($conf[$label]) )
|
||||
return false;
|
||||
|
||||
|
||||
/* [3] Instanciates the driver
|
||||
=========================================================*/
|
||||
try{
|
||||
|
||||
/* (1) If local -> instanciates with local configuration */
|
||||
if( !checkdnsrr($_SERVER['SERVER_NAME'], 'NS') )
|
||||
$conf = json_decode( file_get_contents(self::$config_path['local']), true );
|
||||
self::$instance[$label] = new DatabaseDriver($conf[$label]['local']['host'], $conf[$label]['local']['dbname'], $conf[$label]['local']['user'], $conf[$label]['local']['password']);
|
||||
/* (2) If Remote -> instanciates with Remote configuration */
|
||||
else
|
||||
$conf = json_decode( file_get_contents(self::$config_path['remote']), true );
|
||||
self::$instance[$label] = new DatabaseDriver($conf[$label]['remote']['host'], $conf[$label]['remote']['dbname'], $conf[$label]['remote']['user'], $conf[$label]['remote']['password']);
|
||||
|
||||
// creation de l'instance en fonction des parametres
|
||||
self::$instance = new DataBase($conf['host'], $conf['dbname'], $conf['user'], $conf['password']);
|
||||
return true;
|
||||
|
||||
}catch(\Exception $e){
|
||||
|
||||
/* (3) If fails */
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
|
||||
/* GET A DATABASE DRIVER INSTANCE
|
||||
*
|
||||
* @label<String> [optional] Driver's label
|
||||
*
|
||||
* @return driver<Database> Multiton
|
||||
*
|
||||
*/
|
||||
public static function get($label=null){
|
||||
$conf = self::conf();
|
||||
|
||||
/* [1] Checks arguments
|
||||
=========================================================*/
|
||||
/* (1) Label default value */
|
||||
is_null($label) && ($label = 'default');
|
||||
|
||||
/* (2) If no label, or unknown label */
|
||||
if( is_null($label) || !isset(self::$instance[$label]) ){
|
||||
|
||||
/* (2.1) Try to add the configuration if exists */
|
||||
if( isset($conf[$label]) ){
|
||||
self::add($label);
|
||||
return self::get($label);
|
||||
}
|
||||
|
||||
|
||||
throw new \Exception('Database @label is incorrect.');
|
||||
}
|
||||
|
||||
|
||||
/* [2] Returns instance
|
||||
=========================================================*/
|
||||
return self::$instance[$label];
|
||||
}
|
||||
|
||||
|
||||
/* retourne la connection statique */
|
||||
public static function getPDO(){
|
||||
$instance = self::getInstance();
|
||||
public static function getPDO($label=null){
|
||||
$instance = self::get($label);
|
||||
|
||||
return self::$pdo;
|
||||
return $instance->pdo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function getConfig(){
|
||||
return array(
|
||||
return [
|
||||
'host' => $this->host,
|
||||
'dbname' => $this->dbname,
|
||||
'username' => $this->username
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,7 +196,7 @@
|
|||
public static function delNumeric($fetchData, $oneDimension=false){
|
||||
// On quitte si ce n'est pas un tableau
|
||||
if( !is_array($fetchData) )
|
||||
return array();
|
||||
return [];
|
||||
|
||||
$nextEquivalent = false; // Vaut VRAI si le prochain est peut-etre un equivalent numerique
|
||||
|
||||
|
@ -122,8 +208,10 @@
|
|||
for( $i = 0 ; $i < count($fetchData) ; $i++ ) // pour tout les utilisateurs
|
||||
foreach($fetchData[$i] as $col => $val){ // pour toutes les entrées
|
||||
|
||||
if( !\mb_detect_encoding($val, 'UTF-8') )
|
||||
if( \mb_detect_encoding($val) === 'UTF-8' )
|
||||
$fetchData[$i][$col] = utf8_encode($val);
|
||||
else
|
||||
$fetchData[$i][$col] = utf8_encode(utf8_decode($val));
|
||||
|
||||
if( is_int($col) ){ // Si indice numerique
|
||||
if( $nextEquivalent ) // Si suit un indice textuel
|
||||
|
@ -143,8 +231,10 @@
|
|||
// on supprime les doublons des entrées (indice numérique)
|
||||
foreach($fetchData as $i=>$val){ // pour toutes les entrées
|
||||
|
||||
if( !\mb_detect_encoding($val, 'UTF-8') )
|
||||
if( \mb_detect_encoding($val) === 'UTF-8' )
|
||||
$fetchData[$i] = utf8_encode($val);
|
||||
else
|
||||
$fetchData[$i] = utf8_encode(utf8_decode($val));
|
||||
|
||||
if( is_int($i) ){ // Si indice numerique
|
||||
if( $nextEquivalent ) // Si suit un indice textuel
|
||||
|
@ -164,132 +254,6 @@
|
|||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// _ __ _ _ _
|
||||
// __ _____ _ __(_)/ _(_) ___ __ _| |_(_) ___ _ __ ___
|
||||
// \ \ / / _ \ '__| | |_| |/ __/ _` | __| |/ _ \| '_ \/ __|
|
||||
// \ V / __/ | | | _| | (_| (_| | |_| | (_) | | | \__ \
|
||||
// \_/ \___|_| |_|_| |_|\___\__,_|\__|_|\___/|_| |_|___/
|
||||
//
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/* VERIFICATIONS DES TYPES UTILES GENERIQUES
|
||||
*
|
||||
* @type<String> Type que l'on veut verifier
|
||||
* @value<mixed*> Valeur a verifier
|
||||
*
|
||||
* @return match<Boolean> Retourne si oui ou non la valeur @value est du bon type @type
|
||||
*
|
||||
*/
|
||||
public static function check($type, $value){
|
||||
$checker = true;
|
||||
|
||||
/* [0] On verifie que $value n'est pas nul
|
||||
=========================================================*/
|
||||
if( is_null($value) ) return false;
|
||||
|
||||
|
||||
|
||||
/* [1] Si de type VARCHAR(min, max)
|
||||
=========================================================*/
|
||||
if( preg_match('/^varchar\((\d+), ?(\d+)\)$/', $type, $match) ){
|
||||
// On recupere la taille min
|
||||
$min = (int) $match[1];
|
||||
// On recupere la taille max
|
||||
$max = (int) $match[2];
|
||||
|
||||
// On effectue la verification
|
||||
return $checker && is_string($value) && strlen($value) <= $max && strlen($value) >= $min;
|
||||
}
|
||||
|
||||
|
||||
/* [2] Si de type ARRAY(type_elements)
|
||||
=========================================================*/
|
||||
if( preg_match('/^array<(.+)>$/', $type, $match) ){
|
||||
|
||||
// Si c'est pas un tableau on retourne une erreur
|
||||
if( !is_array($value) )
|
||||
return false;
|
||||
|
||||
|
||||
$elements_type = $match[1];
|
||||
|
||||
// On verifie le type pour chaque element
|
||||
foreach($value as $element)
|
||||
// Si erreur dans au moins 1 element, on retourne que c'est incorrect
|
||||
if( !self::check($elements_type, $element) )
|
||||
return false;
|
||||
|
||||
// Si aucune erreur, on retourne que tout est bon
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* [n] Sinon, tous les autres types definis
|
||||
=========================================================*/
|
||||
switch($type){
|
||||
// Quoi que ce soit
|
||||
case 'mixed':
|
||||
return $checker && !is_null($value);
|
||||
break;
|
||||
|
||||
// Entier positif (id dans BDD)
|
||||
case 'id':
|
||||
return $checker && is_numeric($value) && $value <= 2147483647 && $value >= 0;
|
||||
break;
|
||||
|
||||
// String quelconque (peut etre vide)
|
||||
case 'text':
|
||||
return $checker && is_string($value);
|
||||
|
||||
// Adresse mail (255 caracteres max)
|
||||
case 'mail':
|
||||
return $checker && is_string($value) && strlen($value) <= 50 && preg_match('/^[\w\.-]+@[\w\.-]+\.[a-z]{2,4}$/i', $value);
|
||||
break;
|
||||
|
||||
// Hash sha1
|
||||
case 'sha1':
|
||||
return $checker && is_string($value) && preg_match('/^[\da-f]{40}$/i', $value);
|
||||
break;
|
||||
|
||||
// Numéro de téléphone
|
||||
case 'number':
|
||||
return $checker && is_string($value) && preg_match('/^(?:0|\+33 ?|0?0?33 ?|)([1-9] ?(?:[0-9] ?){8})$/i', $value);
|
||||
break;
|
||||
|
||||
// Tableau non vide
|
||||
case 'array':
|
||||
return $checker && is_array($value) && count($value) > 0;
|
||||
break;
|
||||
|
||||
// Boolean
|
||||
case 'boolean':
|
||||
return $checker && is_bool($value);
|
||||
break;
|
||||
|
||||
// Objet non vide
|
||||
case 'object':
|
||||
return $checker && is_object($value) && count((array) $value) > 0;
|
||||
break;
|
||||
|
||||
// Chaine JSON (on vérifie via le parser)
|
||||
case 'json':
|
||||
return $checker && is_string($value) && json_decode($value, true) !== NULL;
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
return $checker;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* FONCTION QUI FORMATTE UN NUMÉRO DE TÉLÉPHONE
|
||||
*
|
||||
|
@ -339,9 +303,9 @@
|
|||
/* [1] On definit les traductions
|
||||
=========================================================*/
|
||||
// Jours de la semaine
|
||||
$days = array("Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche");
|
||||
$days = ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"];
|
||||
// Mois de l'annee
|
||||
$months = array("Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre");
|
||||
$months = ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"];
|
||||
|
||||
/* [2] On recupere le timestamp et les indices
|
||||
=========================================================*/
|
||||
|
@ -352,12 +316,12 @@
|
|||
|
||||
/* [3] On recupere les infos independemment
|
||||
=========================================================*/
|
||||
$result = array(
|
||||
$result = [
|
||||
$days[$daynum], // nom de jour
|
||||
date('j', $time), // jour du mois
|
||||
$months[$monthnum], // nom du mois
|
||||
date('Y', $time), // annee
|
||||
);
|
||||
];
|
||||
|
||||
|
||||
return implode(" ", $result);
|
|
@ -1,13 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace manager;
|
||||
namespace database\core;
|
||||
use \manager\ManagerError;
|
||||
|
||||
|
||||
// FORMAT:
|
||||
//
|
||||
// path: "nomModule/nomMethode"
|
||||
// data1: {donnee1}
|
||||
// data2: {donnee2}
|
||||
// params1: {donnee1}
|
||||
// params2: {donnee2}
|
||||
// ...
|
||||
//
|
||||
//
|
||||
|
@ -17,12 +18,12 @@
|
|||
class Repo{
|
||||
|
||||
// Constantes
|
||||
public static $config_path = __ROOT__.'/config/repositories.json';
|
||||
public static function config_path(){ return __CONFIG__.'/repositories.json'; }
|
||||
|
||||
|
||||
// Attributs prives utiles (initialisation)
|
||||
private $path;
|
||||
private $data;
|
||||
private $params; // Paramètres de la requête
|
||||
private $repositories;
|
||||
|
||||
// Contiendra la reponse a la requete
|
||||
|
@ -38,12 +39,13 @@
|
|||
/* CONSTRUCTEUR D'UNE REQUETE DE MODULE
|
||||
*
|
||||
* @path<String> Chemin de delegation ("repo/methode")
|
||||
* @data<Array> Tableau contenant les parametres utiles au traitement
|
||||
* @params<Array> Tableau contenant les parametres utiles au traitement
|
||||
*
|
||||
* @return status<Boolean> Retourne si oui ou non tout s'est bien passe
|
||||
*
|
||||
*/
|
||||
public function __construct($path=null, $data=null){
|
||||
public function __construct($path=null, $params=null){
|
||||
|
||||
// Si pas parametre manquant, on quitte
|
||||
if( $path == null ){
|
||||
$this->error = ManagerError::MissingPath;
|
||||
|
@ -53,7 +55,7 @@
|
|||
/* [0] On met a jour la configuration
|
||||
=========================================================*/
|
||||
// Modules specifies
|
||||
$this->repositories = json_decode( file_get_contents(self::$config_path), true );
|
||||
$this->repositories = json_decode( file_get_contents(self::config_path()), true );
|
||||
|
||||
// Gestion de l'erreur de parsage
|
||||
if( $this->repositories == null ){
|
||||
|
@ -71,8 +73,8 @@
|
|||
return false; // On retourne FALSE, si erreur
|
||||
}
|
||||
|
||||
// Type de @data (optionnel)
|
||||
$data = (is_array($data)) ? $data : array();
|
||||
// Type de @params (optionnel)
|
||||
$params = (is_array($params)) ? $params : [];
|
||||
|
||||
|
||||
/* [2] Verification du chemin (existence repo+methode)
|
||||
|
@ -84,7 +86,7 @@
|
|||
|
||||
/* [3] Construction de l'objet
|
||||
=========================================================*/
|
||||
$this->data = $data;
|
||||
$this->params = $params;
|
||||
$this->error = ManagerError::Success;
|
||||
|
||||
/* [4] Enregistrement de la reponse
|
||||
|
@ -101,6 +103,9 @@
|
|||
|
||||
|
||||
public function answer(){
|
||||
if( $this->error != ManagerError::Success )
|
||||
return false;
|
||||
|
||||
return $this->answer;
|
||||
}
|
||||
|
||||
|
@ -128,7 +133,7 @@
|
|||
|
||||
/* [3] On amorce la methode
|
||||
=========================================================*/
|
||||
return call_user_func_array( $this->getFunctionCaller(), $this->data );
|
||||
return call_user_func_array( $this->getFunctionCaller(), $this->params );
|
||||
}
|
||||
|
||||
|
||||
|
@ -150,7 +155,7 @@
|
|||
|
||||
// On recupere les donnes de la regex
|
||||
$repository = $matches[1];
|
||||
$method = $matches[2];
|
||||
$method = $matches[2];
|
||||
|
||||
/* [2] Verification de l'existence du repo (conf)
|
||||
=========================================================*/
|
||||
|
@ -170,10 +175,10 @@
|
|||
|
||||
/* [4] Enregistrement du chemin et renvoi de SUCCESS
|
||||
=========================================================*/
|
||||
$this->path = array(
|
||||
$this->path = [
|
||||
'repo' => $repository,
|
||||
'method' => $method
|
||||
);
|
||||
];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -188,7 +193,7 @@
|
|||
*
|
||||
*/
|
||||
private function getFunctionCaller(){
|
||||
return array( '\\manager\\repo\\'.$this->path['repo'], $this->path['method'] );
|
||||
return [ '\\database\\repo\\'.$this->path['repo'], $this->path['method'] ];
|
||||
}
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace manager\repo;
|
||||
use \manager\Database;
|
||||
namespace database\repo;
|
||||
use \database\core\DatabaseDriver;
|
||||
|
||||
class parentRepo{
|
||||
|
||||
|
@ -30,12 +30,12 @@
|
|||
|
||||
/* [2] On charge la liste des colonnes de la table
|
||||
=========================================================*/
|
||||
$getColumns = Database::getPDO()->query('SHOW COLUMNS FROM '.static::table_name());
|
||||
$cols = Database::delNumeric( $getColumns->fetchAll() );
|
||||
$getColumns = DatabaseDriver::getPDO()->query('SHOW COLUMNS FROM '.static::table_name());
|
||||
$cols = DatabaseDriver::delNumeric( $getColumns->fetchAll() );
|
||||
|
||||
$table_columns = array(
|
||||
'_PRIMARY_' => array() // Contiendra les champs de la clé primaire
|
||||
);
|
||||
$table_columns = [
|
||||
'_PRIMARY_' => [] // Contiendra les champs de la clé primaire
|
||||
];
|
||||
|
||||
// On ajoute la liste des colonnes
|
||||
foreach($cols as $column){
|
||||
|
@ -84,7 +84,7 @@
|
|||
$getRequestString .= ' ORDER BY 1 ASC';
|
||||
|
||||
// On prépare la requête
|
||||
$getRequest = Database::getPDO()->prepare($getRequestString);
|
||||
$getRequest = DatabaseDriver::getPDO()->prepare($getRequestString);
|
||||
|
||||
|
||||
/* [5] On exécute la requête
|
||||
|
@ -92,7 +92,7 @@
|
|||
// Si 'getById', on compose la clé primaire
|
||||
if( $getById ){
|
||||
|
||||
$pdo_vars = array();
|
||||
$pdo_vars = [];
|
||||
|
||||
foreach($table_columns['_PRIMARY_'] as $i=>$primary_column)
|
||||
$pdo_vars[':primary'.$i] = $args[$i];
|
||||
|
@ -107,7 +107,7 @@
|
|||
|
||||
/* [6] On récupère le résultat
|
||||
=========================================================*/
|
||||
return Database::delNumeric( $getRequest->fetchAll() );
|
||||
return DatabaseDriver::delNumeric( $getRequest->fetchAll() );
|
||||
}
|
||||
|
||||
}
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
// TODO: Gestion des droits attribués aux tokens
|
||||
|
||||
namespace manager\repo;
|
||||
namespace database\repo;
|
||||
use \manager\sessionManager;
|
||||
use \manager\Database;
|
||||
use \database\core\DatabaseDriver;
|
||||
use \api\core\Checker;
|
||||
|
||||
class token extends parentRepo{
|
||||
|
||||
|
@ -37,14 +38,14 @@
|
|||
public static function getAll(){
|
||||
/* [1] On prepare et execute la requete
|
||||
=========================================================*/
|
||||
$request = Database::getPDO()->query("SELECT id_token, name, token, expires, (CURDATE() > expires) as expired
|
||||
$request = DatabaseDriver::getPDO()->query("SELECT id_token, name, token, expires, (CURDATE() > expires) as expired
|
||||
FROM api_token
|
||||
ORDER BY expires DESC");
|
||||
|
||||
|
||||
/* [3] On retourne les donnees
|
||||
=========================================================*/
|
||||
return Database::delNumeric( $request->fetchAll() );
|
||||
return DatabaseDriver::delNumeric( $request->fetchAll() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,12 +61,12 @@
|
|||
/* [0] Verification des INPUT
|
||||
=========================================================*/
|
||||
// si le format est incorrect, on retourne FAUX
|
||||
if( !Database::check('sha1', $token) ) return false;
|
||||
if( !Checker::run('hash', $token) ) return false;
|
||||
|
||||
|
||||
/* [1] Verification dans la base de donnees
|
||||
=========================================================*/
|
||||
$check = Database::getPDO()->prepare("SELECT id_token, permission
|
||||
$check = DatabaseDriver::getPDO()->prepare("SELECT id_token, permission
|
||||
FROM api_token
|
||||
WHERE CURDATE() <= expires
|
||||
AND token = :token");
|
||||
|
@ -97,7 +98,7 @@
|
|||
public static function generate($name, $duration){
|
||||
/* [0] Verification des INPUT
|
||||
=========================================================*/
|
||||
if( !Database::check('varchar(3,50)', $name) || !Database::check('id', $duration) ) return false;
|
||||
if( !Checker::run('varchar(3,50)', $name) || !Checker::run('id', $duration) ) return false;
|
||||
|
||||
|
||||
// On definit la date d'expiration du token
|
||||
|
@ -111,7 +112,7 @@
|
|||
$token = sessionManager::sha1(uniqid());
|
||||
|
||||
// Verification dans la BDD
|
||||
$check = Database::getPDO()->prepare("SELECT id_token FROM api_token WHERE token = :token");
|
||||
$check = DatabaseDriver::getPDO()->prepare("SELECT id_token FROM api_token WHERE token = :token");
|
||||
$check->execute( array( ':token' => $token ) );
|
||||
|
||||
// VRAI un token est identique
|
||||
|
@ -121,7 +122,7 @@
|
|||
|
||||
/* [2] On cree le token
|
||||
=========================================================*/
|
||||
$create = Database::getPDO()->prepare("INSERT INTO api_token(id_token, token, name, expires)
|
||||
$create = DatabaseDriver::getPDO()->prepare("INSERT INTO api_token(id_token, token, name, expires)
|
||||
VALUES(DEFAULT, :token, :name, :expiration)");
|
||||
$create->execute(array(
|
||||
':token' => $token,
|
||||
|
@ -131,7 +132,7 @@
|
|||
|
||||
/* [3] On verifie qu'il a bien ete cree
|
||||
=========================================================*/
|
||||
$created = Database::getPDO()->prepare("SELECT id_token FROM api_token
|
||||
$created = DatabaseDriver::getPDO()->prepare("SELECT id_token FROM api_token
|
||||
WHERE token = :token
|
||||
AND name = :name");
|
||||
$created->execute(array(
|
||||
|
@ -164,7 +165,7 @@
|
|||
public static function remove($id_token){
|
||||
/* [0] Verification des INPUT
|
||||
=========================================================*/
|
||||
if( !Database::check('id', $id_token) ) return false;
|
||||
if( !Checker::run('id', $id_token) ) return false;
|
||||
|
||||
|
||||
/* [1] On verifie l'existance du token
|
||||
|
@ -174,7 +175,7 @@
|
|||
|
||||
/* [2] Suppression du token
|
||||
=========================================================*/
|
||||
$remove = Database::getPDO()->prepare("DELETE FROM api_token
|
||||
$remove = DatabaseDriver::getPDO()->prepare("DELETE FROM api_token
|
||||
WHERE id_token = :id_token");
|
||||
$remove->execute(array( ':id_token' => $id_token ));
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace manager\repo;
|
||||
use \manager\Database;
|
||||
namespace database\repo;
|
||||
use \database\core\DatabaseDriver;
|
||||
use \api\core\Checker;
|
||||
use \manager\sessionManager;
|
||||
use \manager\repo\parentRepo;
|
||||
use \database\repo\parentRepo;
|
||||
|
||||
class user extends parentRepo{
|
||||
|
||||
|
@ -22,8 +23,8 @@
|
|||
public static function login($login, $password){
|
||||
/* [0] Gestion des INPUT
|
||||
=========================================================*/
|
||||
$checker = Database::check('varchar(3,50)', $login);
|
||||
$checker = $checker && Database::check('text', $password);
|
||||
$checker = Checker::run('varchar(3,50)', $login);
|
||||
$checker = $checker && Checker::run('text', $password);
|
||||
|
||||
// Si les parametres sont incorrects, on retourne une erreur
|
||||
if( !$checker ) return false;
|
||||
|
@ -31,7 +32,7 @@
|
|||
|
||||
/* [1] On verifie son login/password dans la BDD
|
||||
=========================================================*/
|
||||
$check = Database::getPDO()->prepare("SELECT id_user, login, permission
|
||||
$check = DatabaseDriver::getPDO()->prepare("SELECT id_user, login
|
||||
FROM users
|
||||
WHERE ( login = :username OR mail = :mail ) AND password = :password");
|
||||
$check->execute(array(
|
||||
|
@ -48,7 +49,7 @@
|
|||
|
||||
|
||||
// On retourne le resultat
|
||||
return Database::delNumeric( $result );
|
||||
return DatabaseDriver::delNumeric( $result );
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,20 +62,16 @@
|
|||
* @login<String> Login (identifiant) de l'utilisateur
|
||||
* @password<String> Password de l'utilisateur
|
||||
* @mail<String> Adresse mail de l'utilisateur
|
||||
* @reference<int> Reference vers une Personne (sinon NULL)
|
||||
* @permissions<Array> Liste des permissions de l'utilisateur
|
||||
*
|
||||
* @return id_user<int> Renvoie l'id de l'utilisateur cree ou FALSE si erreur
|
||||
*
|
||||
*/
|
||||
public static function create($login, $password, $mail, $reference, $permission){
|
||||
public static function create($login, $password, $mail){
|
||||
/* [0] Verification et formattage des INPUT
|
||||
=========================================================*/
|
||||
$checkInput = Database::check('sha1', $password);
|
||||
$checkInput = $checkInput && Database::check('varchar(3, 30)', $login);
|
||||
$checkInput = $checkInput && Database::check('mail', $mail);
|
||||
$checkInput = $checkInput && ( Database::check('id', $reference) || is_null($reference) );
|
||||
$checkInput = $checkInput && in_array($permission, array('admin', 'subject'));
|
||||
$checkInput = Checker::run('hash', $password);
|
||||
$checkInput = $checkInput && Checker::run('varchar(3, 30)', $login);
|
||||
$checkInput = $checkInput && Checker::run('mail', $mail);
|
||||
|
||||
// Si erreur en entree, on retourne FAUX
|
||||
if( !$checkInput ) return false;
|
||||
|
@ -82,15 +79,13 @@
|
|||
|
||||
/* [1] On verifie que le login/mail et reference sont uniques
|
||||
=========================================================*/
|
||||
$checkUnique = Database::getPDO()->prepare("SELECT id_user
|
||||
$checkUnique = DatabaseDriver::getPDO()->prepare("SELECT id_user
|
||||
FROM users
|
||||
WHERE login = :login
|
||||
OR mail = :mail
|
||||
OR ( reference = :reference AND reference is not NULL )");
|
||||
OR mail = :mail ");
|
||||
$checkUnique->execute(array(
|
||||
':login' => $login,
|
||||
':mail' => $mail,
|
||||
':reference' => $reference
|
||||
':mail' => $mail
|
||||
));
|
||||
|
||||
// Si un utilisateur a le meme LOGIN/MAIL ou REFERENCE qu'un autre, on retourne une erreur
|
||||
|
@ -99,48 +94,25 @@
|
|||
|
||||
/* [2] Creation de l'utilisateur
|
||||
=========================================================*/
|
||||
/* (1) Si reference NULL */
|
||||
if( $reference == null ){
|
||||
|
||||
$create = Database::getPDO()->prepare("INSERT INTO users(id_user, login, password, mail, reference, permission)
|
||||
VALUES(DEFAULT, :login, :password, :mail, NULL, :permission)");
|
||||
$create->execute(array(
|
||||
':login' => $login,
|
||||
':password' => $password,
|
||||
':mail' => $mail,
|
||||
':permission' => $permission
|
||||
));
|
||||
|
||||
/* (2) Si reference est defini */
|
||||
}else{
|
||||
|
||||
$create = Database::getPDO()->prepare("INSERT INTO users(id_user, login, password, mail, reference, permission)
|
||||
VALUES(DEFAULT, :login, :password, :mail, :reference, :permission)");
|
||||
$create->execute(array(
|
||||
':login' => $login,
|
||||
':password' => $password,
|
||||
':mail' => $mail,
|
||||
':reference' => (int) $reference,
|
||||
':permission' => $permission
|
||||
));
|
||||
|
||||
}
|
||||
$create = DatabaseDriver::getPDO()->prepare("INSERT INTO users(id_user, login, password, mail)
|
||||
VALUES(DEFAULT, :login, :password, :mail)");
|
||||
$create->execute(array(
|
||||
':login' => $login,
|
||||
':password' => $password,
|
||||
':mail' => $mail
|
||||
));
|
||||
|
||||
/* [3] Verification de la creation + recuperation id
|
||||
=========================================================*/
|
||||
$checkCreate = Database::getPDO()->prepare("SELECT id_user
|
||||
$checkCreate = DatabaseDriver::getPDO()->prepare("SELECT id_user
|
||||
FROM users
|
||||
WHERE login = :login
|
||||
AND password = :password
|
||||
AND mail = :mail
|
||||
AND ( reference = :reference OR reference is NULL )
|
||||
AND permission = :permission");
|
||||
AND mail = :mail");
|
||||
$checkCreate->execute(array(
|
||||
':login' => $login,
|
||||
':password' => $password,
|
||||
':mail' => $mail,
|
||||
':reference' => (int) $reference,
|
||||
':permission' => $permission
|
||||
':mail' => $mail
|
||||
));
|
||||
|
||||
// On recupere l'id de l'utilisateur
|
||||
|
@ -170,7 +142,7 @@
|
|||
public static function remove($id_user){
|
||||
/* [1] On effectue la suppression
|
||||
=========================================================*/
|
||||
$getUser = Database::getPDO()->prepare("DELETE FROM users WHERE id_user = :id_user");
|
||||
$getUser = DatabaseDriver::getPDO()->prepare("DELETE FROM users WHERE id_user = :id_user");
|
||||
$getUser->execute(array( ':id_user' => $id_user ));
|
||||
}
|
||||
|
|
@ -0,0 +1,198 @@
|
|||
<?php
|
||||
|
||||
namespace http\core;
|
||||
|
||||
|
||||
class HttpRequest{
|
||||
|
||||
/* [0] Constants
|
||||
=========================================================*/
|
||||
/* (1) Content-Type */
|
||||
const CT_BINARY = 0; // unknown
|
||||
const CT_TEXT = 1;
|
||||
const CT_JSON = 2;
|
||||
const CT_YAML = 3;
|
||||
const CT_MULTIPART_FORM_DATA = 4;
|
||||
const CT_X_WWW_FORM_URLENCODED = 5;
|
||||
|
||||
|
||||
/* [1] Attributes
|
||||
=========================================================*/
|
||||
private $uri;
|
||||
private $headers;
|
||||
private $method;
|
||||
private $postdata;
|
||||
private $getdata;
|
||||
|
||||
private $type;
|
||||
private $body;
|
||||
|
||||
|
||||
/* [2] Constructs an HTTP Request based on environment
|
||||
*
|
||||
* @return instance<HttpRequest> auto-filled HTTP Request
|
||||
*
|
||||
=========================================================*/
|
||||
public function __construct(){
|
||||
/* [1] Define URI & Status Code & method
|
||||
=========================================================*/
|
||||
$this->uri = $_SERVER['REQUEST_URI'];
|
||||
$this->method = $_SERVER['REQUEST_METHOD'];
|
||||
|
||||
|
||||
/* [2] Define headers
|
||||
=========================================================*/
|
||||
$this->headers = \getallheaders();
|
||||
|
||||
|
||||
/* [3] Define default datasets (GET, POST)
|
||||
=========================================================*/
|
||||
$this->getdata = $_GET;
|
||||
$this->postdata = $_POST;
|
||||
|
||||
|
||||
/* [4] Define BODY & its type
|
||||
=========================================================*/
|
||||
/* (1) Default: set plain/text body */
|
||||
$this->body = \file_get_contents('php://input');
|
||||
|
||||
/* (2) Fetch content type */
|
||||
$this->type = self::getContentType($this->headers['Content-Type']);
|
||||
|
||||
|
||||
/* [5] Parse BODY data -> POST
|
||||
=========================================================*/
|
||||
$this->parseBody();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* GET CONSTANT CT_* FROM `Content-Type` HEADER
|
||||
*
|
||||
* @pContentType<String> `Content-Type` header value
|
||||
*
|
||||
* @return type<int> Constant value
|
||||
*
|
||||
*/
|
||||
private static function getContentType($pContentType=null){
|
||||
/* [1] Checks argv
|
||||
=========================================================*/
|
||||
if( is_null($pContentType) )
|
||||
$pContentType = $_SERVER['CONTENT_TYPE'];
|
||||
|
||||
|
||||
/* [2] Checks types
|
||||
=========================================================*/
|
||||
/* (1) Form Data Types
|
||||
---------------------------------------------------------*/
|
||||
/* (1) multipart/form-data */
|
||||
if( preg_match('/^multipart\/form\-data; boundary=(.+)$/i', $pContentType) )
|
||||
return self::CT_MULTIPART_FORM_DATA;
|
||||
|
||||
/* (2) application/x-www-form-urlencoded */
|
||||
if( preg_match('/^application\/x\-www\-form\-urlencoded/i', $pContentType) )
|
||||
return self::CT_X_WWW_FORM_URLENCODED;
|
||||
|
||||
|
||||
/* (2) Data types
|
||||
---------------------------------------------------------*/
|
||||
/* (1) Basic JSON content type */
|
||||
if( preg_match('/^application\/json/i', $pContentType) )
|
||||
return self::CT_JSON;
|
||||
|
||||
/* (2) Basic YAML content type */
|
||||
if( preg_match('/^application\/yaml/i', $pContentType) )
|
||||
return self::CT_YAML;
|
||||
|
||||
/* (3) Basic TEXT content type */
|
||||
if( preg_match('/text\/[a-z]+/', $pContentType) )
|
||||
return self::CT_TEXT;
|
||||
|
||||
|
||||
/* (3) Default Type
|
||||
---------------------------------------------------------*/
|
||||
return self::CT_BINARY;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* PARSES BODY DATA
|
||||
*
|
||||
*/
|
||||
private function parseBody(){
|
||||
/* [1] If empty body -> do nothing
|
||||
=========================================================*/
|
||||
if( strlen($this->body) === 0 )
|
||||
return true;
|
||||
|
||||
|
||||
/* [2] Management for each ContentType
|
||||
=========================================================*/
|
||||
switch($this->type){
|
||||
|
||||
/* (1) multipart/form-data -> parse for not-POST methods
|
||||
---------------------------------------------------------*/
|
||||
case self::CT_MULTIPART_FORM_DATA:
|
||||
/* (1) Fetch the boundary */
|
||||
if( !preg_match('/boundary=(.+)$/i', $this->headers['Content-Type'], $match) )
|
||||
return false;
|
||||
|
||||
$boundary = $match[1];
|
||||
|
||||
/* (2) Break body into parts */
|
||||
$splitter = "/(?:\n|\r\n|--)*$boundary(?:\n|\r\n|--)?/im";
|
||||
$parts = preg_split($splitter, $this->body);
|
||||
|
||||
/* (3) Process parts */
|
||||
foreach($parts as $part)
|
||||
if( preg_match('/^Content\-Disposition: form\-data; name=\"([^"]+)\"(?:\n|\r\n){2}(.+)$/mi', $part, $match) )
|
||||
$this->postdata[$match[1]] = $match[2];
|
||||
|
||||
/* (4) Erases body */
|
||||
$this->body = '';
|
||||
break;
|
||||
|
||||
|
||||
/* (2) application/x-www-form-urlencoded -> parse for not-POST methods
|
||||
---------------------------------------------------------*/
|
||||
case self::CT_X_WWW_FORM_URLENCODED:
|
||||
/* Auto parse builtin-php function */
|
||||
parse_str($this->body, $this->postdata);
|
||||
|
||||
/* Erases body */
|
||||
$this->body = '';
|
||||
break;
|
||||
|
||||
|
||||
/* (3) application/json -> parse if no error
|
||||
---------------------------------------------------------*/
|
||||
case self::CT_JSON:
|
||||
/* (1) Decode body content */
|
||||
$decoded = json_decode($this->body, true);
|
||||
|
||||
/* (2) If error -> do nothing */
|
||||
if( is_null($decoded) )
|
||||
return;
|
||||
|
||||
/* (3) Parse body into body */
|
||||
$this->body = $decoded;
|
||||
break;
|
||||
|
||||
|
||||
/* (4) application/yaml -> parse if no error
|
||||
---------------------------------------------------------*/
|
||||
case self::CT_YAML:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function BODY(){ return $this->body; }
|
||||
public function POST(){ return $this->postdata; }
|
||||
public function GET(){ return $this->getdata; }
|
||||
public function HEADERS(){ return $this->headers; }
|
||||
public function METHOD(){ return $this->method; }
|
||||
public function URI(){ return $this->uri; }
|
||||
}
|
|
@ -1,18 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace manager;
|
||||
|
||||
namespace lightdb\core;
|
||||
|
||||
class lightdb{
|
||||
|
||||
// REPERTOIRE RACINE DE TOUTES LES BDD
|
||||
public static $default_root = __ROOT__;
|
||||
public static function default_root(){ return __BUILD__.'/lightdb/storage'; }
|
||||
|
||||
// ATTRIBUTS
|
||||
private $root;
|
||||
private $dbname;
|
||||
private $dir;
|
||||
private $index;
|
||||
private $date;
|
||||
private $driver;
|
||||
private $line;
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
|||
public function __construct($dbname, $root=null){
|
||||
/* [0] On récupère les attributs
|
||||
=========================================================*/
|
||||
$this->root = is_null($root) ? self::$default_root.'/' : $root;
|
||||
$this->root = is_null($root) ? self::default_root().'/' : $root;
|
||||
$this->dbname = $dbname;
|
||||
$this->dir = $this->root.$dbname.'/';
|
||||
|
||||
|
@ -53,42 +53,62 @@
|
|||
$index = json_decode( $fIndex->fgets(), true );
|
||||
|
||||
// Si erreur de parsage, on retourne une erreur
|
||||
if( is_null($index) ) return;
|
||||
if( is_null($index) ) throw new \Exception('[lightdb] index is null');
|
||||
$this->index = $index;
|
||||
|
||||
/* [3] Initialisation du gestionnaire d'acces (SplFileObject)
|
||||
=========================================================*/
|
||||
/* (1) Si le fichier n'existe pas, on le crée */
|
||||
if( !file_exists($this->dir.'data') )
|
||||
file_put_contents($this->dir.'data', '' );
|
||||
$this->data = $this->dir.'data';
|
||||
if( !file_exists($this->data) )
|
||||
file_put_contents($this->data, '' );
|
||||
|
||||
/* (2) On place un 'driver' sur le fichier */
|
||||
$this->driver = new \SplFileObject($this->dir.'data', 'r+');
|
||||
$this->driver = new \SplFileObject($this->data, 'r+');
|
||||
// $this->driver->setFlags( \SplFileObject::SKIP_EMPTY );
|
||||
|
||||
/* (3) On récupère le nombre de lignes */
|
||||
$this->line = -1;
|
||||
while( !$this->driver->eof() ){
|
||||
while( $this->driver->valid() ){
|
||||
$this->line++;
|
||||
$this->driver->fgetcsv();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function close(){ $this->driver = null; }
|
||||
|
||||
|
||||
|
||||
|
||||
/* RETOURNE LA LISTE DES INDEX
|
||||
/* FLUSH LA BDD (erase all)
|
||||
*
|
||||
* @i<String> Index pour lequel on veut la ligne et le hash
|
||||
*/
|
||||
public function flush(){
|
||||
/* (1) On flush les index */
|
||||
$fIndex = new \SplFileObject($this->dir.'index', 'w');
|
||||
$fIndex->fwrite('[]');
|
||||
$fIndex = null;
|
||||
$this->line = 0;
|
||||
$this->index = [];
|
||||
|
||||
/* (2) On flush les data */
|
||||
file_put_contents($this->dir.'data', '' );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* RETOURNE UN INDEX
|
||||
*
|
||||
* @i<String> [OPT] Index pour lequel on veut la ligne et le hash
|
||||
*
|
||||
* @return Index<Array> Tableau associatif contenant le hash et la ligne
|
||||
*
|
||||
*/
|
||||
public function index($i=null){
|
||||
return is_numeric($i) ? $this->index : $this->index;
|
||||
return is_numeric($i) ? $this->index[$i] : $this->index;
|
||||
}
|
||||
|
||||
|
||||
|
@ -103,25 +123,21 @@
|
|||
public function insert($key, $data){
|
||||
/* (1) On vérifie que la clé est unique */
|
||||
if( array_key_exists($key, $this->index) )
|
||||
return true;
|
||||
return false;
|
||||
|
||||
$key = (string) $key;
|
||||
|
||||
/* (2) On ajoute les données aux fichier */
|
||||
$json_data = json_encode($data);
|
||||
$this->driver->seek($this->line);
|
||||
$this->line++;
|
||||
$written = $this->driver->fwrite( $json_data.PHP_EOL );
|
||||
$written = $this->driver->fwrite( $json_data."\n" );
|
||||
|
||||
// Si erreur d'écriture, on retourne FALSE
|
||||
if( is_null($written) )
|
||||
return false;
|
||||
|
||||
/* (3) On enregistre l'index */
|
||||
$this->index[$key] = array(
|
||||
'line' => $this->line - 1,
|
||||
'hash' => sha1($json_data)
|
||||
);
|
||||
$this->index[$key] = [ 'line' => $this->line++ ];
|
||||
|
||||
/* (4) On enregistre le fichier index */
|
||||
$fIndex = new \SplFileObject($this->dir.'index', 'w');
|
||||
|
@ -152,14 +168,14 @@
|
|||
foreach($dataset as $key=>$data){
|
||||
$json_data = json_encode($data);
|
||||
$this->line++;
|
||||
$written = $this->driver->fwrite( $json_data.PHP_EOL );
|
||||
$written = $this->driver->fwrite( $json_data."\n" );
|
||||
|
||||
|
||||
/* (3) On enregistre les index */
|
||||
$this->index[$key] = array(
|
||||
'line' => $this->line - 1,
|
||||
'hash' => sha1($json_data)
|
||||
);
|
||||
$this->index[$key] = [
|
||||
'line' => $this->line - 1//,
|
||||
//'hash' => sha1($json_data)
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -173,34 +189,31 @@
|
|||
}
|
||||
|
||||
|
||||
/* RENVOIE LES DONNEES ASSOCIEES A UNE CLE DONNEE
|
||||
*
|
||||
* @key<String> Clé associée à la valeur à récupérer
|
||||
*
|
||||
* @return data<mixed*> Renvoie la valeur associée à la clé, FALSE si erreur
|
||||
*
|
||||
*/
|
||||
public function fetch($key){
|
||||
/* (1) On vérifie que la clé existe bien */
|
||||
if( !array_key_exists($key, $this->index) )
|
||||
return false;
|
||||
/* RENVOIE LES DONNEES ASSOCIEES A UNE CLE DONNEE
|
||||
*
|
||||
* @key<String> Clé associée à la valeur à récupérer
|
||||
*
|
||||
* @return data<mixed*> Renvoie la valeur associée à la clé, FALSE si erreur
|
||||
*
|
||||
*/
|
||||
public function fetch($key){
|
||||
/* (1) On vérifie que la clé existe bien */
|
||||
if( !array_key_exists($key, $this->index) )
|
||||
return false;
|
||||
|
||||
/* (2) On récupère la ligne */
|
||||
$line = $this->index[$key]['line'];
|
||||
|
||||
/* (3) On récupère le contenu */
|
||||
$this->driver->seek($line);
|
||||
$json = json_decode( $this->driver->current(), true );
|
||||
|
||||
// Si erreur de parsage
|
||||
if( is_null($json) )
|
||||
return false;
|
||||
|
||||
return $json;
|
||||
}
|
||||
/* (2) On récupère la ligne */
|
||||
$line = $this->index[$key]['line'];
|
||||
|
||||
/* (3) On récupère le contenu */
|
||||
$this->driver->seek($line);
|
||||
$json = json_decode( $this->driver->current(), true );
|
||||
|
||||
// Si erreur de parsage
|
||||
if( is_null($json) )
|
||||
return false;
|
||||
|
||||
return $json;
|
||||
}
|
||||
|
||||
/* RENVOIE LES DONNEES ASSOCIEES AUX CLES DONNEES
|
||||
*
|
||||
|
@ -210,7 +223,7 @@
|
|||
*
|
||||
*/
|
||||
public function fetchAll($keys){
|
||||
$data = array();
|
||||
$data = [];
|
||||
|
||||
/* (0) Pour chaque clé */
|
||||
foreach($keys as $i=>$key){
|
||||
|
@ -248,22 +261,25 @@
|
|||
public function delete($key){
|
||||
/* (1) On vérifie l'existence de la clé */
|
||||
if( !array_key_exists($key, $this->index) )
|
||||
return true; // On considère que l'action souhaitée est effectuée
|
||||
return false; // On considère que l'action souhaitée est effectuée
|
||||
|
||||
$line = $this->index[$key]['line'];
|
||||
|
||||
/* (2) On réarrange la bd pour supprimer la ligne */
|
||||
$tmpfilename = __ROOT__.'/tmp/'.uniqid().'.dat';
|
||||
$tmpfilename = __TMP__.'/'.uniqid().'.dat';
|
||||
$tmpfile = new \SplFileObject($tmpfilename, 'w');
|
||||
$this->driver->seek(0);
|
||||
|
||||
// On recopie toutes les lignes sauf celle à supprimer dans un fichier temporaire
|
||||
while( $this->driver->key() < $this->line ){
|
||||
foreach($this->driver as $k=>$content){
|
||||
// Only valuable lines (not the last linebreak)
|
||||
if( $k >= $this->line )
|
||||
break;
|
||||
|
||||
if( $this->driver->key() != $line )
|
||||
$tmpfile->fwrite( $this->driver->current() );
|
||||
// On n'écrit pas la ligne à supprimer
|
||||
if( $k != $line )
|
||||
$tmpfile->fwrite( $content );
|
||||
|
||||
$this->driver->next();
|
||||
}
|
||||
|
||||
// On décrémente le nb de lignes
|
||||
|
@ -304,7 +320,7 @@
|
|||
*
|
||||
*/
|
||||
public function deleteAll($keys){
|
||||
$keyLines = array();
|
||||
$keyLines = [];
|
||||
|
||||
/* [1] On récupère la ligne associée à chaque clé
|
||||
=========================================================*/
|
||||
|
@ -317,9 +333,12 @@
|
|||
$keyLines[$key] = $this->index[$key]['line'];
|
||||
}
|
||||
|
||||
if( count($keyLines) == 0 )
|
||||
return true;
|
||||
|
||||
/* [2] On trie les clés en fonction de leur ligne
|
||||
=========================================================*/
|
||||
$sorted = array();
|
||||
$sorted = [];
|
||||
|
||||
// Tant que toute les clés ne sont pas triées
|
||||
while( count($keyLines) > 0 ){
|
||||
|
@ -342,18 +361,19 @@
|
|||
/* [3] On supprime les lignes à supprimer
|
||||
=========================================================*/
|
||||
/* (1) On réarrange la bd pour supprimer la ligne */
|
||||
$tmpfilename = __ROOT__.'/tmp/'.uniqid().'.dat';
|
||||
$tmpfilename = __TMP__.'/'.uniqid().'.dat';
|
||||
$tmpfile = new \SplFileObject($tmpfilename, 'w');
|
||||
$this->driver->seek(0);
|
||||
|
||||
/* (2) On recopie toutes les lignes sauf celles à supprimer dans un fichier temporaire */
|
||||
while( $this->driver->key() < $this->line ){
|
||||
foreach($this->driver as $key=>$content){
|
||||
// Only valuable lines (not the last linebreak)
|
||||
if( $key >= $this->line ) break;
|
||||
|
||||
// Si la ligne en cours n'est pas dans la liste des lignes à supprimer
|
||||
if( !in_array($this->driver->key(), $sorted) )
|
||||
$tmpfile->fwrite( $this->driver->current() ); // On l'écrit dans le nouveau fichier
|
||||
// On n'écrit pas la ligne à supprimer
|
||||
if( !in_array($key, $sorted) )
|
||||
$tmpfile->fwrite( $content );
|
||||
|
||||
$this->driver->next();
|
||||
}
|
||||
|
||||
$tmpfile = null;
|
||||
|
@ -392,51 +412,7 @@
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* RENVOIE LES DONNEES ASSOCIEES A UN CHAMP DE RECHERCHE
|
||||
*
|
||||
* @nomParam<typeParam> Description du param
|
||||
*
|
||||
* @return nomRetour<typeRetour> Description du retour
|
||||
*
|
||||
*/
|
||||
public function filter($data){
|
||||
/* (1) Si @data est un tableau associatif */
|
||||
if( is_array($data) ){
|
||||
|
||||
$filtered = array();
|
||||
foreach($this->index as $i=>$indexData){
|
||||
$this->driver->seek( $indexData['line'] );
|
||||
$dbData = json_decode( $this->driver->fgets(), true );
|
||||
|
||||
foreach($data as $key=>$value)
|
||||
if( isset($dbData[$key]) && preg_match("#$value#", $dbData[$key]) ){
|
||||
$filtered[$i] = $dbData;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $filtered;
|
||||
|
||||
|
||||
/* (2) Sinon on compare @data en tant que valeur simple */
|
||||
}else{
|
||||
|
||||
$this->tmp = sha1( json_encode($data) );
|
||||
return array_filter($this->index, array($this, 'simpleFilter'));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
protected function simpleFilter($e){ return $e['hash'] == $this->tmp; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
{"id":16,"name":"contact-x","sexe":"1","age":"6","studies2":"1","reltype":"1","dist":"1","job":"12","famsit":"1","city":"35","cp":"10025","quartier":"25","duration":["25","125"],"context":"11","contextExtra":["internet","",""],"freq":["1","6","11","16","21"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"1","interest":"0","irlfreq":["1","6","11","16","21"],"relmark":"0","medrel":"1"}
|
||||
{"id":17,"name":"contact-1","sexe":"0","age":"6","studies2":"6","reltype":"6","dist":"2","job":"6","famsit":"2","city":"16","cp":"10006","quartier":"6","duration":["6","16"],"context":"6","contextExtra":["","",""],"freq":["2","7","12","17","22"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"2","interest":"1","irlfreq":["2","7","12","17","22"],"relmark":"1","medrel":"0"}
|
||||
{"id":18,"name":"contact-2","sexe":"1","age":"7","studies2":"7","reltype":"autre","dist":"3","job":"7","famsit":"3","city":"17","cp":"10007","quartier":"7","duration":["7","17"],"context":"7","contextExtra":["","",""],"freq":["3","8","13","18","23"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"3","interest":"2","irlfreq":["3","8","13","18","23"],"relmark":"2","medrel":"1"}
|
||||
{"id":19,"name":"contact-3","sexe":"2","age":"8","studies2":"0","reltype":"0","dist":"0","job":"8","famsit":"0","city":"18","cp":"10008","quartier":"8","duration":["8","18"],"context":"8","contextExtra":["","",""],"freq":["0","5","10","15","20"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"0","interest":"3","irlfreq":["0","5","10","15","20"],"relmark":"3","medrel":"2"}
|
||||
{"id":20,"name":"contact-4","sexe":"0","age":"9","studies2":"1","reltype":"1","dist":"1","job":"9","famsit":"1","city":"19","cp":"10009","quartier":"9","duration":["9","19"],"context":"9","contextExtra":["","",""],"freq":["1","6","11","16","21"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"1","interest":"4","irlfreq":["1","6","11","16","21"],"relmark":"4","medrel":"0"}
|
||||
{"id":21,"name":"contact-5","sexe":"1","age":"10","studies2":"2","reltype":"2","dist":"2","job":"10","famsit":"2","city":"20","cp":"10010","quartier":"10","duration":["10","110"],"context":"10","contextExtra":["","",""],"freq":["2","7","12","17","22"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"2","interest":"0","irlfreq":["2","7","12","17","22"],"relmark":"0","medrel":"1"}
|
||||
{"id":22,"name":"contact-6","sexe":"2","age":"11","studies2":"3","reltype":"3","dist":"3","job":"11","famsit":"3","city":"21","cp":"10011","quartier":"11","duration":["11","111"],"context":"11","contextExtra":["internet","",""],"freq":["3","8","13","18","23"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"3","interest":"1","irlfreq":["3","8","13","18","23"],"relmark":"1","medrel":"2"}
|
||||
{"id":23,"name":"contact-7","sexe":"0","age":"12","studies2":"4","reltype":"4","dist":"0","job":"12","famsit":"0","city":"22","cp":"10012","quartier":"12","duration":["12","112"],"context":"12","contextExtra":["","association",""],"freq":["0","5","10","15","20"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"0","interest":"2","irlfreq":["0","5","10","15","20"],"relmark":"2","medrel":"0"}
|
||||
{"id":24,"name":"contact-8","sexe":"1","age":"13","studies2":"5","reltype":"5","dist":"1","job":"0","famsit":"1","city":"23","cp":"10013","quartier":"13","duration":["13","113"],"context":"13","contextExtra":["","","autre"],"freq":["1","6","11","16","21"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"1","interest":"3","irlfreq":["1","6","11","16","21"],"relmark":"3","medrel":"1"}
|
||||
{"id":25,"name":"contact-9","sexe":"2","age":"14","studies2":"6","reltype":"6","dist":"2","job":"1","famsit":"2","city":"24","cp":"10014","quartier":"14","duration":["14","114"],"context":"0","contextExtra":["","",""],"freq":["2","7","12","17","22"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"2","interest":"4","irlfreq":["2","7","12","17","22"],"relmark":"4","medrel":"2"}
|
||||
{"id":26,"name":"contact-10","sexe":"0","age":"15","studies2":"7","reltype":"autre","dist":"3","job":"2","famsit":"3","city":"25","cp":"10015","quartier":"15","duration":["15","115"],"context":"1","contextExtra":["","",""],"freq":["3","8","13","18","23"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"3","interest":"0","irlfreq":["3","8","13","18","23"],"relmark":"0","medrel":"0"}
|
||||
{"id":27,"name":"contact-11","sexe":"1","age":"16","studies2":"0","reltype":"0","dist":"0","job":"3","famsit":"0","city":"26","cp":"10016","quartier":"16","duration":["16","116"],"context":"2","contextExtra":["","",""],"freq":["0","5","10","15","20"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"0","interest":"1","irlfreq":["0","5","10","15","20"],"relmark":"1","medrel":"1"}
|
||||
{"id":28,"name":"contact-12","sexe":"2","age":"17","studies2":"1","reltype":"1","dist":"1","job":"4","famsit":"1","city":"27","cp":"10017","quartier":"17","duration":["17","117"],"context":"3","contextExtra":["","",""],"freq":["1","6","11","16","21"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"1","interest":"2","irlfreq":["1","6","11","16","21"],"relmark":"2","medrel":"2"}
|
||||
{"id":29,"name":"contact-13","sexe":"0","age":"18","studies2":"2","reltype":"2","dist":"2","job":"5","famsit":"2","city":"28","cp":"10018","quartier":"18","duration":["18","118"],"context":"4","contextExtra":["","",""],"freq":["2","7","12","17","22"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"2","interest":"3","irlfreq":["2","7","12","17","22"],"relmark":"3","medrel":"0"}
|
||||
{"id":30,"name":"contact-14","sexe":"1","age":"0","studies2":"3","reltype":"3","dist":"3","job":"6","famsit":"3","city":"29","cp":"10019","quartier":"19","duration":["19","119"],"context":"5","contextExtra":["","",""],"freq":["3","8","13","18","23"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"3","interest":"4","irlfreq":["3","8","13","18","23"],"relmark":"4","medrel":"1"}
|
||||
{"id":31,"name":"contact-15","sexe":"2","age":"1","studies2":"4","reltype":"4","dist":"0","job":"7","famsit":"0","city":"30","cp":"10020","quartier":"20","duration":["20","120"],"context":"6","contextExtra":["","",""],"freq":["0","5","10","15","20"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"0","interest":"0","irlfreq":["0","5","10","15","20"],"relmark":"0","medrel":"2"}
|
||||
{"id":32,"name":"contact-16","sexe":"0","age":"2","studies2":"5","reltype":"5","dist":"1","job":"8","famsit":"1","city":"31","cp":"10021","quartier":"21","duration":["21","121"],"context":"7","contextExtra":["","",""],"freq":["1","6","11","16","21"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"1","interest":"1","irlfreq":["1","6","11","16","21"],"relmark":"1","medrel":"0"}
|
||||
{"id":33,"name":"contact-17","sexe":"1","age":"3","studies2":"6","reltype":"6","dist":"2","job":"9","famsit":"2","city":"32","cp":"10022","quartier":"22","duration":["22","122"],"context":"8","contextExtra":["","",""],"freq":["2","7","12","17","22"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"2","interest":"2","irlfreq":["2","7","12","17","22"],"relmark":"2","medrel":"1"}
|
||||
{"id":34,"name":"contact-18","sexe":"2","age":"4","studies2":"7","reltype":"autre","dist":"3","job":"10","famsit":"3","city":"33","cp":"10023","quartier":"23","duration":["23","123"],"context":"9","contextExtra":["","",""],"freq":["3","8","13","18","23"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"3","interest":"3","irlfreq":["3","8","13","18","23"],"relmark":"3","medrel":"2"}
|
||||
{"id":35,"name":"contact-19","sexe":"0","age":"5","studies2":"0","reltype":"0","dist":"0","job":"11","famsit":"0","city":"34","cp":"10024","quartier":"24","duration":["24","124"],"context":"10","contextExtra":["","",""],"freq":["0","5","10","15","20"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"0","interest":"4","irlfreq":["0","5","10","15","20"],"relmark":"4","medrel":"0"}
|
||||
{"id":37,"name":"contact-21","sexe":"2","age":"7","studies2":"2","reltype":"2","dist":"2","job":"0","famsit":"2","city":"36","cp":"10026","quartier":"26","duration":["26","126"],"context":"12","contextExtra":["","association",""],"freq":["2","7","12","17","22"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"2","interest":"1","irlfreq":["2","7","12","17","22"],"relmark":"1","medrel":"2"}
|
||||
{"id":38,"name":"contact-22","sexe":"0","age":"8","studies2":"3","reltype":"3","dist":"3","job":"1","famsit":"3","city":"37","cp":"10027","quartier":"27","duration":["27","127"],"context":"13","contextExtra":["","","autre"],"freq":["3","8","13","18","23"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"3","interest":"2","irlfreq":["3","8","13","18","23"],"relmark":"2","medrel":"0"}
|
||||
{"id":39,"name":"contact-23","sexe":"1","age":"9","studies2":"4","reltype":"4","dist":"0","job":"2","famsit":"0","city":"38","cp":"10028","quartier":"28","duration":["28","128"],"context":"0","contextExtra":["","",""],"freq":["0","5","10","15","20"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"0","interest":"3","irlfreq":["0","5","10","15","20"],"relmark":"3","medrel":"1"}
|
||||
{"id":40,"name":"contact-24","sexe":"2","age":"10","studies2":"5","reltype":"5","dist":"1","job":"3","famsit":"1","city":"39","cp":"10029","quartier":"29","duration":["29","129"],"context":"1","contextExtra":["","",""],"freq":["1","6","11","16","21"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"1","interest":"4","irlfreq":["1","6","11","16","21"],"relmark":"4","medrel":"2"}
|
||||
{"id":41,"name":"contact-25","sexe":"0","age":"11","studies2":"6","reltype":"6","dist":"2","job":"4","famsit":"2","city":"40","cp":"10030","quartier":"30","duration":["30","130"],"context":"2","contextExtra":["","",""],"freq":["2","7","12","17","22"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"2","interest":"0","irlfreq":["2","7","12","17","22"],"relmark":"0","medrel":"0"}
|
||||
{"id":42,"name":"contact-26","sexe":"1","age":"12","studies2":"7","reltype":"autre","dist":"3","job":"5","famsit":"3","city":"41","cp":"10031","quartier":"31","duration":["31","131"],"context":"3","contextExtra":["","",""],"freq":["3","8","13","18","23"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"3","interest":"1","irlfreq":["3","8","13","18","23"],"relmark":"1","medrel":"1"}
|
||||
{"id":43,"name":"contact-27","sexe":"2","age":"13","studies2":"0","reltype":"0","dist":"0","job":"6","famsit":"0","city":"42","cp":"10032","quartier":"32","duration":["32","132"],"context":"4","contextExtra":["","",""],"freq":["0","5","10","15","20"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"0","interest":"2","irlfreq":["0","5","10","15","20"],"relmark":"2","medrel":"2"}
|
||||
{"id":44,"name":"contact-28","sexe":"0","age":"14","studies2":"1","reltype":"1","dist":"1","job":"7","famsit":"1","city":"43","cp":"10033","quartier":"33","duration":["33","133"],"context":"5","contextExtra":["","",""],"freq":["1","6","11","16","21"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"1","interest":"3","irlfreq":["1","6","11","16","21"],"relmark":"3","medrel":"0"}
|
||||
{"id":45,"name":"contact-29","sexe":"1","age":"15","studies2":"2","reltype":"2","dist":"2","job":"8","famsit":"2","city":"44","cp":"10034","quartier":"34","duration":["34","134"],"context":"6","contextExtra":["","",""],"freq":["2","7","12","17","22"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"2","interest":"4","irlfreq":["2","7","12","17","22"],"relmark":"4","medrel":"1"}
|
||||
{"id":46,"name":"contact-30","sexe":"2","age":"16","studies2":"3","reltype":"3","dist":"3","job":"9","famsit":"3","city":"45","cp":"10035","quartier":"35","duration":["35","135"],"context":"7","contextExtra":["","",""],"freq":["3","8","13","18","23"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"3","interest":"0","irlfreq":["3","8","13","18","23"],"relmark":"0","medrel":"2"}
|
||||
{"id":47,"name":"contact-31","sexe":"0","age":"17","studies2":"4","reltype":"4","dist":"0","job":"10","famsit":"0","city":"46","cp":"10036","quartier":"36","duration":["36","136"],"context":"8","contextExtra":["","",""],"freq":["0","5","10","15","20"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"0","interest":"1","irlfreq":["0","5","10","15","20"],"relmark":"1","medrel":"0"}
|
||||
{"id":48,"name":"contact-32","sexe":"1","age":"18","studies2":"5","reltype":"5","dist":"1","job":"11","famsit":"1","city":"47","cp":"10037","quartier":"37","duration":["37","137"],"context":"9","contextExtra":["","",""],"freq":["1","6","11","16","21"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"1","interest":"2","irlfreq":["1","6","11","16","21"],"relmark":"2","medrel":"1"}
|
||||
{"id":49,"name":"contact-33","sexe":"2","age":"0","studies2":"6","reltype":"6","dist":"2","job":"12","famsit":"2","city":"48","cp":"10038","quartier":"38","duration":["38","138"],"context":"10","contextExtra":["","",""],"freq":["2","7","12","17","22"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"2","interest":"3","irlfreq":["2","7","12","17","22"],"relmark":"3","medrel":"2"}
|
||||
{"id":50,"name":"contact-34","sexe":"0","age":"1","studies2":"7","reltype":"autre","dist":"3","job":"0","famsit":"3","city":"49","cp":"10039","quartier":"39","duration":["39","139"],"context":"11","contextExtra":["internet","",""],"freq":["3","8","13","18","23"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"3","interest":"4","irlfreq":["3","8","13","18","23"],"relmark":"4","medrel":"0"}
|
||||
{"id":51,"name":"contact-35","sexe":"1","age":"2","studies2":"0","reltype":"0","dist":"0","job":"1","famsit":"0","city":"50","cp":"10040","quartier":"40","duration":["40","140"],"context":"12","contextExtra":["","association",""],"freq":["0","5","10","15","20"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"0","interest":"0","irlfreq":["0","5","10","15","20"],"relmark":"0","medrel":"1"}
|
||||
{"id":52,"name":"contact-36","sexe":"2","age":"3","studies2":"1","reltype":"1","dist":"1","job":"2","famsit":"1","city":"51","cp":"10041","quartier":"41","duration":["41","141"],"context":"13","contextExtra":["","","autre"],"freq":["1","6","11","16","21"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"1","interest":"1","irlfreq":["1","6","11","16","21"],"relmark":"1","medrel":"2"}
|
||||
{"id":53,"name":"contact-37","sexe":"0","age":"4","studies2":"2","reltype":"2","dist":"2","job":"3","famsit":"2","city":"52","cp":"10042","quartier":"42","duration":["42","142"],"context":"0","contextExtra":["","",""],"freq":["2","7","12","17","22"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"2","interest":"2","irlfreq":["2","7","12","17","22"],"relmark":"2","medrel":"0"}
|
||||
{"id":54,"name":"contact-38","sexe":"1","age":"5","studies2":"3","reltype":"3","dist":"3","job":"4","famsit":"3","city":"53","cp":"10043","quartier":"43","duration":["43","143"],"context":"1","contextExtra":["","",""],"freq":["3","8","13","18","23"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"3","interest":"3","irlfreq":["3","8","13","18","23"],"relmark":"3","medrel":"1"}
|
||||
{"id":55,"name":"contact-39","sexe":"2","age":"6","studies2":"4","reltype":"4","dist":"0","job":"5","famsit":"0","city":"54","cp":"10044","quartier":"44","duration":["44","144"],"context":"2","contextExtra":["","",""],"freq":["0","5","10","15","20"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"0","interest":"4","irlfreq":["0","5","10","15","20"],"relmark":"4","medrel":"2"}
|
||||
{"id":57,"name":"contact-41","sexe":"1","age":"","studies1":"2","reltype":"1","dist":"0"}
|
||||
{"id":58,"name":"contact-42","sexe":"0","age":"2","studies1":"3","reltype":"2","dist":"1"}
|
||||
{"id":59,"name":"contact-43","sexe":"1","age":"3","studies1":"4","reltype":"3","dist":"2"}
|
||||
{"id":60,"name":"contact-44","sexe":"0","age":"4","studies1":"5","reltype":"4","dist":"3"}
|
||||
{"id":63,"name":"contact-x","sexe":"1","age":"6","studies2":"1","reltype":"1","dist":"1","job":"12","famsit":"1","city":"35","cp":"10025","quartier":"25","duration":["25","125"],"context":"11","contextExtra":["internet","",""],"freq":["1","6","11","16","21"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"1","interest":"0","irlfreq":["1","6","11","16","21"],"relmark":"0","medrel":"1"}
|
||||
{"id":64,"name":"contact-1","sexe":"0","age":"6","studies2":"6","reltype":"6","dist":"2","job":"6","famsit":"2","city":"16","cp":"10006","quartier":"6","duration":["6","16"],"context":"6","contextExtra":["","",""],"freq":["2","7","12","17","22"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"2","interest":"1","irlfreq":["2","7","12","17","22"],"relmark":"1","medrel":"0"}
|
||||
{"id":65,"name":"contact-2","sexe":"1","age":"7","studies2":"7","reltype":"autre","dist":"3","job":"7","famsit":"3","city":"17","cp":"10007","quartier":"7","duration":["7","17"],"context":"7","contextExtra":["","",""],"freq":["3","8","13","18","23"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"3","interest":"2","irlfreq":["3","8","13","18","23"],"relmark":"2","medrel":"1"}
|
||||
{"id":66,"name":"contact-3","sexe":"2","age":"8","studies2":"0","reltype":"0","dist":"0","job":"8","famsit":"0","city":"18","cp":"10008","quartier":"8","duration":["8","18"],"context":"8","contextExtra":["","",""],"freq":["0","5","10","15","20"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"0","interest":"3","irlfreq":["0","5","10","15","20"],"relmark":"3","medrel":"2"}
|
||||
{"id":67,"name":"contact-4","sexe":"0","age":"9","studies2":"1","reltype":"1","dist":"1","job":"9","famsit":"1","city":"19","cp":"10009","quartier":"9","duration":["9","19"],"context":"9","contextExtra":["","",""],"freq":["1","6","11","16","21"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"1","interest":"4","irlfreq":["1","6","11","16","21"],"relmark":"4","medrel":"0"}
|
||||
{"id":68,"name":"contact-5","sexe":"1","age":"10","studies2":"2","reltype":"2","dist":"2","job":"10","famsit":"2","city":"20","cp":"10010","quartier":"10","duration":["10","110"],"context":"10","contextExtra":["","",""],"freq":["2","7","12","17","22"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"2","interest":"0","irlfreq":["2","7","12","17","22"],"relmark":"0","medrel":"1"}
|
||||
{"id":69,"name":"contact-6","sexe":"2","age":"11","studies2":"3","reltype":"3","dist":"3","job":"11","famsit":"3","city":"21","cp":"10011","quartier":"11","duration":["11","111"],"context":"11","contextExtra":["internet","",""],"freq":["3","8","13","18","23"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"3","interest":"1","irlfreq":["3","8","13","18","23"],"relmark":"1","medrel":"2"}
|
||||
{"id":70,"name":"contact-7","sexe":"0","age":"12","studies2":"4","reltype":"4","dist":"0","job":"12","famsit":"0","city":"22","cp":"10012","quartier":"12","duration":["12","112"],"context":"12","contextExtra":["","association",""],"freq":["0","5","10","15","20"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"0","interest":"2","irlfreq":["0","5","10","15","20"],"relmark":"2","medrel":"0"}
|
||||
{"id":71,"name":"contact-8","sexe":"1","age":"13","studies2":"5","reltype":"5","dist":"1","job":"0","famsit":"1","city":"23","cp":"10013","quartier":"13","duration":["13","113"],"context":"13","contextExtra":["","","autre"],"freq":["1","6","11","16","21"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"1","interest":"3","irlfreq":["1","6","11","16","21"],"relmark":"3","medrel":"1"}
|
||||
{"id":72,"name":"contact-9","sexe":"2","age":"14","studies2":"6","reltype":"6","dist":"2","job":"1","famsit":"2","city":"24","cp":"10014","quartier":"14","duration":["14","114"],"context":"0","contextExtra":["","",""],"freq":["2","7","12","17","22"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"2","interest":"4","irlfreq":["2","7","12","17","22"],"relmark":"4","medrel":"2"}
|
||||
{"id":73,"name":"contact-10","sexe":"0","age":"15","studies2":"7","reltype":"autre","dist":"3","job":"2","famsit":"3","city":"25","cp":"10015","quartier":"15","duration":["15","115"],"context":"1","contextExtra":["","",""],"freq":["3","8","13","18","23"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"3","interest":"0","irlfreq":["3","8","13","18","23"],"relmark":"0","medrel":"0"}
|
||||
{"id":74,"name":"contact-11","sexe":"1","age":"16","studies2":"0","reltype":"0","dist":"0","job":"3","famsit":"0","city":"26","cp":"10016","quartier":"16","duration":["16","116"],"context":"2","contextExtra":["","",""],"freq":["0","5","10","15","20"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"0","interest":"1","irlfreq":["0","5","10","15","20"],"relmark":"1","medrel":"1"}
|
||||
{"id":75,"name":"contact-12","sexe":"2","age":"17","studies2":"1","reltype":"1","dist":"1","job":"4","famsit":"1","city":"27","cp":"10017","quartier":"17","duration":["17","117"],"context":"3","contextExtra":["","",""],"freq":["1","6","11","16","21"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"1","interest":"2","irlfreq":["1","6","11","16","21"],"relmark":"2","medrel":"2"}
|
||||
{"id":76,"name":"contact-13","sexe":"0","age":"18","studies2":"2","reltype":"2","dist":"2","job":"5","famsit":"2","city":"28","cp":"10018","quartier":"18","duration":["18","118"],"context":"4","contextExtra":["","",""],"freq":["2","7","12","17","22"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"2","interest":"3","irlfreq":["2","7","12","17","22"],"relmark":"3","medrel":"0"}
|
||||
{"id":77,"name":"contact-14","sexe":"1","age":"0","studies2":"3","reltype":"3","dist":"3","job":"6","famsit":"3","city":"29","cp":"10019","quartier":"19","duration":["19","119"],"context":"5","contextExtra":["","",""],"freq":["3","8","13","18","23"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"3","interest":"4","irlfreq":["3","8","13","18","23"],"relmark":"4","medrel":"1"}
|
||||
{"id":78,"name":"contact-15","sexe":"2","age":"1","studies2":"4","reltype":"4","dist":"0","job":"7","famsit":"0","city":"30","cp":"10020","quartier":"20","duration":["20","120"],"context":"6","contextExtra":["","",""],"freq":["0","5","10","15","20"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"0","interest":"0","irlfreq":["0","5","10","15","20"],"relmark":"0","medrel":"2"}
|
||||
{"id":79,"name":"contact-16","sexe":"0","age":"2","studies2":"5","reltype":"5","dist":"1","job":"8","famsit":"1","city":"31","cp":"10021","quartier":"21","duration":["21","121"],"context":"7","contextExtra":["","",""],"freq":["1","6","11","16","21"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"1","interest":"1","irlfreq":["1","6","11","16","21"],"relmark":"1","medrel":"0"}
|
||||
{"id":80,"name":"contact-17","sexe":"1","age":"3","studies2":"6","reltype":"6","dist":"2","job":"9","famsit":"2","city":"32","cp":"10022","quartier":"22","duration":["22","122"],"context":"8","contextExtra":["","",""],"freq":["2","7","12","17","22"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"2","interest":"2","irlfreq":["2","7","12","17","22"],"relmark":"2","medrel":"1"}
|
||||
{"id":81,"name":"contact-18","sexe":"2","age":"4","studies2":"7","reltype":"autre","dist":"3","job":"10","famsit":"3","city":"33","cp":"10023","quartier":"23","duration":["23","123"],"context":"9","contextExtra":["","",""],"freq":["3","8","13","18","23"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"3","interest":"3","irlfreq":["3","8","13","18","23"],"relmark":"3","medrel":"2"}
|
||||
{"id":82,"name":"contact-19","sexe":"0","age":"5","studies2":"0","reltype":"0","dist":"0","job":"11","famsit":"0","city":"34","cp":"10024","quartier":"24","duration":["24","124"],"context":"10","contextExtra":["","",""],"freq":["0","5","10","15","20"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"0","interest":"4","irlfreq":["0","5","10","15","20"],"relmark":"4","medrel":"0"}
|
||||
{"id":84,"name":"contact-21","sexe":"2","age":"7","studies2":"2","reltype":"2","dist":"2","job":"0","famsit":"2","city":"36","cp":"10026","quartier":"26","duration":["26","126"],"context":"12","contextExtra":["","association",""],"freq":["2","7","12","17","22"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"2","interest":"1","irlfreq":["2","7","12","17","22"],"relmark":"1","medrel":"2"}
|
||||
{"id":85,"name":"contact-22","sexe":"0","age":"8","studies2":"3","reltype":"3","dist":"3","job":"1","famsit":"3","city":"37","cp":"10027","quartier":"27","duration":["27","127"],"context":"13","contextExtra":["","","autre"],"freq":["3","8","13","18","23"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"3","interest":"2","irlfreq":["3","8","13","18","23"],"relmark":"2","medrel":"0"}
|
||||
{"id":86,"name":"contact-23","sexe":"1","age":"9","studies2":"4","reltype":"4","dist":"0","job":"2","famsit":"0","city":"38","cp":"10028","quartier":"28","duration":["28","128"],"context":"0","contextExtra":["","",""],"freq":["0","5","10","15","20"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"0","interest":"3","irlfreq":["0","5","10","15","20"],"relmark":"3","medrel":"1"}
|
||||
{"id":87,"name":"contact-24","sexe":"2","age":"10","studies2":"5","reltype":"5","dist":"1","job":"3","famsit":"1","city":"39","cp":"10029","quartier":"29","duration":["29","129"],"context":"1","contextExtra":["","",""],"freq":["1","6","11","16","21"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"1","interest":"4","irlfreq":["1","6","11","16","21"],"relmark":"4","medrel":"2"}
|
||||
{"id":88,"name":"contact-25","sexe":"0","age":"11","studies2":"6","reltype":"6","dist":"2","job":"4","famsit":"2","city":"40","cp":"10030","quartier":"30","duration":["30","130"],"context":"2","contextExtra":["","",""],"freq":["2","7","12","17","22"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"2","interest":"0","irlfreq":["2","7","12","17","22"],"relmark":"0","medrel":"0"}
|
||||
{"id":89,"name":"contact-26","sexe":"1","age":"12","studies2":"7","reltype":"autre","dist":"3","job":"5","famsit":"3","city":"41","cp":"10031","quartier":"31","duration":["31","131"],"context":"3","contextExtra":["","",""],"freq":["3","8","13","18","23"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"3","interest":"1","irlfreq":["3","8","13","18","23"],"relmark":"1","medrel":"1"}
|
||||
{"id":90,"name":"contact-27","sexe":"2","age":"13","studies2":"0","reltype":"0","dist":"0","job":"6","famsit":"0","city":"42","cp":"10032","quartier":"32","duration":["32","132"],"context":"4","contextExtra":["","",""],"freq":["0","5","10","15","20"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"0","interest":"2","irlfreq":["0","5","10","15","20"],"relmark":"2","medrel":"2"}
|
||||
{"id":91,"name":"contact-28","sexe":"0","age":"14","studies2":"1","reltype":"1","dist":"1","job":"7","famsit":"1","city":"43","cp":"10033","quartier":"33","duration":["33","133"],"context":"5","contextExtra":["","",""],"freq":["1","6","11","16","21"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"1","interest":"3","irlfreq":["1","6","11","16","21"],"relmark":"3","medrel":"0"}
|
||||
{"id":92,"name":"contact-29","sexe":"1","age":"15","studies2":"2","reltype":"2","dist":"2","job":"8","famsit":"2","city":"44","cp":"10034","quartier":"34","duration":["34","134"],"context":"6","contextExtra":["","",""],"freq":["2","7","12","17","22"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"2","interest":"4","irlfreq":["2","7","12","17","22"],"relmark":"4","medrel":"1"}
|
||||
{"id":93,"name":"contact-30","sexe":"2","age":"16","studies2":"3","reltype":"3","dist":"3","job":"9","famsit":"3","city":"45","cp":"10035","quartier":"35","duration":["35","135"],"context":"7","contextExtra":["","",""],"freq":["3","8","13","18","23"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"3","interest":"0","irlfreq":["3","8","13","18","23"],"relmark":"0","medrel":"2"}
|
||||
{"id":94,"name":"contact-31","sexe":"0","age":"17","studies2":"4","reltype":"4","dist":"0","job":"10","famsit":"0","city":"46","cp":"10036","quartier":"36","duration":["36","136"],"context":"8","contextExtra":["","",""],"freq":["0","5","10","15","20"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"0","interest":"1","irlfreq":["0","5","10","15","20"],"relmark":"1","medrel":"0"}
|
||||
{"id":95,"name":"contact-32","sexe":"1","age":"18","studies2":"5","reltype":"5","dist":"1","job":"11","famsit":"1","city":"47","cp":"10037","quartier":"37","duration":["37","137"],"context":"9","contextExtra":["","",""],"freq":["1","6","11","16","21"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"1","interest":"2","irlfreq":["1","6","11","16","21"],"relmark":"2","medrel":"1"}
|
||||
{"id":96,"name":"contact-33","sexe":"2","age":"0","studies2":"6","reltype":"6","dist":"2","job":"12","famsit":"2","city":"48","cp":"10038","quartier":"38","duration":["38","138"],"context":"10","contextExtra":["","",""],"freq":["2","7","12","17","22"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"2","interest":"3","irlfreq":["2","7","12","17","22"],"relmark":"3","medrel":"2"}
|
||||
{"id":97,"name":"contact-34","sexe":"0","age":"1","studies2":"7","reltype":"autre","dist":"3","job":"0","famsit":"3","city":"49","cp":"10039","quartier":"39","duration":["39","139"],"context":"11","contextExtra":["internet","",""],"freq":["3","8","13","18","23"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"3","interest":"4","irlfreq":["3","8","13","18","23"],"relmark":"4","medrel":"0"}
|
||||
{"id":98,"name":"contact-35","sexe":"1","age":"2","studies2":"0","reltype":"0","dist":"0","job":"1","famsit":"0","city":"50","cp":"10040","quartier":"40","duration":["40","140"],"context":"12","contextExtra":["","association",""],"freq":["0","5","10","15","20"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"0","interest":"0","irlfreq":["0","5","10","15","20"],"relmark":"0","medrel":"1"}
|
||||
{"id":99,"name":"contact-36","sexe":"2","age":"3","studies2":"1","reltype":"1","dist":"1","job":"2","famsit":"1","city":"51","cp":"10041","quartier":"41","duration":["41","141"],"context":"13","contextExtra":["","","autre"],"freq":["1","6","11","16","21"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"1","interest":"1","irlfreq":["1","6","11","16","21"],"relmark":"1","medrel":"2"}
|
||||
{"id":100,"name":"contact-37","sexe":"0","age":"4","studies2":"2","reltype":"2","dist":"2","job":"3","famsit":"2","city":"52","cp":"10042","quartier":"42","duration":["42","142"],"context":"0","contextExtra":["","",""],"freq":["2","7","12","17","22"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"2","interest":"2","irlfreq":["2","7","12","17","22"],"relmark":"2","medrel":"0"}
|
||||
{"id":101,"name":"contact-38","sexe":"1","age":"5","studies2":"3","reltype":"3","dist":"3","job":"4","famsit":"3","city":"53","cp":"10043","quartier":"43","duration":["43","143"],"context":"1","contextExtra":["","",""],"freq":["3","8","13","18","23"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""],"medsoc":"3","interest":"3","irlfreq":["3","8","13","18","23"],"relmark":"3","medrel":"1"}
|
||||
{"id":102,"name":"contact-39","sexe":"2","age":"6","studies2":"4","reltype":"4","dist":"0","job":"5","famsit":"0","city":"54","cp":"10044","quartier":"44","duration":["44","144"],"context":"2","contextExtra":["","",""],"freq":["0","5","10","15","20"],"connect":["0","2","4","6","8","10"],"connectExtra":["",""],"medsoc":"0","interest":"4","irlfreq":["0","5","10","15","20"],"relmark":"4","medrel":"2"}
|
||||
{"id":104,"name":"contact-41","sexe":"1","age":"","studies1":"2","reltype":"1","dist":"0"}
|
||||
{"id":105,"name":"contact-42","sexe":"0","age":"2","studies1":"3","reltype":"2","dist":"1"}
|
||||
{"id":106,"name":"contact-43","sexe":"1","age":"3","studies1":"4","reltype":"3","dist":"2"}
|
||||
{"id":107,"name":"contact-44","sexe":"0","age":"4","studies1":"5","reltype":"4","dist":"3"}
|
|
@ -0,0 +1 @@
|
|||
{"16":{"line":0},"17":{"line":1},"18":{"line":2},"19":{"line":3},"20":{"line":4},"21":{"line":5},"22":{"line":6},"23":{"line":7},"24":{"line":8},"25":{"line":9},"26":{"line":10},"27":{"line":11},"28":{"line":12},"29":{"line":13},"30":{"line":14},"31":{"line":15},"32":{"line":16},"33":{"line":17},"34":{"line":18},"35":{"line":19},"37":{"line":20},"38":{"line":21},"39":{"line":22},"40":{"line":23},"41":{"line":24},"42":{"line":25},"43":{"line":26},"44":{"line":27},"45":{"line":28},"46":{"line":29},"47":{"line":30},"48":{"line":31},"49":{"line":32},"50":{"line":33},"51":{"line":34},"52":{"line":35},"53":{"line":36},"54":{"line":37},"55":{"line":38},"57":{"line":39},"58":{"line":40},"59":{"line":41},"60":{"line":42},"63":{"line":43},"64":{"line":44},"65":{"line":45},"66":{"line":46},"67":{"line":47},"68":{"line":48},"69":{"line":49},"70":{"line":50},"71":{"line":51},"72":{"line":52},"73":{"line":53},"74":{"line":54},"75":{"line":55},"76":{"line":56},"77":{"line":57},"78":{"line":58},"79":{"line":59},"80":{"line":60},"81":{"line":61},"82":{"line":62},"84":{"line":63},"85":{"line":64},"86":{"line":65},"87":{"line":66},"88":{"line":67},"89":{"line":68},"90":{"line":69},"91":{"line":70},"92":{"line":71},"93":{"line":72},"94":{"line":73},"95":{"line":74},"96":{"line":75},"97":{"line":76},"98":{"line":77},"99":{"line":78},"100":{"line":79},"101":{"line":80},"102":{"line":81},"104":{"line":82},"105":{"line":83},"106":{"line":84},"107":{"line":85}}
|
|
@ -0,0 +1,218 @@
|
|||
{
|
||||
|
||||
|
||||
"logs": {
|
||||
"direction": { "0": "INCOMING", "1": "OUTGOING", "2": "MISSED" },
|
||||
"type": { "0": "PHONE", "1": "SMS" }
|
||||
},
|
||||
|
||||
|
||||
"questions": {
|
||||
"sexe": { "x": "Civilité" },
|
||||
"age": { "x": "Age" },
|
||||
"studies1": { "x": "Niveau d'études maximal (fiche rapide)" },
|
||||
"studies2": { "x": "Niveau d'études maximal (fiche complète)" },
|
||||
"job": { "x": "Dernière profession exercée" },
|
||||
"city": { "x": "Où habite t-elle/il ? (ville)" },
|
||||
"cp": { "x": "Où habite t-elle/il ? (code postal)" },
|
||||
"quartier": { "x": "Où habite t-elle/il ? (quartier)" },
|
||||
"context": { "x": "Contexte de rencontre" },
|
||||
"contextExtra": { "0": "Internet (quel contexte ? préciser)",
|
||||
"1": "Par une association (quel type ? préciser)",
|
||||
"2": "Autre" },
|
||||
"famsit": { "x": "Situation familiale" },
|
||||
"reltype": { "x": "Type de relation" },
|
||||
"dist": { "x": "À combien de temps est-ce de chez vous (en voiture) ? (si deux domiciles, le plus proche)" },
|
||||
"duration": { "0": "Depuis quand connaissez-vous cette personne ? (mois)",
|
||||
"1": "Depuis quand connaissez-vous cette personne ? (années)" },
|
||||
"freq": { "0": "Avec quelle fréquence discutez-vous avec cette personne face à face ?",
|
||||
"1": "Avec quelle fréquence discutez-vous avec cette personne via téléphone ou skype et équivalent ?",
|
||||
"2": "Avec quelle fréquence discutez-vous avec cette personne via SMS et équivalents ?",
|
||||
"3": "Avec quelle fréquence discutez-vous avec cette personne via courrier éléctronique ?",
|
||||
"4": "Avec quelle fréquence discutez-vous avec cette personne via facebook ou autre réseau social ?" },
|
||||
"irlfreq": { "0": "Selon vous, à quelle fréquence cette personne publie des commentaires personnels ou réagit aux publications des autres ?",
|
||||
"1": "Selon vous, à quelle fréquence cette personne publie des photos personnelles (profil, voyages, etc.) ?",
|
||||
"2": "Selon vous, à quelle fréquence cette personne partage de la musique ou des clips musicaux ?",
|
||||
"3": "Selon vous, à quelle fréquence cette personne partage des informations culturelles (concert, exposition, etc.) ?",
|
||||
"4": "Selon vous, à quelle fréquence cette personne partage des articles, des informations, des contenus avec une portée politique ?" },
|
||||
"connect": { "0": "Ses coordonnées sont dans votre carnet d'adresse",
|
||||
"1": "Son numéro de mobile est enregistré sur votre mobile (ou vous-mêmes êtes sur le sien)",
|
||||
"2": "Elle figure parmi vos amis facebook (idem)",
|
||||
"3": "Elle figure parmi vos amis facebook et vous interagissez avec elle sur ce dispositif régulièrement (idem)",
|
||||
"4": "Vous le suivez sur Twitter (ou elle vous suit)",
|
||||
"5": "Vous communiquez avec cette personne sur Twitter (idem)" },
|
||||
"connectExtra": { "0": "Vous communiquez dans autre réseau",
|
||||
"1": "Vous communiquez dans un autre dispositif (blogs, jeu vidéo ou autre)" },
|
||||
"medsoc": { "x": "Comment cette personne utilise-t-elle les médias sociaux de votre point de vue ?" },
|
||||
"medrel": { "x": "Considérez-vous que vos échange avec cette personne à travers les médias sociaux" },
|
||||
"interest": { "x": "Sur une échelle de 1 à 5, préciser l'intérêt que vous accordez aux contenue qu'elle partage via les médias sociaux" },
|
||||
"relmark": { "x": "Sur une échelle de 1 à 5, comment jugez-vous votre relation à cette personne ?" }
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
||||
"contacts": {
|
||||
|
||||
"sexe": { "0":"Homme", "1":"Femme", "2":"Indéterminé" },
|
||||
"age": {
|
||||
".": "NA",
|
||||
"0": "5 à 10", "1": "10 à 15", "2": "15 à 20", "3": "20 à 25", "4": "25 à 30",
|
||||
"5": "30 à 35", "6": "35 à 40", "7": "40 à 45", "8": "45 à 50", "9": "50 à 55",
|
||||
"10": "55 à 60", "11": "60 à 65", "12": "65 à 70", "13": "70 à 75", "14": "75 à 80",
|
||||
"15": "80 à 85", "16": "85 à 90", "17": "90 à 95", "18": "95 à 100"
|
||||
},
|
||||
|
||||
"studies1": {
|
||||
".": "NA",
|
||||
"0": "Inconnu",
|
||||
"1": "< BAC",
|
||||
"2": "BAC",
|
||||
"3": "BAC+2",
|
||||
"4": "BAC+3",
|
||||
"5": "BAC+4 et plus"
|
||||
},
|
||||
|
||||
"studies2": {
|
||||
".": "NA",
|
||||
"0": "Aucun diplôme, CEP, BEPC",
|
||||
"1": "CAP, CAPA, BEP, BEPA, Brevet de compagnon, Diplômes sociaux (aide-soignante, auxiliaire de puériculture, travailleuse familiale)",
|
||||
"2": "Bac technologique ou professionnel, brevet professionnel ou de technicien",
|
||||
"3": "Baccalauréat général, brevet supérieur",
|
||||
"4": "Diplôme universitaire de 1er cycle: Licence, BTS, DUT",
|
||||
"5": "Diplôme universitaire de 2ème cycle : MASTER, Maîtrise ou DEA, CAPES",
|
||||
"6": "Doctorat (y compris médecine, pharmacie, dentaire)",
|
||||
"7": "Diplôme d'ingénieur, diplôme d'une grande école de commerce"
|
||||
},
|
||||
|
||||
"job": {
|
||||
".": "NA",
|
||||
"0": "Agriculateur exploitants",
|
||||
"1": "Artisans",
|
||||
"2": "Commerçants et assimilés",
|
||||
"3": "Chefs d'entreprise de 10 salariés ou plus",
|
||||
"4": "Professions libérales et assimilés",
|
||||
"5": "Cadres de la fonction publique, professions intellectuelles et artistiques",
|
||||
"6": "Cadres d'entreprise",
|
||||
"7": "Professions intermétiaires de l'enseignement, de la santé, de la fonction publique et assimilés",
|
||||
"8": "Professions intermédiaires administratives et commerciales des entreprises",
|
||||
"9": "Techniciens",
|
||||
"10": "Contremaîtres, agents de maîtrise",
|
||||
"11": "Employés",
|
||||
"12": "Ouvriers"
|
||||
},
|
||||
|
||||
|
||||
"context": {
|
||||
"0": "De la même famille",
|
||||
"1": "Grandi ensemble",
|
||||
"2": "Par mon mari/ma femme/relation amoureuse",
|
||||
"3": "Par mes parents",
|
||||
"4": "Par mes enfants",
|
||||
"5": "Par un ami",
|
||||
"6": "Comme voisin",
|
||||
"7": "Par d’autres membres de la famille",
|
||||
"8": "Etudes",
|
||||
"9": "Etudes supérieures",
|
||||
"10": "Au travail",
|
||||
"11": "Internet",
|
||||
"12": "Association",
|
||||
"13": "Autre"
|
||||
},
|
||||
|
||||
"famsit": {
|
||||
"0": "Seul",
|
||||
"1": "Seul avec enfant(s)",
|
||||
"2": "En couple sans enfants",
|
||||
"3": "En couple avec enfants"
|
||||
},
|
||||
|
||||
"reltype": {
|
||||
"0": "Père, mère ou équivalent",
|
||||
"1": "Frère ou soeur",
|
||||
"2": "Autre membre de la famille",
|
||||
"3": "Relation amoureuse",
|
||||
"4": "Collègue",
|
||||
"5": "Voisin",
|
||||
"6": "Ami proche",
|
||||
"7": "Ami",
|
||||
"8": "Relation de service (médecin, ...)",
|
||||
"9": "Inconnu"
|
||||
},
|
||||
|
||||
"dist": {
|
||||
".": "NA",
|
||||
"0": "- de 5 minutes",
|
||||
"1": "de 5 à 15 minutes",
|
||||
"2": "de 15 à 60 minutes",
|
||||
"3": "+ d'une heure"
|
||||
},
|
||||
|
||||
"freq": {
|
||||
"0": "plusieurs fois par semaine",
|
||||
"1": "1 fois par semaine",
|
||||
"2": "1 fois par mois",
|
||||
"3": "1 fois par an ou moins",
|
||||
"4": "Jamais"
|
||||
},
|
||||
|
||||
"irlfreq": {
|
||||
"0": "plusieurs fois par semaine",
|
||||
"1": "1 fois par semaine",
|
||||
"2": "1 fois par mois",
|
||||
"3": "1 fois par an ou moins",
|
||||
"4": "Jamais"
|
||||
},
|
||||
|
||||
"connect": {
|
||||
"0": "Oui",
|
||||
"1": "Non"
|
||||
},
|
||||
|
||||
"medsoc": {
|
||||
"0": "D'une personne qui n'utilise pas ou peu les médias sociaux",
|
||||
"1": "D'une personne qui consulte des publications mais partage peu de contenus",
|
||||
"2": "D'une personne qui consulte des publication et partage des contenus de temps en temps",
|
||||
"3": "D'une personne qui partage beaucoup de contenus et s'exprime fréquemment"
|
||||
},
|
||||
|
||||
"medrel": {
|
||||
"0": "N'ont aucun effet sur votre relation",
|
||||
"1": "Vous ont rapproché d'elle",
|
||||
"2": "Vous ont éloigné d'elle"
|
||||
},
|
||||
|
||||
"interest": {
|
||||
"0": "1",
|
||||
"1": "2",
|
||||
"2": "3",
|
||||
"3": "4",
|
||||
"4": "5"
|
||||
},
|
||||
|
||||
"relmark": {
|
||||
"0": "1",
|
||||
"1": "2",
|
||||
"2": "3",
|
||||
"3": "4",
|
||||
"4": "5"
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
"relations": {
|
||||
|
||||
"type": {
|
||||
"0": "Aucune relation",
|
||||
"1": "Relation alter-alter",
|
||||
"2": "Relation cellulaire mineure",
|
||||
"3": "Relation facebook mineure",
|
||||
"4": "Top 10 des appels",
|
||||
"5": "Top 10 des sms",
|
||||
"6": "Top 10 de l'historique Facebook",
|
||||
"7": "Top 10 de Facebook Messenger"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,7 @@
|
|||
Contient les équivalences :
|
||||
|
||||
id_subject => {
|
||||
"subject": [données du sujet]
|
||||
"contact": [liste des id des contacts],
|
||||
"relations": [liste des relations]
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
{"2":{"line":0},"4":{"line":1},"5":{"line":2},"6":{"line":3},"7":{"line":4},"8":{"line":5},"9":{"line":6},"10":{"line":7},"11":{"line":8},"12":{"line":9},"13":{"line":10},"14":{"line":11},"15":{"line":12},"1":{"line":13},"3":{"line":14}}
|
|
@ -0,0 +1 @@
|
|||
107
|
|
@ -0,0 +1,131 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace manager;
|
||||
|
||||
|
||||
class ManagerError{
|
||||
|
||||
/* SUCCESS */
|
||||
const Success = 0;
|
||||
|
||||
/* Parsage json */
|
||||
const ParsingFailed = 1;
|
||||
|
||||
/* ResourceDispatcher */
|
||||
|
||||
// Drapeaux invalides
|
||||
const InvalidFlags = 2;
|
||||
|
||||
// Fichier inexistant
|
||||
const UnreachableResource = 3;
|
||||
|
||||
|
||||
/* ModuleRequest */
|
||||
|
||||
// Le @path n'est pas renseigne
|
||||
const MissingPath = 4;
|
||||
|
||||
// Verification de la coherence du chemin (existe dans la conf)
|
||||
const WrongPathModule = 5;
|
||||
|
||||
// Module non specifie dans la conf
|
||||
const UnknownModule = 6;
|
||||
|
||||
// Methode non specifie pour ce Module dans la conf
|
||||
const UnknownMethod = 7;
|
||||
|
||||
// Methode inamorcable
|
||||
const UncallableMethod = 8;
|
||||
|
||||
// Erreur de parametre(s)
|
||||
const ParamError = 9;
|
||||
|
||||
// Erreur dans le traitement
|
||||
const ModuleError = 10;
|
||||
|
||||
/* Repo */
|
||||
|
||||
// Verification de la coherence du chemin (existe dans la conf)
|
||||
const WrongPathRepo = 11;
|
||||
|
||||
// Module non specifie dans la conf
|
||||
const UnknownRepo = 12;
|
||||
|
||||
// Erreur dans le traitement
|
||||
const RepoError = 13;
|
||||
|
||||
/* Database */
|
||||
|
||||
// Erreur lors de la creation d'un objet PDO (connection)
|
||||
const PDOConnection = 14;
|
||||
|
||||
/* API token */
|
||||
// Token inexistant ou faux
|
||||
const TokenError = 15;
|
||||
|
||||
const PermissionError = 16;
|
||||
|
||||
/* Erreur d'UPLOAD */
|
||||
const UploadError = 17;
|
||||
|
||||
// Mauvais format de fichier
|
||||
const FormatError = 18;
|
||||
|
||||
/* Erreur au niveau javascript */
|
||||
//const JavascriptError = 19; // -> géré en js
|
||||
|
||||
// Already done error
|
||||
const Already = 20;
|
||||
|
||||
|
||||
/* EXPLICITE UN CODE D'ERREUR
|
||||
*
|
||||
* @error<Integer> Code d'erreur
|
||||
*
|
||||
* @return explicit<String> Description explicite du code d'erreur
|
||||
*
|
||||
*/
|
||||
public static function explicit($error){
|
||||
switch($error){
|
||||
case self::Success: return "All right."; break;
|
||||
|
||||
case self::ParsingFailed: return "JSON/XML file format error."; break;
|
||||
|
||||
case self::InvalidFlags: return "Flags are incorrect."; break;
|
||||
case self::UnreachableResource: return "Resource unreachable (404)."; break;
|
||||
case self::MissingPath: return "Path missing."; break;
|
||||
case self::WrongPathModule: return "Module path incorrect 'module/method'."; break;
|
||||
case self::WrongPathRepo: return "Repository path incorrect 'repo/method'."; break;
|
||||
case self::UnknownModule: return "Requested module not found."; break;
|
||||
case self::UnknownRepo: return "Requested repository not found."; break;
|
||||
case self::UnknownMethod: return "Requested method not found."; break;
|
||||
case self::UncallableMethod: return "Cannot call requested method."; break;
|
||||
|
||||
case self::ParamError: return "Wrong or missing parameter(s)."; break;
|
||||
case self::ModuleError: return "Module error."; break;
|
||||
case self::RepoError: return "Repository error."; break;
|
||||
|
||||
case self::PDOConnection: return "Database connection failed."; break;
|
||||
|
||||
case self::TokenError: return "Access token wrong, missing or expired."; break;
|
||||
case self::PermissionError: return "Not granted to do so."; break;
|
||||
case self::UploadError: return "Upload error."; break;
|
||||
case self::FormatError: return "Format error."; break;
|
||||
case self::Already: return "Already done."; break;
|
||||
|
||||
default: return "Unknown debug error"; break;
|
||||
}
|
||||
|
||||
// Erreur inconnue
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static function setHttpCode($error){
|
||||
http_response_code( $error == self::Success ? 200 : 417 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -4,10 +4,11 @@
|
|||
|
||||
|
||||
|
||||
|
||||
class MenuManager{
|
||||
|
||||
// Constantes
|
||||
public static $config_path = __ROOT__.'/config/menu.json';
|
||||
public static function config_path(){ return __CONFIG__.'/menu.json'; }
|
||||
|
||||
|
||||
// Attributs prives utiles (initialisation)
|
||||
|
@ -27,7 +28,7 @@
|
|||
/* [0] On met a jour la configuration
|
||||
=========================================================*/
|
||||
// Categories specifiees
|
||||
$this->categories = json_decode( file_get_contents(self::$config_path), true );
|
||||
$this->categories = json_decode( file_get_contents(self::config_path()), true );
|
||||
|
||||
// Gestion de l'erreur de parsage
|
||||
if( $this->categories == null ){
|
||||
|
@ -71,7 +72,7 @@
|
|||
|
||||
// On met l'icone associee
|
||||
if( isset($category['icon']) )
|
||||
$render .= file_get_contents(__ROOT__.$category['icon']);
|
||||
$render .= file_get_contents(__PUBLIC__.$category['icon']);
|
||||
|
||||
// On met le texte de la categorie
|
||||
if( isset($category['text']) )
|
||||
|
@ -112,7 +113,7 @@
|
|||
|
||||
/* [2] On recupere la liste des categories
|
||||
=========================================================*/
|
||||
$views = array();
|
||||
$views = [];
|
||||
|
||||
foreach($this->categories as $category)
|
||||
array_push($views, $category['attributes']['data-link']);
|
||||
|
@ -134,13 +135,13 @@
|
|||
public function buildMenu(){
|
||||
/* [0] Initialisation du menu qui va etre retourne (vide)
|
||||
=========================================================*/
|
||||
$menu = array();
|
||||
$menu = [];
|
||||
|
||||
/* [1] Pour chaque categorie
|
||||
=========================================================*/
|
||||
foreach($this->categories as $a=>$category){
|
||||
// Contiendra les sous-parties dont on a acces
|
||||
$access_children = array();
|
||||
$access_children = [];
|
||||
|
||||
/* [2] Pour chaque sous-partie
|
||||
=========================================================*/
|
||||
|
@ -148,7 +149,7 @@
|
|||
|
||||
foreach($category['children'] as $b=>$children){
|
||||
/* (1) On verifie les permissions */
|
||||
$canView = $this->checkPermissions( isset($children['permissions']) ? $children['permissions'] : array() );
|
||||
$canView = $this->checkPermissions( isset($children['permissions']) ? $children['permissions'] : [] );
|
||||
|
||||
/* (2) Si on a l'acces, ajout au tableau */
|
||||
if( $canView )
|
|
@ -58,8 +58,7 @@
|
|||
/* AMORCEUR */
|
||||
/************/
|
||||
public static function session_start(){
|
||||
\session_start();
|
||||
return;
|
||||
return \session_start();
|
||||
|
||||
|
||||
/* [1] Génération et Gestion des donnees a utiliser
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,370 @@
|
|||
<?php
|
||||
|
||||
namespace orm\core;
|
||||
|
||||
use \database\core\DatabaseDriver;
|
||||
use \orm\core\Rows;
|
||||
|
||||
|
||||
class SQLBuilder{
|
||||
|
||||
|
||||
/* CONSTRUIT LA REQUETE FORMATTEE "SELECT" AVEC UNE LISTE DE CHAMPS
|
||||
*
|
||||
* @sqlFields<Array> Liste de champs : [table => field => [func, alias] ]
|
||||
*
|
||||
* @return sql<Array> Renvoie un tableau formatté
|
||||
*
|
||||
*/
|
||||
public static function SELECT($sqlFields){
|
||||
return $sqlFields;
|
||||
}
|
||||
|
||||
|
||||
/* CONSTRUIT LA REQUETE FORMATTEE "ORDER BY" AVEC UNE LISTE DE CHAMPS
|
||||
*
|
||||
* @tables<Array> Liste de champs : [table => fields]
|
||||
*
|
||||
* @return sql<Array> Renvoie un tableau formatté
|
||||
*
|
||||
*/
|
||||
public static function ORDERBY($tables){
|
||||
return $tables;
|
||||
}
|
||||
|
||||
/* CONSTRUIT LA REQUETE FORMATTEE "GROUP BY" AVEC UNE LISTE DE CHAMPS
|
||||
*
|
||||
* @tables<Array> Liste de champs : [table => fields]
|
||||
*
|
||||
* @return sql<Array> Renvoie un tableau formatté
|
||||
*
|
||||
*/
|
||||
public static function GROUPBY($tables){
|
||||
return $tables;
|
||||
}
|
||||
|
||||
|
||||
/* CONSTRUIT LA REQUETE FORMATTEE "FROM" AVEC UNE LISTE DE TABLES
|
||||
*
|
||||
* @tables<Array> Liste de tables OU SQL PUR
|
||||
*
|
||||
* @return sql<Array> Renvoie un tableau formatté
|
||||
*
|
||||
*/
|
||||
public static function FROM($tables){
|
||||
return $tables;
|
||||
}
|
||||
|
||||
|
||||
/* CONSTRUIT LA REQUETE FORMATTEE "UPDATE" AVEC LA TABLE EN QUESTION
|
||||
*
|
||||
* @table<String> Table en question
|
||||
*
|
||||
* @return sql<Array> Renvoie un tableau formatté
|
||||
*
|
||||
*/
|
||||
public static function UPDATE($table){
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
||||
/* CONSTRUIT LA REQUETE FORMATTEE "DELETE" AVEC LA TABLE EN QUESTION
|
||||
*
|
||||
* @table<String> Table en question
|
||||
*
|
||||
* @return sql<Array> Renvoie un tableau formatté
|
||||
*
|
||||
*/
|
||||
public static function DELETE($table){
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
||||
/* CONSTRUIT LA REQUETE TEXTUELLE "IN" AVEC UNE LISTE DE TABLES
|
||||
*
|
||||
* @field<Array> Tableau contenant [table, field]
|
||||
* @array<Array> Valeurs de la clause IN
|
||||
* @offset<int> Permet de rendre la condition unique (nommage des variables)
|
||||
* @bound<Arary> Tableau associatif contenant les variables "bindés" -> ajout des champs
|
||||
*
|
||||
* @return sql<String> Renvoie le textuel formatté
|
||||
*
|
||||
*/
|
||||
public static function IN($field, $array, $offset=0, &$bound){
|
||||
/* [0] Initialisation
|
||||
=========================================================*/
|
||||
$sql = '';
|
||||
|
||||
/* [1] On construit la requête
|
||||
=========================================================*/
|
||||
/* (1) Champ */
|
||||
$sql .= $field[0].'.'.$field[1].' IN (';
|
||||
|
||||
/* (2) Valeurs */
|
||||
$c = 0;
|
||||
foreach($array as $i=>$value){
|
||||
if( $c > 0 ) $sql .= ', ';
|
||||
|
||||
$sql .= ':'.$field[0].'_x_'.$field[1].'_'.$offset.'_'.$i;
|
||||
|
||||
$bound[':'.$field[0].'_x_'.$field[1].'_'.$offset.'_'.$i] = $value;
|
||||
|
||||
$c++;
|
||||
}
|
||||
|
||||
return $sql.")";
|
||||
} /* CONSTRUIT LA REQUETE TEXTUELLE "WHERE" AVEC UNE LISTE DE TABLES
|
||||
*
|
||||
* @field<Array> Tableau contenant [table, field]
|
||||
* @valeur<Array> Valeurs de la clause WHERE [valeur, opérateur]
|
||||
* @offset<int> Permet de rendre la condition unique (nommage des variables)
|
||||
* @bound<Arary> Tableau associatif contenant les variables "bindés" -> ajout des champs
|
||||
*
|
||||
* @return sql<String> Renvoie le textuel formatté
|
||||
*
|
||||
*/
|
||||
public static function WHERE($field, $value, $offset=0, &$bound){
|
||||
/* [0] Initialisation
|
||||
=========================================================*/
|
||||
$sql = '';
|
||||
|
||||
|
||||
/* [1] On construit la requête
|
||||
=========================================================*/
|
||||
/* (1) Chamo */
|
||||
$sql .= $field[0].'.'.$field[1].' ';
|
||||
|
||||
/* (2) Opérateur */
|
||||
$sql .= substr($value[1], 2, -2).' ';
|
||||
|
||||
/* (3) Variable */
|
||||
$sql .= ':'.$field[0].'_x_'.$field[1].'_'.$offset;
|
||||
|
||||
$bound[':'.$field[0].'_x_'.$field[1].'_'.$offset] = $value[0];
|
||||
|
||||
|
||||
return $sql;
|
||||
} /* CONSTRUIT LA REQUETE FORMATTEE "SET" AVEC UNE LISTE DE TABLES
|
||||
*
|
||||
* @values<Array> Tableau de la forme [ field=>value, field2=>value2 ]
|
||||
* @bound<Arary> Tableau associatif contenant les variables "bindés" -> ajout des champs
|
||||
*
|
||||
* @return sql<Array> Renvoie un tableau formatté
|
||||
*
|
||||
*/
|
||||
public static function SET($values, &$bound){
|
||||
/* [0] Initialisation
|
||||
=========================================================*/
|
||||
$sql = [];
|
||||
|
||||
|
||||
/* [1] On construit la requête
|
||||
=========================================================*/
|
||||
$c = 0;
|
||||
foreach($values as $field=>$value){
|
||||
/* (1) Champ */
|
||||
$sql[$c] = $field.' = ';
|
||||
|
||||
/* (2) Variable */
|
||||
$sql[$c] .= ':update_'.$field;
|
||||
|
||||
$bound[':update_'.$field] = $value;
|
||||
|
||||
$c++;
|
||||
}
|
||||
|
||||
return $sql;
|
||||
} /* CONSTRUIT LA REQUETE FORMATTEE "LIMIT" AVEC UN NOMBRE D'ENTREES
|
||||
*
|
||||
* @count<int> Nombre limite
|
||||
*
|
||||
* @return sql<Array> Renvoie un sql formatté
|
||||
*
|
||||
*/
|
||||
public static function LIMIT($count=null){
|
||||
/* [0] Initialisation
|
||||
=========================================================*/
|
||||
$sql = '';
|
||||
|
||||
|
||||
/* [1] On construit la requête
|
||||
=========================================================*/
|
||||
if( intval($count) == $count )
|
||||
$sql = intval($count);
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/* CONSTRUIT LA REQUETE A PARTIR D'UNE REQUETTE FORMATTEE
|
||||
*
|
||||
* @request<Arary> Requête formattée
|
||||
*
|
||||
* @return sql<String> Requête formattée en SQL
|
||||
*
|
||||
*/
|
||||
public static function BUILD($request){
|
||||
/* [0] On initialise le retour
|
||||
=========================================================*/
|
||||
$sql = '';
|
||||
|
||||
/* [1] Gestion dans l'ordre
|
||||
=========================================================*/
|
||||
foreach($request as $clause=>$statements){
|
||||
|
||||
switch($clause){
|
||||
|
||||
/* (1) Clause SELECT
|
||||
---------------------------------------------------------*/
|
||||
case 'SELECT':
|
||||
$sql .= "SELECT ";
|
||||
$c = 0;
|
||||
foreach($statements as $table=>$fields){
|
||||
foreach($fields as $field=>$select){
|
||||
|
||||
/* (1) On construit le nom du champ */
|
||||
$fieldStr = "$table.$field";
|
||||
|
||||
/* (2) On ajout le DISTINCT s'il y a lieu */
|
||||
if( isset($select[1]) && $select[1] )
|
||||
$fieldStr = "DISTINCT $fieldStr";
|
||||
|
||||
/* (3) On ajoute la fonction d'aggrégation s'il y a lieu */
|
||||
if( isset($select[0]) && !is_null($select[0]) )
|
||||
$fieldStr = substr($select[0], 2, -2)."($fieldStr)";
|
||||
|
||||
|
||||
/* (4) On ajoute l'alias */
|
||||
// si défini
|
||||
if( isset($select[2]) )
|
||||
$fieldStr = "$fieldStr as ".$select[2];
|
||||
// si func et non défini
|
||||
elseif( isset($select[0]) && !is_null($select[0]) )
|
||||
$fieldStr = "$fieldStr as agg_$field";
|
||||
else
|
||||
$fieldStr = "$fieldStr";
|
||||
|
||||
$sql .= ($c==0) ? "$fieldStr" : ", $fieldStr";
|
||||
|
||||
$c++;
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= "\n";
|
||||
break;
|
||||
|
||||
/* (2) Clause FROM
|
||||
---------------------------------------------------------*/
|
||||
case 'FROM':
|
||||
$sql .= 'FROM ';
|
||||
|
||||
$c = 0;
|
||||
foreach($statements as $field){
|
||||
$sql .= ($c==0) ? "$field" : ", $field";
|
||||
$c++;
|
||||
}
|
||||
|
||||
$sql .= "\n";
|
||||
break;
|
||||
|
||||
|
||||
/* (3) Clause WHERE
|
||||
---------------------------------------------------------*/
|
||||
case 'WHERE':
|
||||
$c = 0;
|
||||
foreach($statements as $field){
|
||||
$sql .= ($c==0) ? "WHERE $field\n" : "AND $field\n";
|
||||
$c++;
|
||||
}
|
||||
|
||||
$sql .= ($c==0) ? '' : "\n";
|
||||
break;
|
||||
|
||||
|
||||
|
||||
/* (4) Clause LIMIT
|
||||
---------------------------------------------------------*/
|
||||
case 'LIMIT':
|
||||
if( is_numeric($statements) )
|
||||
$sql .= 'LIMIT '.intval($statements);
|
||||
break;
|
||||
|
||||
|
||||
/* (5) Clause DELETE
|
||||
---------------------------------------------------------*/
|
||||
case 'DELETE':
|
||||
$sql .= "DELETE FROM $statements\n";
|
||||
break;
|
||||
|
||||
|
||||
/* (6) Clause UPDATE
|
||||
---------------------------------------------------------*/
|
||||
case 'UPDATE':
|
||||
$sql .= "UPDATE $statements\n";
|
||||
break;
|
||||
|
||||
|
||||
/* (7) Clause SET
|
||||
---------------------------------------------------------*/
|
||||
case 'SET':
|
||||
$c = 0;
|
||||
foreach($statements as $field){
|
||||
$sql .= ($c>0) ? "\n, $field" : "SET $field";
|
||||
$c++;
|
||||
}
|
||||
$sql .= "\n";
|
||||
break;
|
||||
|
||||
/* (8) Clause GROUP BY
|
||||
---------------------------------------------------------*/
|
||||
case 'GROUPBY':
|
||||
$sql .= 'GROUP BY ';
|
||||
|
||||
$c = 0;
|
||||
foreach($statements as $table=>$fields)
|
||||
foreach($fields as $field){
|
||||
$sql .= ($c==0) ? "$table.$field" : ", $table.$field";
|
||||
$c++;
|
||||
}
|
||||
|
||||
$sql .= "\n";
|
||||
break;
|
||||
|
||||
/* (9) Clause ORDER BY
|
||||
---------------------------------------------------------*/
|
||||
case 'ORDERBY':
|
||||
|
||||
// si aucun ORDER BY, on quitte
|
||||
if( count($statements) == 0 )
|
||||
continue;
|
||||
|
||||
$sql .= 'ORDER BY ';
|
||||
|
||||
$c = 0;
|
||||
foreach($statements as $table=>$fields)
|
||||
foreach($fields as $field=>$order){
|
||||
|
||||
if( $c > 0 ) $sql .= ', ';
|
||||
|
||||
$sql .= "$table.$field ". substr($order, 2, -2);
|
||||
|
||||
$c++;
|
||||
}
|
||||
|
||||
$sql .= "\n";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* [2] On retourne le résultat
|
||||
=========================================================*/
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -0,0 +1,132 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace orm\core;
|
||||
|
||||
use \database\core\DatabaseDriver;
|
||||
use \manager\ManagerError;
|
||||
use \orm\core\Rows;
|
||||
|
||||
|
||||
// CLASSE MAITRE
|
||||
class Table{
|
||||
|
||||
|
||||
/* RENVOIE LES DONNEES D'UNE TABLE
|
||||
*
|
||||
* @table<String> Nom de la table à selectionner
|
||||
* @driver<String> [optional] DatabaseDriver label
|
||||
*
|
||||
* @return this<ORM> Retourne une instance de l'ORM
|
||||
*
|
||||
*/
|
||||
public static function get($table_name, $driver=null){
|
||||
/* [0] Initialisation des attributs
|
||||
=========================================================*/
|
||||
$schema = [
|
||||
'database' => DatabaseDriver::get($driver)->getConfig()['dbname'],
|
||||
'table' => null,
|
||||
'columns' => null
|
||||
];
|
||||
|
||||
|
||||
/* [1] On vérifie que la table existe
|
||||
=========================================================*/
|
||||
/* (1) Requête */
|
||||
$checkTable = DatabaseDriver::getPDO($driver)->query("SHOW tables FROM ".$schema['database']);
|
||||
$checkTableResult = DatabaseDriver::delNumeric( $checkTable->fetchAll() );
|
||||
|
||||
/* (2) On met en forme les données */
|
||||
$tables = [];
|
||||
foreach($checkTableResult as $table)
|
||||
$tables[] = $table['Tables_in_'.$schema['database']];
|
||||
|
||||
/* (3) Si n'existe pas, on renvoie une erreur */
|
||||
if( !in_array($table_name, $tables) )
|
||||
throw new \Exception('[*] Unknown table.');
|
||||
|
||||
/* (4) On enregistre les données */
|
||||
$schema['table'] = $table_name;
|
||||
|
||||
|
||||
|
||||
/* [2] Si la table existe, on récupère les colonnes
|
||||
=========================================================*/
|
||||
/* (1) On récupère les colonnes */
|
||||
$getColumns = DatabaseDriver::getPDO($driver)->query("SHOW columns FROM ".$schema['database'].'.'.$table_name);
|
||||
$columnsResult = DatabaseDriver::delNumeric( $getColumns->fetchAll() );
|
||||
|
||||
/* (2) On met en forme les données */
|
||||
$columns = [];
|
||||
foreach($columnsResult as $col){
|
||||
// On formatte le type //
|
||||
$type = $col['Type'];
|
||||
if( preg_match('/^(int|float|varchar|text)/i', $type, $m) )
|
||||
$type = strtolower($m[1]);
|
||||
|
||||
// On ajoute la colonne //
|
||||
$columns[$col['Field']] = [
|
||||
'type' => $type,
|
||||
'primary' => $col['Key'] == 'PRI'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/* (3) Si on trouve rien, on envoie une erreur */
|
||||
if( !is_array($columns) || count($columns) == 0 )
|
||||
throw new \Exception('[*] Cannot fetch columns');
|
||||
|
||||
/* (4) On enregistre les colonnes */
|
||||
$schema['columns'] = $columns;
|
||||
|
||||
|
||||
|
||||
/* [3] On récupère les clés étrangères
|
||||
=========================================================*/
|
||||
/* (1) On récupère le texte du 'CREATE TABLE' */
|
||||
$getCreateTable = DatabaseDriver::getPDO($driver)->query("show create table ".$table_name);
|
||||
if( is_bool($getCreateTable) )
|
||||
throw new \Exception('[*] Cannot fetch constrains');
|
||||
$create_table = $getCreateTable->fetch()['Create Table'];
|
||||
|
||||
/* (2) On découpte en lignes */
|
||||
$create_table_lines = explode("\n", $create_table);
|
||||
|
||||
/* (3) Pour chaque ligne, si c'est une contrainte, on l'enregistre dans la colonne associée */
|
||||
foreach($create_table_lines as $i=>$line)
|
||||
if( preg_match('/CONSTRAINT `.+` FOREIGN KEY \(`(.+)`\) REFERENCES `(.+)` \(`(.+)`\)+/i', $line, $m) )
|
||||
$schema['columns'][$m[1]]['references'] = [$m[2], $m[3]];
|
||||
|
||||
|
||||
|
||||
/* [3] On renvoie une instance de 'Rows'
|
||||
=========================================================*/
|
||||
return new Rows($schema, $driver);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
// // USE CASE :: ACCESS TABLE
|
||||
// ORM::Table = ORM::Table('user');
|
||||
//
|
||||
// // USE CASE :: getBy{ATTRIBUTE}
|
||||
// ORM::Row = ORM::Table->getByUsername('someUsername'); // ORM_FETCH by default
|
||||
// ORM::Row = ORM::Table->getByUsername('someUsername', ORM_FETCH);
|
||||
// ORM::Column = ORM::Table->getByUsername('someUsername', ORM_FETCHALL);
|
||||
//
|
||||
// // USE CASE :: getById -> primary key(s)
|
||||
// ORM::Row = ORM::Table->getById(5, 7); // because PRIMARY KEY is composed by '5' and '7'
|
||||
//
|
||||
// // USE CASE :: getAll
|
||||
// ORM::Column = ORM::Table->getAll();
|
||||
//
|
||||
// // USE CASE :: select(FIELD)
|
||||
// mixed = ORM::Row->select('username');
|
||||
//
|
||||
// // USE CASE :: select(FIELD1, FIELD2, ...)
|
||||
// mixed = ORM::Row->select('id_user', 'username');
|
|
@ -3,14 +3,14 @@
|
|||
/* Classe de gestion de route (match) */
|
||||
/**************************************/
|
||||
|
||||
namespace router;
|
||||
namespace router\core;
|
||||
|
||||
class Route{
|
||||
|
||||
// ATTRIBUTS
|
||||
private $pattern;
|
||||
private $callback;
|
||||
private $matches = array();
|
||||
private $matches = [];
|
||||
|
||||
/* Initialise la route
|
||||
*
|
|
@ -3,7 +3,7 @@
|
|||
/* Classe de gestion des routes (URL/ressources) */
|
||||
/*************************************************/
|
||||
|
||||
namespace router;
|
||||
namespace router\core;
|
||||
|
||||
class Router{
|
||||
// ATTRIBUTS
|
||||
|
@ -21,10 +21,10 @@ class Router{
|
|||
$this->url = $url;
|
||||
|
||||
// On initialise les routes
|
||||
$this->routes = array(
|
||||
'GET' => array(),
|
||||
'POST' => array()
|
||||
);
|
||||
$this->routes = [
|
||||
'GET' => [],
|
||||
'POST' => []
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
|
@ -0,0 +1,852 @@
|
|||
{
|
||||
"subject": {
|
||||
"subject_id": "1"
|
||||
},
|
||||
"contacts": {
|
||||
"0": {
|
||||
"uid": 0,
|
||||
"username": "Ismael",
|
||||
"existing": ".",
|
||||
"hash": 1627075103
|
||||
},
|
||||
"1": {
|
||||
"uid": 1,
|
||||
"username": "Rosa",
|
||||
"existing": ".",
|
||||
"hash": 498192491
|
||||
},
|
||||
"2": {
|
||||
"uid": 2,
|
||||
"username": "Judith",
|
||||
"existing": ".",
|
||||
"hash": 1451575763
|
||||
},
|
||||
"3": {
|
||||
"uid": 3,
|
||||
"username": "Alex",
|
||||
"existing": ".",
|
||||
"hash": 2660323475
|
||||
},
|
||||
"4": {
|
||||
"uid": 4,
|
||||
"username": "Adri",
|
||||
"existing": ".",
|
||||
"hash": 2559488290
|
||||
},
|
||||
"5": {
|
||||
"uid": 5,
|
||||
"username": "Fred",
|
||||
"existing": ".",
|
||||
"hash": 4039469544
|
||||
},
|
||||
"6": {
|
||||
"uid": 6,
|
||||
"username": "Shanone",
|
||||
"existing": ".",
|
||||
"hash": 28222849
|
||||
},
|
||||
"7": {
|
||||
"uid": 7,
|
||||
"username": "Manon",
|
||||
"existing": ".",
|
||||
"hash": 336712847
|
||||
},
|
||||
"8": {
|
||||
"uid": 8,
|
||||
"username": "Java",
|
||||
"existing": ".",
|
||||
"hash": 1359920097
|
||||
},
|
||||
"9": {
|
||||
"uid": 9,
|
||||
"username": "Thalees",
|
||||
"existing": ".",
|
||||
"hash": 2826325950
|
||||
},
|
||||
"10": {
|
||||
"uid": 10,
|
||||
"username": "Crème",
|
||||
"existing": ".",
|
||||
"hash": 4211503315
|
||||
},
|
||||
"11": {
|
||||
"uid": 11,
|
||||
"username": "Margaux",
|
||||
"existing": ".",
|
||||
"hash": 3915760272
|
||||
},
|
||||
"12": {
|
||||
"uid": 12,
|
||||
"username": "Anthony",
|
||||
"existing": ".",
|
||||
"hash": 410858384
|
||||
},
|
||||
"13": {
|
||||
"uid": 13,
|
||||
"username": "Lino",
|
||||
"existing": ".",
|
||||
"hash": 2457771762
|
||||
}
|
||||
},
|
||||
"mini": {},
|
||||
"fiches": {
|
||||
"0": {
|
||||
"sexe": "0",
|
||||
"age": "0",
|
||||
"job": "10",
|
||||
"famsit": "0",
|
||||
"studies": "",
|
||||
"reltype": "0",
|
||||
"reltypeSpecial": "",
|
||||
"city": "10",
|
||||
"quartier": "0",
|
||||
"cp": "10000",
|
||||
"loc": "0",
|
||||
"duration": [
|
||||
"0",
|
||||
"10"
|
||||
],
|
||||
"context": "0",
|
||||
"contextSpecial": [
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"freq": [
|
||||
"2",
|
||||
"9",
|
||||
"14",
|
||||
"19",
|
||||
"24"
|
||||
],
|
||||
"connect": [
|
||||
"1",
|
||||
"3",
|
||||
"5",
|
||||
"7",
|
||||
"9",
|
||||
"11"
|
||||
],
|
||||
"connectSpecial": [
|
||||
"",
|
||||
""
|
||||
],
|
||||
"uid": 0,
|
||||
"contact": 0,
|
||||
"hash": 3977448909,
|
||||
"valid": true,
|
||||
"timestamp": 1478429171540
|
||||
},
|
||||
"1": {
|
||||
"sexe": "1",
|
||||
"age": "1",
|
||||
"job": "21",
|
||||
"famsit": "0",
|
||||
"studies": "01",
|
||||
"reltype": "1",
|
||||
"reltypeSpecial": "",
|
||||
"city": "11",
|
||||
"quartier": "1",
|
||||
"cp": "10001",
|
||||
"loc": "1",
|
||||
"duration": [
|
||||
"1",
|
||||
"11"
|
||||
],
|
||||
"context": "1",
|
||||
"contextSpecial": [
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"freq": [
|
||||
"4",
|
||||
"9",
|
||||
"14",
|
||||
"19",
|
||||
"24"
|
||||
],
|
||||
"connect": [
|
||||
"1",
|
||||
"3",
|
||||
"5",
|
||||
"7",
|
||||
"9",
|
||||
"11"
|
||||
],
|
||||
"connectSpecial": [
|
||||
"",
|
||||
""
|
||||
],
|
||||
"uid": 1,
|
||||
"contact": 1,
|
||||
"hash": 3439453096,
|
||||
"valid": true,
|
||||
"timestamp": 1478429171592
|
||||
},
|
||||
"2": {
|
||||
"sexe": "2",
|
||||
"age": "2",
|
||||
"job": "22",
|
||||
"famsit": "0",
|
||||
"studies": "02",
|
||||
"reltype": "2",
|
||||
"reltypeSpecial": "",
|
||||
"city": "12",
|
||||
"quartier": "2",
|
||||
"cp": "10002",
|
||||
"loc": "2",
|
||||
"duration": [
|
||||
"2",
|
||||
"12"
|
||||
],
|
||||
"context": "2",
|
||||
"contextSpecial": [
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"freq": [
|
||||
"4",
|
||||
"9",
|
||||
"14",
|
||||
"19",
|
||||
"24"
|
||||
],
|
||||
"connect": [
|
||||
"1",
|
||||
"3",
|
||||
"5",
|
||||
"7",
|
||||
"9",
|
||||
"11"
|
||||
],
|
||||
"connectSpecial": [
|
||||
"",
|
||||
""
|
||||
],
|
||||
"uid": 2,
|
||||
"contact": 2,
|
||||
"hash": 2538679406,
|
||||
"valid": true,
|
||||
"timestamp": 1478429171636
|
||||
},
|
||||
"3": {
|
||||
"sexe": "0",
|
||||
"age": "3",
|
||||
"job": "23",
|
||||
"famsit": "0",
|
||||
"studies": "03",
|
||||
"reltype": "3",
|
||||
"reltypeSpecial": "",
|
||||
"city": "13",
|
||||
"quartier": "3",
|
||||
"cp": "10003",
|
||||
"loc": "3",
|
||||
"duration": [
|
||||
"3",
|
||||
"13"
|
||||
],
|
||||
"context": "3",
|
||||
"contextSpecial": [
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"freq": [
|
||||
"4",
|
||||
"9",
|
||||
"14",
|
||||
"19",
|
||||
"24"
|
||||
],
|
||||
"connect": [
|
||||
"1",
|
||||
"3",
|
||||
"5",
|
||||
"7",
|
||||
"9",
|
||||
"11"
|
||||
],
|
||||
"connectSpecial": [
|
||||
"",
|
||||
""
|
||||
],
|
||||
"uid": 3,
|
||||
"contact": 3,
|
||||
"hash": 1448962210,
|
||||
"valid": true,
|
||||
"timestamp": 1478429171695
|
||||
},
|
||||
"4": {
|
||||
"sexe": "1",
|
||||
"age": "4",
|
||||
"job": "31",
|
||||
"famsit": "0",
|
||||
"studies": "04",
|
||||
"reltype": "4",
|
||||
"reltypeSpecial": "",
|
||||
"city": "14",
|
||||
"quartier": "4",
|
||||
"cp": "10004",
|
||||
"loc": "0",
|
||||
"duration": [
|
||||
"4",
|
||||
"14"
|
||||
],
|
||||
"context": "4",
|
||||
"contextSpecial": [
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"freq": [
|
||||
"4",
|
||||
"9",
|
||||
"14",
|
||||
"19",
|
||||
"24"
|
||||
],
|
||||
"connect": [
|
||||
"1",
|
||||
"3",
|
||||
"5",
|
||||
"7",
|
||||
"9",
|
||||
"11"
|
||||
],
|
||||
"connectSpecial": [
|
||||
"",
|
||||
""
|
||||
],
|
||||
"uid": 4,
|
||||
"contact": 4,
|
||||
"hash": 3000740570,
|
||||
"valid": true,
|
||||
"timestamp": 1478429171741
|
||||
},
|
||||
"5": {
|
||||
"sexe": "2",
|
||||
"age": "5",
|
||||
"job": "32",
|
||||
"famsit": "0",
|
||||
"studies": "05",
|
||||
"reltype": "5",
|
||||
"reltypeSpecial": "",
|
||||
"city": "15",
|
||||
"quartier": "5",
|
||||
"cp": "10005",
|
||||
"loc": "1",
|
||||
"duration": [
|
||||
"5",
|
||||
"15"
|
||||
],
|
||||
"context": "5",
|
||||
"contextSpecial": [
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"freq": [
|
||||
"4",
|
||||
"9",
|
||||
"14",
|
||||
"19",
|
||||
"24"
|
||||
],
|
||||
"connect": [
|
||||
"1",
|
||||
"3",
|
||||
"5",
|
||||
"7",
|
||||
"9",
|
||||
"11"
|
||||
],
|
||||
"connectSpecial": [
|
||||
"",
|
||||
""
|
||||
],
|
||||
"uid": 5,
|
||||
"contact": 5,
|
||||
"hash": 1185776066,
|
||||
"valid": true,
|
||||
"timestamp": 1478429171805
|
||||
},
|
||||
"6": {
|
||||
"sexe": "0",
|
||||
"age": "6",
|
||||
"job": "36",
|
||||
"famsit": "0",
|
||||
"studies": "06",
|
||||
"reltype": "6",
|
||||
"reltypeSpecial": "",
|
||||
"city": "16",
|
||||
"quartier": "6",
|
||||
"cp": "10006",
|
||||
"loc": "2",
|
||||
"duration": [
|
||||
"6",
|
||||
"16"
|
||||
],
|
||||
"context": "6",
|
||||
"contextSpecial": [
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"freq": [
|
||||
"4",
|
||||
"9",
|
||||
"14",
|
||||
"19",
|
||||
"24"
|
||||
],
|
||||
"connect": [
|
||||
"1",
|
||||
"3",
|
||||
"5",
|
||||
"7",
|
||||
"9",
|
||||
"11"
|
||||
],
|
||||
"connectSpecial": [
|
||||
"",
|
||||
""
|
||||
],
|
||||
"uid": 6,
|
||||
"contact": 6,
|
||||
"hash": 3580676315,
|
||||
"valid": true,
|
||||
"timestamp": 1478429171858
|
||||
},
|
||||
"7": {
|
||||
"sexe": "1",
|
||||
"age": "7",
|
||||
"job": "41",
|
||||
"famsit": "0",
|
||||
"studies": "07",
|
||||
"reltype": "7",
|
||||
"reltypeSpecial": "",
|
||||
"city": "17",
|
||||
"quartier": "7",
|
||||
"cp": "10007",
|
||||
"loc": "3",
|
||||
"duration": [
|
||||
"7",
|
||||
"17"
|
||||
],
|
||||
"context": "7",
|
||||
"contextSpecial": [
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"freq": [
|
||||
"4",
|
||||
"9",
|
||||
"14",
|
||||
"19",
|
||||
"24"
|
||||
],
|
||||
"connect": [
|
||||
"1",
|
||||
"3",
|
||||
"5",
|
||||
"7",
|
||||
"9",
|
||||
"11"
|
||||
],
|
||||
"connectSpecial": [
|
||||
"",
|
||||
""
|
||||
],
|
||||
"uid": 7,
|
||||
"contact": 7,
|
||||
"hash": 3989377397,
|
||||
"valid": true,
|
||||
"timestamp": 1478429171905
|
||||
},
|
||||
"8": {
|
||||
"sexe": "2",
|
||||
"age": "8",
|
||||
"job": "46",
|
||||
"famsit": "0",
|
||||
"studies": "08",
|
||||
"reltype": "10",
|
||||
"reltypeSpecial": "autre",
|
||||
"city": "18",
|
||||
"quartier": "8",
|
||||
"cp": "10008",
|
||||
"loc": "0",
|
||||
"duration": [
|
||||
"8",
|
||||
"18"
|
||||
],
|
||||
"context": "8",
|
||||
"contextSpecial": [
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"freq": [
|
||||
"4",
|
||||
"9",
|
||||
"14",
|
||||
"19",
|
||||
"24"
|
||||
],
|
||||
"connect": [
|
||||
"1",
|
||||
"3",
|
||||
"5",
|
||||
"7",
|
||||
"9",
|
||||
"11"
|
||||
],
|
||||
"connectSpecial": [
|
||||
"",
|
||||
""
|
||||
],
|
||||
"uid": 8,
|
||||
"contact": 8,
|
||||
"hash": 594979660,
|
||||
"valid": true,
|
||||
"timestamp": 1478429171955
|
||||
},
|
||||
"9": {
|
||||
"sexe": "0",
|
||||
"age": "9",
|
||||
"job": "47",
|
||||
"famsit": "0",
|
||||
"studies": "09",
|
||||
"reltype": "0",
|
||||
"reltypeSpecial": "",
|
||||
"city": "19",
|
||||
"quartier": "9",
|
||||
"cp": "10009",
|
||||
"loc": "1",
|
||||
"duration": [
|
||||
"9",
|
||||
"19"
|
||||
],
|
||||
"context": "9",
|
||||
"contextSpecial": [
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"freq": [
|
||||
"4",
|
||||
"9",
|
||||
"14",
|
||||
"19",
|
||||
"24"
|
||||
],
|
||||
"connect": [
|
||||
"1",
|
||||
"3",
|
||||
"5",
|
||||
"7",
|
||||
"9",
|
||||
"11"
|
||||
],
|
||||
"connectSpecial": [
|
||||
"",
|
||||
""
|
||||
],
|
||||
"uid": 9,
|
||||
"contact": 9,
|
||||
"hash": 1585642677,
|
||||
"valid": true,
|
||||
"timestamp": 1478429172030
|
||||
},
|
||||
"10": {
|
||||
"sexe": "1",
|
||||
"age": "10",
|
||||
"job": "48",
|
||||
"famsit": "0",
|
||||
"studies": "10",
|
||||
"reltype": "1",
|
||||
"reltypeSpecial": "",
|
||||
"city": "20",
|
||||
"quartier": "10",
|
||||
"cp": "10010",
|
||||
"loc": "2",
|
||||
"duration": [
|
||||
"10",
|
||||
"110"
|
||||
],
|
||||
"context": "10",
|
||||
"contextSpecial": [
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"freq": [
|
||||
"4",
|
||||
"9",
|
||||
"14",
|
||||
"19",
|
||||
"24"
|
||||
],
|
||||
"connect": [
|
||||
"1",
|
||||
"3",
|
||||
"5",
|
||||
"7",
|
||||
"9",
|
||||
"11"
|
||||
],
|
||||
"connectSpecial": [
|
||||
"",
|
||||
""
|
||||
],
|
||||
"uid": 10,
|
||||
"contact": 10,
|
||||
"hash": 350296051,
|
||||
"valid": true,
|
||||
"timestamp": 1478429172091
|
||||
},
|
||||
"11": {
|
||||
"sexe": "2",
|
||||
"age": "11",
|
||||
"job": "51",
|
||||
"famsit": "0",
|
||||
"studies": "11",
|
||||
"reltype": "2",
|
||||
"reltypeSpecial": "",
|
||||
"city": "21",
|
||||
"quartier": "11",
|
||||
"cp": "10011",
|
||||
"loc": "3",
|
||||
"duration": [
|
||||
"11",
|
||||
"111"
|
||||
],
|
||||
"context": "11",
|
||||
"contextSpecial": [
|
||||
"internet",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"freq": [
|
||||
"4",
|
||||
"9",
|
||||
"14",
|
||||
"19",
|
||||
"24"
|
||||
],
|
||||
"connect": [
|
||||
"1",
|
||||
"3",
|
||||
"5",
|
||||
"7",
|
||||
"9",
|
||||
"11"
|
||||
],
|
||||
"connectSpecial": [
|
||||
"",
|
||||
""
|
||||
],
|
||||
"uid": 11,
|
||||
"contact": 11,
|
||||
"hash": 2556603658,
|
||||
"valid": true,
|
||||
"timestamp": 1478429172141
|
||||
},
|
||||
"12": {
|
||||
"sexe": "0",
|
||||
"age": "12",
|
||||
"job": "54",
|
||||
"famsit": "0",
|
||||
"studies": "",
|
||||
"reltype": "3",
|
||||
"reltypeSpecial": "",
|
||||
"city": "22",
|
||||
"quartier": "12",
|
||||
"cp": "10012",
|
||||
"loc": "0",
|
||||
"duration": [
|
||||
"12",
|
||||
"112"
|
||||
],
|
||||
"context": "12",
|
||||
"contextSpecial": [
|
||||
"",
|
||||
"association",
|
||||
""
|
||||
],
|
||||
"freq": [
|
||||
"4",
|
||||
"9",
|
||||
"14",
|
||||
"19",
|
||||
"24"
|
||||
],
|
||||
"connect": [
|
||||
"1",
|
||||
"3",
|
||||
"5",
|
||||
"7",
|
||||
"9",
|
||||
"11"
|
||||
],
|
||||
"connectSpecial": [
|
||||
"",
|
||||
""
|
||||
],
|
||||
"uid": 12,
|
||||
"contact": 12,
|
||||
"hash": 1254626617,
|
||||
"valid": true,
|
||||
"timestamp": 1478429172191
|
||||
},
|
||||
"13": {
|
||||
"sexe": "1",
|
||||
"age": "13",
|
||||
"job": "55",
|
||||
"famsit": "0",
|
||||
"studies": "01",
|
||||
"reltype": "4",
|
||||
"reltypeSpecial": "",
|
||||
"city": "23",
|
||||
"quartier": "13",
|
||||
"cp": "10013",
|
||||
"loc": "1",
|
||||
"duration": [
|
||||
"13",
|
||||
"113"
|
||||
],
|
||||
"context": "13",
|
||||
"contextSpecial": [
|
||||
"",
|
||||
"",
|
||||
"autre"
|
||||
],
|
||||
"freq": [
|
||||
"4",
|
||||
"9",
|
||||
"14",
|
||||
"19",
|
||||
"24"
|
||||
],
|
||||
"connect": [
|
||||
"1",
|
||||
"3",
|
||||
"5",
|
||||
"7",
|
||||
"9",
|
||||
"11"
|
||||
],
|
||||
"connectSpecial": [
|
||||
"",
|
||||
""
|
||||
],
|
||||
"uid": 13,
|
||||
"contact": 13,
|
||||
"hash": 1821404092,
|
||||
"valid": true,
|
||||
"timestamp": 1478429175971
|
||||
}
|
||||
},
|
||||
"matrice": {
|
||||
"0": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12
|
||||
],
|
||||
"1": [
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13
|
||||
],
|
||||
"2": [
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12
|
||||
],
|
||||
"3": [
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12
|
||||
],
|
||||
"4": [
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12
|
||||
],
|
||||
"5": [
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12
|
||||
],
|
||||
"6": [
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
11,
|
||||
12
|
||||
],
|
||||
"7": [
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12
|
||||
],
|
||||
"8": [
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12
|
||||
],
|
||||
"9": [
|
||||
10,
|
||||
11,
|
||||
12
|
||||
],
|
||||
"10": [
|
||||
11
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"default": {
|
||||
"local": {
|
||||
"host" : "localhost",
|
||||
"dbname" : "nxtic",
|
||||
"user" : "php",
|
||||
"password" : "Qt358nUdyeTxLDM8"
|
||||
},
|
||||
"remote": {
|
||||
"host" : "localhost",
|
||||
"dbname" : "nxtic",
|
||||
"user" : "nxtic-php",
|
||||
"password" : "wxcvbn"
|
||||
}
|
||||
},
|
||||
|
||||
"lab-surveys": {
|
||||
"local": {
|
||||
"host" : "listic-lab-surveys.irit.fr",
|
||||
"dbname" : "lab-surveys",
|
||||
"user" : "lab-surveys",
|
||||
"password" : "wxcvbn"
|
||||
},
|
||||
"remote": {
|
||||
"host" : "listic-lab-surveys.irit.fr",
|
||||
"dbname" : "lab-surveys",
|
||||
"user" : "lab-surveys",
|
||||
"password" : "wxcvbn"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"host" : "localhost",
|
||||
"dbname" : "socioview",
|
||||
"user" : "php",
|
||||
"password" : "Qt358nUdyeTxLDM8"
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"host" : "xdrm.io",
|
||||
"dbname" : "socioview",
|
||||
"user" : "php",
|
||||
"password" : "QbzjZACndQM6NmuD"
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"svg": "image/svg+xml",
|
||||
|
||||
"jpg": "image/jpeg",
|
||||
"png": "image/png",
|
||||
|
||||
"css": "text/css",
|
||||
"js": "text/javascript",
|
||||
|
||||
"json": "application/json"
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
"api" : "/api",
|
||||
|
||||
"st" : "/src/static",
|
||||
"dy" : "/src/dynamic",
|
||||
|
||||
"conf" : "/config",
|
||||
|
||||
"css" : "/css",
|
||||
"js" : "/js",
|
||||
|
||||
"highcharts": "/js/lib/highcharts/js",
|
||||
|
||||
"upload": "/src/upload"
|
||||
}
|
|
@ -26,18 +26,6 @@
|
|||
},
|
||||
|
||||
|
||||
{ "icon": "/src/static/menu-side/charts.svg", "text": "Graphiques",
|
||||
"attributes": { "data-link": "charts", "class": "sep" },
|
||||
|
||||
"children": [
|
||||
{ "permissions": [], "text": "Données cellulaires",
|
||||
"attributes": { "data-sublink": "phone" } },
|
||||
{ "permissions": [], "text": "Réseau",
|
||||
"attributes": { "data-sublink": "network" } }
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
{ "icon": "/src/static/menu-side/analytics.svg", "text": "Données",
|
||||
"attributes": { "data-link": "data" },
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
"parameters": {}
|
||||
},
|
||||
|
||||
|
||||
"markdown": {
|
||||
"description": "Retourne une description en markdown des différents modules de l'API",
|
||||
"permissions": [],
|
||||
|
@ -42,7 +41,6 @@
|
|||
"parameters": {}
|
||||
},
|
||||
|
||||
|
||||
"apiBlueprint": {
|
||||
"description": "Retourne une documentation de l'API au format API Blueprint.",
|
||||
"permissions": [],
|
||||
|
@ -66,11 +64,10 @@
|
|||
|
||||
"logout": {
|
||||
"description": "Deconnexion",
|
||||
"permissions": [],
|
||||
"permissions": ["admin"],
|
||||
"parameters": {}
|
||||
},
|
||||
|
||||
|
||||
"getById": {
|
||||
"description": "Retourne les informations d'un utilisateur.",
|
||||
"permissions": ["admin"],
|
||||
|
@ -82,7 +79,6 @@
|
|||
}
|
||||
},
|
||||
|
||||
|
||||
"getAll": {
|
||||
"description": "Retourne les informations de tous les utilisateurs.",
|
||||
"permissions": ["admin"],
|
||||
|
@ -92,23 +88,19 @@
|
|||
}
|
||||
},
|
||||
|
||||
|
||||
"create": {
|
||||
"description": "Creation d'un nouvel utilisateur.",
|
||||
"description": "Creation d'un nouvel administrateur.",
|
||||
"permissions": ["admin"],
|
||||
"parameters": {
|
||||
"login": { "description": "Login de l'utilisateur, 30 caracteres maximum.", "type": "varchar(3,30)" },
|
||||
"password": { "description": "Mot de passe de l'utilisateur.", "type": "text" },
|
||||
"mail": { "description": "Adresse mail de l'utilisateur.", "type": "mail" },
|
||||
"reference": { "description": "UID d'une personne d'un sondage, peut etre vide.", "type": "text" },
|
||||
"permission": { "description": "Permissions de l'utilisateur : 'admin' ou 'subject'", "type": "varchar(5,7)" }
|
||||
"login": { "description": "Login de l'administrateur, 30 caracteres maximum.", "type": "varchar(3,30)" },
|
||||
"password": { "description": "Mot de passe de l'administrateur.", "type": "text" },
|
||||
"mail": { "description": "Adresse mail de l'administrateur.", "type": "mail" }
|
||||
},
|
||||
"output": {
|
||||
"id_user": { "description": "Identifiant de l'utilisateur créé", "type": "id" }
|
||||
"id_user": { "description": "Identifiant de l'administrateur créé", "type": "id" }
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
"remove": {
|
||||
"description": "Suppression d'un utilisateur.",
|
||||
"permissions": ["admin"],
|
||||
|
@ -116,157 +108,7 @@
|
|||
"id_user": { "description": "UID de l'utilisateur", "type": "id" }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"call_log": {
|
||||
"unserialize": {
|
||||
"description": "Recupere le contenu d'un fichier XML de journal d'appel s'il a été importé au préalable.",
|
||||
"permissions": [],
|
||||
"parameters": {},
|
||||
"output": {
|
||||
"tmp_id": { "description": "Identifiant temporaire du journal d'appel", "type": "varchar(40,40)" },
|
||||
"directory": { "description": "Annuaire des contacts trouvés", "type": "array<array<mixed>>" },
|
||||
"call": { "description": "Liste des identifiants des contacts triés par nombre d'appels", "type": "array<id>" },
|
||||
"sms": { "description": "Liste des identifiants des contacts triés par nombre de sms", "type": "array<id>" }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"chart": {
|
||||
|
||||
"direction": {
|
||||
"description": "Renvoie les données pour un graphique sur les sens de communications",
|
||||
"permissions": ["admin"],
|
||||
"parameters": {
|
||||
"subject": { "description": "Identifiant du sujet à étudier,", "type": "id" }
|
||||
},
|
||||
"output": {
|
||||
"type": { "description": "Type de graphique", "type": "text" },
|
||||
"title": { "description": "Titre du graphique", "type": "text" },
|
||||
"pointFormat": { "description": "Format des labels des graphiques", "type": "text" },
|
||||
"series": { "description": "Séries de données et paramètres", "type": "array<array<mixed>>" }
|
||||
}
|
||||
},
|
||||
|
||||
"type": {
|
||||
"description": "Renvoie les données pour un graphique sur les types de communications",
|
||||
"permissions": ["admin"],
|
||||
"parameters": {
|
||||
"subject": { "description": "Identifiant du sujet à étudier,", "type": "id" }
|
||||
},
|
||||
"output": {
|
||||
"type": { "description": "Type de graphique", "type": "text" },
|
||||
"title": { "description": "Titre du graphique", "type": "text" },
|
||||
"pointFormat": { "description": "Format des labels des graphiques", "type": "text" },
|
||||
"series": { "description": "Séries de données et paramètres", "type": "array<array<mixed>>" }
|
||||
}
|
||||
},
|
||||
|
||||
"sexe": {
|
||||
"description": "Renvoie les données pour un graphique sur le sexe des contacts",
|
||||
"permissions": ["admin"],
|
||||
"parameters": {
|
||||
"subject": { "description": "Identifiant du sujet à étudier,", "type": "id" }
|
||||
},
|
||||
"output": {
|
||||
"type": { "description": "Type de graphique", "type": "text" },
|
||||
"title": { "description": "Titre du graphique", "type": "text" },
|
||||
"pointFormat": { "description": "Format des labels des graphiques", "type": "text" },
|
||||
"series": { "description": "Séries de données et paramètres", "type": "array<array<mixed>>" }
|
||||
}
|
||||
},
|
||||
|
||||
"ages": {
|
||||
"description": "Renvoie les données pour un graphique sur les ages des contacts",
|
||||
"permissions": ["admin"],
|
||||
"parameters": {
|
||||
"subject": { "description": "Identifiant du sujet à étudier,", "type": "id" }
|
||||
},
|
||||
"output": {
|
||||
"type": { "description": "Type de graphique", "type": "text" },
|
||||
"title": { "description": "Titre du graphique", "type": "text" },
|
||||
"xlabels": { "description": "Labels des abscisses", "type": "array<text>" },
|
||||
"zoom": { "description": "Paramètres du zoom", "type": "varchar(1,1)" },
|
||||
"pointFormat": { "description": "Format des labels des graphiques", "type": "text" },
|
||||
"ytitle": { "description": "Titre des ordonnées", "type": "text" },
|
||||
"series": { "description": "Séries de données et paramètres", "type": "array<array<mixed>>" }
|
||||
}
|
||||
},
|
||||
|
||||
"relations": {
|
||||
"description": "Renvoie les données pour un graphique sur les types de relations des contacts",
|
||||
"permissions": ["admin"],
|
||||
"parameters": {
|
||||
"subject": { "description": "Identifiant du sujet à étudier,", "type": "id" }
|
||||
},
|
||||
"output": {
|
||||
"type": { "description": "Type de graphique", "type": "text" },
|
||||
"title": { "description": "Titre du graphique", "type": "text" },
|
||||
"xlabels": { "description": "Labels des abscisses", "type": "array<text>" },
|
||||
"ytitle": { "description": "Titre des ordonnées", "type": "text" },
|
||||
"pointFormat": { "description": "Format des labels des graphiques", "type": "text" },
|
||||
"series": { "description": "Séries de données et paramètres", "type": "array<array<mixed>>" }
|
||||
}
|
||||
},
|
||||
|
||||
"weekdays": {
|
||||
"description": "Renvoie les données pour un graphique sur les communication parmi les jours de la semaine",
|
||||
"permissions": ["admin"],
|
||||
"parameters": {
|
||||
"subject": { "description": "Identifiant du sujet à étudier,", "type": "id" }
|
||||
},
|
||||
"output": {
|
||||
"type": { "description": "Type de graphique", "type": "text" },
|
||||
"title": { "description": "Titre du graphique", "type": "text" },
|
||||
"xlabels": { "description": "Labels des abscisses", "type": "array<text>" },
|
||||
"ytitle": { "description": "Titre des ordonnées", "type": "text" },
|
||||
"pointFormat": { "description": "Format des labels des graphiques", "type": "text" },
|
||||
"series": { "description": "Séries de données et paramètres", "type": "array<array<mixed>>" }
|
||||
}
|
||||
},
|
||||
|
||||
"duration": {
|
||||
"description": "Renvoie les données pour un graphique sur les temps de communication",
|
||||
"permissions": ["admin"],
|
||||
"parameters": {
|
||||
"subject": { "description": "Identifiant du sujet à étudier,", "type": "id" }
|
||||
},
|
||||
"output": {
|
||||
"type": { "description": "Type de graphique", "type": "text" },
|
||||
"title": { "description": "Titre du graphique", "type": "text" },
|
||||
"xaxis": { "description": "Paramètres des abscisses", "type": "array<mixed>" },
|
||||
"ytitle": { "description": "Titre des ordonnées", "type": "text" },
|
||||
"zoom": { "description": "Paramètres du zoom", "type": "varchar(1,1)" },
|
||||
"series": { "description": "Séries de données et paramètres", "type": "array<array<mixed>>" }
|
||||
}
|
||||
},
|
||||
|
||||
"timeofday": {
|
||||
"description": "Renvoie les données pour un graphique sur les heures de communication",
|
||||
"permissions": ["admin"],
|
||||
"parameters": {
|
||||
"subject": { "description": "Identifiant du sujet à étudier,", "type": "id" }
|
||||
},
|
||||
"output": {
|
||||
"type": { "description": "Type de graphique", "type": "text" },
|
||||
"title": { "description": "Titre du graphique", "type": "text" },
|
||||
"xlabels": { "description": "Labels des abscisses", "type": "array<text>" },
|
||||
"zoom": { "description": "Paramètres du zoom", "type": "varchar(1,1)" },
|
||||
"series": { "description": "Séries de données et paramètres", "type": "array<array<mixed>>" }
|
||||
}
|
||||
},
|
||||
|
||||
"network": {
|
||||
"description": "Renvoie les données pour un graphique relationnel de type 'réseau'",
|
||||
"permissions": ["admin"],
|
||||
"parameters": {
|
||||
"subject": { "description": "Identifiant du sujet à étudier,", "type": "id" }
|
||||
},
|
||||
"output": {
|
||||
"nodes": { "description": "Liste des noeuds du graphe (contacts)", "type": "array<array<mixed>>" },
|
||||
"edges": { "description": "Liste des liens du graphe", "type": "array<array<mixed>" }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"token": {
|
||||
|
@ -279,7 +121,6 @@
|
|||
}
|
||||
},
|
||||
|
||||
|
||||
"generate": {
|
||||
"description": "Création d'un token de nom et de durée donnée",
|
||||
"permissions": ["admin"],
|
||||
|
@ -299,7 +140,7 @@
|
|||
"description": "Recherche d'un sujet par nom",
|
||||
"permissions": ["admin"],
|
||||
"parameters": {
|
||||
"name": { "description": "Le nom du sujet", "type": "varchar(1,50)" }
|
||||
"name": { "description": "Le nom du sujet", "type": "varchar(0,50)" }
|
||||
},
|
||||
"output": {
|
||||
"results": { "description": "Liste des sujet associés aux mots-clés.", "type": "array<array<mixed>>" }
|
||||
|
@ -326,7 +167,6 @@
|
|||
}
|
||||
},
|
||||
|
||||
|
||||
"create": {
|
||||
"description": "Creation d'un nouveau sujet.",
|
||||
"permissions": ["admin"],
|
||||
|
@ -342,11 +182,26 @@
|
|||
|
||||
"input": {
|
||||
|
||||
"survey": {
|
||||
"description": "Enregistre les données d'une enquête téléphonique.",
|
||||
"permissions": ["admin"],
|
||||
"parameters": {
|
||||
"subject": { "description": "Données du sujet (id, etc)", "type": "array<mixed>" },
|
||||
"contacts": { "description": "Données des contacts de l'enquête.", "type": "array<array>" },
|
||||
"mini": { "description": "Mini fiches relations sur les contacts de l'enquête.", "type": "array<array>" },
|
||||
"fiches": { "description": "Fiches relation sur les plus proches contacts de l'enquête.", "type": "array<array>" },
|
||||
"matrice": { "description": "Matrice contenant les relations entre les plus proches contacts", "type": "array<array>", "optional": true }
|
||||
},
|
||||
"output": {
|
||||
"subject_id": { "description": "Identifiant du sujet complété", "type": "id" }
|
||||
}
|
||||
},
|
||||
|
||||
"phone": {
|
||||
"description": "Enregistre les données d'une enquête téléphonique.",
|
||||
"permissions": ["admin"],
|
||||
"parameters": {
|
||||
"subject": { "description": "Données sur le sujet de l'enquête.", "type": "array" },
|
||||
"subject": { "description": "Données du sujet (id, etc)", "type": "array<mixed>" },
|
||||
"contacts": { "description": "Données des contacts de l'enquête.", "type": "array<array>" },
|
||||
"mini": { "description": "Mini fiches relations sur les contacts de l'enquête.", "type": "array<array>" },
|
||||
"fiches": { "description": "Fiches relation sur les plus proches contacts de l'enquête.", "type": "array<array>" },
|
||||
|
@ -361,7 +216,7 @@
|
|||
"description": "Enregistre les données d'une enquête facebook.",
|
||||
"permissions": ["admin"],
|
||||
"parameters": {
|
||||
"subject": { "description": "Données sur le sujet de l'enquête.", "type": "array" },
|
||||
"subject": { "description": "Données du sujet (id, etc)", "type": "array<mixed>" },
|
||||
"contacts": { "description": "Données des contacts de l'enquête.", "type": "array<array>" },
|
||||
"mini": { "description": "Mini fiches relations sur les contacts de l'enquête.", "type": "array<array>" },
|
||||
"fiches": { "description": "Fiches relation sur les plus proches contacts de l'enquête.", "type": "array<array>" },
|
||||
|
@ -376,21 +231,6 @@
|
|||
|
||||
"upload": {
|
||||
|
||||
"call_log": {
|
||||
"description": "Upload d'un journal d'appel au format .xml. Retour des données de call_log/unserialize",
|
||||
"permissions": ["admin"],
|
||||
"parameters": {
|
||||
"file": { "description": "Fichier du journal d'appel.", "type": "FILE" }
|
||||
},
|
||||
"output": {
|
||||
"tmp_id": { "description": "Identifiant temporaire du journal d'appel", "type": "varchar(40,40)" },
|
||||
"directory": { "description": "Annuaire des contacts trouvés", "type": "array<array<mixed>>" },
|
||||
"call": { "description": "Liste des identifiants des contacts triés par nombre d'appels", "type": "array<id>" },
|
||||
"sms": { "description": "Liste des identifiants des contacts triés par nombre de sms", "type": "array<id>" }
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
"local_data": {
|
||||
"description": "Upload d'une sauvegarde de formulaire local au format .json.",
|
||||
"permissions": ["admin"],
|
||||
|
@ -400,18 +240,6 @@
|
|||
"output": {
|
||||
"local_data": { "description": "Contenu formatté du fichier.", "type": "array<mixed>"}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
"iexplorer_convert": {
|
||||
"description": "Convertisseur .txt (iExplorer) vers .xml (Call Log)",
|
||||
"permissions": ["admin"],
|
||||
"parameters": {
|
||||
"file": { "description": "Fichier exporté de iExplorer", "type": "FILE" }
|
||||
},
|
||||
"output": {
|
||||
"data": { "description": "Contenu formatté du fichier.", "type": "array<mixed>"}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
@ -425,9 +253,6 @@
|
|||
"options": { "download": true },
|
||||
"parameters": {
|
||||
"subjects": { "description": "Identifiants des sujets d'enquêtes à intégrer.", "type": "array<id>", "optional": true },
|
||||
"phone": { "description": "Si vaut TRUE, renvoie les sujets cellulaires.", "type": "boolean", "optional": true },
|
||||
"facebook": { "description": "Si vaut TRUE, renvoie les sujet facebook.", "type": "boolean", "optional": true },
|
||||
"survey": { "description": "Si vaut TRUE, renvoie les sujets ResTIC.", "type": "boolean", "optional": true },
|
||||
"all": { "description": "Si vaut TRUE, renvoie tous les sujets enregistrés.", "type": "boolean", "optional": true }
|
||||
}
|
||||
},
|
||||
|
@ -438,9 +263,6 @@
|
|||
"options": { "download": true },
|
||||
"parameters": {
|
||||
"subjects": { "description": "Identifiants des sujets d'enquêtes à intégrer.", "type": "array<id>", "optional": true },
|
||||
"phone": { "description": "Si vaut TRUE, renvoie les sujets cellulaires.", "type": "boolean", "optional": true },
|
||||
"facebook": { "description": "Si vaut TRUE, renvoie les sujet facebook.", "type": "boolean", "optional": true },
|
||||
"survey": { "description": "Si vaut TRUE, renvoie les sujets ResTIC.", "type": "boolean", "optional": true },
|
||||
"all": { "description": "Si vaut TRUE, renvoie tous les sujets enregistrés.", "type": "boolean", "optional": true }
|
||||
}
|
||||
},
|
||||
|
|
|
@ -9,34 +9,6 @@
|
|||
"remove"
|
||||
],
|
||||
|
||||
"subject": [
|
||||
"getById",
|
||||
"getAll",
|
||||
"create",
|
||||
"merge",
|
||||
"remove",
|
||||
"link"
|
||||
],
|
||||
|
||||
"relation": [
|
||||
"getAll",
|
||||
"getById",
|
||||
"create",
|
||||
"remove"
|
||||
],
|
||||
|
||||
"category": [
|
||||
"getAll",
|
||||
"getById",
|
||||
"getByIntitule",
|
||||
"getOrCreate"
|
||||
],
|
||||
|
||||
"Personnes": [
|
||||
"getById"
|
||||
],
|
||||
|
||||
|
||||
"token": [
|
||||
"getAll",
|
||||
"getById",
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
{
|
||||
|
||||
"local" : {
|
||||
"host" : "http://socioview",
|
||||
"root" : "/"
|
||||
},
|
||||
"local" : {
|
||||
"host" : "http://nxtic/",
|
||||
"root" : "/"
|
||||
},
|
||||
|
||||
"remote" : {
|
||||
"host" : "https://socioview.xdrm.io",
|
||||
"root" : "/"
|
||||
}
|
||||
"remote" : {
|
||||
"host" : "https://nxtic.xdrm.io/",
|
||||
"root" : "/"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
{
|
||||
"root": "/src/upload",
|
||||
"directories": [
|
||||
"call_log",
|
||||
"local_data",
|
||||
"convert_iexplorer"
|
||||
"local_data"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -2,6 +2,5 @@
|
|||
"dashboard",
|
||||
"input",
|
||||
"analytics",
|
||||
"charts",
|
||||
"settings"
|
||||
]
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
/* [1] COULEURS
|
||||
=========================================================*/
|
||||
/* (1) COULEURS DU THEME $DEFAULT */
|
||||
/* (2) COULEURS DE THEME $DARK */
|
||||
/* (3) Couleurs du theme pour la timeline */
|
||||
/* [2] DIMENSIONS
|
||||
=========================================================*/
|
||||
/* (1) Layout de base */
|
||||
/* [3] Mixins
|
||||
=========================================================*/
|
||||
/* [4] Functions
|
||||
=========================================================*/
|
||||
|
||||
/*# sourceMappingURL=data:application/json;base64,ewoJInZlcnNpb24iOiAzLAoJImZpbGUiOiAiZXhwYW5kZWQuY3NzIiwKCSJzb3VyY2VzIjogWwoJCSIuLi9jb25zdGFudHMuc2NzcyIKCV0sCgkic291cmNlc0NvbnRlbnQiOiBbCgkJIi8qIFsxXSBDT1VMRVVSU1xuPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki9cbi8qICgxKSBDT1VMRVVSUyBEVSBUSEVNRSAkREVGQVVMVCAqL1xuJHRoZW1lLWJnOiAgICAgICAgICNlOGU4ZTg7XG4kdGhlbWUtYmctcHJpbWFyeTogI2ZmZmZmZjtcbiR0aGVtZS1mZzogICAgICAgICAjNTE1MTUxO1xuJHRoZW1lLWZnLXByaW1hcnk6ICMzOTljZWQ7XG5cbi8qICgyKSBDT1VMRVVSUyBERSBUSEVNRSAkREFSSyAqL1xuJGRhcmstYmc6ICAgICAgICAgIzMxMzU0MTtcbiRkYXJrLWJnLXByaW1hcnk6ICMyOTI4MmU7XG4kZGFyay1mZzogICAgICAgICAjOTM5MzkzO1xuJGRhcmstZmctcHJpbWFyeTogI2ZmZmZmZjtcblxuJGhlYWRlci1kYXJrOiAgICAgI0Y4RjhGQTtcblxuLyogKDMpIENvdWxldXJzIGR1IHRoZW1lIHBvdXIgbGEgdGltZWxpbmUgKi9cbiR0aW1lbGluZS1jb2xvcjogIzczODM5NDtcbiR0aW1lbGluZS0wOiAjMzk5Y2VkO1xuJHRpbWVsaW5lLTE6ICNlNjRlM2U7XG4kdGltZWxpbmUtMjogIzEwYmFhMztcbiR0aW1lbGluZS0zOiAjYjE0YmU3O1xuJHRpbWVsaW5lLTQ6ICMwNTNiNWQ7XG5cblxuLyogWzJdIERJTUVOU0lPTlNcbj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovXG4vKiAoMSkgTGF5b3V0IGRlIGJhc2UgKi9cbiRtZW51LXNpZGUtd2lkdGg6IDE1ZW07XG4kaGVhZGVyLWhlaWdodDogICA0ZW07XG5cblxuXG4vKiBbM10gTWl4aW5zXG49PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qL1xuQG1peGluIHRyYW5zZm9ybSgkdmFsdWUuLi4pIHtcblx0dHJhbnNmb3JtOiAkdmFsdWU7XG5cdC1tb3otdHJhbnNmb3JtOiAkdmFsdWU7XG5cdC1vLXRyYW5zZm9ybTogJHZhbHVlO1xuXHQtbXMtdHJhbnNmb3JtOiAkdmFsdWU7XG5cdC13ZWJraXQtdHJhbnNmb3JtOiAkdmFsdWU7XG59XG5cblxuQG1peGluIHRyYW5zaXRpb24oJHZhbHVlLi4uKSB7XG5cdC13ZWJraXQtdHJhbnNpdGlvbjogJHZhbHVlO1xuXHR0cmFuc2l0aW9uOiAkdmFsdWU7XG59XG5cbi8qIFs0XSBGdW5jdGlvbnNcbj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovXG4vLyBUcmFuc2Zvcm1lIHVuZSBjb3VsZXVyIGhleCBlbiBzdHJpbmcgc2FucyBsZSAjXG5AZnVuY3Rpb24gY29sb3Itc3RyKCRjb2xvcil7XG5cdEByZXR1cm4gc3RyLXNsaWNlKCN7JGNvbG9yfSwgMiwgc3RyLWxlbmd0aCgjeyRjb2xvcn0pKTtcbn1cbiIKCV0sCgkibWFwcGluZ3MiOiAiQUFBQTsyREFDMkQ7QUFDM0Qsb0NBQW9DO0FBTXBDLGlDQUFpQztBQVFqQyw0Q0FBNEM7QUFTNUM7MkRBQzJEO0FBQzNELHdCQUF3QjtBQU14QjsyREFDMkQ7QUFlM0Q7MkRBQzJEIiwKCSJuYW1lcyI6IFtdCn0= */
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"version": 3,
|
||||
"file": "expanded.css",
|
||||
"sources": [
|
||||
"../constants.scss"
|
||||
],
|
||||
"sourcesContent": [
|
||||
"/* [1] COULEURS\n=========================================================*/\n/* (1) COULEURS DU THEME $DEFAULT */\n$theme-bg: #e8e8e8;\n$theme-bg-primary: #ffffff;\n$theme-fg: #515151;\n$theme-fg-primary: #399ced;\n\n/* (2) COULEURS DE THEME $DARK */\n$dark-bg: #313541;\n$dark-bg-primary: #29282e;\n$dark-fg: #939393;\n$dark-fg-primary: #ffffff;\n\n$header-dark: #F8F8FA;\n\n/* (3) Couleurs du theme pour la timeline */\n$timeline-color: #738394;\n$timeline-0: #399ced;\n$timeline-1: #e64e3e;\n$timeline-2: #10baa3;\n$timeline-3: #b14be7;\n$timeline-4: #053b5d;\n\n\n/* [2] DIMENSIONS\n=========================================================*/\n/* (1) Layout de base */\n$menu-side-width: 15em;\n$header-height: 4em;\n\n\n\n/* [3] Mixins\n=========================================================*/\n@mixin transform($value...) {\n\ttransform: $value;\n\t-moz-transform: $value;\n\t-o-transform: $value;\n\t-ms-transform: $value;\n\t-webkit-transform: $value;\n}\n\n\n@mixin transition($value...) {\n\t-webkit-transition: $value;\n\ttransition: $value;\n}\n\n/* [4] Functions\n=========================================================*/\n// Transforme une couleur hex en string sans le #\n@function color-str($color){\n\t@return str-slice(#{$color}, 2, str-length(#{$color}));\n}\n"
|
||||
],
|
||||
"mappings": "AAAA;2DAC2D;AAC3D,oCAAoC;AAMpC,iCAAiC;AAQjC,4CAA4C;AAS5C;2DAC2D;AAC3D,wBAAwB;AAMxB;2DAC2D;AAe3D;2DAC2D",
|
||||
"names": []
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
|
||||
/*# sourceMappingURL=data:application/json;base64,ewoJInZlcnNpb24iOiAzLAoJImZpbGUiOiAibWluLmNzcyIsCgkic291cmNlcyI6IFsKCQkiLi4vY29uc3RhbnRzLnNjc3MiCgldLAoJInNvdXJjZXNDb250ZW50IjogWwoJCSIvKiBbMV0gQ09VTEVVUlNcbj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovXG4vKiAoMSkgQ09VTEVVUlMgRFUgVEhFTUUgJERFRkFVTFQgKi9cbiR0aGVtZS1iZzogICAgICAgICAjZThlOGU4O1xuJHRoZW1lLWJnLXByaW1hcnk6ICNmZmZmZmY7XG4kdGhlbWUtZmc6ICAgICAgICAgIzUxNTE1MTtcbiR0aGVtZS1mZy1wcmltYXJ5OiAjMzk5Y2VkO1xuXG4vKiAoMikgQ09VTEVVUlMgREUgVEhFTUUgJERBUksgKi9cbiRkYXJrLWJnOiAgICAgICAgICMzMTM1NDE7XG4kZGFyay1iZy1wcmltYXJ5OiAjMjkyODJlO1xuJGRhcmstZmc6ICAgICAgICAgIzkzOTM5MztcbiRkYXJrLWZnLXByaW1hcnk6ICNmZmZmZmY7XG5cbiRoZWFkZXItZGFyazogICAgICNGOEY4RkE7XG5cbi8qICgzKSBDb3VsZXVycyBkdSB0aGVtZSBwb3VyIGxhIHRpbWVsaW5lICovXG4kdGltZWxpbmUtY29sb3I6ICM3MzgzOTQ7XG4kdGltZWxpbmUtMDogIzM5OWNlZDtcbiR0aW1lbGluZS0xOiAjZTY0ZTNlO1xuJHRpbWVsaW5lLTI6ICMxMGJhYTM7XG4kdGltZWxpbmUtMzogI2IxNGJlNztcbiR0aW1lbGluZS00OiAjMDUzYjVkO1xuXG5cbi8qIFsyXSBESU1FTlNJT05TXG49PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qL1xuLyogKDEpIExheW91dCBkZSBiYXNlICovXG4kbWVudS1zaWRlLXdpZHRoOiAxNWVtO1xuJGhlYWRlci1oZWlnaHQ6ICAgNGVtO1xuXG5cblxuLyogWzNdIE1peGluc1xuPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki9cbkBtaXhpbiB0cmFuc2Zvcm0oJHZhbHVlLi4uKSB7XG5cdHRyYW5zZm9ybTogJHZhbHVlO1xuXHQtbW96LXRyYW5zZm9ybTogJHZhbHVlO1xuXHQtby10cmFuc2Zvcm06ICR2YWx1ZTtcblx0LW1zLXRyYW5zZm9ybTogJHZhbHVlO1xuXHQtd2Via2l0LXRyYW5zZm9ybTogJHZhbHVlO1xufVxuXG5cbkBtaXhpbiB0cmFuc2l0aW9uKCR2YWx1ZS4uLikge1xuXHQtd2Via2l0LXRyYW5zaXRpb246ICR2YWx1ZTtcblx0dHJhbnNpdGlvbjogJHZhbHVlO1xufVxuXG4vKiBbNF0gRnVuY3Rpb25zXG49PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qL1xuLy8gVHJhbnNmb3JtZSB1bmUgY291bGV1ciBoZXggZW4gc3RyaW5nIHNhbnMgbGUgI1xuQGZ1bmN0aW9uIGNvbG9yLXN0cigkY29sb3Ipe1xuXHRAcmV0dXJuIHN0ci1zbGljZSgjeyRjb2xvcn0sIDIsIHN0ci1sZW5ndGgoI3skY29sb3J9KSk7XG59XG4iCgldLAoJIm1hcHBpbmdzIjogIiIsCgkibmFtZXMiOiBbXQp9 */
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"version": 3,
|
||||
"file": "min.css",
|
||||
"sources": [
|
||||
"../constants.scss"
|
||||
],
|
||||
"sourcesContent": [
|
||||
"/* [1] COULEURS\n=========================================================*/\n/* (1) COULEURS DU THEME $DEFAULT */\n$theme-bg: #e8e8e8;\n$theme-bg-primary: #ffffff;\n$theme-fg: #515151;\n$theme-fg-primary: #399ced;\n\n/* (2) COULEURS DE THEME $DARK */\n$dark-bg: #313541;\n$dark-bg-primary: #29282e;\n$dark-fg: #939393;\n$dark-fg-primary: #ffffff;\n\n$header-dark: #F8F8FA;\n\n/* (3) Couleurs du theme pour la timeline */\n$timeline-color: #738394;\n$timeline-0: #399ced;\n$timeline-1: #e64e3e;\n$timeline-2: #10baa3;\n$timeline-3: #b14be7;\n$timeline-4: #053b5d;\n\n\n/* [2] DIMENSIONS\n=========================================================*/\n/* (1) Layout de base */\n$menu-side-width: 15em;\n$header-height: 4em;\n\n\n\n/* [3] Mixins\n=========================================================*/\n@mixin transform($value...) {\n\ttransform: $value;\n\t-moz-transform: $value;\n\t-o-transform: $value;\n\t-ms-transform: $value;\n\t-webkit-transform: $value;\n}\n\n\n@mixin transition($value...) {\n\t-webkit-transition: $value;\n\ttransition: $value;\n}\n\n/* [4] Functions\n=========================================================*/\n// Transforme une couleur hex en string sans le #\n@function color-str($color){\n\t@return str-slice(#{$color}, 2, str-length(#{$color}));\n}\n"
|
||||
],
|
||||
"mappings": "",
|
||||
"names": []
|
||||
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"version": 3,
|
||||
"file": "expanded.css",
|
||||
"sources": [
|
||||
"../header.scss",
|
||||
"../constants.scss"
|
||||
],
|
||||
"sourcesContent": [
|
||||
"@import 'constants';\n\n\n#WRAPPER > #HEADER{\n\n\t/* [1] Barre de recherche\n\t=========================================================*/\n\t& > #searchbar{\n\t\tdisplay: inline-block;\n\t\tposition: absolute;\n\t\t\ttop: .8em;\n\t\t\tleft: 1em;\n\t\t\twidth: 20em;\n\t\t\theight: 2em;\n\n\t\tpadding: .2em 1em;\n\n\t\tborder: 0;\n\t\tborder-radius: 3px;\n\n\t\tbackground-color: $theme-bg;\n\n\t}\n\n\t/* [2] Informations utilisateur\n\t=========================================================*/\n\t/* (0) Conteneur */\n\t& > #user-data{\n\t\tdisplay: inline-block;\n\t\tposition: absolute;\n\t\t\ttop: 0;\n\t\t\tright: 0;\n\t\t\theight: calc( 100% - 2*1em );\n\n\n\t\t/* (1) Username de l'utilisateur */\n\t\t& > #user-name{\n\t\t\tdisplay: block;\n\t\t\tposition: absolute;\n\t\t\t\ttop: 0;\n\t\t\t\tright: calc( #{$header-height}*2 - 1em );\n\t\t\t\theight: $header-height;\n\n\t\t\tpadding: 0 1em;\n\n\t\t\tcolor: #555;\n\t\t\tline-height: $header-height;\n\t\t\twhite-space: nowrap;\n\t\t\tfont-weight: bold;\n\n\t\t\tcursor: pointer;\n\n\t\t}\n\n\n\t\t/* (2) Image du profil */\n\t\t& > #user-picture{\n\t\t\tdisplay: block;\n\t\t\tposition: absolute;\n\t\t\t\ttop: 1em;\n\t\t\t\tright: $header-height;\n\t\t\t\twidth: calc( #{$header-height} - 2*1em );\n\t\t\t\theight: calc( #{$header-height} - 2*1em );\n\n\n\t\t\tborder-radius: 50% / 50%;\n\n\t\t\tbackground: $theme-bg url('/src/static/header/nopic.svg') center center no-repeat;\n\t\t\tbackground-size: auto 80%;\n\n\t\t\t// Si on est connecte\n\t\t\t&.active{ background-image: url('/src/dynamic/profile/sample.svg'); background-size: auto 100%; }\n\n\t\t\tcursor: default;\n\n\t\t\talign-self: center;\n\t\t}\n\n\n\n\t\t/* (3) Icone d'activation */\n\t\t&:before{\n\t\t\tcontent: '';\n\t\t\tdisplay: block;\n\t\t\tposition: absolute;\n\t\t\t\ttop: 0;\n\t\t\t\tright: 0;\n\t\t\t\twidth: $header-height;\n\t\t\t\theight: $header-height;\n\n\t\t\tbackground: url('/src/static/header/expand.svg@000000') center center no-repeat;\n\t\t\tbackground-size: 1em 1em;\n\n\t\t\tcursor: pointer;\n\n\t\t}\n\n\n\t}\n\n\n\n\t/* [3] Menu deroulant pour l'administration du profil\n\t=========================================================*/\n\t& > .user-panel{\n\t\tdisplay: block;\n\t\tposition: absolute;\n\t\t\ttop: calc( #{$header-height} - 1em );\n\t\t\tright: 0;\n\n\t\tmargin: .5em;\n\n\t\tborder-radius: 5px;\n\t\tborder: 1px solid darken($theme-bg, 10);\n\n\t\tbackground-color: #fff;\n\n\t\t@include transition( left .3s ease-in-out );\n\n\n\t\t/* (1) Pour chaque element du menu */\n\t\t& > span{\n\t\t\tdisplay: block;\n\t\t\tposition: relative;\n\n\t\t\t// On ajoute une ligne en dessous sauf pour le dernier\n\t\t\t&:not(:last-child){\n\t\t\t\tborder-bottom: 1px solid #ddd;\n\t\t\t}\n\n\t\t\tcolor: #000;\n\t\t\tpadding: .5em 1em;\n\t\t\tpadding-left: 2em;\n\n\t\t\tcursor: pointer;\n\n\t\t\t// @hover\n\t\t\t&:hover{\n\t\t\t\tbackground-color: #eee;\n\t\t\t}\n\t\t}\n\n\n\n\n\t}\n\n\t/* (3) Gestion de l'activation ou non de l'user panel */\n\t& > #toggle-user-panel{ display: none; }\n\t& > #toggle-user-panel + .user-panel{ left: 100%; }\n\t& > #toggle-user-panel:checked + .user-panel{ left: auto; }\n\t& > #toggle-user-panel:checked + .user-panel:before{ left: 7em; }\n\n\n\n\n\n\n}\n",
|
||||
"/* [1] COULEURS\n=========================================================*/\n/* (1) COULEURS DU THEME $DEFAULT */\n$theme-bg: #e8e8e8;\n$theme-bg-primary: #ffffff;\n$theme-fg: #515151;\n$theme-fg-primary: #399ced;\n\n/* (2) COULEURS DE THEME $DARK */\n$dark-bg: #313541;\n$dark-bg-primary: #29282e;\n$dark-fg: #939393;\n$dark-fg-primary: #ffffff;\n\n$header-dark: #F8F8FA;\n\n/* (3) Couleurs du theme pour la timeline */\n$timeline-color: #738394;\n$timeline-0: #399ced;\n$timeline-1: #e64e3e;\n$timeline-2: #10baa3;\n$timeline-3: #b14be7;\n$timeline-4: #053b5d;\n\n\n/* [2] DIMENSIONS\n=========================================================*/\n/* (1) Layout de base */\n$menu-side-width: 15em;\n$header-height: 4em;\n\n\n\n/* [3] Mixins\n=========================================================*/\n@mixin transform($value...) {\n\ttransform: $value;\n\t-moz-transform: $value;\n\t-o-transform: $value;\n\t-ms-transform: $value;\n\t-webkit-transform: $value;\n}\n\n\n@mixin transition($value...) {\n\t-webkit-transition: $value;\n\ttransition: $value;\n}\n\n/* [4] Functions\n=========================================================*/\n// Transforme une couleur hex en string sans le #\n@function color-str($color){\n\t@return str-slice(#{$color}, 2, str-length(#{$color}));\n}\n"
|
||||
],
|
||||
"mappings": "ACAA;2DAC2D;AAC3D,oCAAoC;AAMpC,iCAAiC;AAQjC,4CAA4C;AAS5C;2DAC2D;AAC3D,wBAAwB;AAMxB;2DAC2D;AAe3D;2DAC2D;AD/C3D,AAAW,QAAH,GAAG,OAAO,CAAA;EAEjB;4DAC2D;EAkB3D;4DAC2D;EAC3D,mBAAmB;EA4EnB;4DAC2D;EA4C3D,wDAAwD;CAWxD;;AA3JD,AAIK,QAJG,GAAG,OAAO,GAIb,UAAU,CAAA;EACb,OAAO,EAAE,YAAa;EACtB,QAAQ,EAAE,QAAS;EAClB,GAAG,EAAE,IAAK;EACV,IAAI,EAAE,GAAI;EACV,KAAK,EAAE,IAAK;EACZ,MAAM,EAAE,GAAI;EAEb,OAAO,EAAE,QAAS;EAElB,MAAM,EAAE,CAAE;EACV,aAAa,EAAE,GAAI;EAEnB,gBAAgB,ECjBC,OAAO;CDmBxB;;AAnBF,AAwBK,QAxBG,GAAG,OAAO,GAwBb,UAAU,CAAA;EACb,OAAO,EAAE,YAAa;EACtB,QAAQ,EAAE,QAAS;EAClB,GAAG,EAAE,CAAE;EACP,KAAK,EAAE,CAAE;EACT,MAAM,EAAE,mBAAI;EAGb,mCAAmC;EAoBnC,yBAAyB;EAyBzB,4BAA4B;CAkB5B;;AA/FF,AAiCM,QAjCE,GAAG,OAAO,GAwBb,UAAU,GAST,UAAU,CAAA;EACb,OAAO,EAAE,KAAM;EACf,QAAQ,EAAE,QAAS;EAClB,GAAG,EAAE,CAAE;EACP,KAAK,EAAE,kBAAI;EACX,MAAM,ECZQ,GAAG;EDclB,OAAO,EAAE,KAAM;EAEf,KAAK,EAAE,IAAK;EACZ,WAAW,ECjBI,GAAG;EDkBlB,WAAW,EAAE,MAAO;EACpB,WAAW,EAAE,IAAK;EAElB,MAAM,EAAE,OAAQ;CAEhB;;AAjDH,AAqDM,QArDE,GAAG,OAAO,GAwBb,UAAU,GA6BT,aAAa,CAAA;EAChB,OAAO,EAAE,KAAM;EACf,QAAQ,EAAE,QAAS;EAClB,GAAG,EAAE,GAAI;EACT,KAAK,EC/BS,GAAG;EDgCjB,KAAK,EAAE,kBAAI;EACX,MAAM,EAAE,kBAAI;EAGb,aAAa,EAAE,SAAU;EAEzB,UAAU,EChEM,OAAO,CDgED,mCAAG,CAAiC,MAAM,CAAC,MAAM,CAAC,SAAS;EACjF,eAAe,EAAE,QAAS;EAK1B,MAAM,EAAE,OAAQ;EAEhB,UAAU,EAAE,MAAO;CACnB;;AAzEH,AAqDM,QArDE,GAAG,OAAO,GAwBb,UAAU,GA6BT,aAAa,AAef,OAAO,CAAA;EAAE,gBAAgB,EAAE,sCAAG;EAAqC,eAAe,EAAE,SAAU;CAAI;;AApEtG,AAwBK,QAxBG,GAAG,OAAO,GAwBb,UAAU,AAsDZ,OAAO,CAAA;EACP,OAAO,EAAE,EAAG;EACZ,OAAO,EAAE,KAAM;EACf,QAAQ,EAAE,QAAS;EAClB,GAAG,EAAE,CAAE;EACP,KAAK,EAAE,CAAE;EACT,KAAK,EC1DS,GAAG;ED2DjB,MAAM,EC3DQ,GAAG;ED6DlB,UAAU,EAAE,2CAAG,CAAyC,MAAM,CAAC,MAAM,CAAC,SAAS;EAC/E,eAAe,EAAE,OAAQ;EAEzB,MAAM,EAAE,OAAQ;CAEhB;;AA5FH,AAqGK,QArGG,GAAG,OAAO,GAqGb,WAAW,CAAA;EACd,OAAO,EAAE,KAAM;EACf,QAAQ,EAAE,QAAS;EAClB,GAAG,EAAE,gBAAI;EACT,KAAK,EAAE,CAAE;EAEV,MAAM,EAAE,IAAK;EAEb,aAAa,EAAE,GAAI;EACnB,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,OAAM;EAExB,gBAAgB,EAAE,IAAK;ECtExB,kBAAkB,EDwEI,IAAI,CAAC,IAAG,CAAC,WAAW;ECvE1C,UAAU,EDuEY,IAAI,CAAC,IAAG,CAAC,WAAW;EAGzC,qCAAqC;CAyBrC;;AA9IF,AAsHM,QAtHE,GAAG,OAAO,GAqGb,WAAW,GAiBV,IAAI,CAAA;EACP,OAAO,EAAE,KAAM;EACf,QAAQ,EAAE,QAAS;EAOnB,KAAK,EAAE,IAAK;EACZ,OAAO,EAAE,QAAS;EAClB,YAAY,EAAE,GAAI;EAElB,MAAM,EAAE,OAAQ;CAMhB;;AAzIH,AAsHM,QAtHE,GAAG,OAAO,GAqGb,WAAW,GAiBV,IAAI,AAKN,IAAK,CAAA,AAAA,WAAW,EAAC;EACjB,aAAa,EAAE,cAAe;CAC9B;;AA7HJ,AAsHM,QAtHE,GAAG,OAAO,GAqGb,WAAW,GAiBV,IAAI,AAgBN,MAAM,CAAA;EACN,gBAAgB,EAAE,IAAK;CACvB;;AAxIJ,AAiJK,QAjJG,GAAG,OAAO,GAiJb,kBAAkB,CAAA;EAAE,OAAO,EAAE,IAAK;CAAI;;AAjJ3C,AAkJ0B,QAlJlB,GAAG,OAAO,GAkJb,kBAAkB,GAAG,WAAW,CAAA;EAAE,IAAI,EAAE,IAAK;CAAI;;AAlJtD,AAmJkC,QAnJ1B,GAAG,OAAO,GAmJb,kBAAkB,AAAA,QAAQ,GAAG,WAAW,CAAA;EAAE,IAAI,EAAE,IAAK;CAAI;;AAnJ9D,AAoJ6C,QApJrC,GAAG,OAAO,GAoJb,kBAAkB,AAAA,QAAQ,GAAG,WAAW,AAAA,OAAO,CAAA;EAAE,IAAI,EAAE,GAAI;CAAI",
|
||||
"names": []
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"version": 3,
|
||||
"file": "min.css",
|
||||
"sources": [
|
||||
"../header.scss",
|
||||
"../constants.scss"
|
||||
],
|
||||
"sourcesContent": [
|
||||
"@import 'constants';\n\n\n#WRAPPER > #HEADER{\n\n\t/* [1] Barre de recherche\n\t=========================================================*/\n\t& > #searchbar{\n\t\tdisplay: inline-block;\n\t\tposition: absolute;\n\t\t\ttop: .8em;\n\t\t\tleft: 1em;\n\t\t\twidth: 20em;\n\t\t\theight: 2em;\n\n\t\tpadding: .2em 1em;\n\n\t\tborder: 0;\n\t\tborder-radius: 3px;\n\n\t\tbackground-color: $theme-bg;\n\n\t}\n\n\t/* [2] Informations utilisateur\n\t=========================================================*/\n\t/* (0) Conteneur */\n\t& > #user-data{\n\t\tdisplay: inline-block;\n\t\tposition: absolute;\n\t\t\ttop: 0;\n\t\t\tright: 0;\n\t\t\theight: calc( 100% - 2*1em );\n\n\n\t\t/* (1) Username de l'utilisateur */\n\t\t& > #user-name{\n\t\t\tdisplay: block;\n\t\t\tposition: absolute;\n\t\t\t\ttop: 0;\n\t\t\t\tright: calc( #{$header-height}*2 - 1em );\n\t\t\t\theight: $header-height;\n\n\t\t\tpadding: 0 1em;\n\n\t\t\tcolor: #555;\n\t\t\tline-height: $header-height;\n\t\t\twhite-space: nowrap;\n\t\t\tfont-weight: bold;\n\n\t\t\tcursor: pointer;\n\n\t\t}\n\n\n\t\t/* (2) Image du profil */\n\t\t& > #user-picture{\n\t\t\tdisplay: block;\n\t\t\tposition: absolute;\n\t\t\t\ttop: 1em;\n\t\t\t\tright: $header-height;\n\t\t\t\twidth: calc( #{$header-height} - 2*1em );\n\t\t\t\theight: calc( #{$header-height} - 2*1em );\n\n\n\t\t\tborder-radius: 50% / 50%;\n\n\t\t\tbackground: $theme-bg url('/src/static/header/nopic.svg') center center no-repeat;\n\t\t\tbackground-size: auto 80%;\n\n\t\t\t// Si on est connecte\n\t\t\t&.active{ background-image: url('/src/dynamic/profile/sample.svg'); background-size: auto 100%; }\n\n\t\t\tcursor: default;\n\n\t\t\talign-self: center;\n\t\t}\n\n\n\n\t\t/* (3) Icone d'activation */\n\t\t&:before{\n\t\t\tcontent: '';\n\t\t\tdisplay: block;\n\t\t\tposition: absolute;\n\t\t\t\ttop: 0;\n\t\t\t\tright: 0;\n\t\t\t\twidth: $header-height;\n\t\t\t\theight: $header-height;\n\n\t\t\tbackground: url('/src/static/header/expand.svg@000000') center center no-repeat;\n\t\t\tbackground-size: 1em 1em;\n\n\t\t\tcursor: pointer;\n\n\t\t}\n\n\n\t}\n\n\n\n\t/* [3] Menu deroulant pour l'administration du profil\n\t=========================================================*/\n\t& > .user-panel{\n\t\tdisplay: block;\n\t\tposition: absolute;\n\t\t\ttop: calc( #{$header-height} - 1em );\n\t\t\tright: 0;\n\n\t\tmargin: .5em;\n\n\t\tborder-radius: 5px;\n\t\tborder: 1px solid darken($theme-bg, 10);\n\n\t\tbackground-color: #fff;\n\n\t\t@include transition( left .3s ease-in-out );\n\n\n\t\t/* (1) Pour chaque element du menu */\n\t\t& > span{\n\t\t\tdisplay: block;\n\t\t\tposition: relative;\n\n\t\t\t// On ajoute une ligne en dessous sauf pour le dernier\n\t\t\t&:not(:last-child){\n\t\t\t\tborder-bottom: 1px solid #ddd;\n\t\t\t}\n\n\t\t\tcolor: #000;\n\t\t\tpadding: .5em 1em;\n\t\t\tpadding-left: 2em;\n\n\t\t\tcursor: pointer;\n\n\t\t\t// @hover\n\t\t\t&:hover{\n\t\t\t\tbackground-color: #eee;\n\t\t\t}\n\t\t}\n\n\n\n\n\t}\n\n\t/* (3) Gestion de l'activation ou non de l'user panel */\n\t& > #toggle-user-panel{ display: none; }\n\t& > #toggle-user-panel + .user-panel{ left: 100%; }\n\t& > #toggle-user-panel:checked + .user-panel{ left: auto; }\n\t& > #toggle-user-panel:checked + .user-panel:before{ left: 7em; }\n\n\n\n\n\n\n}\n",
|
||||
"/* [1] COULEURS\n=========================================================*/\n/* (1) COULEURS DU THEME $DEFAULT */\n$theme-bg: #e8e8e8;\n$theme-bg-primary: #ffffff;\n$theme-fg: #515151;\n$theme-fg-primary: #399ced;\n\n/* (2) COULEURS DE THEME $DARK */\n$dark-bg: #313541;\n$dark-bg-primary: #29282e;\n$dark-fg: #939393;\n$dark-fg-primary: #ffffff;\n\n$header-dark: #F8F8FA;\n\n/* (3) Couleurs du theme pour la timeline */\n$timeline-color: #738394;\n$timeline-0: #399ced;\n$timeline-1: #e64e3e;\n$timeline-2: #10baa3;\n$timeline-3: #b14be7;\n$timeline-4: #053b5d;\n\n\n/* [2] DIMENSIONS\n=========================================================*/\n/* (1) Layout de base */\n$menu-side-width: 15em;\n$header-height: 4em;\n\n\n\n/* [3] Mixins\n=========================================================*/\n@mixin transform($value...) {\n\ttransform: $value;\n\t-moz-transform: $value;\n\t-o-transform: $value;\n\t-ms-transform: $value;\n\t-webkit-transform: $value;\n}\n\n\n@mixin transition($value...) {\n\t-webkit-transition: $value;\n\ttransition: $value;\n}\n\n/* [4] Functions\n=========================================================*/\n// Transforme une couleur hex en string sans le #\n@function color-str($color){\n\t@return str-slice(#{$color}, 2, str-length(#{$color}));\n}\n"
|
||||
],
|
||||
"mappings": "AAGA,AAIK,QAJG,CAAG,OAAO,CAIb,UAAU,AAAA,CACb,OAAO,CAAE,YAAa,CACtB,QAAQ,CAAE,QAAS,CAClB,GAAG,CAAE,IAAK,CACV,IAAI,CAAE,GAAI,CACV,KAAK,CAAE,IAAK,CACZ,MAAM,CAAE,GAAI,CAEb,OAAO,CAAE,QAAS,CAElB,MAAM,CAAE,CAAE,CACV,aAAa,CAAE,GAAI,CAEnB,gBAAgB,CCjBC,OAAO,CDmBxB,AAnBF,AAwBK,QAxBG,CAAG,OAAO,CAwBb,UAAU,AAAA,CACb,OAAO,CAAE,YAAa,CACtB,QAAQ,CAAE,QAAS,CAClB,GAAG,CAAE,CAAE,CACP,KAAK,CAAE,CAAE,CACT,MAAM,CAAE,mBAAI,CAkEb,AA/FF,AAiCM,QAjCE,CAAG,OAAO,CAwBb,UAAU,CAST,UAAU,AAAA,CACb,OAAO,CAAE,KAAM,CACf,QAAQ,CAAE,QAAS,CAClB,GAAG,CAAE,CAAE,CACP,KAAK,CAAE,kBAAI,CACX,MAAM,CCZQ,GAAG,CDclB,OAAO,CAAE,KAAM,CAEf,KAAK,CAAE,IAAK,CACZ,WAAW,CCjBI,GAAG,CDkBlB,WAAW,CAAE,MAAO,CACpB,WAAW,CAAE,IAAK,CAElB,MAAM,CAAE,OAAQ,CAEhB,AAjDH,AAqDM,QArDE,CAAG,OAAO,CAwBb,UAAU,CA6BT,aAAa,AAAA,CAChB,OAAO,CAAE,KAAM,CACf,QAAQ,CAAE,QAAS,CAClB,GAAG,CAAE,GAAI,CACT,KAAK,CC/BS,GAAG,CDgCjB,KAAK,CAAE,kBAAI,CACX,MAAM,CAAE,kBAAI,CAGb,aAAa,CAAE,SAAU,CAEzB,UAAU,CChEM,OAAO,CDgED,mCAAG,CAAiC,MAAM,CAAC,MAAM,CAAC,SAAS,CACjF,eAAe,CAAE,QAAS,CAK1B,MAAM,CAAE,OAAQ,CAEhB,UAAU,CAAE,MAAO,CACnB,AAzEH,AAqDM,QArDE,CAAG,OAAO,CAwBb,UAAU,CA6BT,aAAa,AAef,OAAO,AAAA,CAAE,gBAAgB,CAAE,sCAAG,CAAqC,eAAe,CAAE,SAAU,CAAI,AApEtG,AAwBK,QAxBG,CAAG,OAAO,CAwBb,UAAU,AAsDZ,OAAO,AAAA,CACP,OAAO,CAAE,EAAG,CACZ,OAAO,CAAE,KAAM,CACf,QAAQ,CAAE,QAAS,CAClB,GAAG,CAAE,CAAE,CACP,KAAK,CAAE,CAAE,CACT,KAAK,CC1DS,GAAG,CD2DjB,MAAM,CC3DQ,GAAG,CD6DlB,UAAU,CAAE,2CAAG,CAAyC,MAAM,CAAC,MAAM,CAAC,SAAS,CAC/E,eAAe,CAAE,OAAQ,CAEzB,MAAM,CAAE,OAAQ,CAEhB,AA5FH,AAqGK,QArGG,CAAG,OAAO,CAqGb,WAAW,AAAA,CACd,OAAO,CAAE,KAAM,CACf,QAAQ,CAAE,QAAS,CAClB,GAAG,CAAE,gBAAI,CACT,KAAK,CAAE,CAAE,CAEV,MAAM,CAAE,IAAK,CAEb,aAAa,CAAE,GAAI,CACnB,MAAM,CAAE,GAAG,CAAC,KAAK,CAAC,OAAM,CAExB,gBAAgB,CAAE,IAAK,CCtExB,kBAAkB,CDwEI,IAAI,CAAC,IAAG,CAAC,WAAW,CCvE1C,UAAU,CDuEY,IAAI,CAAC,IAAG,CAAC,WAAW,CA4BzC,AA9IF,AAsHM,QAtHE,CAAG,OAAO,CAqGb,WAAW,CAiBV,IAAI,AAAA,CACP,OAAO,CAAE,KAAM,CACf,QAAQ,CAAE,QAAS,CAOnB,KAAK,CAAE,IAAK,CACZ,OAAO,CAAE,QAAS,CAClB,YAAY,CAAE,GAAI,CAElB,MAAM,CAAE,OAAQ,CAMhB,AAzIH,AAsHM,QAtHE,CAAG,OAAO,CAqGb,WAAW,CAiBV,IAAI,AAKN,IAAK,CAAA,AAAA,WAAW,CAAC,CACjB,aAAa,CAAE,cAAe,CAC9B,AA7HJ,AAsHM,QAtHE,CAAG,OAAO,CAqGb,WAAW,CAiBV,IAAI,AAgBN,MAAM,AAAA,CACN,gBAAgB,CAAE,IAAK,CACvB,AAxIJ,AAiJK,QAjJG,CAAG,OAAO,CAiJb,kBAAkB,AAAA,CAAE,OAAO,CAAE,IAAK,CAAI,AAjJ3C,AAkJ0B,QAlJlB,CAAG,OAAO,CAkJb,kBAAkB,CAAG,WAAW,AAAA,CAAE,IAAI,CAAE,IAAK,CAAI,AAlJtD,AAmJkC,QAnJ1B,CAAG,OAAO,CAmJb,kBAAkB,AAAA,QAAQ,CAAG,WAAW,AAAA,CAAE,IAAI,CAAE,IAAK,CAAI,AAnJ9D,AAoJ6C,QApJrC,CAAG,OAAO,CAoJb,kBAAkB,AAAA,QAAQ,CAAG,WAAW,AAAA,OAAO,AAAA,CAAE,IAAI,CAAE,GAAI,CAAI",
|
||||
"names": []
|
||||
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,5 @@
|
|||
document.body.innerHTML="";
|
||||
var default_definition={"input.text":{node_type:"input",attributes:{name:"{name}",value:"{value}",type:"text"}},"/^span:(d+)$/":{node_type:"span",text:"span {spanRepeat:i} on {spanRepeat:n} (={$1})",repeat:{n:"{$1}",id:"spanRepeat"},attributes:{"class":"{class}"}},"simple-select":{node_type:"select",attributes:{"class":"{select-class}"},children:[{node_type:"option",browse:{array:"{options[]}",funcs:{"options.value":"{getvalue()}","options.length":"{getlength()}"}},attributes:{"class":"{option-class}",value:"{options:i}"},
|
||||
text:"{options.value} ({options.length} caract\u00e8res)"}],listeners:{change:"{onchange()}"}}},exempleFormulaire={node_type:"form",attributes:{method:"POST",action:"{url}"},prev_nodes:[{node:"span:2",$class:"beforeSpan"}],children:[{node:"input.text",$name:"fname",$value:"{default_firstname}"},{node:"simple-select",$options:"{liste_noms[]}",$select_class:"gui-option",$option_class:"gui-select",$onchange:"{my_onchange()}",$getvalue:"{getitemvalue()}",$getlength:"{getitemlength()}"},{node_type:"input",
|
||||
attributes:{type:"submit",value:"Valider"}}],next_nodes:[{node:"span:2",$class:"afterSpan"}]},monBuilder=new FormBuilder(exempleFormulaire);monBuilder.add_definition(default_definition);monBuilder.build({url:"https://xdrm.io/page1",default_firstname:"Jean",liste_noms:"Jean Pierre Robert Marie Anna F\u00e9licien Marc J\u00e9sus".split(" "),getitemvalue:function(a){return a},getitemlength:function(a){return a.length}});var monConteneur=document.body;monBuilder.attach(monConteneur);
|
||||
monBuilder.update({url:"https://xdrm.io/page2",getitemlength:function(a){return a.length+1}});monBuilder.attach(monConteneur);
|
|
@ -0,0 +1,225 @@
|
|||
document.body.innerHTML = '';
|
||||
|
||||
// CETTE CLASSE PERMET LA CREATION DE HTML A PARTIR D'UN OBJET JAVASCRIPT
|
||||
//
|
||||
//
|
||||
// Notation:
|
||||
// - Une chaine de caractère précédée du symbole '@' correspond à un commentaire pour expliquer une valeur
|
||||
//
|
||||
//
|
||||
// Types de donées:
|
||||
// - <S> Chaine de caractère
|
||||
// - <A> Tableau
|
||||
// - <O> Tableau associatif (objet)
|
||||
// - <I> Nombre entier
|
||||
// - <F> Fonction
|
||||
// - <*> Qu'importe
|
||||
//
|
||||
// Structure:
|
||||
// - L'objet permettant la création du HTML correspond à un #Element
|
||||
// - L'imbrication de ses #Element permet de construire une structure complète
|
||||
//
|
||||
//
|
||||
// Fonctionnement:
|
||||
// - En plus de l'objet correspondant à l'élément HMTL, il faut spécifier des #Descriptions permettant
|
||||
// de générer le HTML
|
||||
//
|
||||
//
|
||||
// Liste des attributs:
|
||||
// 'node' <S> String permettant de lier l'élément à une définition (qui doit forcément avoir, soit une autre définition, soit 'node_type')
|
||||
// 'node_type' <S> Type d'élément HTML, aucune définition n'est nécessaire
|
||||
// 'children' <A> les #Element enfants de l'#Element en question
|
||||
// 'prev_nodes' <A> les #Element précédant l'#Element en question
|
||||
// 'next_nodes' <A> les #Element suivant l'#Element en question
|
||||
// 'text' <S> Contenu textuel de l'#Element (cf. innerHTML)
|
||||
// 'attributes' <O> Tableau associatif contenant les attributs de l'#Element
|
||||
// 'listeners' <O> Contient les associations { '@eventName': '@eventFunction' } - @eventName<S> - @eventFunction<F>
|
||||
// 'repeat' <O> Définit le nombre de fois qu'il faut dupliquer l'#Element { n: @nbRepeat, id: '@idDuRepeat'}
|
||||
// 'n' <I> Nombre de fois qu'il faut dupliquer l'#Element
|
||||
// 'id' <S> Identifiant de la répétition, permet d'interpoler l'indice et le total
|
||||
// *Note: il est possible d'interpoler l'indice de l'#Element avec '{@idRepeat:i}' et le total avec '{@idRepeat:n}'
|
||||
// 'browse' <A/O> Définit le tableau sur lequel dupliquer l'#Element { array: @tableau, funcs: { @nomValeur1: @func1, @nomValeur2: @func2 } }
|
||||
// 'array' <A> Tableau pour lequel dupliquer l'#Element (pour chaque valeur), l'interpolation se fait avec '{@nomTab.@nomAttr}'
|
||||
// 'funcs' <B> Définition d'actions sur chaque élément du tableau (interpolables de la même manière que les vrais attributs)
|
||||
// *Note: il est possible d'interpoler l'indice de l'#Element avec '{@nomTab:i}' et le total avec '{@nomTab:n}'
|
||||
// '$@someName' <*> Un attribut commençant par le caractère '$' sera passé au scope de ses enfants, voisins, et définitions
|
||||
//
|
||||
//
|
||||
// Interpolation de valeurs:
|
||||
// '{@nomVariable}' sera remplacé par la variable 'nomVariable', si elle n'existe pas, par une chaine vide
|
||||
// *Note: le nom de la variable ne peut contenir que : 1. des lettres en minuscules, des underscore ('_')
|
||||
// '{@nomTab[]}' sera remplacé par le tableau 'nomTab', si il n'existe pas, par un tableau vide
|
||||
// *Note: le nom de la variable ne peut contenir que : 1. des lettres en minuscules, des underscore ('_')
|
||||
// '{@nomFunc()}' sera remplacé par la fonction 'nomFunc', si elle n'existe pas, par une fonction vide
|
||||
// *Note: le nom de la variable ne peut contenir que : 1. des lettres en minuscules, des underscore ('_')
|
||||
// '{$@n}' sera remplacé par le @n-ième match de la dernière RegExp valide
|
||||
// *Note: ne peut qu'être utilisé dans les définitions, car c'est le seul endroit ou peuvent être des RegExp
|
||||
// '{@tab.@attr}' sera remplacé par l'attribut @attr de l'item en cours du tableau @tab
|
||||
// *Note: si l'attribut n'existe pas, mais qu'une fonction est définie pour cette valeur, la fonction calculera la valeur
|
||||
// *Note: n'est utilisable que dans un #Element ayant l'attribut 'browse'
|
||||
//
|
||||
//
|
||||
// Définition
|
||||
// Les clés de l'objet correspondent à l'attribut 'node', il peut soit être une chaine, soit une RegExp @r de la forme: '/^@r$/'
|
||||
//
|
||||
//
|
||||
//
|
||||
// Exemple: objet de définition
|
||||
// ----------------------------
|
||||
var default_definition = {
|
||||
// Les #Element avec 'node' valant 'input' seront liés à cette définition
|
||||
'input.text': {
|
||||
node_type: 'input', // sera un <input>
|
||||
attributes: {
|
||||
name: '{name}', // l'attribut 'name' vaudra la valeur de la variable 'name'
|
||||
value: '{value}', // l'attribut 'value' vaudra la valeur de la variable 'value'
|
||||
type: 'text' // l'attribut 'type' vaudra 'text'
|
||||
}
|
||||
},
|
||||
|
||||
// Les #Element avec 'node' valant 'span:@x' avec @x un nombre entier, seront liés à cette définition
|
||||
'/^span:(\d+)$/': {
|
||||
node_type: 'span', // sera un <span>
|
||||
text: 'span {spanRepeat:i} on {spanRepeat:n} (={$1})',
|
||||
repeat: {
|
||||
n: '{$1}', // sera dupliqué @x fois, avec @x récupéré dans le nom de la définition
|
||||
id: 'spanRepeat' // sera accessible via l'id 'spanRepeat'
|
||||
},
|
||||
attributes: {
|
||||
'class': '{class}' // l'attribut 'class' vaudra la valeur de la variable 'class'
|
||||
}
|
||||
},
|
||||
|
||||
// Les #Element avec 'node' valant 'simple-select', seront liés à cette définition
|
||||
'simple-select': {
|
||||
node_type: 'select', // sera un <select>
|
||||
attributes: {
|
||||
'class': '{select-class}' // l'attribut 'class' prendra la valeur de la variable 'select-class'
|
||||
},
|
||||
children: [
|
||||
{
|
||||
node_type: 'option', // contiendra des <option>
|
||||
browse: {
|
||||
array: '{options[]}', // chaque <option> sera dupliquée pour chaque valeur du tableau 'options'
|
||||
funcs: {
|
||||
// définit le "faux" attribut 'value' de chaque élément du tableau 'options'
|
||||
// avec la fonction 'getvalue()' qui sera passée en paramètre
|
||||
// *Node: le tableau n'aura pas d'attribut (tableau simple), cela renverra
|
||||
// donc directement la valeur de chaque item
|
||||
'options.value': '{getvalue()}',
|
||||
|
||||
// définit le "faux" attribut 'length' de chaque élément du tableau 'options'
|
||||
// avec la fonction 'getstrlen()' qui sera passée en paramètre
|
||||
// la fonction retournera la taille des chaines de chaque valeur du tableau
|
||||
'options.length': '{getlength()}'
|
||||
}
|
||||
},
|
||||
attributes: {
|
||||
'class': '{option-class}', // l'attribut 'class' prendra la valeur de la variable 'option-class'
|
||||
value: '{options:i}' // chaque <option> aura l'attribut 'value' qui vaut l'indice actuel de l'#Element
|
||||
},
|
||||
// aura pour contenu la valeur de l'item actuel @a du tableau,
|
||||
// suivi du nombre de caractère @b de la valeur
|
||||
// ex: "texteDeLitem (12 caractères)"
|
||||
text: '{options.value} ({options.length} caractères)'
|
||||
}
|
||||
],
|
||||
|
||||
listeners: {
|
||||
// ajoutera un listener sur l'évènement 'change' et lancera la fonction passée
|
||||
// qui s'appelle 'onchange'
|
||||
'change': '{onchange()}'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Exemple formulaire
|
||||
// ------------------
|
||||
var exempleFormulaire = {
|
||||
node_type: 'form', // sera un <form>
|
||||
attributes: {
|
||||
'method': 'POST', // aura l'attribut 'method' valant 'POST'
|
||||
'action': '{url}' // aura l'attribut 'action' valant la valeur de la variable 'url'
|
||||
},
|
||||
|
||||
// sera précédé par 2 <span> (cf. définition de 'span:(\d+)')
|
||||
prev_nodes: [
|
||||
{
|
||||
node: 'span:2',
|
||||
$class: 'beforeSpan' // les <span> hériterons de la variable 'class'
|
||||
}
|
||||
],
|
||||
|
||||
children: [
|
||||
{ // contiendra en premier enfant un <input type='text'>
|
||||
node: 'input.text',
|
||||
$name: 'fname', // l'<input> héritera la variable 'name'
|
||||
$value: '{default_firstname}' // l'<input> héritera la variable 'value', qui elle-même sera récupèrée de la variable 'default_firstname'
|
||||
},
|
||||
|
||||
{ // contiendra en second enfant un <select> contenant les <options> en fonction du tableau 'liste-noms'
|
||||
node: 'simple-select',
|
||||
$options: '{liste_noms[]}', // la définition héritera du tableau 'options' valant le tableau donné 'liste_noms'
|
||||
$select_class: 'gui-option', // la définition héritera de la variable 'select_class'
|
||||
$option_class: 'gui-select', // la définition héritera de la variable 'option_class'
|
||||
$onchange: '{my_onchange()}', // la définition héritera de la fonction 'onchange' valant la fonction donnée 'my_onchange'
|
||||
$getvalue: '{getitemvalue()}', // la définition héritera de la fonction 'getvalue' valant la fonction données 'getitemvalue'
|
||||
$getlength: '{getitemlength()}' // la définition héritera de la fonction 'getlength' valant la fonction données 'getitemvalue'
|
||||
},
|
||||
|
||||
{ // contiendra en dernier enfant un <input type='submit' value='Valider'>
|
||||
node_type: 'input', // sera un <input>
|
||||
attributes: {
|
||||
type: 'submit', // aura l'attribut 'type' qui vaut 'submit'
|
||||
value: 'Valider' // aura l'attribut 'value' qui vaut 'Valider'
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
// sera suivi par 2 <span> (cf. définition de 'span:(\d+)')
|
||||
next_nodes: [
|
||||
{
|
||||
node: 'span:2',
|
||||
$class: 'afterSpan' // les <span> hériterons de la variable 'class'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
//
|
||||
// Exemple code de construction
|
||||
// ----------------------------
|
||||
//
|
||||
// On instancie notre builder
|
||||
var monBuilder = new FormBuilder(exempleFormulaire);
|
||||
// on ajoute la/les définition(s)
|
||||
monBuilder.add_definition(default_definition);
|
||||
// on construit notre objet en lui passant toutes les données
|
||||
monBuilder.build({
|
||||
url: 'https://xdrm.io/page1', // variable 'url'
|
||||
default_firstname: 'Jean', // variable 'default_firstname'
|
||||
liste_noms: ['Jean', 'Pierre', 'Robert', 'Marie', 'Anna', 'Félicien', 'Marc', 'Jésus'], // tableau 'list_noms'
|
||||
getitemvalue: function(item){ return item; }, // pour chaque item, retournera la valeur brute
|
||||
getitemlength: function(item){ return item.length; } // pour chaque item, retournera la taille de la valeur
|
||||
});
|
||||
|
||||
//
|
||||
// Exemple code d'ajout au DOM
|
||||
// ---------------------------
|
||||
// soit monConteneur, l'élément qui contiendra le formulaire
|
||||
var monConteneur = document.body;
|
||||
// On ajoute le formulaire au conteneur
|
||||
monBuilder.attach(monConteneur);
|
||||
|
||||
|
||||
//
|
||||
// Exemple de modification des valeurs
|
||||
// -----------------------------------
|
||||
// les variables ommises lors de la création, ne sont pas modifiables
|
||||
monBuilder.update({
|
||||
url: 'https://xdrm.io/page2', // on modifie l'URL
|
||||
getitemlength: function(item){ return item.length+1; } // on modifie notre fonction (on renvoie taille+1)
|
||||
});
|
||||
// reconstruction du DOM
|
||||
monBuilder.attach(monConteneur);
|
|
@ -0,0 +1 @@
|
|||
function formatObject(a){for(var b in a)formatObject(a[b]),a[b].parent=a};
|
|
@ -0,0 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
/* [1] Gestion de la référence vers le parent
|
||||
=========================================================*/
|
||||
function formatObject(object){
|
||||
|
||||
for( var i in object ){
|
||||
formatObject(object[i]);
|
||||
object[i].parent = object;
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue