From 7a60127a4b17e74860a80a62cdfc53ca37cbff19 Mon Sep 17 00:00:00 2001 From: BlueRaja Date: Mon, 1 Oct 2012 14:50:10 -0500 Subject: Added a challenge-listing page, and skeleton code for the listing itself --- includes/datas.php | 10 ++++++++ index.php | 4 ++++ pages/challenge.php | 14 +++++++---- pages/challengelist.php | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 pages/challengelist.php diff --git a/includes/datas.php b/includes/datas.php index 952f903..e8d5871 100644 --- a/includes/datas.php +++ b/includes/datas.php @@ -940,6 +940,16 @@ function loadChallengesForMap($mapIdUnsanitized, $userIdUnsanitized) return NULL; } +/** + * Loads a listing of all maps and challenges for display, along with which ones the user has completed + * @param type $userIdUnsanitized The userID. Assumed to be unsanitized. + * @return Returns a MySQL resultset with the columns listed in the code, or NULL if nothing found + */ +function loadChallengeListing($userIdUnsanitized) +{ + //TODO: Implement +} + /** * Returns the map "code" for the given mapId */ diff --git a/index.php b/index.php index 2046aa7..c1491e5 100644 --- a/index.php +++ b/index.php @@ -130,6 +130,10 @@ switch ($request) { require 'pages/challenge.php'; break; + case "challengelist": + require 'pages/challengelist.php'; + break; + case "home": //No break here Default: diff --git a/pages/challenge.php b/pages/challenge.php index 9690edd..2ab279d 100644 --- a/pages/challenge.php +++ b/pages/challenge.php @@ -83,14 +83,14 @@ if (!$accepted) { if(!isset($_GET["mapID"])) { - //TODO: Redirect to challenge listing + redirectToChallengeListing(); return; } $mapCode = loadMapCode($_GET["mapID"]); if($mapCode === NULL) { - //TODO: Redirect to challenge listing also + redirectToChallengeListing(); return; } @@ -98,7 +98,7 @@ $mapContent = displayMap(GenerateMapByCode($mapCode), $_GET["mapID"]); $challengeResultset = loadChallengesForMap($_GET["mapID"], $userID); if($challengeResultset === NULL) { - //TODO: Redirect to challenge listing also + redirectToChallengeListing(); return; } @@ -131,7 +131,7 @@ htmlFooter(); function displayChallenges($challengeResultset) { echo '
'; - echo '
Challenges
'; //TODO: remove number + echo '
Challenges
'; echo '
    '; while($challenge = mysql_fetch_array($challengeResultset)) { @@ -234,4 +234,10 @@ function getChallengeDisplayString($challenge) $returnMe .= "."; return $returnMe; } + +function redirectToChallengeListing() +{ + header("Location: /challengelist"); + die(); +} ?> \ No newline at end of file diff --git a/pages/challengelist.php b/pages/challengelist.php new file mode 100644 index 0000000..e7ade3c --- /dev/null +++ b/pages/challengelist.php @@ -0,0 +1,63 @@ + + +
    + +Please login to do the challenges!
    "; + htmlFooter(); + return; +} + +//TODO: Uncomment +//if (!hasCompletedTutorial($userID)) { +// echo "
    Please complete the tutorial to unlock Challenge mode!
"; +// htmlFooter(); +// return; +//} + +?> + + +
+ +
+ Copyright © 2011-2012 pathery.com +
+ + + + \ No newline at end of file -- cgit v1.2.3