From 709bb9e4920a07531a5cf47ff96af9b8fdc5b2bb Mon Sep 17 00:00:00 2001 From: CMDR furrycat Date: Mon, 15 Feb 2016 06:32:56 -0500 Subject: [PATCH] Allow hiding specific prizes, so we can produce a raw table. --- lib/race.php | 29 ++++++++++++++++++++--------- style.css | 6 +++++- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/lib/race.php b/lib/race.php index 4c35b4a..83fd87d 100644 --- a/lib/race.php +++ b/lib/race.php @@ -428,11 +428,12 @@ else return $n . array('th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th')[$n % 10]; } - function find_prizewinners($race, $entries) { + function find_prizewinners($race, $entries, $prize_filter = null) { $competitors = array(); $prizes = array(); $last_sort_method = null; foreach ($race->getPrizeKeys() as $p) { + if (! is_null($prize_filter) && ! ($race->PrizeValue($p) & $prize_filter)) continue; $sort_method = $race->PrizeSortMethod($p); if ($sort_method != $last_sort_method) uasort($entries, "Entry::$sort_method"); $last_sort_method = $sort_method; @@ -517,7 +518,7 @@ $eq->filterById($filtered_entry_ids); $entry_objects = $eq->find(); foreach ($entry_objects as $entry) $entries[] = $entry; - $prizewinners = find_prizewinners($race, $entries); + $prizewinners = find_prizewinners($race, $entries, $prize_filter); uasort($entries, "Entry::StandardSort"); $ranked_entries = array(); $competitor_entries = array(); @@ -702,9 +703,10 @@ echo "\n"; } - function build_args($params, $key, $value, $description) { + function build_args($params, $key, $value, $description, $class = null) { $uri = preg_replace('/&args=[^&]+/', '', $_SERVER['REQUEST_URI']); - $uri = " filterById($action); @@ -769,7 +772,7 @@ $entries[] = $entry; $entries_by_id[$entry->getId()] = $entry; } - $prizewinners = find_prizewinners($race, $entries); + $prizewinners = find_prizewinners($race, $entries, $prize_filter); uasort($entries, "Entry::$sort_method"); } else { @@ -777,13 +780,21 @@ continue; } + echo "
\n"; echo "

$name

\n"; + + /* Prize filtering. */ if ($race->getPrizes()) { - $prizes = array(); - foreach ($race->getPrizeKeys() as $p) $prizes[] = $race->PrizeDescription($p); - echo "

Prizes for " . implode(", ", $prizes) . ".

\n"; + $uri_list = array(); + foreach ($race->getPrizeKeys() as $p) { + $Prize = ucfirst($race->PrizeDescription($p)); + $v = $race->PrizeValue($p); + if (is_null($prize_filter) || ($prize_filter & $v)) $uri = build_args($params, "prizes", (is_null($prize_filter)) ? $race->getPrizes() & ~$v : $prize_filter & ~$v, $Prize, "disabled"); + else $uri = build_args($params, "prizes", $prize_filter | $v, $Prize); + $uri_list[] = $uri; + } + echo "

Show prizes: " . implode(" // ", $uri_list) . ".

\n"; } - echo "
\n"; /* Sort options. */ $uri_list = array(); diff --git a/style.css b/style.css index 05b57a0..08c1e41 100644 --- a/style.css +++ b/style.css @@ -1,7 +1,11 @@ body { font-family: 'Sintony'; font-weight: 400; } #header { clear: both; overflow: auto; vertical-align: center; } #header { font-weight: 500; } -#header a { text-decoration: none; } +#header a { text-decoration: none; color: #005195; } +.header a { text-decoration: none; } +a { color: #005195; } +a:visited { color: inherit; } +a.disabled { text-decoration: line-through; color: #ff6418; } #header, .header, h1,h2,h3,h4 { font-family: 'Orbitron'; } #header strong { font-weight: 700; } #laps { overflow-x: auto; } -- 2.7.4