# HG changeset patch # User Matti Hamalainen # Date 1415632932 -7200 # Node ID dff9b125f7742562d38800c749921c182eff3398 # Parent b4e0501f55882f0698be5f25ef07e5c6cfef6965 Work on results printing and remove "show authors" option as it is rather useless. diff -r b4e0501f5588 -r dff9b125f774 dbdefs.inc.php --- a/dbdefs.inc.php Mon Nov 10 16:56:55 2014 +0200 +++ b/dbdefs.inc.php Mon Nov 10 17:22:12 2014 +0200 @@ -32,7 +32,6 @@ "allowVoting" => array(VT_BOOL, false, "Enable voting (individual compos must be enabled as well)"), "showResults" => array(VT_BOOL, false, "Enable results page"), - "showResAuthors" => array(VT_BOOL, true, "Show entry authors on results page"), "showInfoTextOnAbout" => array(VT_BOOL, false, "Show site info HTML on About page"), @@ -239,6 +238,8 @@ array("visible" , "INT", "DEFAULT 0"), array("voting" , "INT", "DEFAULT 0"), array("show_authors" , "INT", "DEFAULT 0"), + // Show author(s) on compo main screen/voting page for COMPO_NORMAL compos + // For COMPO_POINTS and COMPO_ASSIGN, show on results page or not array("ctype" , "INT", "DEFAULT 0"), array("cpath" , "VARCHAR(".SET_LEN_COMPO_PATH.")"), ), diff -r b4e0501f5588 -r dff9b125f774 msite.inc.php --- a/msite.inc.php Mon Nov 10 16:56:55 2014 +0200 +++ b/msite.inc.php Mon Nov 10 17:22:12 2014 +0200 @@ -487,13 +487,20 @@ break; case COMPO_POINTS: - case COMPO_ASSIGN: // - // These essentially do the same ... + // Points .. // $sql = "SELECT entries.* FROM entries"; $extra = "ORDER BY entries.evalue DESC"; break; + + case COMPO_ASSIGN: + // + // Ascending + // + $sql = "SELECT entries.* FROM entries"; + $extra = "ORDER BY entries.evalue ASC"; + break; } return $sql." ". @@ -503,7 +510,24 @@ } -function stGetCompoResultsASCIIStr($showAuthors, $html) +function stGetCompoResultLine($html, $entry, $points, $showAuthor) +{ + $name = stStrChopPad($entry["name"], 30); + $author = stStrChopPad($entry["author"], 30); + + $out = sprintf(" %s", $html ? chentities($name) : $name); + + if ($showAuthor) + $out .= sprintf(" by %s", $html ? chentities($author) : $author); + + if ($points != FALSE) + $out .= sprintf(" (%d pts)", $points); + + return $out."\n"; +} + + +function stGetCompoResultsASCIIStr($html) { $sql = "SELECT * FROM compos WHERE visible<>0 ORDER BY name DESC"; if (($res = stExecSQL($sql)) === false) @@ -546,23 +570,40 @@ foreach (stExecSQL($sql) as $entry) { - if ($entry["votesum"] !== $prev) + + switch ($compo["ctype"]) { - $index++; - $out .= sprintf("%3d%s.", $index, stGetNumberSuffix($index)); - } - else - $out .= " -''-"; + case COMPO_NORMAL: + if ($entry["votesum"] !== $prev) + { + $index++; + $out .= sprintf("%3d%s.", $index, stGetNumberSuffix($index)); + } + else + $out .= " -''-"; + + $out .= stGetCompoResultLine($html, $entry, $entry["votesum"], TRUE); - $name = stStrChopPad($entry["name"], 30); - $author = stStrChopPad($showAuthors ? $entry["author"] : "-", 30); - - $out .= sprintf(" %s by %s (%d pts)\n", - $html ? chentities($name) : $name, - $html ? chentities($author) : $author, - $entry["votesum"]); + $prev = $entry["votesum"]; + break; + + case COMPO_POINTS: + case COMPO_ASSIGN: + if ($entry["evalue"] !== $prev) + { + $index++; + $out .= sprintf("%3d%s.", $index, stGetNumberSuffix($index)); + } + else + $out .= " -''-"; - $prev = $entry["votesum"]; + $out .= stGetCompoResultLine($html, $entry, + ($compo["ctype"] == COMPO_POINTS) ? $entry["votesum"] : FALSE, + $compo["show_authors"]); + + $prev = $entry["evalue"]; + break; + } } $out .= "\n\n".($html ? "\n" : ""); } diff -r b4e0501f5588 -r dff9b125f774 pages/results.inc.php --- a/pages/results.inc.php Mon Nov 10 16:56:55 2014 +0200 +++ b/pages/results.inc.php Mon Nov 10 17:22:12 2014 +0200 @@ -5,8 +5,6 @@ // (C) Copyright 2012-2014 Tecnic Software productions (TNSP) // $showResults = stGetSetting("showResults"); -$showAuthors = stGetSetting("showResAuthors"); - echo "

Results

\n"; @@ -15,15 +13,13 @@ { if (!$showResults) echo "

Results hidden from normal users.

"; - if (!$showAuthors) - echo "

Entry authors hidden from normal users.

"; - $showResults = $showAuthors = TRUE; + $showResults = TRUE; } if ($showResults) - echo stGetCompoResultsASCIIStr($showAuthors, TRUE); + echo stGetCompoResultsASCIIStr(TRUE); else { echo "

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

";