www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit aa0ffc7e1a8408a3925be93e27bd7960d3d38d9b
parent 89b9f2a355cf1eea5a3e2c2569d940278bd63bb2
Author: Yoann <yoann.b87@voila.fr>
Date:   Thu, 14 Apr 2011 11:15:47 +0200

Merge branch 'unstable' of https://github.com/jsmaniac/2011-m1s2-ter into unstable

Diffstat:
Mcode/html5/pticlic.js | 2+-
Mcode/serveur/php/pticlic.php | 10++++++++--
2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/code/html5/pticlic.js b/code/html5/pticlic.js @@ -59,7 +59,7 @@ function jss() { } $(function () { - var url = "tmp.json"; + var url = "http://www.pticlic.fr/unstable/code/serveur/php/server.php?action=0&nb=1&user=foo&passwd=bar&mode=normal"; $.getJSON(url, function(data) { var game = data[0]; var currentWordNb = 0; diff --git a/code/serveur/php/pticlic.php b/code/serveur/php/pticlic.php @@ -358,6 +358,7 @@ function formatWord($word) { */ function game2json($user, $gameId) { + global $stringRelations; $db = getDB(); // TODO : factoriser avec game2array() . // TODO : planter si la requête suivante échoue pour quelque raison que ce soit. @@ -367,9 +368,14 @@ function game2json($user, $gameId) // TODO Yoann : faire des tests d'erreur pour ces select ? $game = $db->query("select gid, (select name from node where eid = eid_central_word) as name_central_word, eid_central_word, relation_1, relation_2 from game where gid = ".$gameId.";"); $game = $game->fetchArray(); - + $retstr = ""; - $retstr .= '{"gid":'.$gameId.',"pgid":'.$pgid.',"cat1":'.$game['relation_1'].',"cat2":'.$game['relation_2'].',"cat3":0,"cat4":-1,'; + $retstr .= '{"gid":'.$gameId.',"pgid":'.$pgid.',"relations":['; + $retstr .= '{"id":'.$game['relation_1'].', "name":'.json_encode(''.formatWord($stringRelations[$game['relation_1']])).'}'; + $retstr .= ', {"id":'.$game['relation_2'].', "name":'.json_encode(''.formatWord($stringRelations[$game['relation_2']])).'}'; + $retstr .= ', {"id":0, "name":'.json_encode(''.formatWord($stringRelations[0])).'}'; + $retstr .= ', {"id":-1, "name":'.json_encode(''.formatWord($stringRelations[-1])).'}],'; + // $retstr .= '{"gid":'.$gameId.',"pgid":'.$pgid.',"cat1":'.$game['relation_1'].',"cat2":'.$game['relation_2'].',"cat3":0,"cat4":-1,'; $retstr .= '"center":{"id":'.$game['eid_central_word'].',"name":'.json_encode(''.formatWord($game['name_central_word'])).'},'; $retstr .= '"cloudsize":10,"cloud":['; // TODO ! compter dynamiquement.