commit 276fa5b4bbd7230f8eb38c2263a6715300c8cd5a
parent c8c9e627fc67ef5906e6dc4bc41e51fa384a33a7
Author: Yoann Bonavero <yoann.b87@voila.fr>
Date: Wed, 9 Mar 2011 14:54:54 +0100
Petit avancement de la page de création de partie. Les trois grandes
étapes sont accéssiblent mais n'éffectuent pas encore d'insertion dans
la base de donnée.
Diffstat:
2 files changed, 69 insertions(+), 20 deletions(-)
diff --git a/code/serveur/php/createGame.php b/code/serveur/php/createGame.php
@@ -14,25 +14,45 @@ if(isset($_POST['nbcloudwords'])) {
$err = true;
$msg = $strings['err_creategame_nbwords_value'];
}
- else
+ else {
$state = 1;
-
- if($state == 1) {
$relations = get_game_relations();
+ }
+
+ if($state == 1 && isset($_POST['centralword']) && !empty($_POST['centralword'])) {
+ if($_POST['relation1'] != $_POST['relation2']) {
+ $centralword = $_POST['centralword'];
+ $rels[0] = $relations[$_POST['relation1']][1];
+ $rels[1] = $relations[$_POST['relation2']][1];
+ $rels[2] = "Est en rapport avec";
+ $rels[3] = "N'a aucun rapport avec";
+
+ for($i = 0; $i < $nbwords; $i++)
+ if(!isset($_POST['word'.$i]) || empty($_POST['word'.$i])) {
+ $err = true;
+ $msg = $strings['err_creategame_fill_all'];
+ break;
+ }
+ else
+ $words[$i] = $_POST['word'.$i];
- for($i = 0; $i < $nbwords; $i++)
- if(!isset($_POST['word'.$i]) || empty($_POST['word'.$i])) {
- $err = true;
- $msg = $strings['err_creategame_fill_all'];
- break;
- }
+ if($err != true)
+ $state = 2;
+ }
+ else {
+ $err = true;
+ $msg = $strings['err_creategame_eq_relations'];
+ }
+ }
+ else {
+ $err = true;
+ $msg = $strings['err_creategame_fill_all'];
}
}
else
$err = true;
-if($err == false)
- $state = 1;
+
?>
@@ -72,17 +92,17 @@ if($err == false)
echo '<table class="wordsform">';
echo '<tr><td><label for="relation1">Relation 1 : </label></td>';
echo '<td class="inputcell"><select name="relation1">';
- foreach($relations as $r)
- echo '<option value="'.$r[0].'">'.$r[1].'</option>';
+ foreach($relations as $key=>$r)
+ echo '<option value="'.$ey.'">'.$r[1].'</option>';
echo '</select></td>';
echo '<td><label for="relation2">Relation 2 : </label></td>';
echo '<td class="inputcell"><select name="relation2">';
- foreach($relations as $r)
- echo '<option value="'.$r[0].'">'.$r[1].'</option>';
+ foreach($relations as $key=>$r)
+ echo '<option value="'.$key.'">'.$r[1].'</option>';
echo '</select></td>';
echo '<input type="hidden" name="nbcloudwords" value="'.$nbwords.'" />';
- echo '<tr><td colspan="2"><label for="centralword">Mot central : </label><br /><br /></td>';
- echo '<td colspan="2" class="inputcell"><input type="text" name="centralword" value="';
+ echo '<tr><td colspan="2"><br /><label for="centralword">Mot central : </label><br /><br /></td>';
+ echo '<td colspan="2" class="inputcell"><br /><input type="text" name="centralword" value="';
if(isset($_POST['centralword'])) echo $_POST['centralword'];
echo '"/><br /><br /></td>';
@@ -102,7 +122,31 @@ if($err == false)
echo '</tr><tr><td colspan="2"></td><td colspan="2" class="td2"><input type="submit" value="Enregistrer la partie" /></td></tr>';
}
else {
+ echo '<table class="wordsform">';
+ echo 'Mot central : ';
+ echo $centralword;
+ echo '<tr>';
+
+ foreach($words as $key=>$w) {
+ echo '<td>'.$w.'</td><td class="inputcell">';
+ echo '<input type="radio" name="'.$key.'" id="'.$key.'_r1" value="0">';
+ echo '<label for="'.$key.'_r1">'.$rels[0].'</label><br />';
+ echo '<input type="radio" name="'.$key.'" id="'.$key.'_r2" value="1">';
+ echo '<label for="'.$key.'_r2">'.$rels[1].'</label><br />';
+ echo '<input type="radio" name="'.$key.'" id="'.$key.'_r3" value="2">';
+ echo '<label for="'.$key.'_r3">'.$rels[2].'</label><br />';
+ echo '<input type="radio" name="'.$key.'" id="'.$key.'_r4" value="3">';
+ echo '<label for="'.$key.'_r4">'.$rels[3].'</label></td>';
+
+ if($key%2 != 0)
+ echo '</tr><tr>';
+ }
+
+ if(count($words)%2 != 0)
+ echo '<td></td><td></td>';
+ echo '</tr>';
+ echo '<tr><td><input type="submit" value="Enregistrer" /></td></tr>';
}
?>
</table>
diff --git a/code/serveur/php/ressources/simple.css b/code/serveur/php/ressources/simple.css
@@ -110,15 +110,20 @@ form input[type=submit] {
height : 200px;
}
-.creategame td {
- vertical-align : top;
+.creategame .wordsform {
+ border-collapse : collapse;
+}
+
+.creategame .wordsform td {
+ border : 1px solid #808080;
+ vertical-align : middle;
+ padding : 1.5ex;
text-align : right;
padding-left : 3em;
padding-right : 1em;
}
.creategame .wordsform .inputcell {
- vertical-align : top;
text-align : left;
padding-left : 1em;
padding-right : 3em;