$competitors = array();
+ uasort($entries, "Entry::StandardSort");
+
/* Leader and runner-up. */
foreach ($entries as $entry) {
if ($entry->isExcluded()) continue;
/* Standard races only have standard classification. */
if (! $allotted_time) return $ret;
- $copy = array();
- foreach ($entries as $entry) $copy[] = $entry;
-
/* Other prizes. */
foreach (array_keys($sorted) as $key) {
- uasort($copy, "Entry::$key");
- foreach ($copy as $entry) {
+ uasort($entries, "Entry::$key");
+ foreach ($entries as $entry) {
if ($entry->isExcluded()) continue;
$entry_id = $entry->getId();
if (in_array($entry_id, array_values($ret))) continue;
$eq->joinWith('Ship.Competitor');
$eq->joinWith('Ship.Hull');
$eq->filterByRaceId($id);
- /*
- Ordering by total distance then penalty time will classify racers
- appropriately in endurance races, while having no effect on dashes.
- Ordering by total time will classify racers in dashes while not
- affecting endurance races.
- Ordering by bonus time will allow a racer who didn't use the joker
- to win a tiebreak with one who did.
- Ordering by cut short endorsement will penalise those who didn't
- compete for the full race time but only when tied for penalty.
- */
- $eq->addAsColumn('CutShort', 'Endorsements & ' . Entry::EndorsementValue('c'));
- $entries = $eq->orderByTotalDistance('desc')->orderByPenaltyTime()->orderBy('CutShort')->orderByTotalTime()->orderByBonusTime()->find();
+ $entry_objects = $eq->find();
if (! $action) {
echo "<p>" . $race->getLink() . "</p>\n";
continue;
}
- if (count($entries)) {
+ if (count($entry_objects)) {
+ $entries = array();
+ foreach ($entry_objects as $entry) $entries[] = $entry;
$prizewinners = find_prizewinners($entries, $allotted_time);
$plots = array(
"cmdr" => array(
echo "var speeds = " . json_encode(array_values($speeds)) . ";\n";
echo "var laps = " . json_encode(array_values($laps)) . ";\n";
echo "//--></script>\n";
+
+ $methods = array(
+ 'distance' => 'StandardSort',
+ 'best_speed' => 'ByBestSpeed',
+ 'average_speed' => 'ByAverageSpeed',
+ 'fastest_lap' => 'ByFastestLap',
+ 'average_lap' => 'ByAverageLap'
+ );
+ if (! in_array($args, array_keys($methods))) $args = 'distance';
+ $sort_method = $methods[$args];
+ uasort($entries, "Entry::$sort_method");
}
else {
echo "<p>No entries.</p>\n";
echo "<div id=\"plot_speeds\"></div>\n";
echo "<div id=\"plot_laps\"></div>\n";
echo "<div class=\"classification\">\n";
+
+ echo "<p>Sort by:";
+ foreach (array_keys($methods) as $method) {
+ $Method = ucfirst($method);
+ if ($method == $arg) echo " $Method";
+ else {
+ $uri = preg_replace('/&args=[^&]+/', '', $_SERVER['REQUEST_URI']);
+ echo " <a href=\"$uri&args=$method\">$Method</a>";
+ }
+ }
+ echo "</p>\n";
+
foreach (array('html', 'bbcode') as $type) {
echo "<div class=\"$type\">\n";
entry_header($type);