Moving views and using router
This commit is contained in:
126
index.php
126
index.php
@@ -1,94 +1,54 @@
|
|||||||
<!doctype html>
|
<?php
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
||||||
<meta name="description" content="">
|
|
||||||
<meta name="author" content="">
|
|
||||||
|
|
||||||
<title>Dinner in the Woods 2019 - Tickets on sale March 15th!</title>
|
use Bramus\Router\Router;
|
||||||
|
|
||||||
<!-- Bootstrap core CSS -->
|
require __DIR__ . '/vendor/autoload.php';
|
||||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
|
require __DIR__ . '/src/functions.php';
|
||||||
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
|
||||||
|
|
||||||
<!-- Custom styles for this template -->
|
// Load environment variables
|
||||||
<link href="https://fonts.googleapis.com/css?family=Bitter" rel="stylesheet">
|
$dotenv = \Dotenv\Dotenv::create(__DIR__ . '/src');
|
||||||
<link rel="stylesheet" href="/css/site.css">
|
$dotenv->load();
|
||||||
|
$dotenv->required([
|
||||||
|
'EVENT_TICKET_PRICE',
|
||||||
|
'ENHANCER_TICKET_PRICE',
|
||||||
|
'DB_HOST',
|
||||||
|
'DB_USER',
|
||||||
|
'DB_PASS',
|
||||||
|
'POSTMARK_API_KEY',
|
||||||
|
]);
|
||||||
|
|
||||||
<!-- Linked Data for the event -->
|
$router = new Router();
|
||||||
<script type="application/ld+json">
|
|
||||||
{
|
|
||||||
"@context": "http://schema.org",
|
|
||||||
"@type": "Event",
|
|
||||||
"location": {
|
|
||||||
"@type": "Place",
|
|
||||||
"address": {
|
|
||||||
"@type": "PostalAddress",
|
|
||||||
"addressLocality": "Mukwonago",
|
|
||||||
"addressRegion": "WI",
|
|
||||||
"postalCode": "53149",
|
|
||||||
"streetAddress": "W336 S8455 Hwy E"
|
|
||||||
},
|
|
||||||
"name": "Nature's Classroom Institute of Wisconsin"
|
|
||||||
},
|
|
||||||
"name": "Dinner in the Woods",
|
|
||||||
"startDate": "2019-06-01T17:30-06:00",
|
|
||||||
"endDate": "2019-06-02T00:00-06:00",
|
|
||||||
"description": "Annual Dinner in the Woods at Nature's classroom. Live Music. Local Food. Live & Silent Auctions"
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
// Custom 404 Handler
|
||||||
|
$router->set404(function () {
|
||||||
|
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
|
||||||
|
echo '404, route not found!';
|
||||||
|
});
|
||||||
|
|
||||||
<div class="website">
|
// Static route: / (homepage)
|
||||||
<div class="gridStyle container">
|
$router->get('/', function () {
|
||||||
<div class="py-5 text-center">
|
include 'views/common/head.php';
|
||||||
<h4 class="pad-25-top">Nature's Classroom Institute & Montessori School Presents</h4>
|
include 'views/step1.php';
|
||||||
<img src="/images/logo.png" alt="Dinner in the Woods Event Logo">
|
include 'views/common/footer.php';
|
||||||
<h1>Dinner in the Woods</h1>
|
});
|
||||||
<h5>Live Music · Local Food · Live & Silent Auction · Cabanas</h5>
|
|
||||||
<h5>Saturday June 1st, 2019 5:00pm-11:30pm</h5>
|
|
||||||
|
|
||||||
</div>
|
$router->post('/', function () {
|
||||||
|
// POST variables
|
||||||
|
$eventTicketQty = getInteger($_POST['eventTicketQty']);
|
||||||
|
$ticketEnhancerQty = getInteger($_POST['ticketEnhancerQty']);
|
||||||
|
|
||||||
<?php include('views/step2.php'); ?>
|
// Calculate totals
|
||||||
|
$additionalContribution = convertPossibleFloatToCents($_POST['additionalContribution']);
|
||||||
|
$eventTicketPrice = convertPossibleFloatToCents($eventTicketQty * $_SERVER['EVENT_TICKET_PRICE']);
|
||||||
|
$ticketEnhancerPrice = convertPossibleFloatToCents($ticketEnhancerQty * $_SERVER['ENHANCER_TICKET_PRICE']);
|
||||||
|
|
||||||
<footer class="my-5 pt-5 text-muted text-center text-small">
|
// Sum the cart totals
|
||||||
<p class="mb-1">© <?= date('Y'); ?> Natures Classroom Institute of Wisconsin</p>
|
$cartTotal = $eventTicketPrice + $ticketEnhancerPrice + $additionalContribution;
|
||||||
</footer>
|
include 'views/common/head.php';
|
||||||
</div>
|
include 'views/step2.php';
|
||||||
</div>
|
include 'views/common/footer.php';
|
||||||
|
});
|
||||||
|
|
||||||
<!-- Bootstrap core JavaScript
|
|
||||||
================================================== -->
|
|
||||||
<!-- Placed at the end of the document so the pages load faster -->
|
|
||||||
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
|
|
||||||
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
|
|
||||||
crossorigin="anonymous"></script>
|
|
||||||
<script src="/js/main.js"></script>
|
|
||||||
<script>
|
|
||||||
// Example starter JavaScript for disabling form submissions if there are invalid fields
|
|
||||||
(function () {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
window.addEventListener('load', function () {
|
// Run it!
|
||||||
// Fetch all the forms we want to apply custom Bootstrap validation styles to
|
$router->run();
|
||||||
var forms = document.getElementsByClassName('needs-validation');
|
|
||||||
|
|
||||||
// Loop over them and prevent submission
|
|
||||||
var validation = Array.prototype.filter.call(forms, function (form) {
|
|
||||||
form.addEventListener('submit', function (event) {
|
|
||||||
if (form.checkValidity() === false) {
|
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
}
|
|
||||||
form.classList.add('was-validated');
|
|
||||||
}, false);
|
|
||||||
});
|
|
||||||
}, false);
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
38
views/common/footer.php
Normal file
38
views/common/footer.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
<footer class="my-5 pt-5 text-muted text-center text-small">
|
||||||
|
<p class="mb-1">© <?= date('Y'); ?> Natures Classroom Institute of Wisconsin</p>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Bootstrap core JavaScript
|
||||||
|
================================================== -->
|
||||||
|
<!-- Placed at the end of the document so the pages load faster -->
|
||||||
|
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
|
||||||
|
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
<script src="/js/main.js"></script>
|
||||||
|
<script>
|
||||||
|
// Example starter JavaScript for disabling form submissions if there are invalid fields
|
||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
window.addEventListener('load', function () {
|
||||||
|
// Fetch all the forms we want to apply custom Bootstrap validation styles to
|
||||||
|
var forms = document.getElementsByClassName('needs-validation');
|
||||||
|
|
||||||
|
// Loop over them and prevent submission
|
||||||
|
var validation = Array.prototype.filter.call(forms, function (form) {
|
||||||
|
form.addEventListener('submit', function (event) {
|
||||||
|
if (form.checkValidity() === false) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
|
form.classList.add('was-validated');
|
||||||
|
}, false);
|
||||||
|
});
|
||||||
|
}, false);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
54
views/common/head.php
Normal file
54
views/common/head.php
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
<meta name="description" content="">
|
||||||
|
<meta name="author" content="">
|
||||||
|
|
||||||
|
<title>Dinner in the Woods 2019 - Tickets on sale March 15th!</title>
|
||||||
|
|
||||||
|
<!-- Bootstrap core CSS -->
|
||||||
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
|
||||||
|
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
||||||
|
|
||||||
|
<!-- Custom styles for this template -->
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Bitter" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="/css/site.css">
|
||||||
|
|
||||||
|
<!-- Linked Data for the event -->
|
||||||
|
<script type="application/ld+json">
|
||||||
|
{
|
||||||
|
"@context": "http://schema.org",
|
||||||
|
"@type": "Event",
|
||||||
|
"location": {
|
||||||
|
"@type": "Place",
|
||||||
|
"address": {
|
||||||
|
"@type": "PostalAddress",
|
||||||
|
"addressLocality": "Mukwonago",
|
||||||
|
"addressRegion": "WI",
|
||||||
|
"postalCode": "53149",
|
||||||
|
"streetAddress": "W336 S8455 Hwy E"
|
||||||
|
},
|
||||||
|
"name": "Nature's Classroom Institute of Wisconsin"
|
||||||
|
},
|
||||||
|
"name": "Dinner in the Woods",
|
||||||
|
"startDate": "2019-06-01T17:30-06:00",
|
||||||
|
"endDate": "2019-06-02T00:00-06:00",
|
||||||
|
"description": "Annual Dinner in the Woods at Nature's classroom. Live Music. Local Food. Live & Silent Auctions"
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="website">
|
||||||
|
<div class="gridStyle container">
|
||||||
|
<div class="py-5 text-center">
|
||||||
|
<h4 class="pad-25-top">Nature's Classroom Institute & Montessori School Presents</h4>
|
||||||
|
<img src="/images/logo.png" alt="Dinner in the Woods Event Logo">
|
||||||
|
<h1>Dinner in the Woods</h1>
|
||||||
|
<h5>Live Music · Local Food · Live & Silent Auction · Cabanas</h5>
|
||||||
|
<h5>Saturday June 1st, 2019 5:00pm-11:30pm</h5>
|
||||||
|
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user