diff --git a/lab-6/lecture-task/index_v1.php b/lab-6/lecture-task/index_v1.php new file mode 100644 index 0000000000000000000000000000000000000000..e3538d037926c474c6ad1416b831140f4e2c3ddc --- /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 0000000000000000000000000000000000000000..708e971d9cdfdf65280f7747144baeb1ba45e893 --- /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 0000000000000000000000000000000000000000..308b1d01b6ca1e7ab1b1fa896e6a8497bbcd1a37 --- /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 0000000000000000000000000000000000000000..e08b370b57e850fe50c819bd39b13ea9f5e277e2 --- /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 0000000000000000000000000000000000000000..bdc9fb9901683b937b1cf028ec13d894d6d51dcd --- /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 0000000000000000000000000000000000000000..79cc20912914602530541b0f18d23e66d71209b0 --- /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 0000000000000000000000000000000000000000..a0279ca92dbaff804d54f2d6ed08f7bda3623125 --- /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 0000000000000000000000000000000000000000..3a0639879a240bf865d83e39f242f47b96659b71 --- /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 0000000000000000000000000000000000000000..79995dc837bea26ce03ef72883bbc57f1ffda4c2 --- /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>"; + +?>