<?php require SCRIPTROOT . 'jamstates.php'; $stmt = $dbconnection->prepare('SELECT * FROM jams ORDER BY suggestionsbegin DESC;'); $stmt->execute(); $rows = $stmt->fetchAll(); $jams = array(); foreach ($rows as $row) { $jam = array(); $jam['id'] = $row['id']; $jam['title'] = $row['title']; $jam['status'] = $row['status']; $jam['suggestionsbegin'] = SuggestionsBegin($row); $jam['votingbegins'] = VotingBegins($row); $jam['themeannounce'] = ThemeAnnounce($row); $jam['jambegins'] = JamBegins($row); $jam['submissionsbegin'] = SubmissionsBegin($row); $jam['submissionsend'] = SubmissionsEnd($row); $jam['judgingends'] = JudgingEnds($row); array_push($jams, $jam); } SendResponse($jams);
<table class="table table-striped table-bordered clickabletable"> <thead> <tr> <th>Title</th> <th>Suggestions Open</th> <th>Jam Start</th> <th>Status</th> </tr> </thead> <tbody> <?php foreach ($jams as $jam) { echo ' <tr class="jamrow" jamviewurl="' . $routes->generate('jam_page', array('id' => $jam['id'])) . '"> <td>' . $jam['title'] . '</td> <td>' . date(DATETIME_FORMAT, SuggestionsBegin($jam)) . '</td> <td>' . date(DATETIME_FORMAT, JamBegins($jam)) . '</td> <td>' . JamStatusString($jam['status']) . '</td> </tr>'; } ?> </tbody> </table> <?php if (count($jams) == 0) { echo 'Nothing was found :('; } ?> </div> </div>
function JamRemainingTime($Jam) { if ($Jam['status'] == JamStatus::Disabled || $Jam['status'] == JamStatus::Complete) { return 0; } else { if ($Jam['status'] == JamStatus::Judging) { return JudgingEnds($Jam) - time(); } else { if ($Jam['status'] == JamStatus::ReceivingGameSubmissions) { return SubmissionsEnd($Jam) - time(); } else { if ($Jam['status'] == JamStatus::JamRunning) { return SubmissionsBegin($Jam) - time(); } else { if ($Jam['status'] == JamStatus::ThemeAnnounced) { return JamBegins($Jam) - time(); } else { if ($Jam['status'] == JamStatus::ThemeVoting) { return ThemeAnnounce($Jam) - time(); } else { if ($Jam['status'] == JamStatus::WaitingThemeApprovals) { return VotingBegins($Jam) - time(); } else { if ($Jam['status'] == JamStatus::ReceivingSuggestions) { return ApprovalsBegin($Jam) - time(); } else { if ($Jam['status'] == JamStatus::WaitingSuggestionsStart) { return SuggestionsBegin($Jam) - time(); } } } } } } } } } }