Mercurial > hg > fapweb
changeset 792:b42b23073209
Improve printing of results with more options (in the admin interface).
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 21 Nov 2014 21:42:47 +0200 |
parents | 771057e1cef1 |
children | ff6e6c6200a4 |
files | admajax.php msite.inc.php pages/results.inc.php print.php |
diffstat | 4 files changed, 30 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/admajax.php Fri Nov 21 16:19:15 2014 +0200 +++ b/admajax.php Fri Nov 21 21:42:47 2014 +0200 @@ -1100,13 +1100,12 @@ // $showMode = stGetDisplayVar("showMode"); echo - "<div id=\"ctrlModeControls\">\n". + "<div id=\"ctrlModeControls\" class=\"ctrlModeControls\">\n". "Active mode:\n". stGetShowModeButton(SMODE_DISABLED, "Off/disabled", $showMode)."\n". stGetShowModeButton(SMODE_ROTATE, "Slide rotation", $showMode)."\n". stGetShowModeButton(SMODE_COMPO, "Compo mode", $showMode)."\n". "<a href=\"show.php\" target=\"_blank\">Open info window</a>\n". - "<a href=\"print.php?type=results\" target=\"_blank\">Printable results list</a>\n". "</div>\n". "<div id=\"ctrlSystemControls\">\n". stGetFormButtonInput("syscheck", "", "", "Perform system check", "performSystemCheck()")."\n". @@ -1387,6 +1386,11 @@ case "compos": echo + "<div class=\"ctrlModeControls\">\n". + " <a href=\"print.php?type=results&flags=".(RFLAG_DEFAULTS)."\" target=\"_blank\">Printable results</a>\n". + " <a href=\"print.php?type=results&flags=".(RFLAG_DISQUALIFIED)."\" target=\"_blank\">Printable full results</a> (shows also disqualified entries)\n". + " <a href=\"print.php?type=results&flags=".(RFLAG_DISQUALIFIED | RFLAG_HIDDEN_COMPOS)."\" target=\"_blank\">Printable FULL results</a> (shows also hidden compos)\n". + "</div>\n". "<form method=\"post\" action=\"\" onsubmit=\"return addCompo()\">\n". " ".stGetFormTextInput(64, SET_LEN_COMPO_NAME, "", "ncname", "", "")."<br />\n". " ".stGetFormTextArea(5, 60, "", "ncdescription", "", "")."<br />\n".
--- a/msite.inc.php Fri Nov 21 16:19:15 2014 +0200 +++ b/msite.inc.php Fri Nov 21 21:42:47 2014 +0200 @@ -69,6 +69,13 @@ // +// Results output flags +// +define("RFLAG_NORMAL", 0); +define("RFLAG_DISQUALIFIED", 1); +define("RFLAG_HIDDEN_COMPOS", 2); + +// // Competition types // define("COMPO_NORMAL", 0); // Normal voting compo, points determine placement @@ -457,7 +464,7 @@ } -function stGetCompoResultsSQL($mode, $compo) +function stGetCompoResultsSQL($mode, $compo, $flags) { // // Act based on competition type @@ -524,16 +531,16 @@ return $sql." ". "WHERE entries.compo_id=".$compo["id"]." ". - "AND (entries.flags & ".EFLAG_DISQUALIFIED.")=0 ". + (($flags & RFLAG_DISQUALIFIED) ? "" : "AND (entries.flags & ".EFLAG_DISQUALIFIED.")=0 "). $extra; } -function stGetCompoResults() +function stGetCompoResults($flags) { $voteKeyMode = stGetSetting("voteKeyMode"); $out = array(); - $sql = "SELECT * FROM compos WHERE visible<>0 ORDER BY name DESC"; + $sql = "SELECT * FROM compos ".(($flags & RFLAG_HIDDEN_COMPOS) ? "" : "WHERE visible<>0 ")."ORDER BY name DESC"; if (($res = stExecSQL($sql)) === false) return $out; @@ -543,13 +550,13 @@ // Check if there are any entries for it $sql = "SELECT COUNT(*) FROM entries ". - "WHERE compo_id=".$compo["id"]." ". - "AND (entries.flags & ".EFLAG_DISQUALIFIED.")=0"; + "WHERE compo_id=".$compo["id"]. + (($flags & RFLAG_DISQUALIFIED) ? "" : " AND (entries.flags & ".EFLAG_DISQUALIFIED.")=0"); if (($nentries = stFetchSQLColumn($sql)) !== FALSE && $nentries > 0) { // Get voting results by mode - $sql = stGetCompoResultsSQL($voteKeyMode, $compo); + $sql = stGetCompoResultsSQL($voteKeyMode, $compo, $flags); $out[$compo["id"]] = $compo; $out[$compo["id"]]["results"] = array(); @@ -580,20 +587,26 @@ $out = sprintf(" %s", $html ? chentities($name) : $name); + // Author? if ($showAuthor) $out .= sprintf(" by %s", $html ? chentities($author) : $author); + // Points? if ($points !== FALSE) $out .= sprintf(" (%d pts)", $points); + // Add disqualified flag etc. + if ($entry["flags"] & EFLAG_DISQUALIFIED) + $out .= " [DISQ]"; + return $out."\n"; } -function stGetCompoResultsASCIIStr($html) +function stGetCompoResultsASCIIStr($html, $flags) { $out = ""; - foreach (stGetCompoResults() as $compo) + foreach (stGetCompoResults($flags) as $compo) { // Output compo title / header if ($html)
--- a/pages/results.inc.php Fri Nov 21 16:19:15 2014 +0200 +++ b/pages/results.inc.php Fri Nov 21 21:42:47 2014 +0200 @@ -19,7 +19,7 @@ if ($showResults) - echo stGetCompoResultsASCIIStr(TRUE); + echo stGetCompoResultsASCIIStr(TRUE, RFLAG_NORMAL); else { echo "<p>Sorry, no results available! Nothing to see here, move along.</p>";
--- a/print.php Fri Nov 21 16:19:15 2014 +0200 +++ b/print.php Fri Nov 21 21:42:47 2014 +0200 @@ -49,7 +49,7 @@ { case "results": header("Content-Type: text/plain"); - echo stGetCompoResultsASCIIStr(FALSE); + echo stGetCompoResultsASCIIStr(FALSE, intval(stGetRequestItem("flags", RFLAG_NORMAL))); break; case "emails":