Mercurial > hg > fapweb
changeset 242:c52ca3a89989
Some random broken work on vote page.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 22 Nov 2013 01:08:15 +0200 |
parents | b55d6b6efa1a |
children | e284f867c1d8 |
files | vote.inc.php |
diffstat | 1 files changed, 45 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/vote.inc.php Thu Nov 21 21:10:01 2013 +0200 +++ b/vote.inc.php Fri Nov 22 01:08:15 2013 +0200 @@ -63,59 +63,67 @@ // Output voting system HTML echo "<h1>Voting system</h1>\n". - stGetFormStart("vote", "usrvote.php"). + stGetFormStart("vote", "usrajax.php"). " ".stGetFormHiddenInput("mode", "done")."\n". - " ".stGetFormHiddenInput("goto", "vote")."\n". + " ".stGetFormHiddenInput("action", "submit")."\n". stGetVoteButton(); - foreach ($compos as $id => $compo) - if (count($compo["entries"]) > 0) + foreach (stExecSQL("SELECT * FROM compos WHERE visible<>0 AND voting<>0") as $compo) { - echo - " <table class=\"vote\">\n". - " <tr><th colspan=\"".($compo["showAuthors"] ? "3" : "2")."\">".chentities($compo["name"])."</th></tr>\n". - " <tr>\n". - " <th class=\"vshown\">#</th>\n". - " <th class=\"vtitle\">Title</th>\n". - ($compo["showAuthors"] ? " <th class=\"vauthor\">Author</th>\n" : ""). - " "; + $cid = $compo["id"]; - for ($i = stGetSetting("voteMin"); $i <= stGetSetting("voteMax"); $i++) + $nentries = stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$cid)); + if ($nentries > 0) { echo - "<th class=\"vvalue\">".$i."</th>"; - } - echo "\n". - " </tr>\n"; - - $row = 0; - foreach ($compo["entries"] as $eid => $entry) - { - echo - " <tr class=\"".($row % 2 == 1 ? "rodd" : "reven")."\">\n". - " <td class=\"vshown\">".($entry["show_id"] > 0 ? $entry["show_id"] : "-")."</td>\n". - " <td class=\"vtitle\">".$entry["name"]."</td>\n". - ($compo["showAuthors"] ? " <td class=\"vauthor\">".$entry["author"]."</td>\n" : ""). + " <table class=\"vote\">\n". + " <tr><th colspan=\"".($compo["showAuthors"] ? "3" : "2")."\">".chentities($compo["name"])."</th></tr>\n". + " <tr>\n". + " <th class=\"vshown\">#</th>\n". + " <th class=\"vtitle\">Title</th>\n". + ($compo["showAuthors"] ? " <th class=\"vauthor\">Author</th>\n" : ""). " "; - $val = isset($votes[$eid]) ? $votes[$eid] : 0; - for ($i = stGetSetting("voteMin"); $i <= stGetSetting("voteMax"); $i++) { echo - "<td class=\"vvalue\">". - stGetFormRadioButtonInput("entry".$eid, "", "", $i, ($i == $val), ""). - "</td>"; + "<th class=\"vvalue\">".$i."</th>"; } - - echo - "\n". + echo "\n". " </tr>\n"; - $row++; + $row = 0; + foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$cid) as $entry) + { + $eid = $entry["id"]; + echo + " <tr class=\"".($row % 2 == 1 ? "rodd" : "reven")."\">\n". + " <td class=\"vshown\">".($entry["show_id"] > 0 ? $entry["show_id"] : "-")."</td>\n". + " <td class=\"vtitle\">".$entry["name"]."</td>\n". + ($compo["showAuthors"] ? " <td class=\"vauthor\">".$entry["author"]."</td>\n" : ""). + " "; + + $val = isset($votes[$eid]) ? $votes[$eid] : 0; + + for ($i = stGetSetting("voteMin"); $i <= stGetSetting("voteMax"); $i++) + { + echo + "<td class=\"vvalue\">". + stGetFormRadioButtonInput( + "entry".$eid, "", "", $i, ($i == $val), + "onClick=\"updateVote(".$eid.",".$i.")\""). + "</td>"; + } + + echo + "\n". + " </tr>\n"; + + $row++; + } + echo + " </table>\n"; } - echo - " </table>\n"; } echo