From a19f4d5ae9bea69e3a54abef9243e2e693c50d0b Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Wed, 25 May 2016 19:29:47 +0200 Subject: [PATCH] =?UTF-8?q?#15;=20Impl=C3=A9mentation=20du=20module=20'cha?= =?UTF-8?q?rt/network'=20fonctionnelle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/modules.json | 8 +++++++ manager/module/chart.php | 48 ++++++++++++++++++++++++++++++++++++++-- test-charts/network.php | 39 +++++++++++++++++++++++++++----- 3 files changed, 88 insertions(+), 7 deletions(-) diff --git a/config/modules.json b/config/modules.json index bf9bd0c..995644d 100755 --- a/config/modules.json +++ b/config/modules.json @@ -168,6 +168,14 @@ "parameters": { "subject": { "description": "Identifiant du sujet à étudier,", "type": "id" } } + }, + + "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" } + } } }, diff --git a/manager/module/chart.php b/manager/module/chart.php index 5d67b08..ef738b8 100755 --- a/manager/module/chart.php +++ b/manager/module/chart.php @@ -651,7 +651,7 @@ // Si erreur if( $phone === false ) - return array( 'ModuleError' => ManagerError::ModuleError ); + $phone = array(); /* (2) On récupère les données facebook */ $db = new lightdb('facebook_db', __ROOT__.'/src/dynamic/'); @@ -660,12 +660,56 @@ // Si erreur if( $facebook === false ) + $facebook = array(); + + /* (3) Si aucune donnée, erreur */ + if( count($phone) + count($facebook) == 0 ) return array( 'ModuleError' => ManagerError::ModuleError ); /* [2] On récupère les top20 de chaque jeu (les contacts intéressants) =========================================================*/ - $nodes = array(); + $nodes = array(); + + /* (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( + '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( + 'id' => $contact['id'], + 'label' => $contact['name'], + 'type' => 'facebook' + ) ); + + + + /* [3] On récupère toutes les relations + =========================================================*/ + $edges = array(); + + /* (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']) ); + + + /* (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']) ); + + diff --git a/test-charts/network.php b/test-charts/network.php index 3717acb..cc1adeb 100644 --- a/test-charts/network.php +++ b/test-charts/network.php @@ -1,3 +1,14 @@ + + @@ -6,13 +17,31 @@ - - "; - echo ""; + /* [1] On récupère les données + =========================================================*/ + $req = new ModuleRequest('chart/network', array('subject'=>273)); + $res = $req->dispatch(); + + if( $res->error != ManagerError::Success ) + var_dump( ManagerError::explicit($res->error) ); + + var_dump($res->getAll()); + + + /* [2] Gestion spatiale + =========================================================*/ + + + + + + /* [3] On affiche le contenu + =========================================================*/ + echo ""; + echo ""; + - echo "";