From 7eeebe64587b76d742c597fb3acd041c65a48614 Mon Sep 17 00:00:00 2001
From: Sorrel Harriet <s.harriet@gold.ac.uk>
Date: Sat, 12 Nov 2016 21:53:09 +0000
Subject: [PATCH] initial work on lecture 6 task resources

---
 lab-6/lecture-task/index_v1.php          | 30 ++++++++++++++++++
 lab-6/lecture-task/index_v2.php          | 40 ++++++++++++++++++++++++
 lab-6/lecture-task/templates/footer.html |  2 ++
 lab-6/lecture-task/templates/header.html |  7 +++++
 lab-6/lecture-task/templates/nav.html    |  7 +++++
 lab-6/lecture-task/views/404.php         |  6 ++++
 lab-6/lecture-task/views/customers.php   |  6 ++++
 lab-6/lecture-task/views/home.php        |  6 ++++
 lab-6/lecture-task/views/orders.php      |  6 ++++
 9 files changed, 110 insertions(+)
 create mode 100644 lab-6/lecture-task/index_v1.php
 create mode 100644 lab-6/lecture-task/index_v2.php
 create mode 100644 lab-6/lecture-task/templates/footer.html
 create mode 100644 lab-6/lecture-task/templates/header.html
 create mode 100644 lab-6/lecture-task/templates/nav.html
 create mode 100644 lab-6/lecture-task/views/404.php
 create mode 100644 lab-6/lecture-task/views/customers.php
 create mode 100644 lab-6/lecture-task/views/home.php
 create mode 100644 lab-6/lecture-task/views/orders.php

diff --git a/lab-6/lecture-task/index_v1.php b/lab-6/lecture-task/index_v1.php
new file mode 100644
index 0000000..e3538d0
--- /dev/null
+++ b/lab-6/lecture-task/index_v1.php
@@ -0,0 +1,30 @@
+<?php
+
+if (isset($_GET['id'])) {
+$myvar = $_GET['id'];
+} else {
+$myvar = 'home';
+}
+$html = "<!DOCTYPE html
+			<html>
+			<head>
+			<meta charset='utf-8'/>
+			<title>Music Store: $myvar</title>
+			</head>
+			<body>";
+$html .= "<nav><ul><a href='index_v1.php?id=home'>Home</a></li>";
+$html .= "<li><a href='index_v1.php?id=customers'>Customers</a></li>";
+$html .= "<li><a href='index_v1.php?id=orders'>Orders</a></li></ul></nav>";
+
+switch ($myvar) {
+case 'home' :	include 'views/home.php';
+	break;
+case 'customers' :
+include 'views/customers.php';break;
+case 'orders' :
+include 'views/orders.php' break;
+default :
+include 'views/404.php';}
+$html .= "</body></html>";echo$html;
+
+?>
diff --git a/lab-6/lecture-task/index_v2.php b/lab-6/lecture-task/index_v2.php
new file mode 100644
index 0000000..708e971
--- /dev/null
+++ b/lab-6/lecture-task/index_v2.php
@@ -0,0 +1,40 @@
+<?php
+
+// include the header HTML
+include('templates/header.html');
+
+// include the navigation HTML
+include('templates/nav.html');
+
+// define variable for storing body HTML
+$html = "";
+
+// check if 'page' parameter is set in query string
+if (isset($_GET['page'])) {
+	$page = $_GET['page']; // if so, set page variable to value of 'page' parameter
+} else {
+	$page = 'home'; // if not, set page variable to home
+}
+
+// determine which view to serve based on value of $page
+switch ($page) {
+case 'home' :
+	include 'views/home.php';
+	break;
+case 'customers' :
+	include 'views/customers.php';
+	break;
+case 'orders' :
+	include 'views/orders.php'
+	break;
+default :
+	include 'views/404.php';
+}
+
+// output body HTML
+echo $html;
+
+// include the footer HTML
+include('templates/footer.html');
+
+?>
diff --git a/lab-6/lecture-task/templates/footer.html b/lab-6/lecture-task/templates/footer.html
new file mode 100644
index 0000000..308b1d0
--- /dev/null
+++ b/lab-6/lecture-task/templates/footer.html
@@ -0,0 +1,2 @@
+</body>
+</html>
diff --git a/lab-6/lecture-task/templates/header.html b/lab-6/lecture-task/templates/header.html
new file mode 100644
index 0000000..e08b370
--- /dev/null
+++ b/lab-6/lecture-task/templates/header.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset='utf-8'/>
+<title>Music Store: {{ page }}</title>
+</head>
+<body>
diff --git a/lab-6/lecture-task/templates/nav.html b/lab-6/lecture-task/templates/nav.html
new file mode 100644
index 0000000..bdc9fb9
--- /dev/null
+++ b/lab-6/lecture-task/templates/nav.html
@@ -0,0 +1,7 @@
+<nav>
+	<ul>
+		<a href='index_v2.php?page=home'>Home</a></li>
+		<li><a href='index_v2.php?page=customers'>Customers</a></li>
+		<li><a href='index_v2.php?page=orders'>Orders</a></li>
+	</ul>
+</nav>
diff --git a/lab-6/lecture-task/views/404.php b/lab-6/lecture-task/views/404.php
new file mode 100644
index 0000000..79cc209
--- /dev/null
+++ b/lab-6/lecture-task/views/404.php
@@ -0,0 +1,6 @@
+<?php
+
+$html .= "<h1>Oops!</h1>";
+$html .= "<p>Sorry, the page you're looking for cannot be found.</p>";
+
+?>
diff --git a/lab-6/lecture-task/views/customers.php b/lab-6/lecture-task/views/customers.php
new file mode 100644
index 0000000..a0279ca
--- /dev/null
+++ b/lab-6/lecture-task/views/customers.php
@@ -0,0 +1,6 @@
+<?php
+
+$html .= "<h1>Customers</h1>";
+$html .= "<p>Browse the app's customers here...maybe add/delete/edit customers too...whatever.</p>";
+
+?>
diff --git a/lab-6/lecture-task/views/home.php b/lab-6/lecture-task/views/home.php
new file mode 100644
index 0000000..3a06398
--- /dev/null
+++ b/lab-6/lecture-task/views/home.php
@@ -0,0 +1,6 @@
+<?php
+
+$html .= "<h1>Welcome to the Music Store</h1>";
+$html .= "<p>Some content here...</p>";
+
+?>
diff --git a/lab-6/lecture-task/views/orders.php b/lab-6/lecture-task/views/orders.php
new file mode 100644
index 0000000..79995dc
--- /dev/null
+++ b/lab-6/lecture-task/views/orders.php
@@ -0,0 +1,6 @@
+<?php
+
+$html .= "<h1>Orders</h1>";
+$html .= "<p>Browse the orders here...maybe add/delete/edit/mark dispatched...whatever.</p>";
+
+?>
-- 
GitLab