function deckRegisterForm($deck = NULL) { $player = isset($_POST['player']) ? $_POST['player'] : $_GET['player']; $event = isset($_POST['event']) ? $_POST['event'] : $_GET['event']; $vals = array('contents' => '', 'sideboard' => ''); echo "<form action=\"deck.php?mode=addregdeck\" method=\"post\">\n"; echo "<table align=\"center\" style=\"border-width: 0px;\">\n"; echo "<tr><td valign=\"top\"><b>Directions:</td>\n"; echo "<td>To enter your deck, please give it "; echo "a name and select an archetype from the drop-down menu below. If "; echo "you do not specify and archetype, your deck will be labeled as "; echo "\"Unclassified\". To enter cards, save your deck as a .txt file using the "; echo "official MTGO client, and then copy and paste the maindeck and "; echo "sideboard into the appropriate text boxes. "; echo "Do not use a format such as \"1x Card\". "; echo "The parser will not accept this structure. The correct pattern is "; echo "\"1 Card\".</td></tr>\n"; echo "<tr><td><b>Recent Decks</b></td>\n<td>\n"; echo "<select id=\"autoenter-deck\">\n"; echo "<option value=\"0\">Select a recent deck to start from there</option>\n"; $deckplayer = new Player($player); $recentdecks = $deckplayer->getRecentDecks(); foreach ($recentdecks as $adeck) { echo "<option value=\"{$adeck->id}\">{$adeck->name}</option>\n"; } echo "</select></td></tr>"; echo "<tr><td><b>Name</td>\n<td>"; echo "<input id=\"deck-name\" type=\"text\" name=\"name\" value=\"" . htmlentities($vals['name']) . "\" "; echo "size=\"40\"></td></tr>\n"; echo "<tr><td><b>Archetype</td>\n<td>"; archetypeDropMenu($vals['archetype']); echo "</td></tr>\n"; echo "<tr><td valign=\"top\"><b>Main Deck</td>\n<td>"; echo "<textarea id=\"deck-contents\" rows=\"20\" cols=\"60\" name=\"contents\">"; echo "{$vals['contents']}</textarea></td></tr>\n"; echo "<tr><td valign=\"top\"><b>Sideboard</td>\n<td>"; echo "<textarea id=\"deck-sideboard\" rows=\"10\" cols=\"60\" name=\"sideboard\">"; echo "{$vals['sideboard']}</textarea></td></tr>\n"; echo "<tr><td valign=\"top\"><b>Comments</td>\n<td>"; echo "<textarea rows=\"10\" cols=\"60\" name=\"notes\">"; echo "{$vals['desc']}</textarea></td></tr>\n"; echo "<tr><td> </td></tr>\n"; echo "<tr><td colspan=\"2\" align=\"center\">\n"; echo "<input type=\"submit\" name=\"mode\" value=\"Create Deck\">\n"; echo "<input type=\"hidden\" name=\"player\" value=\"" . htmlentities($player) . "\">"; echo "<input type=\"hidden\" name=\"event\" value=\"" . htmlentities($event) . "\">"; echo "</td></tr></table></form>\n"; }
function deckForm($deck = NULL) { $mode = is_null($deck) ? "Create Deck" : "Update Deck"; if (!is_null($deck)) { $player = $deck->playername; $event = $deck->eventname; } else { $player = isset($_POST['player']) ? $_POST['player'] : $_GET['player']; $event = isset($_POST['player']) ? $_POST['event'] : $_GET['event']; } $auth = false; if (is_null($deck)) { // Creating a deck. $entry = new Entry($event, $player); $auth = $entry->canCreateDeck($_SESSION['username']); } else { // Updating a deck. $auth = $deck->canEdit($_SESSION['username']); } if (!$auth) { authFailed(); return; } $vals = array(); if (!is_null($deck)) { foreach ($deck->maindeck_cards as $card => $amt) { $line = $amt . " " . $card . "\n"; $vals['contents'] = $vals['contents'] . $line; } foreach ($deck->sideboard_cards as $card => $amt) { $line = $amt . " " . $card . "\n"; $vals['sideboard'] = $vals['sideboard'] . $line; } $vals['desc'] = $deck->notes; $vals['archetype'] = $deck->archetype; $vals['name'] = $deck->name; } echo "<form action=\"deck.php\" method=\"post\">\n"; echo "<table align=\"center\" style=\"border-width: 0px;\">\n"; echo "<tr><td valign=\"top\"><b>Directions:</td>\n"; echo "<td style=\"color: #000000\">To enter your deck, please give it "; echo "a name and select an archetype from the drop-down menu below. If "; echo "you do not specify and archetype, your deck will be labeled as "; echo "\"rogue.\" To enter cards, save your deck a a .txt file using the "; echo "official MTGO client, and then copy and paste the maindeck and "; echo "sideboard into the appropriate text boxes. "; echo "<font color=\"#FF0000\">Do not use a format such as \"1x Card\". "; echo "The parser will not accept this structure. The correct pattern is "; echo "\"1 Card\".</font></td></tr>\n"; echo "<tr><td> </td></tr>\n"; echo "<tr><td><b>Name</td>\n<td>"; echo "<input type=\"text\" name=\"name\" value=\"{$vals['name']}\" "; echo "size=\"40\"></td></tr>\n"; if (!is_null($deck)) { echo "<input type=\"hidden\" name=\"id\" value=\"{$deck->id}\">\n"; } echo "<tr><td><b>Archetype</td>\n<td>"; archetypeDropMenu($vals['archetype']); echo "</td></tr>\n"; echo "<tr><td valign=\"top\"><b>Main Deck</td>\n<td>"; echo "<textarea rows=\"20\" cols=\"60\" name=\"contents\">"; echo "{$vals['contents']}</textarea></td></tr>\n"; echo "<tr><td valign=\"top\"><b>Sideboard</td>\n<td>"; echo "<textarea rows=\"10\" cols=\"60\" name=\"sideboard\">"; echo "{$vals['sideboard']}</textarea></td></tr>\n"; //echo "<tr><td valign=\"top\"><b>Comments</td>\n<td>"; //echo "<textarea rows=\"10\" cols=\"60\" name=\"notes\">"; //echo "{$vals['desc']}</textarea></td></tr>\n"; echo "<tr><td> </td></tr>\n"; echo "<tr><td colspan=\"2\" align=\"center\">\n"; echo "<input type=\"submit\" name=\"mode\" value=\"{$mode}\">\n"; echo "<input type=\"hidden\" name=\"player\" value=\"{$player}\">"; echo "<input type=\"hidden\" name=\"event\" value=\"{$event}\">"; echo "</td></tr></table></form>\n"; }