Mercurial > hg > fapweb
changeset 4:934ab7d8c244
Various improvements.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 04 Dec 2012 21:28:11 +0200 |
parents | 916623924bd5 |
children | 76c3b89d7b11 |
files | fap.css index.php results.inc.php vote.inc.php |
diffstat | 4 files changed, 89 insertions(+), 62 deletions(-) [+] |
line wrap: on
line diff
--- a/fap.css Tue Dec 04 20:27:08 2012 +0200 +++ b/fap.css Tue Dec 04 21:28:11 2012 +0200 @@ -238,3 +238,11 @@ position: relative; right: -2em; } + +table.misc th.vvalue { + width: 1%; +} + +table.misc td.vvalue { + text-align: center; +}
--- a/index.php Tue Dec 04 20:27:08 2012 +0200 +++ b/index.php Tue Dec 04 21:28:11 2012 +0200 @@ -44,6 +44,8 @@ if (stGetSetting("showResults", FALSE)) echo " <a href=\"results\">Results</a>\n"; + +echo " <a href=\"admin\">Admin</a>\n"; ?> </div> </div>
--- a/results.inc.php Tue Dec 04 20:27:08 2012 +0200 +++ b/results.inc.php Tue Dec 04 21:28:11 2012 +0200 @@ -1,66 +1,75 @@ <? -echo "<h1>Results</h1>\n"; - $text = TRUE; $showResults = stGetSetting("showResults", FALSE); +$showAuthors = stGetSetting("showResAuthors", FALSE); -if (($res = stExecSQL("SELECT * FROM compos WHERE enabled<>0 ORDER BY name DESC")) !== FALSE) +echo "<h1>Results</h1>\n"; +if (!$showResults) { - if ($text) echo "<pre>\n"; - foreach ($res as $compo) + echo "<p>Sorry, no results available! Nothing to see here, move along.</p>"; +} +else +{ + if (($res = stExecSQL("SELECT * FROM compos WHERE enabled<>0 ORDER BY name DESC")) !== FALSE) { - $sql = - "SELECT entries.*,SUM(votes.value) AS votesum ". - "FROM entries LEFT JOIN votes ON entries.id=votes.entry_id ". - "WHERE entries.compo_id=".$compo["id"]." ". - "GROUP BY votes.entry_id ". - "ORDER BY ".($showResults ? "votesum DESC" : "entries.id ASC"); + if ($text) echo "<pre>\n"; + foreach ($res as $compo) + { + $sql = + "SELECT entries.*,SUM(votes.value) AS votesum ". + "FROM entries LEFT JOIN votes ON entries.id=votes.entry_id ". + "WHERE entries.compo_id=".$compo["id"]." ". + "GROUP BY votes.entry_id ". + "ORDER BY votesum DESC"; + + if (($fres = stExecSQL($sql)) !== FALSE) + { + if ($text) + { + echo "<b> ".$compo["name"]." </b>\n"; + echo str_repeat("=", strlen($compo["name"]) + 2)."-- - .\n\n"; - if (($fres = stExecSQL($sql)) !== FALSE) - { - if ($text) - { - echo "\n<b>".$compo["name"]."</b>\n"; - $index = 1; - foreach ($fres as $entry) + $index = 1; + foreach ($fres as $entry) + { + printf("%3s. %-35s by %-25s (%d pts)\n", + $index, + chentities($entry["name"]), + ($showAuthors ? chentities($entry["author"]) : "-"), + $entry["votesum"]); + $index++; + } + echo "\n\n"; + } + else { - printf("%3s. %-35s by %-25s (%d pts)\n", - ($showResults ? $index : ""), - chentities($entry["name"]), - (stGetSetting("showAuthors", FALSE) ? chentities($entry["author"]) : "-"), - ($showResults ? $entry["votesum"] : "?") - ); - $index++; + echo "<h2>".$compo["name"]."</h2>\n". + "<table class=\"attendees\" style=\"width: 80%;\">\n". + " <tr>\n". + " <th style=\"width: 1%;\">#</th>\n". + " <th style=\"width: 3%;\">Points</th>\n". + " <th>Name</th>\n". + " <th>Author</th>\n". + " </tr>\n"; + + $index = 1; + foreach ($fres as $entry) + { + echo + "<tr>". + "<td>#".$index."</td>". + "<td>".$entry["votesum"]."</td>". + "<td>".chentities($entry["name"])."</td>". + "<td>".($showAuthors ? chentities($entry["author"]) : "-")."</td>". + "</tr>\n"; + $index++; + } + + echo "</table>\n"; } } - else - { - echo "<h2>".$compo["name"]."</h2>\n". - "<table class=\"attendees\" style=\"width: 80%;\">\n". - " <tr>\n". - " <th style=\"width: 1%;\">#</th>\n". - " <th style=\"width: 3%;\">Points</th>\n". - " <th>Name</th>\n". - " <th>Author</th>\n". - " </tr>\n"; - - $index = 1; - foreach ($fres as $entry) - { - echo - "<tr>". - "<td>".($showResults ? "#".$index : "")."</td>". - "<td>".($showResults ? $entry["votesum"] : "?")."</td>". - "<td>".chentities($entry["name"])."</td>". - "<td>".(stGetSetting("showAuthors", FALSE) ? chentities($entry["author"]) : "-")."</td>". - "</tr>\n"; - $index++; - } - - echo "</table>\n"; - } } + if ($text) echo "</pre>\n"; } - if ($text) echo "</pre>\n"; } ?> \ No newline at end of file
--- a/vote.inc.php Tue Dec 04 20:27:08 2012 +0200 +++ b/vote.inc.php Tue Dec 04 21:28:11 2012 +0200 @@ -1,5 +1,6 @@ <? $mode = stGetRequestItem("mode", "start"); +$showAuthors = stGetSetting("showVoteAuthors", FALSE); stGetCompoList(FALSE); @@ -47,6 +48,7 @@ <input type="hidden" name="mode" value="check"> <table class="misc"> <? + stPrintFormTextInput("Vote key:", "(that series of characters)", 30, 30, "key", "autocomplete=\"off\""); echo "</table>\n"; @@ -57,31 +59,37 @@ " <table class=\"misc\">\n". " <tr><th colspan=\"3\">".chentities($compo["name"])."</th></tr>\n". " <tr>\n". - " <th>Title</th>\n". - " <th>Author</th>\n". - " <th>Actions</th>\n". + " <th class=\"vtitle\">Title</th>\n". + ($showAuthors ? " <th class=\"vauthor\">Author</th>\n" : ""). + " "; + + for ($i = stGetSetting("voteMin", -2); $i <= stGetSetting("voteMax", 2); $i++) + { + echo + "<th class=\"vvalue\">".$i."</th>"; + } + echo "\n". " </tr>\n"; foreach ($compo["entries"] as $eid => $entry) { echo " <tr>\n". - " <td>".$entry["name"]."</td>\n". - " <td>".$entry["author"]."</td>\n". - " <td>\n"; + " <td class=\"vtitle\">".$entry["name"]."</td>\n". + ($showAuthors ? " <td class=\"vauthor\">".$entry["author"]."</td>\n" : ""). + " "; for ($i = stGetSetting("voteMin", -2); $i <= stGetSetting("voteMax", 2); $i++) { $name = "entry".$eid; $checked = stChkRequestItem($name) ? stGetRequestItem($name) : 0; echo - " <input type=\"radio\" name=\"".$name."\" ". - ($i == $checked ? "checked=\"checked\" " : ""). - "value=\"".$i."\"><label for=\"".$name."\">".$i."</label>\n"; + "<td class=\"vvalue\"><input type=\"radio\" name=\"".$name."\" ". + ($i == $checked ? "checked=\"checked\" " : "")."value=\"".$i."\" /></td>"; } echo - " </td>\n". + "\n". " </tr>\n"; } echo