ADD #143 (80%)
[cl7.git] / php / pages / jeux_joues.php
index 9c531ec..276c8f5 100644 (file)
@@ -17,7 +17,7 @@ echo '
 <form id="formulaireJeuxJoues" method="post" action="index.php?page=jeux_joues">\r
    <p><input type="hidden" name="set_jeux_joues" value="1" /></p>\r
    <table>\r
-      <tr>', ($vote_possible ? '<th></th>' : ''), '<th>Votes</th><th>Jeux</th></tr>';\r
+      <tr>', ($vote_possible ? '<th></th>' : ''), '<th>Votes</th><th>Nom</th><th>Type</th><th></th></tr>';\r
 
 # /!\ Attention, requête un poil tricky :
 # On souhait avoir une liste des jeux joués avec pour chaque tuple :
@@ -28,12 +28,14 @@ $jeux_query = pg_query("
    SELECT 
       jeux.id,
       jeux.nom,
+      jeux.type,
+      jeux.url,
       array_agg(jeux_choisis.participant_id) AS participants,
       (COUNT(*) + (CASE WHEN bool_and(jeux_choisis.participant_id is null) THEN -1 ELSE 0 END)) as nb_vote
    FROM 
       jeux 
       LEFT JOIN jeux_choisis ON jeux.id = jeux_choisis.jeu_id
-   GROUP BY jeux.id, jeux.nom  
+   GROUP BY jeux.id, jeux.nom, jeux.type, jeux.url
    ORDER BY nb_vote DESC, jeux.nom\r
 ");\r
    \r
@@ -50,11 +52,15 @@ while ($jeu = pg_fetch_object($jeux_query))
       
       $a_vote = in_array($participant->info->id, $participants);\r
    }\r
+   
+   $a_url = preg_match('/^https?:\/\/.+$/', $jeu->url);
    \r
    echo '<tr>',\r
       $vote_possible ? '<td><input type="checkbox" name="votes[]" '. ($a_vote ? 'checked="checked"' : '') .' value="'.$jeu->id.'" /></td>' : '',\r
       '<td>' . $jeu->nb_vote . '</td>',\r
-      '<td ' . ($a_vote ? 'class="aVote" ': '').'>' . traitement_pre_affichage($jeu->nom) . '</td></tr>';\r
+      '<td ' . ($a_vote ? 'class="aVote" ': '').'>' . ($a_url ? '<a href="'. htmlentities($jeu->url) .'">' : '') . traitement_pre_affichage($jeu->nom) . ($a_url ? '</a>' : '') . '</td>',
+      '<td ' . ($a_vote ? 'class="aVote" ': '').'>' . traitement_pre_affichage($jeu->type) . '</td>',
+      '<td>x</td></tr>';\r
 }\r
 \r
 echo '\r
@@ -62,7 +68,11 @@ echo '
 \r
 if ($vote_possible)\r
    echo '\r
-   <p>Autre : <input type="text" maxlength="50" name="jeu" /></p>\r
+   <p>Ajouter : 
+      <input class="info" type="text" size="20" maxlength="50" name="jeu" value="<nom>" >
+      <input class="info" type="text" size="10" maxlength="100" name="type" value="<type>" />
+      <input class="info" type="text" size="20" maxlength="200" name="url" value="<URL>" />
+   </p>\r
    <p><input type="submit" value="Voter" /></p>';\r
    \r
 echo '</form>';\r