# HG changeset patch # User Matti Hamalainen # Date 1354828126 -7200 # Node ID e6ffab8414ccb12ce68014857b2d6854d7de1e26 # Parent f2877f1b0b7575f5c2f9ffcf4188e442b61cd613 Improve display of results. diff -r f2877f1b0b75 -r e6ffab8414cc results.inc.php --- a/results.inc.php Thu Dec 06 21:28:17 2012 +0200 +++ b/results.inc.php Thu Dec 06 23:08:46 2012 +0200 @@ -3,6 +3,16 @@ $showResults = stGetSetting("showResults"); $showAuthors = stGetSetting("showResAuthors"); +function stChop($str, $len) +{ + if (strlen($str) > $len) + $s = substr($str, 0, $len - 3)."..."; + else + $s = $str; + return sprintf("%-".$len."s", $s); +} + + echo "

Results

\n"; if (!$showResults) { @@ -29,15 +39,24 @@ echo " ".$compo["name"]." \n"; echo str_repeat("=", strlen($compo["name"]) + 2)."-- - .\n\n"; - $index = 1; + $index = 0; + $prev = FALSE; foreach ($fres as $entry) { - printf("%3s. %s by %s (%d pts)\n", - $index, - chentities(sprintf("%-35s", $entry["name"])), - chentities(sprintf("%-25s", $showAuthors ? $entry["author"] : "-")), + if ($entry["votesum"] != $prev) + { + $index++; + printf("%3d.", $index); + } + else + echo " "; + $prev = $entry["votesum"]; + + printf(" %s by %s (%d pts)\n", + chentities(stChop($entry["name"], 30)), + chentities(stChop($showAuthors ? $entry["author"] : "-", 30)), $entry["votesum"]); - $index++; + } echo "\n\n"; } @@ -52,9 +71,12 @@ " Author\n". " \n"; - $index = 1; + $index = 0; foreach ($fres as $entry) { + if ($entry["votesum"] != $prev) + $index++; + $prev = $entry["votesum"]; echo "". "#".$index."". @@ -62,7 +84,6 @@ "".chentities($entry["name"])."". "".($showAuthors ? chentities($entry["author"]) : "-")."". "\n"; - $index++; } echo "\n";