# HG changeset patch # User Matti Hamalainen # Date 1416598967 -7200 # Node ID b42b23073209da0a0be00650ac95d050853f0f84 # Parent 771057e1cef1ef438429ab600f7441cb0136a7a8 Improve printing of results with more options (in the admin interface). diff -r 771057e1cef1 -r b42b23073209 admajax.php --- 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 - "
\n". + "
\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". "Open info window\n". - "Printable results list\n". "
\n". "
\n". stGetFormButtonInput("syscheck", "", "", "Perform system check", "performSystemCheck()")."\n". @@ -1387,6 +1386,11 @@ case "compos": echo + "
\n". + " Printable results\n". + " Printable full results (shows also disqualified entries)\n". + " Printable FULL results (shows also hidden compos)\n". + "
\n". "
\n". " ".stGetFormTextInput(64, SET_LEN_COMPO_NAME, "", "ncname", "", "")."
\n". " ".stGetFormTextArea(5, 60, "", "ncdescription", "", "")."
\n". diff -r 771057e1cef1 -r b42b23073209 msite.inc.php --- 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) diff -r 771057e1cef1 -r b42b23073209 pages/results.inc.php --- 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 "

Sorry, no results available! Nothing to see here, move along.

"; diff -r 771057e1cef1 -r b42b23073209 print.php --- 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":